From 88ff3cf1e056a8c3901f17e73ae0d1fba991a17f Mon Sep 17 00:00:00 2001 From: Adam Leventhal Date: Tue, 31 Jan 2023 21:28:12 -0800 Subject: [PATCH] update typify and nexus.json (#323) --- Cargo.lock | 6 +- progenitor-impl/src/lib.rs | 27 +- .../tests/output/nexus-builder-tagged.out | 13939 +++++++++++++--- .../tests/output/nexus-builder.out | 13557 ++++++++++++--- .../tests/output/nexus-positional.out | 6187 +++++-- progenitor-impl/tests/test_output.rs | 7 +- progenitor-macro/src/lib.rs | 16 +- progenitor-macro/src/token_utils.rs | 48 +- sample_openapi/nexus.json | 7077 ++++++-- 9 files changed, 33828 insertions(+), 7036 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6d63d42..740dec2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2025,7 +2025,7 @@ checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" [[package]] name = "typify" version = "0.0.11-dev" -source = "git+https://github.com/oxidecomputer/typify#cd1f95b66b0d0fbb33537d66043f26512ee3268b" +source = "git+https://github.com/oxidecomputer/typify#b745a238675ef5c9ee2466029fc8804db292eb51" dependencies = [ "typify-impl", "typify-macro", @@ -2034,7 +2034,7 @@ dependencies = [ [[package]] name = "typify-impl" version = "0.0.11-dev" -source = "git+https://github.com/oxidecomputer/typify#cd1f95b66b0d0fbb33537d66043f26512ee3268b" +source = "git+https://github.com/oxidecomputer/typify#b745a238675ef5c9ee2466029fc8804db292eb51" dependencies = [ "heck", "log", @@ -2052,7 +2052,7 @@ dependencies = [ [[package]] name = "typify-macro" version = "0.0.11-dev" -source = "git+https://github.com/oxidecomputer/typify#cd1f95b66b0d0fbb33537d66043f26512ee3268b" +source = "git+https://github.com/oxidecomputer/typify#b745a238675ef5c9ee2466029fc8804db292eb51" dependencies = [ "proc-macro2", "quote", diff --git a/progenitor-impl/src/lib.rs b/progenitor-impl/src/lib.rs index 4bbd1d7..a0cb0f0 100644 --- a/progenitor-impl/src/lib.rs +++ b/progenitor-impl/src/lib.rs @@ -1,4 +1,4 @@ -// Copyright 2022 Oxide Computer Company +// Copyright 2023 Oxide Computer Company use std::collections::{HashMap, HashSet}; @@ -11,6 +11,7 @@ use typify::{TypeSpace, TypeSpaceSettings}; use crate::to_schema::ToSchema; +pub use typify::TypeSpaceImpl as TypeImpl; pub use typify::TypeSpacePatch as TypePatch; mod method; @@ -53,8 +54,8 @@ pub struct GenerationSettings { extra_derives: Vec, patch: HashMap, - replace: HashMap)>, - convert: Vec<(schemars::schema::SchemaObject, String, Vec)>, + replace: HashMap)>, + convert: Vec<(schemars::schema::SchemaObject, String, Vec)>, } #[derive(Clone, Deserialize, PartialEq, Eq)] @@ -129,7 +130,7 @@ impl GenerationSettings { pub fn with_replacement< TS: ToString, RS: ToString, - I: Iterator, + I: Iterator, >( &mut self, type_name: TS, @@ -138,25 +139,19 @@ impl GenerationSettings { ) -> &mut Self { self.replace.insert( type_name.to_string(), - ( - replace_name.to_string(), - impls.map(|x| x.to_string()).collect(), - ), + (replace_name.to_string(), impls.collect()), ); self } - pub fn with_conversion>( + pub fn with_conversion>( &mut self, schema: schemars::schema::SchemaObject, type_name: S, impls: I, ) -> &mut Self { - self.convert.push(( - schema, - type_name.to_string(), - impls.map(|x| x.to_string()).collect(), - )); + self.convert + .push((schema, type_name.to_string(), impls.collect())); self } } @@ -191,7 +186,7 @@ impl Generator { type_settings.with_replacement( type_name, replace_name, - impls.iter(), + impls.iter().cloned(), ); }, ); @@ -202,7 +197,7 @@ impl Generator { type_settings.with_conversion( schema.clone(), type_name, - impls.iter(), + impls.iter().cloned(), ); }); Self { diff --git a/progenitor-impl/tests/output/nexus-builder-tagged.out b/progenitor-impl/tests/output/nexus-builder-tagged.out index 0324676..1b8d71a 100644 --- a/progenitor-impl/tests/output/nexus-builder-tagged.out +++ b/progenitor-impl/tests/output/nexus-builder-tagged.out @@ -7,6 +7,20 @@ pub mod types { use serde::{Deserialize, Serialize}; #[allow(unused_imports)] use std::convert::TryFrom; + ///Describes properties that should uniquely identify a Gimlet. + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct Baseboard { + pub part: String, + pub revision: i64, + pub serial: String, + } + + impl Baseboard { + pub fn builder() -> builder::Baseboard { + builder::Baseboard::default() + } + } + ///A type storing a range over `T`. /// ///This type supports ranges similar to the `RangeTo`, `Range` and @@ -77,7 +91,7 @@ pub mod types { } } - #[derive(Clone, Debug, Deserialize, Serialize)] + #[derive(Clone, Debug, Serialize)] pub struct BlockSize(i64); impl std::ops::Deref for BlockSize { type Target = i64; @@ -97,6 +111,16 @@ pub mod types { } } + impl<'de> serde::Deserialize<'de> for BlockSize { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + Self::try_from(i64::deserialize(deserializer)?) + .map_err(|e| ::custom(e.to_string())) + } + } + ///A count of bytes, typically used either for memory or storage capacity /// ///The maximum supported byte count is [`i64::MAX`]. This makes it @@ -113,6 +137,100 @@ pub mod types { } } + ///Client view of a [`Certificate`] + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct Certificate { + ///human-readable free-form text about a resource + pub description: String, + ///unique, immutable, system-controlled identifier for each resource + pub id: uuid::Uuid, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + pub service: ServiceUsingCertificate, + ///timestamp when this resource was created + pub time_created: chrono::DateTime, + ///timestamp when this resource was last modified + pub time_modified: chrono::DateTime, + } + + impl Certificate { + pub fn builder() -> builder::Certificate { + builder::Certificate::default() + } + } + + ///Create-time parameters for a + /// [`Certificate`](crate::external_api::views::Certificate) + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct CertificateCreate { + ///PEM file containing public certificate chain + pub cert: Vec, + pub description: String, + ///PEM file containing private key + pub key: Vec, + pub name: Name, + ///The service using this certificate + pub service: ServiceUsingCertificate, + } + + impl CertificateCreate { + pub fn builder() -> builder::CertificateCreate { + builder::CertificateCreate::default() + } + } + + ///A single page of results + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct CertificateResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + + impl CertificateResultsPage { + pub fn builder() -> builder::CertificateResultsPage { + builder::CertificateResultsPage::default() + } + } + + ///Identity-related metadata that's included in "asset" public API objects + /// (which generally have no name or description) + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct ComponentUpdate { + pub component_type: UpdateableComponentType, + ///unique, immutable, system-controlled identifier for each resource + pub id: uuid::Uuid, + ///timestamp when this resource was created + pub time_created: chrono::DateTime, + ///timestamp when this resource was last modified + pub time_modified: chrono::DateTime, + pub version: SemverVersion, + } + + impl ComponentUpdate { + pub fn builder() -> builder::ComponentUpdate { + builder::ComponentUpdate::default() + } + } + + ///A single page of results + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct ComponentUpdateResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + + impl ComponentUpdateResultsPage { + pub fn builder() -> builder::ComponentUpdateResultsPage { + builder::ComponentUpdateResultsPage::default() + } + } + ///A cumulative or counter data type. #[derive(Clone, Debug, Deserialize, Serialize)] pub struct Cumulativedouble { @@ -345,8 +463,9 @@ pub mod types { } } - ///Parameters for the [`Disk`](omicron_common::api::external::Disk) to be - /// attached or detached to an instance + ///TODO-v1: Delete this Parameters for the + /// [`Disk`](omicron_common::api::external::Disk) to be attached or detached + /// to an instance #[derive(Clone, Debug, Deserialize, Serialize)] pub struct DiskIdentifier { pub name: Name, @@ -423,6 +542,17 @@ pub mod types { } } + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct DiskPath { + pub disk: NameOrId, + } + + impl DiskPath { + pub fn builder() -> builder::DiskPath { + builder::DiskPath::default() + } + } + ///A single page of results #[derive(Clone, Debug, Deserialize, Serialize)] pub struct DiskResultsPage { @@ -808,7 +938,7 @@ pub mod types { } ///Create-time parameters for an - /// [`GlobalImage`](omicron_common::api::external::GlobalImage) + /// [`GlobalImage`](crate::external_api::views::GlobalImage) #[derive(Clone, Debug, Deserialize, Serialize)] pub struct GlobalImageCreate { ///block size in bytes @@ -843,6 +973,38 @@ pub mod types { } } + ///Client view of a [`Group`] + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct Group { + ///Human-readable name that can identify the group + pub display_name: String, + pub id: uuid::Uuid, + ///Uuid of the silo to which this group belongs + pub silo_id: uuid::Uuid, + } + + impl Group { + pub fn builder() -> builder::Group { + builder::Group::default() + } + } + + ///A single page of results + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct GroupResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + + impl GroupResultsPage { + pub fn builder() -> builder::GroupResultsPage { + builder::GroupResultsPage::default() + } + } + ///A simple type for managing a histogram metric. /// ///A histogram maintains the count of any number of samples, over a set of @@ -958,6 +1120,7 @@ pub mod types { ///Currently, we only support scanning in ascending order. #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] pub enum IdSortMode { + ///sort in increasing order of "id" #[serde(rename = "id_ascending")] IdAscending, } @@ -1042,6 +1205,7 @@ pub mod types { #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] pub enum IdentityProviderType { + ///SAML identity provider #[serde(rename = "saml")] Saml, } @@ -1090,12 +1254,15 @@ pub mod types { pub enum IdentityType { #[serde(rename = "silo_user")] SiloUser, + #[serde(rename = "silo_group")] + SiloGroup, } impl ToString for IdentityType { fn to_string(&self) -> String { match *self { Self::SiloUser => "silo_user".to_string(), + Self::SiloGroup => "silo_group".to_string(), } } } @@ -1105,6 +1272,7 @@ pub mod types { fn from_str(value: &str) -> Result { match value { "silo_user" => Ok(Self::SiloUser), + "silo_group" => Ok(Self::SiloGroup), _ => Err("invalid value"), } } @@ -1177,7 +1345,7 @@ pub mod types { } ///Create-time parameters for an - /// [`Image`](omicron_common::api::external::Image) + /// [`Image`](crate::external_api::views::Image) #[derive(Clone, Debug, Deserialize, Serialize)] pub struct ImageCreate { ///block size in bytes @@ -1286,6 +1454,9 @@ pub mod types { ///The network interfaces to be created for this instance. #[serde(default = "defaults::instance_create_network_interfaces")] pub network_interfaces: InstanceNetworkInterfaceAttachment, + ///Should this instance be started upon creation; true by default. + #[serde(default = "defaults::default_bool::")] + pub start: bool, ///User data for instance initialization systems (such as cloud-init). /// Must be a Base64-encoded string, as specified in RFC 4648 § 4 (+ and /// / characters with padding). Maximum 32 KiB unencoded data. @@ -1391,24 +1562,38 @@ pub mod types { /// stopped, but also includes states related to the Instance's lifecycle #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] pub enum InstanceState { + ///The instance is being created. #[serde(rename = "creating")] Creating, + ///The instance is currently starting up. #[serde(rename = "starting")] Starting, + ///The instance is currently running. #[serde(rename = "running")] Running, + ///The instance has been requested to stop and a transition to + /// "Stopped" is imminent. #[serde(rename = "stopping")] Stopping, + ///The instance is currently stopped. #[serde(rename = "stopped")] Stopped, + ///The instance is in the process of rebooting - it will remain in the + /// "rebooting" state until the VM is starting once more. #[serde(rename = "rebooting")] Rebooting, + ///The instance is in the process of migrating - it will remain in the + /// "migrating" state until the migration process is complete and the + /// destination propolis is ready to continue execution. #[serde(rename = "migrating")] Migrating, + ///The instance is attempting to recover from a failure. #[serde(rename = "repairing")] Repairing, + ///The instance has encountered a failure. #[serde(rename = "failed")] Failed, + ///The instance has been deleted. #[serde(rename = "destroyed")] Destroyed, } @@ -1580,8 +1765,6 @@ pub mod types { pub id: uuid::Uuid, ///unique, mutable, user-controlled identifier for each resource pub name: Name, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub project_id: Option, ///timestamp when this resource was created pub time_created: chrono::DateTime, ///timestamp when this resource was last modified @@ -1596,15 +1779,11 @@ pub mod types { ///Create-time parameters for an IP Pool. /// - ///See [`IpPool`](omicron_nexus::external_api::views::IpPool) + ///See [`IpPool`](crate::external_api::views::IpPool) #[derive(Clone, Debug, Deserialize, Serialize)] pub struct IpPoolCreate { pub description: String, pub name: Name, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub organization: Option, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub project: Option, } impl IpPoolCreate { @@ -1693,7 +1872,7 @@ pub mod types { impl std::str::FromStr for Ipv4Net { type Err = &'static str; fn from_str(value: &str) -> Result { - if regress :: Regex :: new ("^(10\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\/([8-9]|1[0-9]|2[0-9]|3[0-2])|172\\.(1[6-9]|2[0-9]|3[0-1])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\/(1[2-9]|2[0-9]|3[0-2])|192\\.168\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\/(1[6-9]|2[0-9]|3[0-2]))$") . unwrap () . find (value) . is_none () { return Err ("doesn't match pattern \"^(10\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\/([8-9]|1[0-9]|2[0-9]|3[0-2])|172\\.(1[6-9]|2[0-9]|3[0-1])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\/(1[2-9]|2[0-9]|3[0-2])|192\\.168\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\/(1[6-9]|2[0-9]|3[0-2]))$\"") ; } + if regress :: Regex :: new ("^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/([8-9]|1[0-9]|2[0-9]|3[0-2])$") . unwrap () . find (value) . is_none () { return Err ("doesn't match pattern \"^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/([8-9]|1[0-9]|2[0-9]|3[0-2])$\"") ; } Ok(Self(value.to_string())) } } @@ -2019,13 +2198,66 @@ pub mod types { } } + #[derive(Clone, Debug, Deserialize, Serialize)] + #[serde(untagged)] + pub enum NameOrId { + Id(uuid::Uuid), + Name(Name), + } + + impl std::str::FromStr for NameOrId { + type Err = &'static str; + fn from_str(value: &str) -> Result { + if let Ok(v) = value.parse() { + Ok(Self::Id(v)) + } else if let Ok(v) = value.parse() { + Ok(Self::Name(v)) + } else { + Err("string conversion failed for all variants") + } + } + } + + impl std::convert::TryFrom<&str> for NameOrId { + type Error = &'static str; + fn try_from(value: &str) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom<&String> for NameOrId { + type Error = &'static str; + fn try_from(value: &String) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom for NameOrId { + type Error = &'static str; + fn try_from(value: String) -> Result { + value.parse() + } + } + + impl ToString for NameOrId { + fn to_string(&self) -> String { + match self { + Self::Id(x) => x.to_string(), + Self::Name(x) => x.to_string(), + } + } + } + ///Supported set of sort modes for scanning by name or id #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] pub enum NameOrIdSortMode { + ///sort in increasing order of "name" #[serde(rename = "name_ascending")] NameAscending, + ///sort in decreasing order of "name" #[serde(rename = "name_descending")] NameDescending, + ///sort in increasing order of "id" #[serde(rename = "id_ascending")] IdAscending, } @@ -2078,6 +2310,7 @@ pub mod types { ///Currently, we only support scanning in ascending order. #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] pub enum NameSortMode { + ///sort in increasing order of "name" #[serde(rename = "name_ascending")] NameAscending, } @@ -2202,6 +2435,8 @@ pub mod types { pub struct NetworkInterfaceUpdate { #[serde(default, skip_serializing_if = "Option::is_none")] pub description: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub name: Option, ///Make a secondary interface the instance's primary interface. /// ///If applied to a secondary interface, that interface will become the @@ -2214,9 +2449,7 @@ pub mod types { /// for an instance. Requests to change the primary interface into a /// secondary will return an error. #[serde(default)] - pub make_primary: bool, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub name: Option, + pub primary: bool, } impl NetworkInterfaceUpdate { @@ -2225,6 +2458,21 @@ pub mod types { } } + ///Unique name for a saga [`Node`] + /// + ///Each node requires a string name that's unique within its DAG. The name + /// is used to identify its output. Nodes that depend on a given node + /// (either directly or indirectly) can access the node's output using its + /// name. + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct NodeName(pub String); + impl std::ops::Deref for NodeName { + type Target = String; + fn deref(&self) -> &String { + &self.0 + } + } + ///Client view of an [`Organization`] #[derive(Clone, Debug, Deserialize, Serialize)] pub struct Organization { @@ -2382,6 +2630,147 @@ pub mod types { } } + ///Passwords may be subject to additional constraints. + #[derive(Clone, Debug, Serialize)] + pub struct Password(String); + impl std::ops::Deref for Password { + type Target = String; + fn deref(&self) -> &String { + &self.0 + } + } + + impl std::str::FromStr for Password { + type Err = &'static str; + fn from_str(value: &str) -> Result { + if value.len() > 512usize { + return Err("longer than 512 characters"); + } + Ok(Self(value.to_string())) + } + } + + impl std::convert::TryFrom<&str> for Password { + type Error = &'static str; + fn try_from(value: &str) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom<&String> for Password { + type Error = &'static str; + fn try_from(value: &String) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom for Password { + type Error = &'static str; + fn try_from(value: String) -> Result { + value.parse() + } + } + + impl<'de> serde::Deserialize<'de> for Password { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + String::deserialize(deserializer)? + .parse() + .map_err(|e: &'static str| ::custom(e.to_string())) + } + } + + ///Client view of a [`PhysicalDisk`] + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct PhysicalDisk { + pub disk_type: PhysicalDiskType, + ///unique, immutable, system-controlled identifier for each resource + pub id: uuid::Uuid, + pub model: String, + pub serial: String, + ///The sled to which this disk is attached, if any. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub sled_id: Option, + ///timestamp when this resource was created + pub time_created: chrono::DateTime, + ///timestamp when this resource was last modified + pub time_modified: chrono::DateTime, + pub vendor: String, + } + + impl PhysicalDisk { + pub fn builder() -> builder::PhysicalDisk { + builder::PhysicalDisk::default() + } + } + + ///A single page of results + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct PhysicalDiskResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + + impl PhysicalDiskResultsPage { + pub fn builder() -> builder::PhysicalDiskResultsPage { + builder::PhysicalDiskResultsPage::default() + } + } + + #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] + pub enum PhysicalDiskType { + #[serde(rename = "internal")] + Internal, + #[serde(rename = "external")] + External, + } + + impl ToString for PhysicalDiskType { + fn to_string(&self) -> String { + match *self { + Self::Internal => "internal".to_string(), + Self::External => "external".to_string(), + } + } + } + + impl std::str::FromStr for PhysicalDiskType { + type Err = &'static str; + fn from_str(value: &str) -> Result { + match value { + "internal" => Ok(Self::Internal), + "external" => Ok(Self::External), + _ => Err("invalid value"), + } + } + } + + impl std::convert::TryFrom<&str> for PhysicalDiskType { + type Error = &'static str; + fn try_from(value: &str) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom<&String> for PhysicalDiskType { + type Error = &'static str; + fn try_from(value: &String) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom for PhysicalDiskType { + type Error = &'static str; + fn try_from(value: String) -> Result { + value.parse() + } + } + ///Client view of a [`Project`] #[derive(Clone, Debug, Deserialize, Serialize)] pub struct Project { @@ -2756,12 +3145,25 @@ pub mod types { ///See [RFD-21](https://rfd.shared.oxide.computer/rfd/0021#concept-router) for more context #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] pub enum RouterRouteKind { + ///Determines the default destination of traffic, such as whether it + /// goes to the internet or not. + /// + ///`Destination: An Internet Gateway` `Modifiable: true` #[serde(rename = "default")] Default, + ///Automatically added for each VPC Subnet in the VPC + /// + ///`Destination: A VPC Subnet` `Modifiable: false` #[serde(rename = "vpc_subnet")] VpcSubnet, + ///Automatically added when VPC peering is established + /// + ///`Destination: A different VPC` `Modifiable: false` #[serde(rename = "vpc_peering")] VpcPeering, + ///Created by a user See [`RouteTarget`] + /// + ///`Destination: User defined` `Modifiable: true` #[serde(rename = "custom")] Custom, } @@ -2897,7 +3299,7 @@ pub mod types { #[serde(rename = "failed")] Failed { error_info: SagaErrorInfo, - error_node_name: String, + error_node_name: NodeName, }, } @@ -2943,6 +3345,11 @@ pub mod types { ///service provider endpoint where the response will be sent pub acs_url: String, pub description: String, + ///If set, SAML attributes with this name will be considered to denote + /// a user's group membership, where the attribute value(s) should be a + /// comma-separated list of group names. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub group_attribute_name: Option, ///idp's entity id pub idp_entity_id: String, ///the source of an identity provider metadata descriptor @@ -2965,6 +3372,108 @@ pub mod types { } } + #[derive(Clone, Debug, Serialize)] + pub struct SemverVersion(String); + impl std::ops::Deref for SemverVersion { + type Target = String; + fn deref(&self) -> &String { + &self.0 + } + } + + impl std::str::FromStr for SemverVersion { + type Err = &'static str; + fn from_str(value: &str) -> Result { + if regress::Regex::new("^\\d+\\.\\d+\\.\\d+([\\-\\+].+)?$") + .unwrap() + .find(value) + .is_none() + { + return Err("doesn't match pattern \"^\\d+\\.\\d+\\.\\d+([\\-\\+].+)?$\""); + } + Ok(Self(value.to_string())) + } + } + + impl std::convert::TryFrom<&str> for SemverVersion { + type Error = &'static str; + fn try_from(value: &str) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom<&String> for SemverVersion { + type Error = &'static str; + fn try_from(value: &String) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom for SemverVersion { + type Error = &'static str; + fn try_from(value: String) -> Result { + value.parse() + } + } + + impl<'de> serde::Deserialize<'de> for SemverVersion { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + String::deserialize(deserializer)? + .parse() + .map_err(|e: &'static str| ::custom(e.to_string())) + } + } + + ///The service intended to use this certificate. + #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] + pub enum ServiceUsingCertificate { + ///This certificate is intended for access to the external API. + #[serde(rename = "external_api")] + ExternalApi, + } + + impl ToString for ServiceUsingCertificate { + fn to_string(&self) -> String { + match *self { + Self::ExternalApi => "external_api".to_string(), + } + } + } + + impl std::str::FromStr for ServiceUsingCertificate { + type Err = &'static str; + fn from_str(value: &str) -> Result { + match value { + "external_api" => Ok(Self::ExternalApi), + _ => Err("invalid value"), + } + } + } + + impl std::convert::TryFrom<&str> for ServiceUsingCertificate { + type Error = &'static str; + fn try_from(value: &str) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom<&String> for ServiceUsingCertificate { + type Error = &'static str; + fn try_from(value: &String) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom for ServiceUsingCertificate { + type Error = &'static str; + fn try_from(value: String) -> Result { + value.parse() + } + } + ///Client view of a ['Silo'] #[derive(Clone, Debug, Deserialize, Serialize)] pub struct Silo { @@ -2975,14 +3484,14 @@ pub mod types { pub discoverable: bool, ///unique, immutable, system-controlled identifier for each resource pub id: uuid::Uuid, + ///How users and groups are managed in this Silo + pub identity_mode: SiloIdentityMode, ///unique, mutable, user-controlled identifier for each resource pub name: Name, ///timestamp when this resource was created pub time_created: chrono::DateTime, ///timestamp when this resource was last modified pub time_modified: chrono::DateTime, - ///User provision type - pub user_provision_type: UserProvisionType, } impl Silo { @@ -2994,10 +3503,20 @@ pub mod types { ///Create-time parameters for a [`Silo`](crate::external_api::views::Silo) #[derive(Clone, Debug, Deserialize, Serialize)] pub struct SiloCreate { + ///If set, this group will be created during Silo creation and granted + /// the "Silo Admin" role. Identity providers can assert that users + /// belong to this group and those users can log in and further + /// initialize the Silo. + /// + ///Note that if configuring a SAML based identity provider, + /// group_attribute_name must be set for users to be considered part of + /// a group. See [`SamlIdentityProviderCreate`] for more information. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub admin_group_name: Option, pub description: String, pub discoverable: bool, + pub identity_mode: SiloIdentityMode, pub name: Name, - pub user_provision_type: UserProvisionType, } impl SiloCreate { @@ -3006,6 +3525,63 @@ pub mod types { } } + ///Describes how identities are managed and users are authenticated in this + /// Silo + #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] + pub enum SiloIdentityMode { + ///Users are authenticated with SAML using an external authentication + /// provider. The system updates information about users and groups + /// only during successful authentication (i.e,. "JIT provisioning" of + /// users and groups). + #[serde(rename = "saml_jit")] + SamlJit, + ///The system is the source of truth about users. There is no linkage + /// to an external authentication provider or identity provider. + #[serde(rename = "local_only")] + LocalOnly, + } + + impl ToString for SiloIdentityMode { + fn to_string(&self) -> String { + match *self { + Self::SamlJit => "saml_jit".to_string(), + Self::LocalOnly => "local_only".to_string(), + } + } + } + + impl std::str::FromStr for SiloIdentityMode { + type Err = &'static str; + fn from_str(value: &str) -> Result { + match value { + "saml_jit" => Ok(Self::SamlJit), + "local_only" => Ok(Self::LocalOnly), + _ => Err("invalid value"), + } + } + } + + impl std::convert::TryFrom<&str> for SiloIdentityMode { + type Error = &'static str; + fn try_from(value: &str) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom<&String> for SiloIdentityMode { + type Error = &'static str; + fn try_from(value: &String) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom for SiloIdentityMode { + type Error = &'static str; + fn try_from(value: String) -> Result { + value.parse() + } + } + ///A single page of results #[derive(Clone, Debug, Deserialize, Serialize)] pub struct SiloResultsPage { @@ -3112,9 +3688,10 @@ pub mod types { } } - ///Client view of an [`Sled`] + ///Client view of a [`Sled`] #[derive(Clone, Debug, Deserialize, Serialize)] pub struct Sled { + pub baseboard: Baseboard, ///unique, immutable, system-controlled identifier for each resource pub id: uuid::Uuid, pub service_address: String, @@ -3158,6 +3735,7 @@ pub mod types { pub name: Name, pub project_id: uuid::Uuid, pub size: ByteCount, + pub state: SnapshotState, ///timestamp when this resource was created pub time_created: chrono::DateTime, ///timestamp when this resource was last modified @@ -3171,7 +3749,7 @@ pub mod types { } ///Create-time parameters for a - /// [`Snapshot`](omicron_common::api::external::Snapshot) + /// [`Snapshot`](crate::external_api::views::Snapshot) #[derive(Clone, Debug, Deserialize, Serialize)] pub struct SnapshotCreate { pub description: String, @@ -3202,6 +3780,63 @@ pub mod types { } } + #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] + pub enum SnapshotState { + #[serde(rename = "creating")] + Creating, + #[serde(rename = "ready")] + Ready, + #[serde(rename = "faulted")] + Faulted, + #[serde(rename = "destroyed")] + Destroyed, + } + + impl ToString for SnapshotState { + fn to_string(&self) -> String { + match *self { + Self::Creating => "creating".to_string(), + Self::Ready => "ready".to_string(), + Self::Faulted => "faulted".to_string(), + Self::Destroyed => "destroyed".to_string(), + } + } + } + + impl std::str::FromStr for SnapshotState { + type Err = &'static str; + fn from_str(value: &str) -> Result { + match value { + "creating" => Ok(Self::Creating), + "ready" => Ok(Self::Ready), + "faulted" => Ok(Self::Faulted), + "destroyed" => Ok(Self::Destroyed), + _ => Err("invalid value"), + } + } + } + + impl std::convert::TryFrom<&str> for SnapshotState { + type Error = &'static str; + fn try_from(value: &str) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom<&String> for SnapshotState { + type Error = &'static str; + fn try_from(value: &String) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom for SnapshotState { + type Error = &'static str; + fn try_from(value: String) -> Result { + value.parse() + } + } + #[derive(Clone, Debug, Deserialize, Serialize)] pub struct SpoofLoginBody { pub username: String, @@ -3270,6 +3905,117 @@ pub mod types { } } + #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] + pub enum SystemMetricName { + #[serde(rename = "virtual_disk_space_provisioned")] + VirtualDiskSpaceProvisioned, + #[serde(rename = "cpus_provisioned")] + CpusProvisioned, + #[serde(rename = "ram_provisioned")] + RamProvisioned, + } + + impl ToString for SystemMetricName { + fn to_string(&self) -> String { + match *self { + Self::VirtualDiskSpaceProvisioned => "virtual_disk_space_provisioned".to_string(), + Self::CpusProvisioned => "cpus_provisioned".to_string(), + Self::RamProvisioned => "ram_provisioned".to_string(), + } + } + } + + impl std::str::FromStr for SystemMetricName { + type Err = &'static str; + fn from_str(value: &str) -> Result { + match value { + "virtual_disk_space_provisioned" => Ok(Self::VirtualDiskSpaceProvisioned), + "cpus_provisioned" => Ok(Self::CpusProvisioned), + "ram_provisioned" => Ok(Self::RamProvisioned), + _ => Err("invalid value"), + } + } + } + + impl std::convert::TryFrom<&str> for SystemMetricName { + type Error = &'static str; + fn try_from(value: &str) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom<&String> for SystemMetricName { + type Error = &'static str; + fn try_from(value: &String) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom for SystemMetricName { + type Error = &'static str; + fn try_from(value: String) -> Result { + value.parse() + } + } + + ///Identity-related metadata that's included in "asset" public API objects + /// (which generally have no name or description) + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct SystemUpdate { + ///unique, immutable, system-controlled identifier for each resource + pub id: uuid::Uuid, + ///timestamp when this resource was created + pub time_created: chrono::DateTime, + ///timestamp when this resource was last modified + pub time_modified: chrono::DateTime, + pub version: SemverVersion, + } + + impl SystemUpdate { + pub fn builder() -> builder::SystemUpdate { + builder::SystemUpdate::default() + } + } + + ///A single page of results + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct SystemUpdateResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + + impl SystemUpdateResultsPage { + pub fn builder() -> builder::SystemUpdateResultsPage { + builder::SystemUpdateResultsPage::default() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct SystemUpdateStart { + pub version: SemverVersion, + } + + impl SystemUpdateStart { + pub fn builder() -> builder::SystemUpdateStart { + builder::SystemUpdateStart::default() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct SystemVersion { + pub status: UpdateStatus, + pub version_range: VersionRange, + } + + impl SystemVersion { + pub fn builder() -> builder::SystemVersion { + builder::SystemVersion::default() + } + } + ///Names are constructed by concatenating the target and metric names with /// ':'. Target and metric names must be lowercase alphanumeric characters /// with '_' separating words. @@ -3364,12 +4110,228 @@ pub mod types { } } + ///Identity-related metadata that's included in "asset" public API objects + /// (which generally have no name or description) + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct UpdateDeployment { + ///unique, immutable, system-controlled identifier for each resource + pub id: uuid::Uuid, + pub status: UpdateStatus, + ///timestamp when this resource was created + pub time_created: chrono::DateTime, + ///timestamp when this resource was last modified + pub time_modified: chrono::DateTime, + pub version: SemverVersion, + } + + impl UpdateDeployment { + pub fn builder() -> builder::UpdateDeployment { + builder::UpdateDeployment::default() + } + } + + ///A single page of results + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct UpdateDeploymentResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + + impl UpdateDeploymentResultsPage { + pub fn builder() -> builder::UpdateDeploymentResultsPage { + builder::UpdateDeploymentResultsPage::default() + } + } + + #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] + #[serde(tag = "status")] + pub enum UpdateStatus { + #[serde(rename = "updating")] + Updating, + #[serde(rename = "steady")] + Steady, + } + + impl ToString for UpdateStatus { + fn to_string(&self) -> String { + match *self { + Self::Updating => "updating".to_string(), + Self::Steady => "steady".to_string(), + } + } + } + + impl std::str::FromStr for UpdateStatus { + type Err = &'static str; + fn from_str(value: &str) -> Result { + match value { + "updating" => Ok(Self::Updating), + "steady" => Ok(Self::Steady), + _ => Err("invalid value"), + } + } + } + + impl std::convert::TryFrom<&str> for UpdateStatus { + type Error = &'static str; + fn try_from(value: &str) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom<&String> for UpdateStatus { + type Error = &'static str; + fn try_from(value: &String) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom for UpdateStatus { + type Error = &'static str; + fn try_from(value: String) -> Result { + value.parse() + } + } + + ///Identity-related metadata that's included in "asset" public API objects + /// (which generally have no name or description) + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct UpdateableComponent { + pub component_type: UpdateableComponentType, + pub device_id: String, + ///unique, immutable, system-controlled identifier for each resource + pub id: uuid::Uuid, + pub status: UpdateStatus, + pub system_version: SemverVersion, + ///timestamp when this resource was created + pub time_created: chrono::DateTime, + ///timestamp when this resource was last modified + pub time_modified: chrono::DateTime, + pub version: SemverVersion, + } + + impl UpdateableComponent { + pub fn builder() -> builder::UpdateableComponent { + builder::UpdateableComponent::default() + } + } + + ///A single page of results + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct UpdateableComponentResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + + impl UpdateableComponentResultsPage { + pub fn builder() -> builder::UpdateableComponentResultsPage { + builder::UpdateableComponentResultsPage::default() + } + } + + #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] + pub enum UpdateableComponentType { + #[serde(rename = "bootloader_for_rot")] + BootloaderForRot, + #[serde(rename = "bootloader_for_sp")] + BootloaderForSp, + #[serde(rename = "bootloader_for_host_proc")] + BootloaderForHostProc, + #[serde(rename = "hubris_for_psc_rot")] + HubrisForPscRot, + #[serde(rename = "hubris_for_psc_sp")] + HubrisForPscSp, + #[serde(rename = "hubris_for_sidecar_rot")] + HubrisForSidecarRot, + #[serde(rename = "hubris_for_sidecar_sp")] + HubrisForSidecarSp, + #[serde(rename = "hubris_for_gimlet_rot")] + HubrisForGimletRot, + #[serde(rename = "hubris_for_gimlet_sp")] + HubrisForGimletSp, + #[serde(rename = "helios_host_phase1")] + HeliosHostPhase1, + #[serde(rename = "helios_host_phase2")] + HeliosHostPhase2, + #[serde(rename = "host_omicron")] + HostOmicron, + } + + impl ToString for UpdateableComponentType { + fn to_string(&self) -> String { + match *self { + Self::BootloaderForRot => "bootloader_for_rot".to_string(), + Self::BootloaderForSp => "bootloader_for_sp".to_string(), + Self::BootloaderForHostProc => "bootloader_for_host_proc".to_string(), + Self::HubrisForPscRot => "hubris_for_psc_rot".to_string(), + Self::HubrisForPscSp => "hubris_for_psc_sp".to_string(), + Self::HubrisForSidecarRot => "hubris_for_sidecar_rot".to_string(), + Self::HubrisForSidecarSp => "hubris_for_sidecar_sp".to_string(), + Self::HubrisForGimletRot => "hubris_for_gimlet_rot".to_string(), + Self::HubrisForGimletSp => "hubris_for_gimlet_sp".to_string(), + Self::HeliosHostPhase1 => "helios_host_phase1".to_string(), + Self::HeliosHostPhase2 => "helios_host_phase2".to_string(), + Self::HostOmicron => "host_omicron".to_string(), + } + } + } + + impl std::str::FromStr for UpdateableComponentType { + type Err = &'static str; + fn from_str(value: &str) -> Result { + match value { + "bootloader_for_rot" => Ok(Self::BootloaderForRot), + "bootloader_for_sp" => Ok(Self::BootloaderForSp), + "bootloader_for_host_proc" => Ok(Self::BootloaderForHostProc), + "hubris_for_psc_rot" => Ok(Self::HubrisForPscRot), + "hubris_for_psc_sp" => Ok(Self::HubrisForPscSp), + "hubris_for_sidecar_rot" => Ok(Self::HubrisForSidecarRot), + "hubris_for_sidecar_sp" => Ok(Self::HubrisForSidecarSp), + "hubris_for_gimlet_rot" => Ok(Self::HubrisForGimletRot), + "hubris_for_gimlet_sp" => Ok(Self::HubrisForGimletSp), + "helios_host_phase1" => Ok(Self::HeliosHostPhase1), + "helios_host_phase2" => Ok(Self::HeliosHostPhase2), + "host_omicron" => Ok(Self::HostOmicron), + _ => Err("invalid value"), + } + } + } + + impl std::convert::TryFrom<&str> for UpdateableComponentType { + type Error = &'static str; + fn try_from(value: &str) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom<&String> for UpdateableComponentType { + type Error = &'static str; + fn try_from(value: &String) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom for UpdateableComponentType { + type Error = &'static str; + fn try_from(value: String) -> Result { + value.parse() + } + } + ///Client view of a [`User`] #[derive(Clone, Debug, Deserialize, Serialize)] pub struct User { ///Human-readable name that can identify the user pub display_name: String, pub id: uuid::Uuid, + ///Uuid of the silo to which this user belongs + pub silo_id: uuid::Uuid, } impl User { @@ -3415,56 +4377,87 @@ pub mod types { } } - ///How users will be provisioned in a silo during authentication. - #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] - pub enum UserProvisionType { - #[serde(rename = "fixed")] - Fixed, - #[serde(rename = "jit")] - Jit, + ///Create-time parameters for a [`User`](crate::external_api::views::User) + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct UserCreate { + ///username used to log in + pub external_id: UserId, + ///password used to log in + pub password: UserPassword, } - impl ToString for UserProvisionType { - fn to_string(&self) -> String { - match *self { - Self::Fixed => "fixed".to_string(), - Self::Jit => "jit".to_string(), - } + impl UserCreate { + pub fn builder() -> builder::UserCreate { + builder::UserCreate::default() } } - impl std::str::FromStr for UserProvisionType { + ///Names must begin with a lower case ASCII letter, be composed exclusively + /// of lowercase ASCII, uppercase ASCII, numbers, and '-', and may not end + /// with a '-'. Names cannot be a UUID though they may contain a UUID. + #[derive(Clone, Debug, Serialize)] + pub struct UserId(String); + impl std::ops::Deref for UserId { + type Target = String; + fn deref(&self) -> &String { + &self.0 + } + } + + impl std::str::FromStr for UserId { type Err = &'static str; fn from_str(value: &str) -> Result { - match value { - "fixed" => Ok(Self::Fixed), - "jit" => Ok(Self::Jit), - _ => Err("invalid value"), + if value.len() > 63usize { + return Err("longer than 63 characters"); } + if regress :: Regex :: new ("^(?![0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$)^[a-z][a-z0-9-]*[a-zA-Z0-9]$") . unwrap () . find (value) . is_none () { return Err ("doesn't match pattern \"^(?![0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$)^[a-z][a-z0-9-]*[a-zA-Z0-9]$\"") ; } + Ok(Self(value.to_string())) } } - impl std::convert::TryFrom<&str> for UserProvisionType { + impl std::convert::TryFrom<&str> for UserId { type Error = &'static str; fn try_from(value: &str) -> Result { value.parse() } } - impl std::convert::TryFrom<&String> for UserProvisionType { + impl std::convert::TryFrom<&String> for UserId { type Error = &'static str; fn try_from(value: &String) -> Result { value.parse() } } - impl std::convert::TryFrom for UserProvisionType { + impl std::convert::TryFrom for UserId { type Error = &'static str; fn try_from(value: String) -> Result { value.parse() } } + impl<'de> serde::Deserialize<'de> for UserId { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + String::deserialize(deserializer)? + .parse() + .map_err(|e: &'static str| ::custom(e.to_string())) + } + } + + ///Parameters for setting a user's password + #[derive(Clone, Debug, Deserialize, Serialize)] + #[serde(tag = "user_password_value", content = "details")] + pub enum UserPassword { + ///Sets the user's password to the provided value + #[serde(rename = "password")] + Password(Password), + #[serde(rename = "invalid_password")] + InvalidPassword, + } + ///A single page of results #[derive(Clone, Debug, Deserialize, Serialize)] pub struct UserResultsPage { @@ -3481,6 +4474,31 @@ pub mod types { } } + ///Credentials for local user login + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct UsernamePasswordCredentials { + pub password: Password, + pub username: UserId, + } + + impl UsernamePasswordCredentials { + pub fn builder() -> builder::UsernamePasswordCredentials { + builder::UsernamePasswordCredentials::default() + } + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct VersionRange { + pub high: SemverVersion, + pub low: SemverVersion, + } + + impl VersionRange { + pub fn builder() -> builder::VersionRange { + builder::VersionRange::default() + } + } + ///Client view of a [`Vpc`] #[derive(Clone, Debug, Deserialize, Serialize)] pub struct Vpc { @@ -3876,7 +4894,7 @@ pub mod types { } } - ///Collection of a [`Vpc`]'s firewall rules + ///Collection of a Vpc's firewall rules #[derive(Clone, Debug, Deserialize, Serialize)] pub struct VpcFirewallRules { pub rules: Vec, @@ -4130,6 +5148,66 @@ pub mod types { } mod builder { + pub struct Baseboard { + part: Result, + revision: Result, + serial: Result, + } + + impl Default for Baseboard { + fn default() -> Self { + Self { + part: Err("no value supplied for part".to_string()), + revision: Err("no value supplied for revision".to_string()), + serial: Err("no value supplied for serial".to_string()), + } + } + } + + impl Baseboard { + pub fn part(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.part = value + .try_into() + .map_err(|e| format!("error converting supplied value for part: {}", e)); + self + } + pub fn revision(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.revision = value + .try_into() + .map_err(|e| format!("error converting supplied value for revision: {}", e)); + self + } + pub fn serial(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.serial = value + .try_into() + .map_err(|e| format!("error converting supplied value for serial: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::Baseboard { + type Error = String; + fn try_from(value: Baseboard) -> Result { + Ok(Self { + part: value.part?, + revision: value.revision?, + serial: value.serial?, + }) + } + } + pub struct Bindouble { count: Result, range: Result, @@ -4224,6 +5302,371 @@ pub mod types { } } + pub struct Certificate { + description: Result, + id: Result, + name: Result, + service: Result, + time_created: Result, String>, + time_modified: Result, String>, + } + + impl Default for Certificate { + fn default() -> Self { + Self { + description: Err("no value supplied for description".to_string()), + id: Err("no value supplied for id".to_string()), + name: Err("no value supplied for name".to_string()), + service: Err("no value supplied for service".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + } + } + } + + impl Certificate { + pub fn description(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn service(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.service = value + .try_into() + .map_err(|e| format!("error converting supplied value for service: {}", e)); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + } + + impl std::convert::TryFrom for super::Certificate { + type Error = String; + fn try_from(value: Certificate) -> Result { + Ok(Self { + description: value.description?, + id: value.id?, + name: value.name?, + service: value.service?, + time_created: value.time_created?, + time_modified: value.time_modified?, + }) + } + } + + pub struct CertificateCreate { + cert: Result, String>, + description: Result, + key: Result, String>, + name: Result, + service: Result, + } + + impl Default for CertificateCreate { + fn default() -> Self { + Self { + cert: Err("no value supplied for cert".to_string()), + description: Err("no value supplied for description".to_string()), + key: Err("no value supplied for key".to_string()), + name: Err("no value supplied for name".to_string()), + service: Err("no value supplied for service".to_string()), + } + } + } + + impl CertificateCreate { + pub fn cert(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.cert = value + .try_into() + .map_err(|e| format!("error converting supplied value for cert: {}", e)); + self + } + pub fn description(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn key(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.key = value + .try_into() + .map_err(|e| format!("error converting supplied value for key: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn service(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.service = value + .try_into() + .map_err(|e| format!("error converting supplied value for service: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::CertificateCreate { + type Error = String; + fn try_from(value: CertificateCreate) -> Result { + Ok(Self { + cert: value.cert?, + description: value.description?, + key: value.key?, + name: value.name?, + service: value.service?, + }) + } + } + + pub struct CertificateResultsPage { + items: Result, String>, + next_page: Result, String>, + } + + impl Default for CertificateResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl CertificateResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::CertificateResultsPage { + type Error = String; + fn try_from(value: CertificateResultsPage) -> Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + pub struct ComponentUpdate { + component_type: Result, + id: Result, + time_created: Result, String>, + time_modified: Result, String>, + version: Result, + } + + impl Default for ComponentUpdate { + fn default() -> Self { + Self { + component_type: Err("no value supplied for component_type".to_string()), + id: Err("no value supplied for id".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + version: Err("no value supplied for version".to_string()), + } + } + } + + impl ComponentUpdate { + pub fn component_type(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.component_type = value.try_into().map_err(|e| { + format!("error converting supplied value for component_type: {}", e) + }); + self + } + pub fn id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + pub fn version(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.version = value + .try_into() + .map_err(|e| format!("error converting supplied value for version: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::ComponentUpdate { + type Error = String; + fn try_from(value: ComponentUpdate) -> Result { + Ok(Self { + component_type: value.component_type?, + id: value.id?, + time_created: value.time_created?, + time_modified: value.time_modified?, + version: value.version?, + }) + } + } + + pub struct ComponentUpdateResultsPage { + items: Result, String>, + next_page: Result, String>, + } + + impl Default for ComponentUpdateResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl ComponentUpdateResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::ComponentUpdateResultsPage { + type Error = String; + fn try_from(value: ComponentUpdateResultsPage) -> Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + pub struct Cumulativedouble { start_time: Result, String>, value: Result, @@ -4775,6 +6218,38 @@ pub mod types { } } + pub struct DiskPath { + disk: Result, + } + + impl Default for DiskPath { + fn default() -> Self { + Self { + disk: Err("no value supplied for disk".to_string()), + } + } + } + + impl DiskPath { + pub fn disk(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.disk = value + .try_into() + .map_err(|e| format!("error converting supplied value for disk: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::DiskPath { + type Error = String; + fn try_from(value: DiskPath) -> Result { + Ok(Self { disk: value.disk? }) + } + } + pub struct DiskResultsPage { items: Result, String>, next_page: Result, String>, @@ -5477,6 +6952,113 @@ pub mod types { } } + pub struct Group { + display_name: Result, + id: Result, + silo_id: Result, + } + + impl Default for Group { + fn default() -> Self { + Self { + display_name: Err("no value supplied for display_name".to_string()), + id: Err("no value supplied for id".to_string()), + silo_id: Err("no value supplied for silo_id".to_string()), + } + } + } + + impl Group { + pub fn display_name(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.display_name = value.try_into().map_err(|e| { + format!("error converting supplied value for display_name: {}", e) + }); + self + } + pub fn id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn silo_id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.silo_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for silo_id: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::Group { + type Error = String; + fn try_from(value: Group) -> Result { + Ok(Self { + display_name: value.display_name?, + id: value.id?, + silo_id: value.silo_id?, + }) + } + } + + pub struct GroupResultsPage { + items: Result, String>, + next_page: Result, String>, + } + + impl Default for GroupResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl GroupResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::GroupResultsPage { + type Error = String; + fn try_from(value: GroupResultsPage) -> Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + pub struct Histogramdouble { bins: Result, String>, n_samples: Result, @@ -6205,6 +7787,7 @@ pub mod types { name: Result, ncpus: Result, network_interfaces: Result, + start: Result, user_data: Result, } @@ -6219,6 +7802,7 @@ pub mod types { name: Err("no value supplied for name".to_string()), ncpus: Err("no value supplied for ncpus".to_string()), network_interfaces: Ok(super::defaults::instance_create_network_interfaces()), + start: Ok(super::defaults::default_bool::()), user_data: Ok(Default::default()), } } @@ -6308,6 +7892,16 @@ pub mod types { }); self } + pub fn start(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.start = value + .try_into() + .map_err(|e| format!("error converting supplied value for start: {}", e)); + self + } pub fn user_data(mut self, value: T) -> Self where T: std::convert::TryInto, @@ -6332,6 +7926,7 @@ pub mod types { name: value.name?, ncpus: value.ncpus?, network_interfaces: value.network_interfaces?, + start: value.start?, user_data: value.user_data?, }) } @@ -6472,7 +8067,6 @@ pub mod types { description: Result, id: Result, name: Result, - project_id: Result, String>, time_created: Result, String>, time_modified: Result, String>, } @@ -6483,7 +8077,6 @@ pub mod types { description: Err("no value supplied for description".to_string()), id: Err("no value supplied for id".to_string()), name: Err("no value supplied for name".to_string()), - project_id: Ok(Default::default()), time_created: Err("no value supplied for time_created".to_string()), time_modified: Err("no value supplied for time_modified".to_string()), } @@ -6521,16 +8114,6 @@ pub mod types { .map_err(|e| format!("error converting supplied value for name: {}", e)); self } - pub fn project_id(mut self, value: T) -> Self - where - T: std::convert::TryInto>, - T::Error: std::fmt::Display, - { - self.project_id = value - .try_into() - .map_err(|e| format!("error converting supplied value for project_id: {}", e)); - self - } pub fn time_created(mut self, value: T) -> Self where T: std::convert::TryInto>, @@ -6560,7 +8143,6 @@ pub mod types { description: value.description?, id: value.id?, name: value.name?, - project_id: value.project_id?, time_created: value.time_created?, time_modified: value.time_modified?, }) @@ -6570,8 +8152,6 @@ pub mod types { pub struct IpPoolCreate { description: Result, name: Result, - organization: Result, String>, - project: Result, String>, } impl Default for IpPoolCreate { @@ -6579,8 +8159,6 @@ pub mod types { Self { description: Err("no value supplied for description".to_string()), name: Err("no value supplied for name".to_string()), - organization: Ok(Default::default()), - project: Ok(Default::default()), } } } @@ -6606,26 +8184,6 @@ pub mod types { .map_err(|e| format!("error converting supplied value for name: {}", e)); self } - pub fn organization(mut self, value: T) -> Self - where - T: std::convert::TryInto>, - T::Error: std::fmt::Display, - { - self.organization = value.try_into().map_err(|e| { - format!("error converting supplied value for organization: {}", e) - }); - self - } - pub fn project(mut self, value: T) -> Self - where - T: std::convert::TryInto>, - T::Error: std::fmt::Display, - { - self.project = value - .try_into() - .map_err(|e| format!("error converting supplied value for project: {}", e)); - self - } } impl std::convert::TryFrom for super::IpPoolCreate { @@ -6634,8 +8192,6 @@ pub mod types { Ok(Self { description: value.description?, name: value.name?, - organization: value.organization?, - project: value.project?, }) } } @@ -7328,16 +8884,16 @@ pub mod types { pub struct NetworkInterfaceUpdate { description: Result, String>, - make_primary: Result, name: Result, String>, + primary: Result, } impl Default for NetworkInterfaceUpdate { fn default() -> Self { Self { description: Ok(Default::default()), - make_primary: Ok(Default::default()), name: Ok(Default::default()), + primary: Ok(Default::default()), } } } @@ -7353,16 +8909,6 @@ pub mod types { .map_err(|e| format!("error converting supplied value for description: {}", e)); self } - pub fn make_primary(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.make_primary = value.try_into().map_err(|e| { - format!("error converting supplied value for make_primary: {}", e) - }); - self - } pub fn name(mut self, value: T) -> Self where T: std::convert::TryInto>, @@ -7373,6 +8919,16 @@ pub mod types { .map_err(|e| format!("error converting supplied value for name: {}", e)); self } + pub fn primary(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.primary = value + .try_into() + .map_err(|e| format!("error converting supplied value for primary: {}", e)); + self + } } impl std::convert::TryFrom for super::NetworkInterfaceUpdate { @@ -7380,8 +8936,8 @@ pub mod types { fn try_from(value: NetworkInterfaceUpdate) -> Result { Ok(Self { description: value.description?, - make_primary: value.make_primary?, name: value.name?, + primary: value.primary?, }) } } @@ -7712,6 +9268,178 @@ pub mod types { } } + pub struct PhysicalDisk { + disk_type: Result, + id: Result, + model: Result, + serial: Result, + sled_id: Result, String>, + time_created: Result, String>, + time_modified: Result, String>, + vendor: Result, + } + + impl Default for PhysicalDisk { + fn default() -> Self { + Self { + disk_type: Err("no value supplied for disk_type".to_string()), + id: Err("no value supplied for id".to_string()), + model: Err("no value supplied for model".to_string()), + serial: Err("no value supplied for serial".to_string()), + sled_id: Ok(Default::default()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + vendor: Err("no value supplied for vendor".to_string()), + } + } + } + + impl PhysicalDisk { + pub fn disk_type(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.disk_type = value + .try_into() + .map_err(|e| format!("error converting supplied value for disk_type: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn model(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.model = value + .try_into() + .map_err(|e| format!("error converting supplied value for model: {}", e)); + self + } + pub fn serial(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.serial = value + .try_into() + .map_err(|e| format!("error converting supplied value for serial: {}", e)); + self + } + pub fn sled_id(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.sled_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for sled_id: {}", e)); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + pub fn vendor(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.vendor = value + .try_into() + .map_err(|e| format!("error converting supplied value for vendor: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::PhysicalDisk { + type Error = String; + fn try_from(value: PhysicalDisk) -> Result { + Ok(Self { + disk_type: value.disk_type?, + id: value.id?, + model: value.model?, + serial: value.serial?, + sled_id: value.sled_id?, + time_created: value.time_created?, + time_modified: value.time_modified?, + vendor: value.vendor?, + }) + } + } + + pub struct PhysicalDiskResultsPage { + items: Result, String>, + next_page: Result, String>, + } + + impl Default for PhysicalDiskResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl PhysicalDiskResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::PhysicalDiskResultsPage { + type Error = String; + fn try_from(value: PhysicalDiskResultsPage) -> Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + pub struct Project { description: Result, id: Result, @@ -8847,6 +10575,7 @@ pub mod types { pub struct SamlIdentityProviderCreate { acs_url: Result, description: Result, + group_attribute_name: Result, String>, idp_entity_id: Result, idp_metadata_source: Result, name: Result, @@ -8861,6 +10590,7 @@ pub mod types { Self { acs_url: Err("no value supplied for acs_url".to_string()), description: Err("no value supplied for description".to_string()), + group_attribute_name: Ok(Default::default()), idp_entity_id: Err("no value supplied for idp_entity_id".to_string()), idp_metadata_source: Err( "no value supplied for idp_metadata_source".to_string() @@ -8897,6 +10627,19 @@ pub mod types { .map_err(|e| format!("error converting supplied value for description: {}", e)); self } + pub fn group_attribute_name(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.group_attribute_name = value.try_into().map_err(|e| { + format!( + "error converting supplied value for group_attribute_name: {}", + e + ) + }); + self + } pub fn idp_entity_id(mut self, value: T) -> Self where T: std::convert::TryInto, @@ -8981,6 +10724,7 @@ pub mod types { Ok(Self { acs_url: value.acs_url?, description: value.description?, + group_attribute_name: value.group_attribute_name?, idp_entity_id: value.idp_entity_id?, idp_metadata_source: value.idp_metadata_source?, name: value.name?, @@ -8996,10 +10740,10 @@ pub mod types { description: Result, discoverable: Result, id: Result, + identity_mode: Result, name: Result, time_created: Result, String>, time_modified: Result, String>, - user_provision_type: Result, } impl Default for Silo { @@ -9008,12 +10752,10 @@ pub mod types { description: Err("no value supplied for description".to_string()), discoverable: Err("no value supplied for discoverable".to_string()), id: Err("no value supplied for id".to_string()), + identity_mode: Err("no value supplied for identity_mode".to_string()), name: Err("no value supplied for name".to_string()), time_created: Err("no value supplied for time_created".to_string()), time_modified: Err("no value supplied for time_modified".to_string()), - user_provision_type: Err( - "no value supplied for user_provision_type".to_string() - ), } } } @@ -9049,6 +10791,16 @@ pub mod types { .map_err(|e| format!("error converting supplied value for id: {}", e)); self } + pub fn identity_mode(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.identity_mode = value.try_into().map_err(|e| { + format!("error converting supplied value for identity_mode: {}", e) + }); + self + } pub fn name(mut self, value: T) -> Self where T: std::convert::TryInto, @@ -9079,19 +10831,6 @@ pub mod types { }); self } - pub fn user_provision_type(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.user_provision_type = value.try_into().map_err(|e| { - format!( - "error converting supplied value for user_provision_type: {}", - e - ) - }); - self - } } impl std::convert::TryFrom for super::Silo { @@ -9101,35 +10840,48 @@ pub mod types { description: value.description?, discoverable: value.discoverable?, id: value.id?, + identity_mode: value.identity_mode?, name: value.name?, time_created: value.time_created?, time_modified: value.time_modified?, - user_provision_type: value.user_provision_type?, }) } } pub struct SiloCreate { + admin_group_name: Result, String>, description: Result, discoverable: Result, + identity_mode: Result, name: Result, - user_provision_type: Result, } impl Default for SiloCreate { fn default() -> Self { Self { + admin_group_name: Ok(Default::default()), description: Err("no value supplied for description".to_string()), discoverable: Err("no value supplied for discoverable".to_string()), + identity_mode: Err("no value supplied for identity_mode".to_string()), name: Err("no value supplied for name".to_string()), - user_provision_type: Err( - "no value supplied for user_provision_type".to_string() - ), } } } impl SiloCreate { + pub fn admin_group_name(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.admin_group_name = value.try_into().map_err(|e| { + format!( + "error converting supplied value for admin_group_name: {}", + e + ) + }); + self + } pub fn description(mut self, value: T) -> Self where T: std::convert::TryInto, @@ -9150,6 +10902,16 @@ pub mod types { }); self } + pub fn identity_mode(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.identity_mode = value.try_into().map_err(|e| { + format!("error converting supplied value for identity_mode: {}", e) + }); + self + } pub fn name(mut self, value: T) -> Self where T: std::convert::TryInto, @@ -9160,29 +10922,17 @@ pub mod types { .map_err(|e| format!("error converting supplied value for name: {}", e)); self } - pub fn user_provision_type(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.user_provision_type = value.try_into().map_err(|e| { - format!( - "error converting supplied value for user_provision_type: {}", - e - ) - }); - self - } } impl std::convert::TryFrom for super::SiloCreate { type Error = String; fn try_from(value: SiloCreate) -> Result { Ok(Self { + admin_group_name: value.admin_group_name?, description: value.description?, discoverable: value.discoverable?, + identity_mode: value.identity_mode?, name: value.name?, - user_provision_type: value.user_provision_type?, }) } } @@ -9332,6 +11082,7 @@ pub mod types { } pub struct Sled { + baseboard: Result, id: Result, service_address: Result, time_created: Result, String>, @@ -9341,6 +11092,7 @@ pub mod types { impl Default for Sled { fn default() -> Self { Self { + baseboard: Err("no value supplied for baseboard".to_string()), id: Err("no value supplied for id".to_string()), service_address: Err("no value supplied for service_address".to_string()), time_created: Err("no value supplied for time_created".to_string()), @@ -9350,6 +11102,16 @@ pub mod types { } impl Sled { + pub fn baseboard(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.baseboard = value + .try_into() + .map_err(|e| format!("error converting supplied value for baseboard: {}", e)); + self + } pub fn id(mut self, value: T) -> Self where T: std::convert::TryInto, @@ -9396,6 +11158,7 @@ pub mod types { type Error = String; fn try_from(value: Sled) -> Result { Ok(Self { + baseboard: value.baseboard?, id: value.id?, service_address: value.service_address?, time_created: value.time_created?, @@ -9458,6 +11221,7 @@ pub mod types { name: Result, project_id: Result, size: Result, + state: Result, time_created: Result, String>, time_modified: Result, String>, } @@ -9471,6 +11235,7 @@ pub mod types { name: Err("no value supplied for name".to_string()), project_id: Err("no value supplied for project_id".to_string()), size: Err("no value supplied for size".to_string()), + state: Err("no value supplied for state".to_string()), time_created: Err("no value supplied for time_created".to_string()), time_modified: Err("no value supplied for time_modified".to_string()), } @@ -9538,6 +11303,16 @@ pub mod types { .map_err(|e| format!("error converting supplied value for size: {}", e)); self } + pub fn state(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.state = value + .try_into() + .map_err(|e| format!("error converting supplied value for state: {}", e)); + self + } pub fn time_created(mut self, value: T) -> Self where T: std::convert::TryInto>, @@ -9570,6 +11345,7 @@ pub mod types { name: value.name?, project_id: value.project_id?, size: value.size?, + state: value.state?, time_created: value.time_created?, time_modified: value.time_modified?, }) @@ -9936,6 +11712,207 @@ pub mod types { } } + pub struct SystemUpdate { + id: Result, + time_created: Result, String>, + time_modified: Result, String>, + version: Result, + } + + impl Default for SystemUpdate { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + version: Err("no value supplied for version".to_string()), + } + } + } + + impl SystemUpdate { + pub fn id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + pub fn version(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.version = value + .try_into() + .map_err(|e| format!("error converting supplied value for version: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::SystemUpdate { + type Error = String; + fn try_from(value: SystemUpdate) -> Result { + Ok(Self { + id: value.id?, + time_created: value.time_created?, + time_modified: value.time_modified?, + version: value.version?, + }) + } + } + + pub struct SystemUpdateResultsPage { + items: Result, String>, + next_page: Result, String>, + } + + impl Default for SystemUpdateResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl SystemUpdateResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::SystemUpdateResultsPage { + type Error = String; + fn try_from(value: SystemUpdateResultsPage) -> Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + pub struct SystemUpdateStart { + version: Result, + } + + impl Default for SystemUpdateStart { + fn default() -> Self { + Self { + version: Err("no value supplied for version".to_string()), + } + } + } + + impl SystemUpdateStart { + pub fn version(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.version = value + .try_into() + .map_err(|e| format!("error converting supplied value for version: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::SystemUpdateStart { + type Error = String; + fn try_from(value: SystemUpdateStart) -> Result { + Ok(Self { + version: value.version?, + }) + } + } + + pub struct SystemVersion { + status: Result, + version_range: Result, + } + + impl Default for SystemVersion { + fn default() -> Self { + Self { + status: Err("no value supplied for status".to_string()), + version_range: Err("no value supplied for version_range".to_string()), + } + } + } + + impl SystemVersion { + pub fn status(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.status = value + .try_into() + .map_err(|e| format!("error converting supplied value for status: {}", e)); + self + } + pub fn version_range(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.version_range = value.try_into().map_err(|e| { + format!("error converting supplied value for version_range: {}", e) + }); + self + } + } + + impl std::convert::TryFrom for super::SystemVersion { + type Error = String; + fn try_from(value: SystemVersion) -> Result { + Ok(Self { + status: value.status?, + version_range: value.version_range?, + }) + } + } + pub struct TimeseriesSchema { created: Result, String>, datum_type: Result, @@ -10056,9 +12033,317 @@ pub mod types { } } + pub struct UpdateDeployment { + id: Result, + status: Result, + time_created: Result, String>, + time_modified: Result, String>, + version: Result, + } + + impl Default for UpdateDeployment { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + status: Err("no value supplied for status".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + version: Err("no value supplied for version".to_string()), + } + } + } + + impl UpdateDeployment { + pub fn id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn status(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.status = value + .try_into() + .map_err(|e| format!("error converting supplied value for status: {}", e)); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + pub fn version(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.version = value + .try_into() + .map_err(|e| format!("error converting supplied value for version: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::UpdateDeployment { + type Error = String; + fn try_from(value: UpdateDeployment) -> Result { + Ok(Self { + id: value.id?, + status: value.status?, + time_created: value.time_created?, + time_modified: value.time_modified?, + version: value.version?, + }) + } + } + + pub struct UpdateDeploymentResultsPage { + items: Result, String>, + next_page: Result, String>, + } + + impl Default for UpdateDeploymentResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl UpdateDeploymentResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::UpdateDeploymentResultsPage { + type Error = String; + fn try_from(value: UpdateDeploymentResultsPage) -> Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + pub struct UpdateableComponent { + component_type: Result, + device_id: Result, + id: Result, + status: Result, + system_version: Result, + time_created: Result, String>, + time_modified: Result, String>, + version: Result, + } + + impl Default for UpdateableComponent { + fn default() -> Self { + Self { + component_type: Err("no value supplied for component_type".to_string()), + device_id: Err("no value supplied for device_id".to_string()), + id: Err("no value supplied for id".to_string()), + status: Err("no value supplied for status".to_string()), + system_version: Err("no value supplied for system_version".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + version: Err("no value supplied for version".to_string()), + } + } + } + + impl UpdateableComponent { + pub fn component_type(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.component_type = value.try_into().map_err(|e| { + format!("error converting supplied value for component_type: {}", e) + }); + self + } + pub fn device_id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.device_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for device_id: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn status(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.status = value + .try_into() + .map_err(|e| format!("error converting supplied value for status: {}", e)); + self + } + pub fn system_version(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.system_version = value.try_into().map_err(|e| { + format!("error converting supplied value for system_version: {}", e) + }); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + pub fn version(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.version = value + .try_into() + .map_err(|e| format!("error converting supplied value for version: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::UpdateableComponent { + type Error = String; + fn try_from(value: UpdateableComponent) -> Result { + Ok(Self { + component_type: value.component_type?, + device_id: value.device_id?, + id: value.id?, + status: value.status?, + system_version: value.system_version?, + time_created: value.time_created?, + time_modified: value.time_modified?, + version: value.version?, + }) + } + } + + pub struct UpdateableComponentResultsPage { + items: Result, String>, + next_page: Result, String>, + } + + impl Default for UpdateableComponentResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl UpdateableComponentResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl std::convert::TryFrom + for super::UpdateableComponentResultsPage + { + type Error = String; + fn try_from(value: UpdateableComponentResultsPage) -> Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + pub struct User { display_name: Result, id: Result, + silo_id: Result, } impl Default for User { @@ -10066,6 +12351,7 @@ pub mod types { Self { display_name: Err("no value supplied for display_name".to_string()), id: Err("no value supplied for id".to_string()), + silo_id: Err("no value supplied for silo_id".to_string()), } } } @@ -10091,6 +12377,16 @@ pub mod types { .map_err(|e| format!("error converting supplied value for id: {}", e)); self } + pub fn silo_id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.silo_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for silo_id: {}", e)); + self + } } impl std::convert::TryFrom for super::User { @@ -10099,6 +12395,7 @@ pub mod types { Ok(Self { display_name: value.display_name?, id: value.id?, + silo_id: value.silo_id?, }) } } @@ -10236,6 +12533,53 @@ pub mod types { } } + pub struct UserCreate { + external_id: Result, + password: Result, + } + + impl Default for UserCreate { + fn default() -> Self { + Self { + external_id: Err("no value supplied for external_id".to_string()), + password: Err("no value supplied for password".to_string()), + } + } + } + + impl UserCreate { + pub fn external_id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.external_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for external_id: {}", e)); + self + } + pub fn password(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.password = value + .try_into() + .map_err(|e| format!("error converting supplied value for password: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::UserCreate { + type Error = String; + fn try_from(value: UserCreate) -> Result { + Ok(Self { + external_id: value.external_id?, + password: value.password?, + }) + } + } + pub struct UserResultsPage { items: Result, String>, next_page: Result, String>, @@ -10283,6 +12627,100 @@ pub mod types { } } + pub struct UsernamePasswordCredentials { + password: Result, + username: Result, + } + + impl Default for UsernamePasswordCredentials { + fn default() -> Self { + Self { + password: Err("no value supplied for password".to_string()), + username: Err("no value supplied for username".to_string()), + } + } + } + + impl UsernamePasswordCredentials { + pub fn password(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.password = value + .try_into() + .map_err(|e| format!("error converting supplied value for password: {}", e)); + self + } + pub fn username(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.username = value + .try_into() + .map_err(|e| format!("error converting supplied value for username: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::UsernamePasswordCredentials { + type Error = String; + fn try_from(value: UsernamePasswordCredentials) -> Result { + Ok(Self { + password: value.password?, + username: value.username?, + }) + } + } + + pub struct VersionRange { + high: Result, + low: Result, + } + + impl Default for VersionRange { + fn default() -> Self { + Self { + high: Err("no value supplied for high".to_string()), + low: Err("no value supplied for low".to_string()), + } + } + } + + impl VersionRange { + pub fn high(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.high = value + .try_into() + .map_err(|e| format!("error converting supplied value for high: {}", e)); + self + } + pub fn low(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.low = value + .try_into() + .map_err(|e| format!("error converting supplied value for low: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::VersionRange { + type Error = String; + fn try_from(value: VersionRange) -> Result { + Ok(Self { + high: value.high?, + low: value.low?, + }) + } + } + pub struct Vpc { description: Result, dns_name: Result, @@ -11581,6 +14019,10 @@ pub mod types { } mod defaults { + pub(super) fn default_bool() -> bool { + V + } + pub(super) fn instance_create_network_interfaces( ) -> super::InstanceNetworkInterfaceAttachment { super::InstanceNetworkInterfaceAttachment::Default @@ -11638,7 +14080,9 @@ impl Client { } pub trait ClientDisksExt { - ///Get a disk by id + ///Fetch a disk by id + /// + ///Use `GET /v1/disks/{disk}` instead /// ///Sends a `GET` request to `/by-id/disks/{id}` /// @@ -11649,7 +14093,9 @@ pub trait ClientDisksExt { /// .await; /// ``` fn disk_view_by_id(&self) -> builder::DiskViewById; - ///List disks in a project + ///List disks + /// + ///Use `GET /v1/disks` instead /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/disks` @@ -11672,7 +14118,7 @@ pub trait ClientDisksExt { /// .await; /// ``` fn disk_list(&self) -> builder::DiskList; - ///Create a disk in a project + ///Use `POST /v1/disks` instead /// ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/disks` @@ -11690,7 +14136,9 @@ pub trait ClientDisksExt { /// .await; /// ``` fn disk_create(&self) -> builder::DiskCreate; - ///Get a single disk in a project + ///Fetch a disk + /// + ///Use `GET /v1/disks/{disk}` instead /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/disks/ @@ -11705,7 +14153,7 @@ pub trait ClientDisksExt { /// .await; /// ``` fn disk_view(&self) -> builder::DiskView; - ///Delete a disk from a project + ///Use `DELETE /v1/disks/{disk}` instead /// ///Sends a `DELETE` request to /// `/organizations/{organization_name}/projects/{project_name}/disks/ @@ -11720,7 +14168,7 @@ pub trait ClientDisksExt { /// .await; /// ``` fn disk_delete(&self) -> builder::DiskDelete; - ///Fetch metrics for a disk + ///Fetch disk metrics /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/disks/ @@ -11750,6 +14198,67 @@ pub trait ClientDisksExt { /// .await; /// ``` fn disk_metrics_list(&self) -> builder::DiskMetricsList; + ///List disks + /// + ///Sends a `GET` request to `/v1/disks` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `organization` + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `project` + /// - `sort_by` + ///```ignore + /// let response = client.disk_list_v1() + /// .limit(limit) + /// .organization(organization) + /// .page_token(page_token) + /// .project(project) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn disk_list_v1(&self) -> builder::DiskListV1; + ///Create a disk + /// + ///Sends a `POST` request to `/v1/disks` + /// + ///```ignore + /// let response = client.disk_create_v1() + /// .organization(organization) + /// .project(project) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn disk_create_v1(&self) -> builder::DiskCreateV1; + ///Fetch a disk + /// + ///Sends a `GET` request to `/v1/disks/{disk}` + /// + ///```ignore + /// let response = client.disk_view_v1() + /// .disk(disk) + /// .organization(organization) + /// .project(project) + /// .send() + /// .await; + /// ``` + fn disk_view_v1(&self) -> builder::DiskViewV1; + ///Delete a disk + /// + ///Sends a `DELETE` request to `/v1/disks/{disk}` + /// + ///```ignore + /// let response = client.disk_delete_v1() + /// .disk(disk) + /// .organization(organization) + /// .project(project) + /// .send() + /// .await; + /// ``` + fn disk_delete_v1(&self) -> builder::DiskDeleteV1; } impl ClientDisksExt for Client { @@ -11776,88 +14285,21 @@ impl ClientDisksExt for Client { fn disk_metrics_list(&self) -> builder::DiskMetricsList { builder::DiskMetricsList::new(self) } -} -pub trait ClientHardwareExt { - ///List racks in the system - /// - ///Sends a `GET` request to `/hardware/racks` - /// - ///Arguments: - /// - `limit`: Maximum number of items returned by a single call - /// - `page_token`: Token returned by previous call to retrieve the - /// subsequent page - /// - `sort_by` - ///```ignore - /// let response = client.rack_list() - /// .limit(limit) - /// .page_token(page_token) - /// .sort_by(sort_by) - /// .send() - /// .await; - /// ``` - fn rack_list(&self) -> builder::RackList; - ///Fetch information about a particular rack - /// - ///Sends a `GET` request to `/hardware/racks/{rack_id}` - /// - ///Arguments: - /// - `rack_id`: The rack's unique ID. - ///```ignore - /// let response = client.rack_view() - /// .rack_id(rack_id) - /// .send() - /// .await; - /// ``` - fn rack_view(&self) -> builder::RackView; - ///List sleds in the system - /// - ///Sends a `GET` request to `/hardware/sleds` - /// - ///Arguments: - /// - `limit`: Maximum number of items returned by a single call - /// - `page_token`: Token returned by previous call to retrieve the - /// subsequent page - /// - `sort_by` - ///```ignore - /// let response = client.sled_list() - /// .limit(limit) - /// .page_token(page_token) - /// .sort_by(sort_by) - /// .send() - /// .await; - /// ``` - fn sled_list(&self) -> builder::SledList; - ///Fetch information about a sled in the system - /// - ///Sends a `GET` request to `/hardware/sleds/{sled_id}` - /// - ///Arguments: - /// - `sled_id`: The sled's unique ID. - ///```ignore - /// let response = client.sled_view() - /// .sled_id(sled_id) - /// .send() - /// .await; - /// ``` - fn sled_view(&self) -> builder::SledView; -} - -impl ClientHardwareExt for Client { - fn rack_list(&self) -> builder::RackList { - builder::RackList::new(self) + fn disk_list_v1(&self) -> builder::DiskListV1 { + builder::DiskListV1::new(self) } - fn rack_view(&self) -> builder::RackView { - builder::RackView::new(self) + fn disk_create_v1(&self) -> builder::DiskCreateV1 { + builder::DiskCreateV1::new(self) } - fn sled_list(&self) -> builder::SledList { - builder::SledList::new(self) + fn disk_view_v1(&self) -> builder::DiskViewV1 { + builder::DiskViewV1::new(self) } - fn sled_view(&self) -> builder::SledView { - builder::SledView::new(self) + fn disk_delete_v1(&self) -> builder::DiskDeleteV1 { + builder::DiskDeleteV1::new(self) } } @@ -11910,12 +14352,12 @@ pub trait ClientHiddenExt { ///Sends a `POST` request to `/login` /// ///```ignore - /// let response = client.spoof_login() + /// let response = client.login_spoof() /// .body(body) /// .send() /// .await; /// ``` - fn spoof_login(&self) -> builder::SpoofLogin; + fn login_spoof(&self) -> builder::LoginSpoof; ///Sends a `POST` request to `/logout` /// ///```ignore @@ -11934,6 +14376,24 @@ pub trait ClientHiddenExt { /// .await; /// ``` fn session_me(&self) -> builder::SessionMe; + ///Fetch the silo groups the current user belongs to + /// + ///Sends a `GET` request to `/session/me/groups` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.session_me_groups() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn session_me_groups(&self) -> builder::SessionMeGroups; } impl ClientHiddenExt for Client { @@ -11949,8 +14409,8 @@ impl ClientHiddenExt for Client { builder::DeviceAccessToken::new(self) } - fn spoof_login(&self) -> builder::SpoofLogin { - builder::SpoofLogin::new(self) + fn login_spoof(&self) -> builder::LoginSpoof { + builder::LoginSpoof::new(self) } fn logout(&self) -> builder::Logout { @@ -11960,6 +14420,10 @@ impl ClientHiddenExt for Client { fn session_me(&self) -> builder::SessionMe { builder::SessionMe::new(self) } + + fn session_me_groups(&self) -> builder::SessionMeGroups { + builder::SessionMeGroups::new(self) + } } pub trait ClientImagesExt { @@ -12020,9 +14484,9 @@ pub trait ClientImagesExt { /// .await; /// ``` fn image_create(&self) -> builder::ImageCreate; - ///Get an image + ///Fetch an image /// - ///Get the details of a specific image in a project. + ///Fetch the details for a specific image in a project. /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/images/ @@ -12080,107 +14544,8 @@ impl ClientImagesExt for Client { } } -pub trait ClientImagesGlobalExt { - ///Get a global image by id - /// - ///Sends a `GET` request to `/by-id/global-images/{id}` - /// - ///```ignore - /// let response = client.image_global_view_by_id() - /// .id(id) - /// .send() - /// .await; - /// ``` - fn image_global_view_by_id(&self) -> builder::ImageGlobalViewById; - ///List global images - /// - ///Returns a list of all the global images. Global images are returned - /// sorted by creation date, with the most recent images appearing first. - /// - ///Sends a `GET` request to `/images` - /// - ///Arguments: - /// - `limit`: Maximum number of items returned by a single call - /// - `page_token`: Token returned by previous call to retrieve the - /// subsequent page - /// - `sort_by` - ///```ignore - /// let response = client.image_global_list() - /// .limit(limit) - /// .page_token(page_token) - /// .sort_by(sort_by) - /// .send() - /// .await; - /// ``` - fn image_global_list(&self) -> builder::ImageGlobalList; - ///Create a global image - /// - ///Create a new global image. This image can then be used by any user as a - /// base for instances. - /// - ///Sends a `POST` request to `/images` - /// - ///```ignore - /// let response = client.image_global_create() - /// .body(body) - /// .send() - /// .await; - /// ``` - fn image_global_create(&self) -> builder::ImageGlobalCreate; - ///Get a global image - /// - ///Returns the details of a specific global image. - /// - ///Sends a `GET` request to `/images/{image_name}` - /// - ///```ignore - /// let response = client.image_global_view() - /// .image_name(image_name) - /// .send() - /// .await; - /// ``` - fn image_global_view(&self) -> builder::ImageGlobalView; - ///Delete a global image - /// - ///Permanently delete a global image. This operation cannot be undone. Any - /// instances using the global image will continue to run, however new - /// instances can not be created with this image. - /// - ///Sends a `DELETE` request to `/images/{image_name}` - /// - ///```ignore - /// let response = client.image_global_delete() - /// .image_name(image_name) - /// .send() - /// .await; - /// ``` - fn image_global_delete(&self) -> builder::ImageGlobalDelete; -} - -impl ClientImagesGlobalExt for Client { - fn image_global_view_by_id(&self) -> builder::ImageGlobalViewById { - builder::ImageGlobalViewById::new(self) - } - - fn image_global_list(&self) -> builder::ImageGlobalList { - builder::ImageGlobalList::new(self) - } - - fn image_global_create(&self) -> builder::ImageGlobalCreate { - builder::ImageGlobalCreate::new(self) - } - - fn image_global_view(&self) -> builder::ImageGlobalView { - builder::ImageGlobalView::new(self) - } - - fn image_global_delete(&self) -> builder::ImageGlobalDelete { - builder::ImageGlobalDelete::new(self) - } -} - pub trait ClientInstancesExt { - ///Get an instance by id + ///Fetch an instance by id /// ///Sends a `GET` request to `/by-id/instances/{id}` /// @@ -12191,7 +14556,7 @@ pub trait ClientInstancesExt { /// .await; /// ``` fn instance_view_by_id(&self) -> builder::InstanceViewById; - ///Get an instance's network interface by id + ///Fetch a network interface by id /// ///Sends a `GET` request to `/by-id/network-interfaces/{id}` /// @@ -12202,7 +14567,7 @@ pub trait ClientInstancesExt { /// .await; /// ``` fn instance_network_interface_view_by_id(&self) -> builder::InstanceNetworkInterfaceViewById; - ///List instances in a project + ///List instances /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/instances` @@ -12225,7 +14590,9 @@ pub trait ClientInstancesExt { /// .await; /// ``` fn instance_list(&self) -> builder::InstanceList; - ///Create an instance in a project + ///Create an instance + /// + ///Use `POST /v1/instances` instead /// ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/instances` @@ -12243,7 +14610,9 @@ pub trait ClientInstancesExt { /// .await; /// ``` fn instance_create(&self) -> builder::InstanceCreate; - ///Get an instance in a project + ///Fetch an instance + /// + ///Use `GET /v1/instances/{instance}` instead /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/instances/ @@ -12258,7 +14627,7 @@ pub trait ClientInstancesExt { /// .await; /// ``` fn instance_view(&self) -> builder::InstanceView; - ///Delete an instance from a project + ///Delete an instance /// ///Sends a `DELETE` request to /// `/organizations/{organization_name}/projects/{project_name}/instances/ @@ -12273,7 +14642,9 @@ pub trait ClientInstancesExt { /// .await; /// ``` fn instance_delete(&self) -> builder::InstanceDelete; - ///List disks attached to this instance + ///List an instance's disks + /// + ///Use `GET /v1/instances/{instance}/disks` instead /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/instances/ @@ -12299,6 +14670,10 @@ pub trait ClientInstancesExt { /// .await; /// ``` fn instance_disk_list(&self) -> builder::InstanceDiskList; + ///Attach a disk to an instance + /// + ///Use `POST /v1/instances/{instance}/disks/attach` instead + /// ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/instances/ /// {instance_name}/disks/attach` @@ -12313,6 +14688,10 @@ pub trait ClientInstancesExt { /// .await; /// ``` fn instance_disk_attach(&self) -> builder::InstanceDiskAttach; + ///Detach a disk from an instance + /// + ///Use `POST /v1/disks/{disk}/detach` instead + /// ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/instances/ /// {instance_name}/disks/detach` @@ -12327,7 +14706,7 @@ pub trait ClientInstancesExt { /// .await; /// ``` fn instance_disk_detach(&self) -> builder::InstanceDiskDetach; - ///List external IP addresses associated with an instance + ///List external IP addresses /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/instances/ @@ -12342,8 +14721,9 @@ pub trait ClientInstancesExt { /// .await; /// ``` fn instance_external_ip_list(&self) -> builder::InstanceExternalIpList; - ///Migrate an instance to a different propolis-server, possibly on a - /// different sled + ///Migrate an instance + /// + ///Use `POST /v1/instances/{instance}/migrate` instead /// ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/instances/ @@ -12359,7 +14739,7 @@ pub trait ClientInstancesExt { /// .await; /// ``` fn instance_migrate(&self) -> builder::InstanceMigrate; - ///List network interfaces attached to this instance + ///List network interfaces /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/instances/ @@ -12385,7 +14765,7 @@ pub trait ClientInstancesExt { /// .await; /// ``` fn instance_network_interface_list(&self) -> builder::InstanceNetworkInterfaceList; - ///Create a network interface for an instance + ///Create a network interface /// ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/instances/ @@ -12401,7 +14781,7 @@ pub trait ClientInstancesExt { /// .await; /// ``` fn instance_network_interface_create(&self) -> builder::InstanceNetworkInterfaceCreate; - ///Get an interface attached to an instance + ///Fetch a network interface /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/instances/ @@ -12417,7 +14797,7 @@ pub trait ClientInstancesExt { /// .await; /// ``` fn instance_network_interface_view(&self) -> builder::InstanceNetworkInterfaceView; - ///Update information about an instance's network interface + ///Update a network interface /// ///Sends a `PUT` request to /// `/organizations/{organization_name}/projects/{project_name}/instances/ @@ -12434,7 +14814,7 @@ pub trait ClientInstancesExt { /// .await; /// ``` fn instance_network_interface_update(&self) -> builder::InstanceNetworkInterfaceUpdate; - ///Detach a network interface from an instance + ///Delete a network interface /// ///Note that the primary interface for an instance cannot be deleted if /// there are any secondary interfaces. A new primary interface must be @@ -12457,6 +14837,8 @@ pub trait ClientInstancesExt { fn instance_network_interface_delete(&self) -> builder::InstanceNetworkInterfaceDelete; ///Reboot an instance /// + ///Use `POST /v1/instances/{instance}/reboot` instead + /// ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/instances/ /// {instance_name}/reboot` @@ -12470,7 +14852,9 @@ pub trait ClientInstancesExt { /// .await; /// ``` fn instance_reboot(&self) -> builder::InstanceReboot; - ///Get contents of an instance's serial console + ///Fetch an instance's serial console + /// + ///Use `GET /v1/instances/{instance}/serial-console` instead /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/instances/ @@ -12503,8 +14887,27 @@ pub trait ClientInstancesExt { /// .await; /// ``` fn instance_serial_console(&self) -> builder::InstanceSerialConsole; + ///Connect to an instance's serial console + /// + ///Use `GET /v1/instances/{instance}/serial-console/stream` instead + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/serial-console/stream` + /// + ///```ignore + /// let response = client.instance_serial_console_stream() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .instance_name(instance_name) + /// .send() + /// .await; + /// ``` + fn instance_serial_console_stream(&self) -> builder::InstanceSerialConsoleStream; ///Boot an instance /// + ///Use `POST /v1/instances/{instance}/start` instead + /// ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/instances/ /// {instance_name}/start` @@ -12520,6 +14923,8 @@ pub trait ClientInstancesExt { fn instance_start(&self) -> builder::InstanceStart; ///Halt an instance /// + ///Use `POST /v1/instances/{instance}/stop` instead + /// ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/instances/ /// {instance_name}/stop` @@ -12533,6 +14938,217 @@ pub trait ClientInstancesExt { /// .await; /// ``` fn instance_stop(&self) -> builder::InstanceStop; + ///List instances + /// + ///Sends a `GET` request to `/v1/instances` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `organization` + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `project` + /// - `sort_by` + ///```ignore + /// let response = client.instance_list_v1() + /// .limit(limit) + /// .organization(organization) + /// .page_token(page_token) + /// .project(project) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn instance_list_v1(&self) -> builder::InstanceListV1; + ///Create an instance + /// + ///Sends a `POST` request to `/v1/instances` + /// + ///```ignore + /// let response = client.instance_create_v1() + /// .organization(organization) + /// .project(project) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn instance_create_v1(&self) -> builder::InstanceCreateV1; + ///Fetch an instance + /// + ///Sends a `GET` request to `/v1/instances/{instance}` + /// + ///```ignore + /// let response = client.instance_view_v1() + /// .instance(instance) + /// .organization(organization) + /// .project(project) + /// .send() + /// .await; + /// ``` + fn instance_view_v1(&self) -> builder::InstanceViewV1; + ///Delete an instance + /// + ///Sends a `DELETE` request to `/v1/instances/{instance}` + /// + ///```ignore + /// let response = client.instance_delete_v1() + /// .instance(instance) + /// .organization(organization) + /// .project(project) + /// .send() + /// .await; + /// ``` + fn instance_delete_v1(&self) -> builder::InstanceDeleteV1; + ///List an instance's disks + /// + ///Sends a `GET` request to `/v1/instances/{instance}/disks` + /// + ///Arguments: + /// - `instance` + /// - `limit`: Maximum number of items returned by a single call + /// - `organization` + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `project` + /// - `sort_by` + ///```ignore + /// let response = client.instance_disk_list_v1() + /// .instance(instance) + /// .limit(limit) + /// .organization(organization) + /// .page_token(page_token) + /// .project(project) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn instance_disk_list_v1(&self) -> builder::InstanceDiskListV1; + ///Attach a disk to an instance + /// + ///Sends a `POST` request to `/v1/instances/{instance}/disks/attach` + /// + ///```ignore + /// let response = client.instance_disk_attach_v1() + /// .instance(instance) + /// .organization(organization) + /// .project(project) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn instance_disk_attach_v1(&self) -> builder::InstanceDiskAttachV1; + ///Detach a disk from an instance + /// + ///Sends a `POST` request to `/v1/instances/{instance}/disks/detach` + /// + ///```ignore + /// let response = client.instance_disk_detach_v1() + /// .instance(instance) + /// .organization(organization) + /// .project(project) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn instance_disk_detach_v1(&self) -> builder::InstanceDiskDetachV1; + ///Migrate an instance + /// + ///Sends a `POST` request to `/v1/instances/{instance}/migrate` + /// + ///```ignore + /// let response = client.instance_migrate_v1() + /// .instance(instance) + /// .organization(organization) + /// .project(project) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn instance_migrate_v1(&self) -> builder::InstanceMigrateV1; + ///Reboot an instance + /// + ///Sends a `POST` request to `/v1/instances/{instance}/reboot` + /// + ///```ignore + /// let response = client.instance_reboot_v1() + /// .instance(instance) + /// .organization(organization) + /// .project(project) + /// .send() + /// .await; + /// ``` + fn instance_reboot_v1(&self) -> builder::InstanceRebootV1; + ///Fetch an instance's serial console + /// + ///Sends a `GET` request to `/v1/instances/{instance}/serial-console` + /// + ///Arguments: + /// - `instance` + /// - `from_start`: Character index in the serial buffer from which to read, + /// counting the bytes output since instance start. If this is not + /// provided, `most_recent` must be provided, and if this *is* provided, + /// `most_recent` must *not* be provided. + /// - `max_bytes`: Maximum number of bytes of buffered serial console + /// contents to return. If the requested range runs to the end of the + /// available buffer, the data returned will be shorter than `max_bytes`. + /// - `most_recent`: Character index in the serial buffer from which to + /// read, counting *backward* from the most recently buffered data + /// retrieved from the instance. (See note on `from_start` about mutual + /// exclusivity) + /// - `organization` + /// - `project` + ///```ignore + /// let response = client.instance_serial_console_v1() + /// .instance(instance) + /// .from_start(from_start) + /// .max_bytes(max_bytes) + /// .most_recent(most_recent) + /// .organization(organization) + /// .project(project) + /// .send() + /// .await; + /// ``` + fn instance_serial_console_v1(&self) -> builder::InstanceSerialConsoleV1; + ///Stream an instance's serial console + /// + ///Sends a `GET` request to + /// `/v1/instances/{instance}/serial-console/stream` + /// + ///```ignore + /// let response = client.instance_serial_console_stream_v1() + /// .instance(instance) + /// .organization(organization) + /// .project(project) + /// .send() + /// .await; + /// ``` + fn instance_serial_console_stream_v1(&self) -> builder::InstanceSerialConsoleStreamV1; + ///Boot an instance + /// + ///Sends a `POST` request to `/v1/instances/{instance}/start` + /// + ///```ignore + /// let response = client.instance_start_v1() + /// .instance(instance) + /// .organization(organization) + /// .project(project) + /// .send() + /// .await; + /// ``` + fn instance_start_v1(&self) -> builder::InstanceStartV1; + ///Stop an instance + /// + ///Sends a `POST` request to `/v1/instances/{instance}/stop` + /// + ///```ignore + /// let response = client.instance_stop_v1() + /// .instance(instance) + /// .organization(organization) + /// .project(project) + /// .send() + /// .await; + /// ``` + fn instance_stop_v1(&self) -> builder::InstanceStopV1; } impl ClientInstancesExt for Client { @@ -12608,6 +15224,10 @@ impl ClientInstancesExt for Client { builder::InstanceSerialConsole::new(self) } + fn instance_serial_console_stream(&self) -> builder::InstanceSerialConsoleStream { + builder::InstanceSerialConsoleStream::new(self) + } + fn instance_start(&self) -> builder::InstanceStart { builder::InstanceStart::new(self) } @@ -12615,199 +15235,119 @@ impl ClientInstancesExt for Client { fn instance_stop(&self) -> builder::InstanceStop { builder::InstanceStop::new(self) } -} -pub trait ClientIpPoolsExt { - ///List IP Pools - /// - ///Sends a `GET` request to `/ip-pools` - /// - ///Arguments: - /// - `limit`: Maximum number of items returned by a single call - /// - `page_token`: Token returned by previous call to retrieve the - /// subsequent page - /// - `sort_by` - ///```ignore - /// let response = client.ip_pool_list() - /// .limit(limit) - /// .page_token(page_token) - /// .sort_by(sort_by) - /// .send() - /// .await; - /// ``` - fn ip_pool_list(&self) -> builder::IpPoolList; - ///Create a new IP Pool - /// - ///Sends a `POST` request to `/ip-pools` - /// - ///```ignore - /// let response = client.ip_pool_create() - /// .body(body) - /// .send() - /// .await; - /// ``` - fn ip_pool_create(&self) -> builder::IpPoolCreate; - ///Fetch a single IP Pool - /// - ///Sends a `GET` request to `/ip-pools/{pool_name}` - /// - ///```ignore - /// let response = client.ip_pool_view() - /// .pool_name(pool_name) - /// .send() - /// .await; - /// ``` - fn ip_pool_view(&self) -> builder::IpPoolView; - ///Update an IP Pool - /// - ///Sends a `PUT` request to `/ip-pools/{pool_name}` - /// - ///```ignore - /// let response = client.ip_pool_update() - /// .pool_name(pool_name) - /// .body(body) - /// .send() - /// .await; - /// ``` - fn ip_pool_update(&self) -> builder::IpPoolUpdate; - ///Delete an IP Pool - /// - ///Sends a `DELETE` request to `/ip-pools/{pool_name}` - /// - ///```ignore - /// let response = client.ip_pool_delete() - /// .pool_name(pool_name) - /// .send() - /// .await; - /// ``` - fn ip_pool_delete(&self) -> builder::IpPoolDelete; - ///List the ranges of IP addresses within an existing IP Pool - /// - ///Note that ranges are listed sorted by their first address. - /// - ///Sends a `GET` request to `/ip-pools/{pool_name}/ranges` - /// - ///Arguments: - /// - `pool_name` - /// - `limit`: Maximum number of items returned by a single call - /// - `page_token`: Token returned by previous call to retrieve the - /// subsequent page - ///```ignore - /// let response = client.ip_pool_range_list() - /// .pool_name(pool_name) - /// .limit(limit) - /// .page_token(page_token) - /// .send() - /// .await; - /// ``` - fn ip_pool_range_list(&self) -> builder::IpPoolRangeList; - ///Add a new range to an existing IP Pool - /// - ///Sends a `POST` request to `/ip-pools/{pool_name}/ranges/add` - /// - ///```ignore - /// let response = client.ip_pool_range_add() - /// .pool_name(pool_name) - /// .body(body) - /// .send() - /// .await; - /// ``` - fn ip_pool_range_add(&self) -> builder::IpPoolRangeAdd; - ///Remove a range from an existing IP Pool - /// - ///Sends a `POST` request to `/ip-pools/{pool_name}/ranges/remove` - /// - ///```ignore - /// let response = client.ip_pool_range_remove() - /// .pool_name(pool_name) - /// .body(body) - /// .send() - /// .await; - /// ``` - fn ip_pool_range_remove(&self) -> builder::IpPoolRangeRemove; -} - -impl ClientIpPoolsExt for Client { - fn ip_pool_list(&self) -> builder::IpPoolList { - builder::IpPoolList::new(self) + fn instance_list_v1(&self) -> builder::InstanceListV1 { + builder::InstanceListV1::new(self) } - fn ip_pool_create(&self) -> builder::IpPoolCreate { - builder::IpPoolCreate::new(self) + fn instance_create_v1(&self) -> builder::InstanceCreateV1 { + builder::InstanceCreateV1::new(self) } - fn ip_pool_view(&self) -> builder::IpPoolView { - builder::IpPoolView::new(self) + fn instance_view_v1(&self) -> builder::InstanceViewV1 { + builder::InstanceViewV1::new(self) } - fn ip_pool_update(&self) -> builder::IpPoolUpdate { - builder::IpPoolUpdate::new(self) + fn instance_delete_v1(&self) -> builder::InstanceDeleteV1 { + builder::InstanceDeleteV1::new(self) } - fn ip_pool_delete(&self) -> builder::IpPoolDelete { - builder::IpPoolDelete::new(self) + fn instance_disk_list_v1(&self) -> builder::InstanceDiskListV1 { + builder::InstanceDiskListV1::new(self) } - fn ip_pool_range_list(&self) -> builder::IpPoolRangeList { - builder::IpPoolRangeList::new(self) + fn instance_disk_attach_v1(&self) -> builder::InstanceDiskAttachV1 { + builder::InstanceDiskAttachV1::new(self) } - fn ip_pool_range_add(&self) -> builder::IpPoolRangeAdd { - builder::IpPoolRangeAdd::new(self) + fn instance_disk_detach_v1(&self) -> builder::InstanceDiskDetachV1 { + builder::InstanceDiskDetachV1::new(self) } - fn ip_pool_range_remove(&self) -> builder::IpPoolRangeRemove { - builder::IpPoolRangeRemove::new(self) + fn instance_migrate_v1(&self) -> builder::InstanceMigrateV1 { + builder::InstanceMigrateV1::new(self) + } + + fn instance_reboot_v1(&self) -> builder::InstanceRebootV1 { + builder::InstanceRebootV1::new(self) + } + + fn instance_serial_console_v1(&self) -> builder::InstanceSerialConsoleV1 { + builder::InstanceSerialConsoleV1::new(self) + } + + fn instance_serial_console_stream_v1(&self) -> builder::InstanceSerialConsoleStreamV1 { + builder::InstanceSerialConsoleStreamV1::new(self) + } + + fn instance_start_v1(&self) -> builder::InstanceStartV1 { + builder::InstanceStartV1::new(self) + } + + fn instance_stop_v1(&self) -> builder::InstanceStopV1 { + builder::InstanceStopV1::new(self) } } pub trait ClientLoginExt { - ///Ask the user to login to their identity provider + ///Authenticate a user (i.e., log in) via username and password + /// + ///Sends a `POST` request to `/login/{silo_name}/local` + /// + ///```ignore + /// let response = client.login_local() + /// .silo_name(silo_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn login_local(&self) -> builder::LoginLocal; + ///Prompt user login /// ///Either display a page asking a user for their credentials, or redirect /// them to their identity provider. /// - ///Sends a `GET` request to `/login/{silo_name}/{provider_name}` + ///Sends a `GET` request to `/login/{silo_name}/saml/{provider_name}` /// ///```ignore - /// let response = client.login() + /// let response = client.login_saml_begin() /// .silo_name(silo_name) /// .provider_name(provider_name) /// .send() /// .await; /// ``` - fn login(&self) -> builder::Login; - ///Consume some sort of credentials, and authenticate a user + fn login_saml_begin(&self) -> builder::LoginSamlBegin; + ///Authenticate a user (i.e., log in) via SAML /// - ///Either receive a username and password, or some sort of identity - /// provider data (like a SAMLResponse). Use these to set the user's session - /// cookie. - /// - ///Sends a `POST` request to `/login/{silo_name}/{provider_name}` + ///Sends a `POST` request to `/login/{silo_name}/saml/{provider_name}` /// ///```ignore - /// let response = client.consume_credentials() + /// let response = client.login_saml() /// .silo_name(silo_name) /// .provider_name(provider_name) /// .body(body) /// .send() /// .await; /// ``` - fn consume_credentials(&self) -> builder::ConsumeCredentials; + fn login_saml(&self) -> builder::LoginSaml; } impl ClientLoginExt for Client { - fn login(&self) -> builder::Login { - builder::Login::new(self) + fn login_local(&self) -> builder::LoginLocal { + builder::LoginLocal::new(self) } - fn consume_credentials(&self) -> builder::ConsumeCredentials { - builder::ConsumeCredentials::new(self) + fn login_saml_begin(&self) -> builder::LoginSamlBegin { + builder::LoginSamlBegin::new(self) + } + + fn login_saml(&self) -> builder::LoginSaml { + builder::LoginSaml::new(self) } } pub trait ClientMetricsExt { - ///List all timeseries schema + ///List timeseries schema /// ///Sends a `GET` request to `/timeseries/schema` /// @@ -12832,7 +15372,9 @@ impl ClientMetricsExt for Client { } pub trait ClientOrganizationsExt { - ///Get an organization by id + ///Fetch an organization by id + /// + ///Use `GET /v1/organizations/{organization}` instead /// ///Sends a `GET` request to `/by-id/organizations/{id}` /// @@ -12843,7 +15385,9 @@ pub trait ClientOrganizationsExt { /// .await; /// ``` fn organization_view_by_id(&self) -> builder::OrganizationViewById; - ///List all organizations + ///List organizations + /// + ///Use `GET /v1/organizations` instead /// ///Sends a `GET` request to `/organizations` /// @@ -12861,7 +15405,9 @@ pub trait ClientOrganizationsExt { /// .await; /// ``` fn organization_list(&self) -> builder::OrganizationList; - ///Create a new organization + ///Create an organization + /// + ///Use `POST /v1/organizations` instead /// ///Sends a `POST` request to `/organizations` /// @@ -12872,7 +15418,9 @@ pub trait ClientOrganizationsExt { /// .await; /// ``` fn organization_create(&self) -> builder::OrganizationCreate; - ///Fetch a specific organization + ///Fetch an organization + /// + ///Use `GET /v1/organizations/{organization}` instead /// ///Sends a `GET` request to `/organizations/{organization_name}` /// @@ -12885,7 +15433,9 @@ pub trait ClientOrganizationsExt { /// .await; /// ``` fn organization_view(&self) -> builder::OrganizationView; - ///Update a specific organization + ///Update an organization + /// + ///Use `PUT /v1/organizations/{organization}` instead /// ///Sends a `PUT` request to `/organizations/{organization_name}` /// @@ -12900,7 +15450,9 @@ pub trait ClientOrganizationsExt { /// .await; /// ``` fn organization_update(&self) -> builder::OrganizationUpdate; - ///Delete a specific organization + ///Delete an organization + /// + ///Use `DELETE /v1/organizations/{organization}` instead /// ///Sends a `DELETE` request to `/organizations/{organization_name}` /// @@ -12913,7 +15465,9 @@ pub trait ClientOrganizationsExt { /// .await; /// ``` fn organization_delete(&self) -> builder::OrganizationDelete; - ///Fetch the IAM policy for this Organization + ///Fetch an organization's IAM policy + /// + ///Use `GET /v1/organizations/{organization}/policy` instead /// ///Sends a `GET` request to `/organizations/{organization_name}/policy` /// @@ -12926,7 +15480,9 @@ pub trait ClientOrganizationsExt { /// .await; /// ``` fn organization_policy_view(&self) -> builder::OrganizationPolicyView; - ///Update the IAM policy for this Organization + ///Update an organization's IAM policy + /// + ///Use `PUT /v1/organizations/{organization}/policy` instead /// ///Sends a `PUT` request to `/organizations/{organization_name}/policy` /// @@ -12941,6 +15497,92 @@ pub trait ClientOrganizationsExt { /// .await; /// ``` fn organization_policy_update(&self) -> builder::OrganizationPolicyUpdate; + ///List organizations + /// + ///Sends a `GET` request to `/v1/organizations` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.organization_list_v1() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn organization_list_v1(&self) -> builder::OrganizationListV1; + ///Create an organization + /// + ///Sends a `POST` request to `/v1/organizations` + /// + ///```ignore + /// let response = client.organization_create_v1() + /// .body(body) + /// .send() + /// .await; + /// ``` + fn organization_create_v1(&self) -> builder::OrganizationCreateV1; + ///Fetch an organization + /// + ///Sends a `GET` request to `/v1/organizations/{organization}` + /// + ///```ignore + /// let response = client.organization_view_v1() + /// .organization(organization) + /// .send() + /// .await; + /// ``` + fn organization_view_v1(&self) -> builder::OrganizationViewV1; + ///Update an organization + /// + ///Sends a `PUT` request to `/v1/organizations/{organization}` + /// + ///```ignore + /// let response = client.organization_update_v1() + /// .organization(organization) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn organization_update_v1(&self) -> builder::OrganizationUpdateV1; + ///Delete an organization + /// + ///Sends a `DELETE` request to `/v1/organizations/{organization}` + /// + ///```ignore + /// let response = client.organization_delete_v1() + /// .organization(organization) + /// .send() + /// .await; + /// ``` + fn organization_delete_v1(&self) -> builder::OrganizationDeleteV1; + ///Fetch an organization's IAM policy + /// + ///Sends a `GET` request to `/v1/organizations/{organization}/policy` + /// + ///```ignore + /// let response = client.organization_policy_view_v1() + /// .organization(organization) + /// .send() + /// .await; + /// ``` + fn organization_policy_view_v1(&self) -> builder::OrganizationPolicyViewV1; + ///Update an organization's IAM policy + /// + ///Sends a `PUT` request to `/v1/organizations/{organization}/policy` + /// + ///```ignore + /// let response = client.organization_policy_update_v1() + /// .organization(organization) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn organization_policy_update_v1(&self) -> builder::OrganizationPolicyUpdateV1; } impl ClientOrganizationsExt for Client { @@ -12975,44 +15617,74 @@ impl ClientOrganizationsExt for Client { fn organization_policy_update(&self) -> builder::OrganizationPolicyUpdate { builder::OrganizationPolicyUpdate::new(self) } + + fn organization_list_v1(&self) -> builder::OrganizationListV1 { + builder::OrganizationListV1::new(self) + } + + fn organization_create_v1(&self) -> builder::OrganizationCreateV1 { + builder::OrganizationCreateV1::new(self) + } + + fn organization_view_v1(&self) -> builder::OrganizationViewV1 { + builder::OrganizationViewV1::new(self) + } + + fn organization_update_v1(&self) -> builder::OrganizationUpdateV1 { + builder::OrganizationUpdateV1::new(self) + } + + fn organization_delete_v1(&self) -> builder::OrganizationDeleteV1 { + builder::OrganizationDeleteV1::new(self) + } + + fn organization_policy_view_v1(&self) -> builder::OrganizationPolicyViewV1 { + builder::OrganizationPolicyViewV1::new(self) + } + + fn organization_policy_update_v1(&self) -> builder::OrganizationPolicyUpdateV1 { + builder::OrganizationPolicyUpdateV1::new(self) + } } pub trait ClientPolicyExt { ///Fetch the top-level IAM policy /// - ///Sends a `GET` request to `/policy` + ///Sends a `GET` request to `/system/policy` /// ///```ignore - /// let response = client.policy_view() + /// let response = client.system_policy_view() /// .send() /// .await; /// ``` - fn policy_view(&self) -> builder::PolicyView; + fn system_policy_view(&self) -> builder::SystemPolicyView; ///Update the top-level IAM policy /// - ///Sends a `PUT` request to `/policy` + ///Sends a `PUT` request to `/system/policy` /// ///```ignore - /// let response = client.policy_update() + /// let response = client.system_policy_update() /// .body(body) /// .send() /// .await; /// ``` - fn policy_update(&self) -> builder::PolicyUpdate; + fn system_policy_update(&self) -> builder::SystemPolicyUpdate; } impl ClientPolicyExt for Client { - fn policy_view(&self) -> builder::PolicyView { - builder::PolicyView::new(self) + fn system_policy_view(&self) -> builder::SystemPolicyView { + builder::SystemPolicyView::new(self) } - fn policy_update(&self) -> builder::PolicyUpdate { - builder::PolicyUpdate::new(self) + fn system_policy_update(&self) -> builder::SystemPolicyUpdate { + builder::SystemPolicyUpdate::new(self) } } pub trait ClientProjectsExt { - ///Get a project by id + ///Fetch a project by id + /// + ///Use `GET /v1/projects/{project}` instead /// ///Sends a `GET` request to `/by-id/projects/{id}` /// @@ -13023,7 +15695,9 @@ pub trait ClientProjectsExt { /// .await; /// ``` fn project_view_by_id(&self) -> builder::ProjectViewById; - ///List all projects + ///List projects + /// + ///Use `GET /v1/projects` instead /// ///Sends a `GET` request to `/organizations/{organization_name}/projects` /// @@ -13043,7 +15717,9 @@ pub trait ClientProjectsExt { /// .await; /// ``` fn project_list(&self) -> builder::ProjectList; - ///Create a new project + ///Create a project + /// + ///Use `POST /v1/projects` instead /// ///Sends a `POST` request to `/organizations/{organization_name}/projects` /// @@ -13058,7 +15734,9 @@ pub trait ClientProjectsExt { /// .await; /// ``` fn project_create(&self) -> builder::ProjectCreate; - ///Fetch a specific project + ///Fetch a project + /// + ///Use `GET /v1/projects/{project}` instead /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}` @@ -13074,7 +15752,9 @@ pub trait ClientProjectsExt { /// .await; /// ``` fn project_view(&self) -> builder::ProjectView; - ///Update a specific project + ///Update a project + /// + ///Use `PUT /v1/projects/{project}` instead /// ///Sends a `PUT` request to /// `/organizations/{organization_name}/projects/{project_name}` @@ -13092,7 +15772,9 @@ pub trait ClientProjectsExt { /// .await; /// ``` fn project_update(&self) -> builder::ProjectUpdate; - ///Delete a specific project + ///Delete a project + /// + ///Use `DELETE /v1/projects/{project}` instead /// ///Sends a `DELETE` request to /// `/organizations/{organization_name}/projects/{project_name}` @@ -13108,7 +15790,9 @@ pub trait ClientProjectsExt { /// .await; /// ``` fn project_delete(&self) -> builder::ProjectDelete; - ///Fetch the IAM policy for this Project + ///Fetch a project's IAM policy + /// + ///Use `GET /v1/projects/{project}/policy` instead /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/policy` @@ -13124,7 +15808,7 @@ pub trait ClientProjectsExt { /// .await; /// ``` fn project_policy_view(&self) -> builder::ProjectPolicyView; - ///Update the IAM policy for this Project + ///Update a project's IAM policy /// ///Sends a `PUT` request to /// `/organizations/{organization_name}/projects/{project_name}/policy` @@ -13142,6 +15826,100 @@ pub trait ClientProjectsExt { /// .await; /// ``` fn project_policy_update(&self) -> builder::ProjectPolicyUpdate; + ///List projects + /// + ///Sends a `GET` request to `/v1/projects` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `organization` + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.project_list_v1() + /// .limit(limit) + /// .organization(organization) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn project_list_v1(&self) -> builder::ProjectListV1; + ///Create a project + /// + ///Sends a `POST` request to `/v1/projects` + /// + ///```ignore + /// let response = client.project_create_v1() + /// .organization(organization) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn project_create_v1(&self) -> builder::ProjectCreateV1; + ///Fetch a project + /// + ///Sends a `GET` request to `/v1/projects/{project}` + /// + ///```ignore + /// let response = client.project_view_v1() + /// .project(project) + /// .organization(organization) + /// .send() + /// .await; + /// ``` + fn project_view_v1(&self) -> builder::ProjectViewV1; + ///Update a project + /// + ///Sends a `PUT` request to `/v1/projects/{project}` + /// + ///```ignore + /// let response = client.project_update_v1() + /// .project(project) + /// .organization(organization) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn project_update_v1(&self) -> builder::ProjectUpdateV1; + ///Delete a project + /// + ///Sends a `DELETE` request to `/v1/projects/{project}` + /// + ///```ignore + /// let response = client.project_delete_v1() + /// .project(project) + /// .organization(organization) + /// .send() + /// .await; + /// ``` + fn project_delete_v1(&self) -> builder::ProjectDeleteV1; + ///Fetch a project's IAM policy + /// + ///Sends a `GET` request to `/v1/projects/{project}/policy` + /// + ///```ignore + /// let response = client.project_policy_view_v1() + /// .project(project) + /// .organization(organization) + /// .send() + /// .await; + /// ``` + fn project_policy_view_v1(&self) -> builder::ProjectPolicyViewV1; + ///Update a project's IAM policy + /// + ///Sends a `PUT` request to `/v1/projects/{project}/policy` + /// + ///```ignore + /// let response = client.project_policy_update_v1() + /// .project(project) + /// .organization(organization) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn project_policy_update_v1(&self) -> builder::ProjectPolicyUpdateV1; } impl ClientProjectsExt for Client { @@ -13176,10 +15954,38 @@ impl ClientProjectsExt for Client { fn project_policy_update(&self) -> builder::ProjectPolicyUpdate { builder::ProjectPolicyUpdate::new(self) } + + fn project_list_v1(&self) -> builder::ProjectListV1 { + builder::ProjectListV1::new(self) + } + + fn project_create_v1(&self) -> builder::ProjectCreateV1 { + builder::ProjectCreateV1::new(self) + } + + fn project_view_v1(&self) -> builder::ProjectViewV1 { + builder::ProjectViewV1::new(self) + } + + fn project_update_v1(&self) -> builder::ProjectUpdateV1 { + builder::ProjectUpdateV1::new(self) + } + + fn project_delete_v1(&self) -> builder::ProjectDeleteV1 { + builder::ProjectDeleteV1::new(self) + } + + fn project_policy_view_v1(&self) -> builder::ProjectPolicyViewV1 { + builder::ProjectPolicyViewV1::new(self) + } + + fn project_policy_update_v1(&self) -> builder::ProjectPolicyUpdateV1 { + builder::ProjectPolicyUpdateV1::new(self) + } } pub trait ClientRolesExt { - ///List the built-in roles + ///List built-in roles /// ///Sends a `GET` request to `/roles` /// @@ -13195,7 +16001,7 @@ pub trait ClientRolesExt { /// .await; /// ``` fn role_list(&self) -> builder::RoleList; - ///Fetch a specific built-in role + ///Fetch a built-in role /// ///Sends a `GET` request to `/roles/{role_name}` /// @@ -13220,50 +16026,10 @@ impl ClientRolesExt for Client { } } -pub trait ClientSagasExt { - ///List all sagas (for debugging) - /// - ///Sends a `GET` request to `/sagas` - /// - ///Arguments: - /// - `limit`: Maximum number of items returned by a single call - /// - `page_token`: Token returned by previous call to retrieve the - /// subsequent page - /// - `sort_by` - ///```ignore - /// let response = client.saga_list() - /// .limit(limit) - /// .page_token(page_token) - /// .sort_by(sort_by) - /// .send() - /// .await; - /// ``` - fn saga_list(&self) -> builder::SagaList; - ///Fetch information about a single saga (for debugging) - /// - ///Sends a `GET` request to `/sagas/{saga_id}` - /// - ///```ignore - /// let response = client.saga_view() - /// .saga_id(saga_id) - /// .send() - /// .await; - /// ``` - fn saga_view(&self) -> builder::SagaView; -} - -impl ClientSagasExt for Client { - fn saga_list(&self) -> builder::SagaList { - builder::SagaList::new(self) - } - - fn saga_view(&self) -> builder::SagaView { - builder::SagaView::new(self) - } -} - pub trait ClientSessionExt { - ///List the current user's SSH public keys + ///List SSH public keys + /// + ///Lists SSH public keys for the currently authenticated user. /// ///Sends a `GET` request to `/session/me/sshkeys` /// @@ -13281,7 +16047,9 @@ pub trait ClientSessionExt { /// .await; /// ``` fn session_sshkey_list(&self) -> builder::SessionSshkeyList; - ///Create a new SSH public key for the current user + ///Create an SSH public key + /// + ///Create an SSH public key for the currently authenticated user. /// ///Sends a `POST` request to `/session/me/sshkeys` /// @@ -13292,7 +16060,10 @@ pub trait ClientSessionExt { /// .await; /// ``` fn session_sshkey_create(&self) -> builder::SessionSshkeyCreate; - ///Get (by name) an SSH public key belonging to the current user + ///Fetch an SSH public key + /// + ///Fetch an SSH public key associated with the currently authenticated + /// user. /// ///Sends a `GET` request to `/session/me/sshkeys/{ssh_key_name}` /// @@ -13303,7 +16074,10 @@ pub trait ClientSessionExt { /// .await; /// ``` fn session_sshkey_view(&self) -> builder::SessionSshkeyView; - ///Delete (by name) an SSH public key belonging to the current user + ///Delete an SSH public key + /// + ///Delete an SSH public key associated with the currently authenticated + /// user. /// ///Sends a `DELETE` request to `/session/me/sshkeys/{ssh_key_name}` /// @@ -13335,7 +16109,9 @@ impl ClientSessionExt for Client { } pub trait ClientSilosExt { - ///Sends a `GET` request to `/silos` + ///List groups + /// + ///Sends a `GET` request to `/groups` /// ///Arguments: /// - `limit`: Maximum number of items returned by a single call @@ -13343,130 +16119,35 @@ pub trait ClientSilosExt { /// subsequent page /// - `sort_by` ///```ignore - /// let response = client.silo_list() + /// let response = client.group_list() /// .limit(limit) /// .page_token(page_token) /// .sort_by(sort_by) /// .send() /// .await; /// ``` - fn silo_list(&self) -> builder::SiloList; - ///Create a new silo + fn group_list(&self) -> builder::GroupList; + ///Fetch the current silo's IAM policy /// - ///Sends a `POST` request to `/silos` + ///Sends a `GET` request to `/policy` /// ///```ignore - /// let response = client.silo_create() + /// let response = client.policy_view() + /// .send() + /// .await; + /// ``` + fn policy_view(&self) -> builder::PolicyView; + ///Update the current silo's IAM policy + /// + ///Sends a `PUT` request to `/policy` + /// + ///```ignore + /// let response = client.policy_update() /// .body(body) /// .send() /// .await; /// ``` - fn silo_create(&self) -> builder::SiloCreate; - ///Fetch a specific silo - /// - ///Sends a `GET` request to `/silos/{silo_name}` - /// - ///Arguments: - /// - `silo_name`: The silo's unique name. - ///```ignore - /// let response = client.silo_view() - /// .silo_name(silo_name) - /// .send() - /// .await; - /// ``` - fn silo_view(&self) -> builder::SiloView; - ///Delete a specific silo - /// - ///Sends a `DELETE` request to `/silos/{silo_name}` - /// - ///Arguments: - /// - `silo_name`: The silo's unique name. - ///```ignore - /// let response = client.silo_delete() - /// .silo_name(silo_name) - /// .send() - /// .await; - /// ``` - fn silo_delete(&self) -> builder::SiloDelete; - ///List Silo identity providers - /// - ///Sends a `GET` request to `/silos/{silo_name}/identity-providers` - /// - ///Arguments: - /// - `silo_name`: The silo's unique name. - /// - `limit`: Maximum number of items returned by a single call - /// - `page_token`: Token returned by previous call to retrieve the - /// subsequent page - /// - `sort_by` - ///```ignore - /// let response = client.silo_identity_provider_list() - /// .silo_name(silo_name) - /// .limit(limit) - /// .page_token(page_token) - /// .sort_by(sort_by) - /// .send() - /// .await; - /// ``` - fn silo_identity_provider_list(&self) -> builder::SiloIdentityProviderList; - ///Fetch the IAM policy for this Silo - /// - ///Sends a `GET` request to `/silos/{silo_name}/policy` - /// - ///Arguments: - /// - `silo_name`: The silo's unique name. - ///```ignore - /// let response = client.silo_policy_view() - /// .silo_name(silo_name) - /// .send() - /// .await; - /// ``` - fn silo_policy_view(&self) -> builder::SiloPolicyView; - ///Update the IAM policy for this Silo - /// - ///Sends a `PUT` request to `/silos/{silo_name}/policy` - /// - ///Arguments: - /// - `silo_name`: The silo's unique name. - /// - `body` - ///```ignore - /// let response = client.silo_policy_update() - /// .silo_name(silo_name) - /// .body(body) - /// .send() - /// .await; - /// ``` - fn silo_policy_update(&self) -> builder::SiloPolicyUpdate; - ///Create a new SAML identity provider for a silo - /// - ///Sends a `POST` request to `/silos/{silo_name}/saml-identity-providers` - /// - ///Arguments: - /// - `silo_name`: The silo's unique name. - /// - `body` - ///```ignore - /// let response = client.silo_identity_provider_create() - /// .silo_name(silo_name) - /// .body(body) - /// .send() - /// .await; - /// ``` - fn silo_identity_provider_create(&self) -> builder::SiloIdentityProviderCreate; - ///GET a silo's SAML identity provider - /// - ///Sends a `GET` request to - /// `/silos/{silo_name}/saml-identity-providers/{provider_name}` - /// - ///Arguments: - /// - `silo_name`: The silo's unique name. - /// - `provider_name`: The SAML identity provider's name - ///```ignore - /// let response = client.silo_identity_provider_view() - /// .silo_name(silo_name) - /// .provider_name(provider_name) - /// .send() - /// .await; - /// ``` - fn silo_identity_provider_view(&self) -> builder::SiloIdentityProviderView; + fn policy_update(&self) -> builder::PolicyUpdate; ///List users /// ///Sends a `GET` request to `/users` @@ -13488,40 +16169,16 @@ pub trait ClientSilosExt { } impl ClientSilosExt for Client { - fn silo_list(&self) -> builder::SiloList { - builder::SiloList::new(self) + fn group_list(&self) -> builder::GroupList { + builder::GroupList::new(self) } - fn silo_create(&self) -> builder::SiloCreate { - builder::SiloCreate::new(self) + fn policy_view(&self) -> builder::PolicyView { + builder::PolicyView::new(self) } - fn silo_view(&self) -> builder::SiloView { - builder::SiloView::new(self) - } - - fn silo_delete(&self) -> builder::SiloDelete { - builder::SiloDelete::new(self) - } - - fn silo_identity_provider_list(&self) -> builder::SiloIdentityProviderList { - builder::SiloIdentityProviderList::new(self) - } - - fn silo_policy_view(&self) -> builder::SiloPolicyView { - builder::SiloPolicyView::new(self) - } - - fn silo_policy_update(&self) -> builder::SiloPolicyUpdate { - builder::SiloPolicyUpdate::new(self) - } - - fn silo_identity_provider_create(&self) -> builder::SiloIdentityProviderCreate { - builder::SiloIdentityProviderCreate::new(self) - } - - fn silo_identity_provider_view(&self) -> builder::SiloIdentityProviderView { - builder::SiloIdentityProviderView::new(self) + fn policy_update(&self) -> builder::PolicyUpdate { + builder::PolicyUpdate::new(self) } fn user_list(&self) -> builder::UserList { @@ -13530,7 +16187,7 @@ impl ClientSilosExt for Client { } pub trait ClientSnapshotsExt { - ///Get a snapshot by id + ///Fetch a snapshot by id /// ///Sends a `GET` request to `/by-id/snapshots/{id}` /// @@ -13541,7 +16198,7 @@ pub trait ClientSnapshotsExt { /// .await; /// ``` fn snapshot_view_by_id(&self) -> builder::SnapshotViewById; - ///List snapshots in a project + ///List snapshots /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/snapshots` @@ -13564,7 +16221,9 @@ pub trait ClientSnapshotsExt { /// .await; /// ``` fn snapshot_list(&self) -> builder::SnapshotList; - ///Create a snapshot of a disk + ///Create a snapshot + /// + ///Creates a point-in-time snapshot from a disk. /// ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/snapshots` @@ -13582,7 +16241,7 @@ pub trait ClientSnapshotsExt { /// .await; /// ``` fn snapshot_create(&self) -> builder::SnapshotCreate; - ///Get a snapshot in a project + ///Fetch a snapshot /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/snapshots/ @@ -13597,7 +16256,7 @@ pub trait ClientSnapshotsExt { /// .await; /// ``` fn snapshot_view(&self) -> builder::SnapshotView; - ///Delete a snapshot from a project + ///Delete a snapshot /// ///Sends a `DELETE` request to /// `/organizations/{organization_name}/projects/{project_name}/snapshots/ @@ -13637,7 +16296,710 @@ impl ClientSnapshotsExt for Client { } pub trait ClientSystemExt { - ///List the built-in system users + ///Fetch a system-wide image by id + /// + ///Sends a `GET` request to `/system/by-id/images/{id}` + /// + ///```ignore + /// let response = client.system_image_view_by_id() + /// .id(id) + /// .send() + /// .await; + /// ``` + fn system_image_view_by_id(&self) -> builder::SystemImageViewById; + ///Fetch an IP pool by id + /// + ///Sends a `GET` request to `/system/by-id/ip-pools/{id}` + /// + ///```ignore + /// let response = client.ip_pool_view_by_id() + /// .id(id) + /// .send() + /// .await; + /// ``` + fn ip_pool_view_by_id(&self) -> builder::IpPoolViewById; + ///Fetch a silo by id + /// + ///Sends a `GET` request to `/system/by-id/silos/{id}` + /// + ///```ignore + /// let response = client.silo_view_by_id() + /// .id(id) + /// .send() + /// .await; + /// ``` + fn silo_view_by_id(&self) -> builder::SiloViewById; + ///List system-wide certificates + /// + ///Returns a list of all the system-wide certificates. System-wide + /// certificates are returned sorted by creation date, with the most recent + /// certificates appearing first. + /// + ///Sends a `GET` request to `/system/certificates` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.certificate_list() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn certificate_list(&self) -> builder::CertificateList; + ///Create a new system-wide x.509 certificate + /// + ///This certificate is automatically used by the Oxide Control plane to + /// serve external connections. + /// + ///Sends a `POST` request to `/system/certificates` + /// + ///```ignore + /// let response = client.certificate_create() + /// .body(body) + /// .send() + /// .await; + /// ``` + fn certificate_create(&self) -> builder::CertificateCreate; + ///Fetch a certificate + /// + ///Returns the details of a specific certificate + /// + ///Sends a `GET` request to `/system/certificates/{certificate}` + /// + ///```ignore + /// let response = client.certificate_view() + /// .certificate(certificate) + /// .send() + /// .await; + /// ``` + fn certificate_view(&self) -> builder::CertificateView; + ///Delete a certificate + /// + ///Permanently delete a certificate. This operation cannot be undone. + /// + ///Sends a `DELETE` request to `/system/certificates/{certificate}` + /// + ///```ignore + /// let response = client.certificate_delete() + /// .certificate(certificate) + /// .send() + /// .await; + /// ``` + fn certificate_delete(&self) -> builder::CertificateDelete; + ///List physical disks + /// + ///Sends a `GET` request to `/system/hardware/disks` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.physical_disk_list() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn physical_disk_list(&self) -> builder::PhysicalDiskList; + ///List racks + /// + ///Sends a `GET` request to `/system/hardware/racks` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.rack_list() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn rack_list(&self) -> builder::RackList; + ///Fetch a rack + /// + ///Sends a `GET` request to `/system/hardware/racks/{rack_id}` + /// + ///Arguments: + /// - `rack_id`: The rack's unique ID. + ///```ignore + /// let response = client.rack_view() + /// .rack_id(rack_id) + /// .send() + /// .await; + /// ``` + fn rack_view(&self) -> builder::RackView; + ///List sleds + /// + ///Sends a `GET` request to `/system/hardware/sleds` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.sled_list() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn sled_list(&self) -> builder::SledList; + ///Fetch a sled + /// + ///Sends a `GET` request to `/system/hardware/sleds/{sled_id}` + /// + ///Arguments: + /// - `sled_id`: The sled's unique ID. + ///```ignore + /// let response = client.sled_view() + /// .sled_id(sled_id) + /// .send() + /// .await; + /// ``` + fn sled_view(&self) -> builder::SledView; + ///List physical disks attached to sleds + /// + ///Sends a `GET` request to `/system/hardware/sleds/{sled_id}/disks` + /// + ///Arguments: + /// - `sled_id`: The sled's unique ID. + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.sled_physical_disk_list() + /// .sled_id(sled_id) + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn sled_physical_disk_list(&self) -> builder::SledPhysicalDiskList; + ///List system-wide images + /// + ///Returns a list of all the system-wide images. System-wide images are + /// returned sorted by creation date, with the most recent images appearing + /// first. + /// + ///Sends a `GET` request to `/system/images` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.system_image_list() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn system_image_list(&self) -> builder::SystemImageList; + ///Create a system-wide image + /// + ///Create a new system-wide image. This image can then be used by any user + /// in any silo as a base for instances. + /// + ///Sends a `POST` request to `/system/images` + /// + ///```ignore + /// let response = client.system_image_create() + /// .body(body) + /// .send() + /// .await; + /// ``` + fn system_image_create(&self) -> builder::SystemImageCreate; + ///Fetch a system-wide image + /// + ///Returns the details of a specific system-wide image. + /// + ///Sends a `GET` request to `/system/images/{image_name}` + /// + ///```ignore + /// let response = client.system_image_view() + /// .image_name(image_name) + /// .send() + /// .await; + /// ``` + fn system_image_view(&self) -> builder::SystemImageView; + ///Delete a system-wide image + /// + ///Permanently delete a system-wide image. This operation cannot be undone. + /// Any instances using the system-wide image will continue to run, however + /// new instances can not be created with this image. + /// + ///Sends a `DELETE` request to `/system/images/{image_name}` + /// + ///```ignore + /// let response = client.system_image_delete() + /// .image_name(image_name) + /// .send() + /// .await; + /// ``` + fn system_image_delete(&self) -> builder::SystemImageDelete; + ///List IP pools + /// + ///Sends a `GET` request to `/system/ip-pools` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.ip_pool_list() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn ip_pool_list(&self) -> builder::IpPoolList; + ///Create an IP pool + /// + ///Sends a `POST` request to `/system/ip-pools` + /// + ///```ignore + /// let response = client.ip_pool_create() + /// .body(body) + /// .send() + /// .await; + /// ``` + fn ip_pool_create(&self) -> builder::IpPoolCreate; + ///Fetch an IP pool + /// + ///Sends a `GET` request to `/system/ip-pools/{pool_name}` + /// + ///```ignore + /// let response = client.ip_pool_view() + /// .pool_name(pool_name) + /// .send() + /// .await; + /// ``` + fn ip_pool_view(&self) -> builder::IpPoolView; + ///Update an IP Pool + /// + ///Sends a `PUT` request to `/system/ip-pools/{pool_name}` + /// + ///```ignore + /// let response = client.ip_pool_update() + /// .pool_name(pool_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn ip_pool_update(&self) -> builder::IpPoolUpdate; + ///Delete an IP Pool + /// + ///Sends a `DELETE` request to `/system/ip-pools/{pool_name}` + /// + ///```ignore + /// let response = client.ip_pool_delete() + /// .pool_name(pool_name) + /// .send() + /// .await; + /// ``` + fn ip_pool_delete(&self) -> builder::IpPoolDelete; + ///List ranges for an IP pool + /// + ///Ranges are ordered by their first address. + /// + ///Sends a `GET` request to `/system/ip-pools/{pool_name}/ranges` + /// + ///Arguments: + /// - `pool_name` + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + ///```ignore + /// let response = client.ip_pool_range_list() + /// .pool_name(pool_name) + /// .limit(limit) + /// .page_token(page_token) + /// .send() + /// .await; + /// ``` + fn ip_pool_range_list(&self) -> builder::IpPoolRangeList; + ///Add a range to an IP pool + /// + ///Sends a `POST` request to `/system/ip-pools/{pool_name}/ranges/add` + /// + ///```ignore + /// let response = client.ip_pool_range_add() + /// .pool_name(pool_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn ip_pool_range_add(&self) -> builder::IpPoolRangeAdd; + ///Remove a range from an IP pool + /// + ///Sends a `POST` request to `/system/ip-pools/{pool_name}/ranges/remove` + /// + ///```ignore + /// let response = client.ip_pool_range_remove() + /// .pool_name(pool_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn ip_pool_range_remove(&self) -> builder::IpPoolRangeRemove; + ///Fetch the IP pool used for Oxide services + /// + ///Sends a `GET` request to `/system/ip-pools-service` + /// + ///```ignore + /// let response = client.ip_pool_service_view() + /// .send() + /// .await; + /// ``` + fn ip_pool_service_view(&self) -> builder::IpPoolServiceView; + ///List ranges for the IP pool used for Oxide services + /// + ///Ranges are ordered by their first address. + /// + ///Sends a `GET` request to `/system/ip-pools-service/ranges` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + ///```ignore + /// let response = client.ip_pool_service_range_list() + /// .limit(limit) + /// .page_token(page_token) + /// .send() + /// .await; + /// ``` + fn ip_pool_service_range_list(&self) -> builder::IpPoolServiceRangeList; + ///Add a range to an IP pool used for Oxide services + /// + ///Sends a `POST` request to `/system/ip-pools-service/ranges/add` + /// + ///```ignore + /// let response = client.ip_pool_service_range_add() + /// .body(body) + /// .send() + /// .await; + /// ``` + fn ip_pool_service_range_add(&self) -> builder::IpPoolServiceRangeAdd; + ///Remove a range from an IP pool used for Oxide services + /// + ///Sends a `POST` request to `/system/ip-pools-service/ranges/remove` + /// + ///```ignore + /// let response = client.ip_pool_service_range_remove() + /// .body(body) + /// .send() + /// .await; + /// ``` + fn ip_pool_service_range_remove(&self) -> builder::IpPoolServiceRangeRemove; + ///Access metrics data + /// + ///Sends a `GET` request to `/system/metrics/{metric_name}` + /// + ///Arguments: + /// - `metric_name` + /// - `end_time`: An exclusive end time of metrics. + /// - `id`: The UUID of the container being queried + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `start_time`: An inclusive start time of metrics. + ///```ignore + /// let response = client.system_metric() + /// .metric_name(metric_name) + /// .end_time(end_time) + /// .id(id) + /// .limit(limit) + /// .page_token(page_token) + /// .start_time(start_time) + /// .send() + /// .await; + /// ``` + fn system_metric(&self) -> builder::SystemMetric; + ///List sagas + /// + ///Sends a `GET` request to `/system/sagas` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.saga_list() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn saga_list(&self) -> builder::SagaList; + ///Fetch a saga + /// + ///Sends a `GET` request to `/system/sagas/{saga_id}` + /// + ///```ignore + /// let response = client.saga_view() + /// .saga_id(saga_id) + /// .send() + /// .await; + /// ``` + fn saga_view(&self) -> builder::SagaView; + ///List silos + /// + ///Lists silos that are discoverable based on the current permissions. + /// + ///Sends a `GET` request to `/system/silos` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.silo_list() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn silo_list(&self) -> builder::SiloList; + ///Create a silo + /// + ///Sends a `POST` request to `/system/silos` + /// + ///```ignore + /// let response = client.silo_create() + /// .body(body) + /// .send() + /// .await; + /// ``` + fn silo_create(&self) -> builder::SiloCreate; + ///Fetch a silo + /// + ///Fetch a silo by name. + /// + ///Sends a `GET` request to `/system/silos/{silo_name}` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + ///```ignore + /// let response = client.silo_view() + /// .silo_name(silo_name) + /// .send() + /// .await; + /// ``` + fn silo_view(&self) -> builder::SiloView; + ///Delete a silo + /// + ///Delete a silo by name. + /// + ///Sends a `DELETE` request to `/system/silos/{silo_name}` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + ///```ignore + /// let response = client.silo_delete() + /// .silo_name(silo_name) + /// .send() + /// .await; + /// ``` + fn silo_delete(&self) -> builder::SiloDelete; + ///List a silo's IDPs + /// + ///Sends a `GET` request to `/system/silos/{silo_name}/identity-providers` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.silo_identity_provider_list() + /// .silo_name(silo_name) + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn silo_identity_provider_list(&self) -> builder::SiloIdentityProviderList; + ///Create a user + /// + ///Users can only be created in Silos with `provision_type` == `Fixed`. + /// Otherwise, Silo users are just-in-time (JIT) provisioned when a user + /// first logs in using an external Identity Provider. + /// + ///Sends a `POST` request to + /// `/system/silos/{silo_name}/identity-providers/local/users` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + /// - `body` + ///```ignore + /// let response = client.local_idp_user_create() + /// .silo_name(silo_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn local_idp_user_create(&self) -> builder::LocalIdpUserCreate; + ///Delete a user + /// + ///Sends a `DELETE` request to + /// `/system/silos/{silo_name}/identity-providers/local/users/{user_id}` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + /// - `user_id`: The user's internal id + ///```ignore + /// let response = client.local_idp_user_delete() + /// .silo_name(silo_name) + /// .user_id(user_id) + /// .send() + /// .await; + /// ``` + fn local_idp_user_delete(&self) -> builder::LocalIdpUserDelete; + ///Set or invalidate a user's password + /// + ///Passwords can only be updated for users in Silos with identity mode + /// `LocalOnly`. + /// + ///Sends a `POST` request to + /// `/system/silos/{silo_name}/identity-providers/local/users/{user_id}/ + /// set-password` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + /// - `user_id`: The user's internal id + /// - `body` + ///```ignore + /// let response = client.local_idp_user_set_password() + /// .silo_name(silo_name) + /// .user_id(user_id) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn local_idp_user_set_password(&self) -> builder::LocalIdpUserSetPassword; + ///Create a SAML IDP + /// + ///Sends a `POST` request to + /// `/system/silos/{silo_name}/identity-providers/saml` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + /// - `body` + ///```ignore + /// let response = client.saml_identity_provider_create() + /// .silo_name(silo_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn saml_identity_provider_create(&self) -> builder::SamlIdentityProviderCreate; + ///Fetch a SAML IDP + /// + ///Sends a `GET` request to + /// `/system/silos/{silo_name}/identity-providers/saml/{provider_name}` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + /// - `provider_name`: The SAML identity provider's name + ///```ignore + /// let response = client.saml_identity_provider_view() + /// .silo_name(silo_name) + /// .provider_name(provider_name) + /// .send() + /// .await; + /// ``` + fn saml_identity_provider_view(&self) -> builder::SamlIdentityProviderView; + ///Fetch a silo's IAM policy + /// + ///Sends a `GET` request to `/system/silos/{silo_name}/policy` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + ///```ignore + /// let response = client.silo_policy_view() + /// .silo_name(silo_name) + /// .send() + /// .await; + /// ``` + fn silo_policy_view(&self) -> builder::SiloPolicyView; + ///Update a silo's IAM policy + /// + ///Sends a `PUT` request to `/system/silos/{silo_name}/policy` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + /// - `body` + ///```ignore + /// let response = client.silo_policy_update() + /// .silo_name(silo_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn silo_policy_update(&self) -> builder::SiloPolicyUpdate; + ///List users in a silo + /// + ///Sends a `GET` request to `/system/silos/{silo_name}/users/all` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.silo_users_list() + /// .silo_name(silo_name) + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn silo_users_list(&self) -> builder::SiloUsersList; + ///Fetch a user + /// + ///Sends a `GET` request to `/system/silos/{silo_name}/users/id/{user_id}` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + /// - `user_id`: The user's internal id + ///```ignore + /// let response = client.silo_user_view() + /// .silo_name(silo_name) + /// .user_id(user_id) + /// .send() + /// .await; + /// ``` + fn silo_user_view(&self) -> builder::SiloUserView; + ///List built-in users /// ///Sends a `GET` request to `/system/user` /// @@ -13655,7 +17017,7 @@ pub trait ClientSystemExt { /// .await; /// ``` fn system_user_list(&self) -> builder::SystemUserList; - ///Fetch a specific built-in system user + ///Fetch a built-in user /// ///Sends a `GET` request to `/system/user/{user_name}` /// @@ -13668,9 +17030,324 @@ pub trait ClientSystemExt { /// .await; /// ``` fn system_user_view(&self) -> builder::SystemUserView; + ///View version and update status of component tree + /// + ///Sends a `GET` request to `/v1/system/update/components` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.system_component_version_list() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn system_component_version_list(&self) -> builder::SystemComponentVersionList; + ///List all update deployments + /// + ///Sends a `GET` request to `/v1/system/update/deployments` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.update_deployments_list() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn update_deployments_list(&self) -> builder::UpdateDeploymentsList; + ///Fetch a system update deployment + /// + ///Sends a `GET` request to `/v1/system/update/deployments/{id}` + /// + ///```ignore + /// let response = client.update_deployment_view() + /// .id(id) + /// .send() + /// .await; + /// ``` + fn update_deployment_view(&self) -> builder::UpdateDeploymentView; + ///Refresh update data + /// + ///Sends a `POST` request to `/v1/system/update/refresh` + /// + ///```ignore + /// let response = client.system_update_refresh() + /// .send() + /// .await; + /// ``` + fn system_update_refresh(&self) -> builder::SystemUpdateRefresh; + ///Start system update + /// + ///Sends a `POST` request to `/v1/system/update/start` + /// + ///```ignore + /// let response = client.system_update_start() + /// .body(body) + /// .send() + /// .await; + /// ``` + fn system_update_start(&self) -> builder::SystemUpdateStart; + ///Stop system update + /// + ///If there is no update in progress, do nothing. + /// + ///Sends a `POST` request to `/v1/system/update/stop` + /// + ///```ignore + /// let response = client.system_update_stop() + /// .send() + /// .await; + /// ``` + fn system_update_stop(&self) -> builder::SystemUpdateStop; + ///List all updates + /// + ///Sends a `GET` request to `/v1/system/update/updates` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.system_update_list() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn system_update_list(&self) -> builder::SystemUpdateList; + ///View system update + /// + ///Sends a `GET` request to `/v1/system/update/updates/{version}` + /// + ///```ignore + /// let response = client.system_update_view() + /// .version(version) + /// .send() + /// .await; + /// ``` + fn system_update_view(&self) -> builder::SystemUpdateView; + ///View system update component tree + /// + ///Sends a `GET` request to + /// `/v1/system/update/updates/{version}/components` + /// + ///```ignore + /// let response = client.system_update_components_list() + /// .version(version) + /// .send() + /// .await; + /// ``` + fn system_update_components_list(&self) -> builder::SystemUpdateComponentsList; + ///View system version and update status + /// + ///Sends a `GET` request to `/v1/system/update/version` + /// + ///```ignore + /// let response = client.system_version() + /// .send() + /// .await; + /// ``` + fn system_version(&self) -> builder::SystemVersion; } impl ClientSystemExt for Client { + fn system_image_view_by_id(&self) -> builder::SystemImageViewById { + builder::SystemImageViewById::new(self) + } + + fn ip_pool_view_by_id(&self) -> builder::IpPoolViewById { + builder::IpPoolViewById::new(self) + } + + fn silo_view_by_id(&self) -> builder::SiloViewById { + builder::SiloViewById::new(self) + } + + fn certificate_list(&self) -> builder::CertificateList { + builder::CertificateList::new(self) + } + + fn certificate_create(&self) -> builder::CertificateCreate { + builder::CertificateCreate::new(self) + } + + fn certificate_view(&self) -> builder::CertificateView { + builder::CertificateView::new(self) + } + + fn certificate_delete(&self) -> builder::CertificateDelete { + builder::CertificateDelete::new(self) + } + + fn physical_disk_list(&self) -> builder::PhysicalDiskList { + builder::PhysicalDiskList::new(self) + } + + fn rack_list(&self) -> builder::RackList { + builder::RackList::new(self) + } + + fn rack_view(&self) -> builder::RackView { + builder::RackView::new(self) + } + + fn sled_list(&self) -> builder::SledList { + builder::SledList::new(self) + } + + fn sled_view(&self) -> builder::SledView { + builder::SledView::new(self) + } + + fn sled_physical_disk_list(&self) -> builder::SledPhysicalDiskList { + builder::SledPhysicalDiskList::new(self) + } + + fn system_image_list(&self) -> builder::SystemImageList { + builder::SystemImageList::new(self) + } + + fn system_image_create(&self) -> builder::SystemImageCreate { + builder::SystemImageCreate::new(self) + } + + fn system_image_view(&self) -> builder::SystemImageView { + builder::SystemImageView::new(self) + } + + fn system_image_delete(&self) -> builder::SystemImageDelete { + builder::SystemImageDelete::new(self) + } + + fn ip_pool_list(&self) -> builder::IpPoolList { + builder::IpPoolList::new(self) + } + + fn ip_pool_create(&self) -> builder::IpPoolCreate { + builder::IpPoolCreate::new(self) + } + + fn ip_pool_view(&self) -> builder::IpPoolView { + builder::IpPoolView::new(self) + } + + fn ip_pool_update(&self) -> builder::IpPoolUpdate { + builder::IpPoolUpdate::new(self) + } + + fn ip_pool_delete(&self) -> builder::IpPoolDelete { + builder::IpPoolDelete::new(self) + } + + fn ip_pool_range_list(&self) -> builder::IpPoolRangeList { + builder::IpPoolRangeList::new(self) + } + + fn ip_pool_range_add(&self) -> builder::IpPoolRangeAdd { + builder::IpPoolRangeAdd::new(self) + } + + fn ip_pool_range_remove(&self) -> builder::IpPoolRangeRemove { + builder::IpPoolRangeRemove::new(self) + } + + fn ip_pool_service_view(&self) -> builder::IpPoolServiceView { + builder::IpPoolServiceView::new(self) + } + + fn ip_pool_service_range_list(&self) -> builder::IpPoolServiceRangeList { + builder::IpPoolServiceRangeList::new(self) + } + + fn ip_pool_service_range_add(&self) -> builder::IpPoolServiceRangeAdd { + builder::IpPoolServiceRangeAdd::new(self) + } + + fn ip_pool_service_range_remove(&self) -> builder::IpPoolServiceRangeRemove { + builder::IpPoolServiceRangeRemove::new(self) + } + + fn system_metric(&self) -> builder::SystemMetric { + builder::SystemMetric::new(self) + } + + fn saga_list(&self) -> builder::SagaList { + builder::SagaList::new(self) + } + + fn saga_view(&self) -> builder::SagaView { + builder::SagaView::new(self) + } + + fn silo_list(&self) -> builder::SiloList { + builder::SiloList::new(self) + } + + fn silo_create(&self) -> builder::SiloCreate { + builder::SiloCreate::new(self) + } + + fn silo_view(&self) -> builder::SiloView { + builder::SiloView::new(self) + } + + fn silo_delete(&self) -> builder::SiloDelete { + builder::SiloDelete::new(self) + } + + fn silo_identity_provider_list(&self) -> builder::SiloIdentityProviderList { + builder::SiloIdentityProviderList::new(self) + } + + fn local_idp_user_create(&self) -> builder::LocalIdpUserCreate { + builder::LocalIdpUserCreate::new(self) + } + + fn local_idp_user_delete(&self) -> builder::LocalIdpUserDelete { + builder::LocalIdpUserDelete::new(self) + } + + fn local_idp_user_set_password(&self) -> builder::LocalIdpUserSetPassword { + builder::LocalIdpUserSetPassword::new(self) + } + + fn saml_identity_provider_create(&self) -> builder::SamlIdentityProviderCreate { + builder::SamlIdentityProviderCreate::new(self) + } + + fn saml_identity_provider_view(&self) -> builder::SamlIdentityProviderView { + builder::SamlIdentityProviderView::new(self) + } + + fn silo_policy_view(&self) -> builder::SiloPolicyView { + builder::SiloPolicyView::new(self) + } + + fn silo_policy_update(&self) -> builder::SiloPolicyUpdate { + builder::SiloPolicyUpdate::new(self) + } + + fn silo_users_list(&self) -> builder::SiloUsersList { + builder::SiloUsersList::new(self) + } + + fn silo_user_view(&self) -> builder::SiloUserView { + builder::SiloUserView::new(self) + } + fn system_user_list(&self) -> builder::SystemUserList { builder::SystemUserList::new(self) } @@ -13678,29 +17355,50 @@ impl ClientSystemExt for Client { fn system_user_view(&self) -> builder::SystemUserView { builder::SystemUserView::new(self) } -} -pub trait ClientUpdatesExt { - ///Refresh update metadata - /// - ///Sends a `POST` request to `/updates/refresh` - /// - ///```ignore - /// let response = client.updates_refresh() - /// .send() - /// .await; - /// ``` - fn updates_refresh(&self) -> builder::UpdatesRefresh; -} + fn system_component_version_list(&self) -> builder::SystemComponentVersionList { + builder::SystemComponentVersionList::new(self) + } -impl ClientUpdatesExt for Client { - fn updates_refresh(&self) -> builder::UpdatesRefresh { - builder::UpdatesRefresh::new(self) + fn update_deployments_list(&self) -> builder::UpdateDeploymentsList { + builder::UpdateDeploymentsList::new(self) + } + + fn update_deployment_view(&self) -> builder::UpdateDeploymentView { + builder::UpdateDeploymentView::new(self) + } + + fn system_update_refresh(&self) -> builder::SystemUpdateRefresh { + builder::SystemUpdateRefresh::new(self) + } + + fn system_update_start(&self) -> builder::SystemUpdateStart { + builder::SystemUpdateStart::new(self) + } + + fn system_update_stop(&self) -> builder::SystemUpdateStop { + builder::SystemUpdateStop::new(self) + } + + fn system_update_list(&self) -> builder::SystemUpdateList { + builder::SystemUpdateList::new(self) + } + + fn system_update_view(&self) -> builder::SystemUpdateView { + builder::SystemUpdateView::new(self) + } + + fn system_update_components_list(&self) -> builder::SystemUpdateComponentsList { + builder::SystemUpdateComponentsList::new(self) + } + + fn system_version(&self) -> builder::SystemVersion { + builder::SystemVersion::new(self) } } pub trait ClientVpcsExt { - ///Get a vpc router route by id + ///Fetch a route by id /// ///Sends a `GET` request to `/by-id/vpc-router-routes/{id}` /// @@ -13711,7 +17409,7 @@ pub trait ClientVpcsExt { /// .await; /// ``` fn vpc_router_route_view_by_id(&self) -> builder::VpcRouterRouteViewById; - ///Get a VPC Router by id + ///Get a router by id /// ///Sends a `GET` request to `/by-id/vpc-routers/{id}` /// @@ -13722,7 +17420,7 @@ pub trait ClientVpcsExt { /// .await; /// ``` fn vpc_router_view_by_id(&self) -> builder::VpcRouterViewById; - ///Get a VPC subnet by id + ///Fetch a subnet by id /// ///Sends a `GET` request to `/by-id/vpc-subnets/{id}` /// @@ -13733,7 +17431,7 @@ pub trait ClientVpcsExt { /// .await; /// ``` fn vpc_subnet_view_by_id(&self) -> builder::VpcSubnetViewById; - ///Get a VPC by id + ///Fetch a VPC /// ///Sends a `GET` request to `/by-id/vpcs/{id}` /// @@ -13744,7 +17442,7 @@ pub trait ClientVpcsExt { /// .await; /// ``` fn vpc_view_by_id(&self) -> builder::VpcViewById; - ///List VPCs in a project + ///List VPCs /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs` @@ -13767,7 +17465,7 @@ pub trait ClientVpcsExt { /// .await; /// ``` fn vpc_list(&self) -> builder::VpcList; - ///Create a VPC in a project + ///Create a VPC /// ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs` @@ -13785,7 +17483,7 @@ pub trait ClientVpcsExt { /// .await; /// ``` fn vpc_create(&self) -> builder::VpcCreate; - ///Get a VPC in a project + ///Fetch a VPC /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -13816,7 +17514,7 @@ pub trait ClientVpcsExt { /// .await; /// ``` fn vpc_update(&self) -> builder::VpcUpdate; - ///Delete a vpc from a project + ///Delete a VPC /// ///Sends a `DELETE` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -13831,7 +17529,7 @@ pub trait ClientVpcsExt { /// .await; /// ``` fn vpc_delete(&self) -> builder::VpcDelete; - ///List firewall rules for a VPC + ///List firewall rules /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -13846,7 +17544,7 @@ pub trait ClientVpcsExt { /// .await; /// ``` fn vpc_firewall_rules_view(&self) -> builder::VpcFirewallRulesView; - ///Replace the firewall rules for a VPC + ///Replace firewall rules /// ///Sends a `PUT` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -13862,7 +17560,7 @@ pub trait ClientVpcsExt { /// .await; /// ``` fn vpc_firewall_rules_update(&self) -> builder::VpcFirewallRulesUpdate; - ///List VPC Custom and System Routers + ///List routers /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -13888,7 +17586,7 @@ pub trait ClientVpcsExt { /// .await; /// ``` fn vpc_router_list(&self) -> builder::VpcRouterList; - ///Create a VPC Router + ///Create a router /// ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -13904,7 +17602,7 @@ pub trait ClientVpcsExt { /// .await; /// ``` fn vpc_router_create(&self) -> builder::VpcRouterCreate; - ///Get a VPC Router + ///Get a router /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -13920,7 +17618,7 @@ pub trait ClientVpcsExt { /// .await; /// ``` fn vpc_router_view(&self) -> builder::VpcRouterView; - ///Update a VPC Router + ///Update a router /// ///Sends a `PUT` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -13937,7 +17635,7 @@ pub trait ClientVpcsExt { /// .await; /// ``` fn vpc_router_update(&self) -> builder::VpcRouterUpdate; - ///Delete a router from its VPC + ///Delete a router /// ///Sends a `DELETE` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -13953,7 +17651,9 @@ pub trait ClientVpcsExt { /// .await; /// ``` fn vpc_router_delete(&self) -> builder::VpcRouterDelete; - ///List a Router's routes + ///List routes + /// + ///List the routes associated with a router in a particular VPC. /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -13981,7 +17681,7 @@ pub trait ClientVpcsExt { /// .await; /// ``` fn vpc_router_route_list(&self) -> builder::VpcRouterRouteList; - ///Create a VPC Router + ///Create a router /// ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -13998,7 +17698,7 @@ pub trait ClientVpcsExt { /// .await; /// ``` fn vpc_router_route_create(&self) -> builder::VpcRouterRouteCreate; - ///Get a VPC Router route + ///Fetch a route /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -14015,7 +17715,7 @@ pub trait ClientVpcsExt { /// .await; /// ``` fn vpc_router_route_view(&self) -> builder::VpcRouterRouteView; - ///Update a Router route + ///Update a route /// ///Sends a `PUT` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -14033,7 +17733,7 @@ pub trait ClientVpcsExt { /// .await; /// ``` fn vpc_router_route_update(&self) -> builder::VpcRouterRouteUpdate; - ///Delete a route from its router + ///Delete a route /// ///Sends a `DELETE` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -14050,7 +17750,7 @@ pub trait ClientVpcsExt { /// .await; /// ``` fn vpc_router_route_delete(&self) -> builder::VpcRouterRouteDelete; - ///List subnets in a VPC + ///List subnets /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -14076,7 +17776,7 @@ pub trait ClientVpcsExt { /// .await; /// ``` fn vpc_subnet_list(&self) -> builder::VpcSubnetList; - ///Create a subnet in a VPC + ///Create a subnet /// ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -14092,7 +17792,7 @@ pub trait ClientVpcsExt { /// .await; /// ``` fn vpc_subnet_create(&self) -> builder::VpcSubnetCreate; - ///Get subnet in a VPC + ///Fetch a subnet /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -14108,7 +17808,7 @@ pub trait ClientVpcsExt { /// .await; /// ``` fn vpc_subnet_view(&self) -> builder::VpcSubnetView; - ///Update a VPC Subnet + ///Update a subnet /// ///Sends a `PUT` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -14125,7 +17825,7 @@ pub trait ClientVpcsExt { /// .await; /// ``` fn vpc_subnet_update(&self) -> builder::VpcSubnetUpdate; - ///Delete a subnet from a VPC + ///Delete a subnet /// ///Sends a `DELETE` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -14141,7 +17841,7 @@ pub trait ClientVpcsExt { /// .await; /// ``` fn vpc_subnet_delete(&self) -> builder::VpcSubnetDelete; - ///List network interfaces in a VPC subnet + ///List network interfaces /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -14339,58 +18039,6 @@ pub mod builder { } } - ///Builder for [`ClientImagesGlobalExt::image_global_view_by_id`] - /// - ///[`ClientImagesGlobalExt::image_global_view_by_id`]: super::ClientImagesGlobalExt::image_global_view_by_id - #[derive(Debug, Clone)] - pub struct ImageGlobalViewById<'a> { - client: &'a super::Client, - id: Result, - } - - impl<'a> ImageGlobalViewById<'a> { - pub fn new(client: &'a super::Client) -> Self { - Self { - client, - id: Err("id was not initialized".to_string()), - } - } - - pub fn id(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.id = value - .try_into() - .map_err(|_| "conversion to `uuid :: Uuid` for id failed".to_string()); - self - } - - ///Sends a `GET` request to `/by-id/global-images/{id}` - pub async fn send(self) -> Result, Error> { - let Self { client, id } = self; - let id = id.map_err(Error::InvalidRequest)?; - let url = format!( - "{}/by-id/global-images/{}", - client.baseurl, - encode_path(&id.to_string()), - ); - let request = client.client.get(url).build()?; - let result = client.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 200u16 => ResponseValue::from_response(response).await, - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - } - ///Builder for [`ClientImagesExt::image_view_by_id`] /// ///[`ClientImagesExt::image_view_by_id`]: super::ClientImagesExt::image_view_by_id @@ -15046,18 +18694,18 @@ pub mod builder { } } - ///Builder for [`ClientHardwareExt::rack_list`] + ///Builder for [`ClientSilosExt::group_list`] /// - ///[`ClientHardwareExt::rack_list`]: super::ClientHardwareExt::rack_list + ///[`ClientSilosExt::group_list`]: super::ClientSilosExt::group_list #[derive(Debug, Clone)] - pub struct RackList<'a> { + pub struct GroupList<'a> { client: &'a super::Client, limit: Result, String>, page_token: Result, String>, sort_by: Result, String>, } - impl<'a> RackList<'a> { + impl<'a> GroupList<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client, @@ -15098,10 +18746,10 @@ pub mod builder { self } - ///Sends a `GET` request to `/hardware/racks` + ///Sends a `GET` request to `/groups` pub async fn send( self, - ) -> Result, Error> { + ) -> Result, Error> { let Self { client, limit, @@ -15111,7 +18759,7 @@ pub mod builder { let limit = limit.map_err(Error::InvalidRequest)?; let page_token = page_token.map_err(Error::InvalidRequest)?; let sort_by = sort_by.map_err(Error::InvalidRequest)?; - let url = format!("{}/hardware/racks", client.baseurl,); + let url = format!("{}/groups", client.baseurl,); let mut query = Vec::with_capacity(3usize); if let Some(v) = &limit { query.push(("limit", v.to_string())); @@ -15137,10 +18785,10 @@ pub mod builder { } } - ///Streams `GET` requests to `/hardware/racks` + ///Streams `GET` requests to `/groups` pub fn stream( self, - ) -> impl futures::Stream>> + Unpin + 'a + ) -> impl futures::Stream>> + Unpin + 'a { use futures::StreamExt; use futures::TryFutureExt; @@ -15185,1187 +18833,16 @@ pub mod builder { } } - ///Builder for [`ClientHardwareExt::rack_view`] + ///Builder for [`ClientHiddenExt::login_spoof`] /// - ///[`ClientHardwareExt::rack_view`]: super::ClientHardwareExt::rack_view + ///[`ClientHiddenExt::login_spoof`]: super::ClientHiddenExt::login_spoof #[derive(Debug, Clone)] - pub struct RackView<'a> { - client: &'a super::Client, - rack_id: Result, - } - - impl<'a> RackView<'a> { - pub fn new(client: &'a super::Client) -> Self { - Self { - client, - rack_id: Err("rack_id was not initialized".to_string()), - } - } - - pub fn rack_id(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.rack_id = value - .try_into() - .map_err(|_| "conversion to `uuid :: Uuid` for rack_id failed".to_string()); - self - } - - ///Sends a `GET` request to `/hardware/racks/{rack_id}` - pub async fn send(self) -> Result, Error> { - let Self { client, rack_id } = self; - let rack_id = rack_id.map_err(Error::InvalidRequest)?; - let url = format!( - "{}/hardware/racks/{}", - client.baseurl, - encode_path(&rack_id.to_string()), - ); - let request = client.client.get(url).build()?; - let result = client.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 200u16 => ResponseValue::from_response(response).await, - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - } - - ///Builder for [`ClientHardwareExt::sled_list`] - /// - ///[`ClientHardwareExt::sled_list`]: super::ClientHardwareExt::sled_list - #[derive(Debug, Clone)] - pub struct SledList<'a> { - client: &'a super::Client, - limit: Result, String>, - page_token: Result, String>, - sort_by: Result, String>, - } - - impl<'a> SledList<'a> { - pub fn new(client: &'a super::Client) -> Self { - Self { - client, - limit: Ok(None), - page_token: Ok(None), - sort_by: Ok(None), - } - } - - pub fn limit(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.limit = value.try_into().map(Some).map_err(|_| { - "conversion to `Option < std :: num :: NonZeroU32 >` for limit failed".to_string() - }); - self - } - - pub fn page_token(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.page_token = value - .try_into() - .map(Some) - .map_err(|_| "conversion to `Option < String >` for page_token failed".to_string()); - self - } - - pub fn sort_by(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.sort_by = value.try_into().map(Some).map_err(|_| { - "conversion to `Option < IdSortMode >` for sort_by failed".to_string() - }); - self - } - - ///Sends a `GET` request to `/hardware/sleds` - pub async fn send( - self, - ) -> Result, Error> { - let Self { - client, - limit, - page_token, - sort_by, - } = self; - let limit = limit.map_err(Error::InvalidRequest)?; - let page_token = page_token.map_err(Error::InvalidRequest)?; - let sort_by = sort_by.map_err(Error::InvalidRequest)?; - let url = format!("{}/hardware/sleds", client.baseurl,); - let mut query = Vec::with_capacity(3usize); - if let Some(v) = &limit { - query.push(("limit", v.to_string())); - } - if let Some(v) = &page_token { - query.push(("page_token", v.to_string())); - } - if let Some(v) = &sort_by { - query.push(("sort_by", v.to_string())); - } - let request = client.client.get(url).query(&query).build()?; - let result = client.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 200u16 => ResponseValue::from_response(response).await, - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - - ///Streams `GET` requests to `/hardware/sleds` - pub fn stream( - self, - ) -> impl futures::Stream>> + Unpin + 'a - { - use futures::StreamExt; - use futures::TryFutureExt; - use futures::TryStreamExt; - let next = Self { - limit: Ok(None), - page_token: Ok(None), - sort_by: Ok(None), - ..self.clone() - }; - self.send() - .map_ok(move |page| { - let page = page.into_inner(); - let first = futures::stream::iter(page.items.into_iter().map(Ok)); - let rest = futures::stream::try_unfold( - (page.next_page, next), - |(next_page, next)| async { - if next_page.is_none() { - Ok(None) - } else { - Self { - page_token: Ok(next_page), - ..next.clone() - } - .send() - .map_ok(|page| { - let page = page.into_inner(); - Some(( - futures::stream::iter(page.items.into_iter().map(Ok)), - (page.next_page, next), - )) - }) - .await - } - }, - ) - .try_flatten(); - first.chain(rest) - }) - .try_flatten_stream() - .boxed() - } - } - - ///Builder for [`ClientHardwareExt::sled_view`] - /// - ///[`ClientHardwareExt::sled_view`]: super::ClientHardwareExt::sled_view - #[derive(Debug, Clone)] - pub struct SledView<'a> { - client: &'a super::Client, - sled_id: Result, - } - - impl<'a> SledView<'a> { - pub fn new(client: &'a super::Client) -> Self { - Self { - client, - sled_id: Err("sled_id was not initialized".to_string()), - } - } - - pub fn sled_id(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.sled_id = value - .try_into() - .map_err(|_| "conversion to `uuid :: Uuid` for sled_id failed".to_string()); - self - } - - ///Sends a `GET` request to `/hardware/sleds/{sled_id}` - pub async fn send(self) -> Result, Error> { - let Self { client, sled_id } = self; - let sled_id = sled_id.map_err(Error::InvalidRequest)?; - let url = format!( - "{}/hardware/sleds/{}", - client.baseurl, - encode_path(&sled_id.to_string()), - ); - let request = client.client.get(url).build()?; - let result = client.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 200u16 => ResponseValue::from_response(response).await, - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - } - - ///Builder for [`ClientImagesGlobalExt::image_global_list`] - /// - ///[`ClientImagesGlobalExt::image_global_list`]: super::ClientImagesGlobalExt::image_global_list - #[derive(Debug, Clone)] - pub struct ImageGlobalList<'a> { - client: &'a super::Client, - limit: Result, String>, - page_token: Result, String>, - sort_by: Result, String>, - } - - impl<'a> ImageGlobalList<'a> { - pub fn new(client: &'a super::Client) -> Self { - Self { - client, - limit: Ok(None), - page_token: Ok(None), - sort_by: Ok(None), - } - } - - pub fn limit(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.limit = value.try_into().map(Some).map_err(|_| { - "conversion to `Option < std :: num :: NonZeroU32 >` for limit failed".to_string() - }); - self - } - - pub fn page_token(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.page_token = value - .try_into() - .map(Some) - .map_err(|_| "conversion to `Option < String >` for page_token failed".to_string()); - self - } - - pub fn sort_by(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.sort_by = value.try_into().map(Some).map_err(|_| { - "conversion to `Option < NameSortMode >` for sort_by failed".to_string() - }); - self - } - - ///Sends a `GET` request to `/images` - pub async fn send( - self, - ) -> Result, Error> { - let Self { - client, - limit, - page_token, - sort_by, - } = self; - let limit = limit.map_err(Error::InvalidRequest)?; - let page_token = page_token.map_err(Error::InvalidRequest)?; - let sort_by = sort_by.map_err(Error::InvalidRequest)?; - let url = format!("{}/images", client.baseurl,); - let mut query = Vec::with_capacity(3usize); - if let Some(v) = &limit { - query.push(("limit", v.to_string())); - } - if let Some(v) = &page_token { - query.push(("page_token", v.to_string())); - } - if let Some(v) = &sort_by { - query.push(("sort_by", v.to_string())); - } - let request = client.client.get(url).query(&query).build()?; - let result = client.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 200u16 => ResponseValue::from_response(response).await, - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - - ///Streams `GET` requests to `/images` - pub fn stream( - self, - ) -> impl futures::Stream>> + Unpin + 'a - { - use futures::StreamExt; - use futures::TryFutureExt; - use futures::TryStreamExt; - let next = Self { - limit: Ok(None), - page_token: Ok(None), - sort_by: Ok(None), - ..self.clone() - }; - self.send() - .map_ok(move |page| { - let page = page.into_inner(); - let first = futures::stream::iter(page.items.into_iter().map(Ok)); - let rest = futures::stream::try_unfold( - (page.next_page, next), - |(next_page, next)| async { - if next_page.is_none() { - Ok(None) - } else { - Self { - page_token: Ok(next_page), - ..next.clone() - } - .send() - .map_ok(|page| { - let page = page.into_inner(); - Some(( - futures::stream::iter(page.items.into_iter().map(Ok)), - (page.next_page, next), - )) - }) - .await - } - }, - ) - .try_flatten(); - first.chain(rest) - }) - .try_flatten_stream() - .boxed() - } - } - - ///Builder for [`ClientImagesGlobalExt::image_global_create`] - /// - ///[`ClientImagesGlobalExt::image_global_create`]: super::ClientImagesGlobalExt::image_global_create - #[derive(Debug, Clone)] - pub struct ImageGlobalCreate<'a> { - client: &'a super::Client, - body: Result, - } - - impl<'a> ImageGlobalCreate<'a> { - pub fn new(client: &'a super::Client) -> Self { - Self { - client, - body: Err("body was not initialized".to_string()), - } - } - - pub fn body(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.body = value - .try_into() - .map_err(|_| "conversion to `GlobalImageCreate` for body failed".to_string()); - self - } - - ///Sends a `POST` request to `/images` - pub async fn send(self) -> Result, Error> { - let Self { client, body } = self; - let body = body.map_err(Error::InvalidRequest)?; - let url = format!("{}/images", client.baseurl,); - let request = client.client.post(url).json(&body).build()?; - let result = client.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 201u16 => ResponseValue::from_response(response).await, - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - } - - ///Builder for [`ClientImagesGlobalExt::image_global_view`] - /// - ///[`ClientImagesGlobalExt::image_global_view`]: super::ClientImagesGlobalExt::image_global_view - #[derive(Debug, Clone)] - pub struct ImageGlobalView<'a> { - client: &'a super::Client, - image_name: Result, - } - - impl<'a> ImageGlobalView<'a> { - pub fn new(client: &'a super::Client) -> Self { - Self { - client, - image_name: Err("image_name was not initialized".to_string()), - } - } - - pub fn image_name(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.image_name = value - .try_into() - .map_err(|_| "conversion to `Name` for image_name failed".to_string()); - self - } - - ///Sends a `GET` request to `/images/{image_name}` - pub async fn send(self) -> Result, Error> { - let Self { client, image_name } = self; - let image_name = image_name.map_err(Error::InvalidRequest)?; - let url = format!( - "{}/images/{}", - client.baseurl, - encode_path(&image_name.to_string()), - ); - let request = client.client.get(url).build()?; - let result = client.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 200u16 => ResponseValue::from_response(response).await, - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - } - - ///Builder for [`ClientImagesGlobalExt::image_global_delete`] - /// - ///[`ClientImagesGlobalExt::image_global_delete`]: super::ClientImagesGlobalExt::image_global_delete - #[derive(Debug, Clone)] - pub struct ImageGlobalDelete<'a> { - client: &'a super::Client, - image_name: Result, - } - - impl<'a> ImageGlobalDelete<'a> { - pub fn new(client: &'a super::Client) -> Self { - Self { - client, - image_name: Err("image_name was not initialized".to_string()), - } - } - - pub fn image_name(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.image_name = value - .try_into() - .map_err(|_| "conversion to `Name` for image_name failed".to_string()); - self - } - - ///Sends a `DELETE` request to `/images/{image_name}` - pub async fn send(self) -> Result, Error> { - let Self { client, image_name } = self; - let image_name = image_name.map_err(Error::InvalidRequest)?; - let url = format!( - "{}/images/{}", - client.baseurl, - encode_path(&image_name.to_string()), - ); - let request = client.client.delete(url).build()?; - let result = client.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 204u16 => Ok(ResponseValue::empty(response)), - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - } - - ///Builder for [`ClientIpPoolsExt::ip_pool_list`] - /// - ///[`ClientIpPoolsExt::ip_pool_list`]: super::ClientIpPoolsExt::ip_pool_list - #[derive(Debug, Clone)] - pub struct IpPoolList<'a> { - client: &'a super::Client, - limit: Result, String>, - page_token: Result, String>, - sort_by: Result, String>, - } - - impl<'a> IpPoolList<'a> { - pub fn new(client: &'a super::Client) -> Self { - Self { - client, - limit: Ok(None), - page_token: Ok(None), - sort_by: Ok(None), - } - } - - pub fn limit(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.limit = value.try_into().map(Some).map_err(|_| { - "conversion to `Option < std :: num :: NonZeroU32 >` for limit failed".to_string() - }); - self - } - - pub fn page_token(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.page_token = value - .try_into() - .map(Some) - .map_err(|_| "conversion to `Option < String >` for page_token failed".to_string()); - self - } - - pub fn sort_by(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.sort_by = value.try_into().map(Some).map_err(|_| { - "conversion to `Option < NameOrIdSortMode >` for sort_by failed".to_string() - }); - self - } - - ///Sends a `GET` request to `/ip-pools` - pub async fn send( - self, - ) -> Result, Error> { - let Self { - client, - limit, - page_token, - sort_by, - } = self; - let limit = limit.map_err(Error::InvalidRequest)?; - let page_token = page_token.map_err(Error::InvalidRequest)?; - let sort_by = sort_by.map_err(Error::InvalidRequest)?; - let url = format!("{}/ip-pools", client.baseurl,); - let mut query = Vec::with_capacity(3usize); - if let Some(v) = &limit { - query.push(("limit", v.to_string())); - } - if let Some(v) = &page_token { - query.push(("page_token", v.to_string())); - } - if let Some(v) = &sort_by { - query.push(("sort_by", v.to_string())); - } - let request = client.client.get(url).query(&query).build()?; - let result = client.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 200u16 => ResponseValue::from_response(response).await, - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - - ///Streams `GET` requests to `/ip-pools` - pub fn stream( - self, - ) -> impl futures::Stream>> + Unpin + 'a - { - use futures::StreamExt; - use futures::TryFutureExt; - use futures::TryStreamExt; - let next = Self { - limit: Ok(None), - page_token: Ok(None), - sort_by: Ok(None), - ..self.clone() - }; - self.send() - .map_ok(move |page| { - let page = page.into_inner(); - let first = futures::stream::iter(page.items.into_iter().map(Ok)); - let rest = futures::stream::try_unfold( - (page.next_page, next), - |(next_page, next)| async { - if next_page.is_none() { - Ok(None) - } else { - Self { - page_token: Ok(next_page), - ..next.clone() - } - .send() - .map_ok(|page| { - let page = page.into_inner(); - Some(( - futures::stream::iter(page.items.into_iter().map(Ok)), - (page.next_page, next), - )) - }) - .await - } - }, - ) - .try_flatten(); - first.chain(rest) - }) - .try_flatten_stream() - .boxed() - } - } - - ///Builder for [`ClientIpPoolsExt::ip_pool_create`] - /// - ///[`ClientIpPoolsExt::ip_pool_create`]: super::ClientIpPoolsExt::ip_pool_create - #[derive(Debug, Clone)] - pub struct IpPoolCreate<'a> { - client: &'a super::Client, - body: Result, - } - - impl<'a> IpPoolCreate<'a> { - pub fn new(client: &'a super::Client) -> Self { - Self { - client, - body: Err("body was not initialized".to_string()), - } - } - - pub fn body(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.body = value - .try_into() - .map_err(|_| "conversion to `IpPoolCreate` for body failed".to_string()); - self - } - - ///Sends a `POST` request to `/ip-pools` - pub async fn send(self) -> Result, Error> { - let Self { client, body } = self; - let body = body.map_err(Error::InvalidRequest)?; - let url = format!("{}/ip-pools", client.baseurl,); - let request = client.client.post(url).json(&body).build()?; - let result = client.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 201u16 => ResponseValue::from_response(response).await, - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - } - - ///Builder for [`ClientIpPoolsExt::ip_pool_view`] - /// - ///[`ClientIpPoolsExt::ip_pool_view`]: super::ClientIpPoolsExt::ip_pool_view - #[derive(Debug, Clone)] - pub struct IpPoolView<'a> { - client: &'a super::Client, - pool_name: Result, - } - - impl<'a> IpPoolView<'a> { - pub fn new(client: &'a super::Client) -> Self { - Self { - client, - pool_name: Err("pool_name was not initialized".to_string()), - } - } - - pub fn pool_name(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.pool_name = value - .try_into() - .map_err(|_| "conversion to `Name` for pool_name failed".to_string()); - self - } - - ///Sends a `GET` request to `/ip-pools/{pool_name}` - pub async fn send(self) -> Result, Error> { - let Self { client, pool_name } = self; - let pool_name = pool_name.map_err(Error::InvalidRequest)?; - let url = format!( - "{}/ip-pools/{}", - client.baseurl, - encode_path(&pool_name.to_string()), - ); - let request = client.client.get(url).build()?; - let result = client.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 200u16 => ResponseValue::from_response(response).await, - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - } - - ///Builder for [`ClientIpPoolsExt::ip_pool_update`] - /// - ///[`ClientIpPoolsExt::ip_pool_update`]: super::ClientIpPoolsExt::ip_pool_update - #[derive(Debug, Clone)] - pub struct IpPoolUpdate<'a> { - client: &'a super::Client, - pool_name: Result, - body: Result, - } - - impl<'a> IpPoolUpdate<'a> { - pub fn new(client: &'a super::Client) -> Self { - Self { - client, - pool_name: Err("pool_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), - } - } - - pub fn pool_name(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.pool_name = value - .try_into() - .map_err(|_| "conversion to `Name` for pool_name failed".to_string()); - self - } - - pub fn body(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.body = value - .try_into() - .map_err(|_| "conversion to `IpPoolUpdate` for body failed".to_string()); - self - } - - ///Sends a `PUT` request to `/ip-pools/{pool_name}` - pub async fn send(self) -> Result, Error> { - let Self { - client, - pool_name, - body, - } = self; - let pool_name = pool_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; - let url = format!( - "{}/ip-pools/{}", - client.baseurl, - encode_path(&pool_name.to_string()), - ); - let request = client.client.put(url).json(&body).build()?; - let result = client.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 200u16 => ResponseValue::from_response(response).await, - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - } - - ///Builder for [`ClientIpPoolsExt::ip_pool_delete`] - /// - ///[`ClientIpPoolsExt::ip_pool_delete`]: super::ClientIpPoolsExt::ip_pool_delete - #[derive(Debug, Clone)] - pub struct IpPoolDelete<'a> { - client: &'a super::Client, - pool_name: Result, - } - - impl<'a> IpPoolDelete<'a> { - pub fn new(client: &'a super::Client) -> Self { - Self { - client, - pool_name: Err("pool_name was not initialized".to_string()), - } - } - - pub fn pool_name(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.pool_name = value - .try_into() - .map_err(|_| "conversion to `Name` for pool_name failed".to_string()); - self - } - - ///Sends a `DELETE` request to `/ip-pools/{pool_name}` - pub async fn send(self) -> Result, Error> { - let Self { client, pool_name } = self; - let pool_name = pool_name.map_err(Error::InvalidRequest)?; - let url = format!( - "{}/ip-pools/{}", - client.baseurl, - encode_path(&pool_name.to_string()), - ); - let request = client.client.delete(url).build()?; - let result = client.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 204u16 => Ok(ResponseValue::empty(response)), - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - } - - ///Builder for [`ClientIpPoolsExt::ip_pool_range_list`] - /// - ///[`ClientIpPoolsExt::ip_pool_range_list`]: super::ClientIpPoolsExt::ip_pool_range_list - #[derive(Debug, Clone)] - pub struct IpPoolRangeList<'a> { - client: &'a super::Client, - pool_name: Result, - limit: Result, String>, - page_token: Result, String>, - } - - impl<'a> IpPoolRangeList<'a> { - pub fn new(client: &'a super::Client) -> Self { - Self { - client, - pool_name: Err("pool_name was not initialized".to_string()), - limit: Ok(None), - page_token: Ok(None), - } - } - - pub fn pool_name(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.pool_name = value - .try_into() - .map_err(|_| "conversion to `Name` for pool_name failed".to_string()); - self - } - - pub fn limit(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.limit = value.try_into().map(Some).map_err(|_| { - "conversion to `Option < std :: num :: NonZeroU32 >` for limit failed".to_string() - }); - self - } - - pub fn page_token(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.page_token = value - .try_into() - .map(Some) - .map_err(|_| "conversion to `Option < String >` for page_token failed".to_string()); - self - } - - ///Sends a `GET` request to `/ip-pools/{pool_name}/ranges` - pub async fn send( - self, - ) -> Result, Error> { - let Self { - client, - pool_name, - limit, - page_token, - } = self; - let pool_name = pool_name.map_err(Error::InvalidRequest)?; - let limit = limit.map_err(Error::InvalidRequest)?; - let page_token = page_token.map_err(Error::InvalidRequest)?; - let url = format!( - "{}/ip-pools/{}/ranges", - client.baseurl, - encode_path(&pool_name.to_string()), - ); - let mut query = Vec::with_capacity(2usize); - if let Some(v) = &limit { - query.push(("limit", v.to_string())); - } - if let Some(v) = &page_token { - query.push(("page_token", v.to_string())); - } - let request = client.client.get(url).query(&query).build()?; - let result = client.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 200u16 => ResponseValue::from_response(response).await, - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - - ///Streams `GET` requests to `/ip-pools/{pool_name}/ranges` - pub fn stream( - self, - ) -> impl futures::Stream>> + Unpin + 'a - { - use futures::StreamExt; - use futures::TryFutureExt; - use futures::TryStreamExt; - let next = Self { - limit: Ok(None), - page_token: Ok(None), - ..self.clone() - }; - self.send() - .map_ok(move |page| { - let page = page.into_inner(); - let first = futures::stream::iter(page.items.into_iter().map(Ok)); - let rest = futures::stream::try_unfold( - (page.next_page, next), - |(next_page, next)| async { - if next_page.is_none() { - Ok(None) - } else { - Self { - page_token: Ok(next_page), - ..next.clone() - } - .send() - .map_ok(|page| { - let page = page.into_inner(); - Some(( - futures::stream::iter(page.items.into_iter().map(Ok)), - (page.next_page, next), - )) - }) - .await - } - }, - ) - .try_flatten(); - first.chain(rest) - }) - .try_flatten_stream() - .boxed() - } - } - - ///Builder for [`ClientIpPoolsExt::ip_pool_range_add`] - /// - ///[`ClientIpPoolsExt::ip_pool_range_add`]: super::ClientIpPoolsExt::ip_pool_range_add - #[derive(Debug, Clone)] - pub struct IpPoolRangeAdd<'a> { - client: &'a super::Client, - pool_name: Result, - body: Result, - } - - impl<'a> IpPoolRangeAdd<'a> { - pub fn new(client: &'a super::Client) -> Self { - Self { - client, - pool_name: Err("pool_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), - } - } - - pub fn pool_name(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.pool_name = value - .try_into() - .map_err(|_| "conversion to `Name` for pool_name failed".to_string()); - self - } - - pub fn body(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.body = value - .try_into() - .map_err(|_| "conversion to `IpRange` for body failed".to_string()); - self - } - - ///Sends a `POST` request to `/ip-pools/{pool_name}/ranges/add` - pub async fn send(self) -> Result, Error> { - let Self { - client, - pool_name, - body, - } = self; - let pool_name = pool_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; - let url = format!( - "{}/ip-pools/{}/ranges/add", - client.baseurl, - encode_path(&pool_name.to_string()), - ); - let request = client.client.post(url).json(&body).build()?; - let result = client.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 201u16 => ResponseValue::from_response(response).await, - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - } - - ///Builder for [`ClientIpPoolsExt::ip_pool_range_remove`] - /// - ///[`ClientIpPoolsExt::ip_pool_range_remove`]: super::ClientIpPoolsExt::ip_pool_range_remove - #[derive(Debug, Clone)] - pub struct IpPoolRangeRemove<'a> { - client: &'a super::Client, - pool_name: Result, - body: Result, - } - - impl<'a> IpPoolRangeRemove<'a> { - pub fn new(client: &'a super::Client) -> Self { - Self { - client, - pool_name: Err("pool_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), - } - } - - pub fn pool_name(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.pool_name = value - .try_into() - .map_err(|_| "conversion to `Name` for pool_name failed".to_string()); - self - } - - pub fn body(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.body = value - .try_into() - .map_err(|_| "conversion to `IpRange` for body failed".to_string()); - self - } - - ///Sends a `POST` request to `/ip-pools/{pool_name}/ranges/remove` - pub async fn send(self) -> Result, Error> { - let Self { - client, - pool_name, - body, - } = self; - let pool_name = pool_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; - let url = format!( - "{}/ip-pools/{}/ranges/remove", - client.baseurl, - encode_path(&pool_name.to_string()), - ); - let request = client.client.post(url).json(&body).build()?; - let result = client.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 204u16 => Ok(ResponseValue::empty(response)), - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - } - - ///Builder for [`ClientHiddenExt::spoof_login`] - /// - ///[`ClientHiddenExt::spoof_login`]: super::ClientHiddenExt::spoof_login - #[derive(Debug, Clone)] - pub struct SpoofLogin<'a> { + pub struct LoginSpoof<'a> { client: &'a super::Client, body: Result, } - impl<'a> SpoofLogin<'a> { + impl<'a> LoginSpoof<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client, @@ -16384,7 +18861,7 @@ pub mod builder { } ///Sends a `POST` request to `/login` - pub async fn send(self) -> Result, Error> { + pub async fn send(self) -> Result, Error> { let Self { client, body } = self; let body = body.map_err(Error::InvalidRequest)?; let url = format!("{}/login", client.baseurl,); @@ -16392,23 +18869,98 @@ pub mod builder { let result = client.client.execute(request).await; let response = result?; match response.status().as_u16() { - 200..=299 => Ok(ResponseValue::stream(response)), - _ => Err(Error::ErrorResponse(ResponseValue::stream(response))), + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), } } } - ///Builder for [`ClientLoginExt::login`] + ///Builder for [`ClientLoginExt::login_local`] /// - ///[`ClientLoginExt::login`]: super::ClientLoginExt::login + ///[`ClientLoginExt::login_local`]: super::ClientLoginExt::login_local #[derive(Debug, Clone)] - pub struct Login<'a> { + pub struct LoginLocal<'a> { + client: &'a super::Client, + silo_name: Result, + body: Result, + } + + impl<'a> LoginLocal<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + silo_name: Err("silo_name was not initialized".to_string()), + body: Err("body was not initialized".to_string()), + } + } + + pub fn silo_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.silo_name = value + .try_into() + .map_err(|_| "conversion to `Name` for silo_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value.try_into().map_err(|_| { + "conversion to `UsernamePasswordCredentials` for body failed".to_string() + }); + self + } + + ///Sends a `POST` request to `/login/{silo_name}/local` + pub async fn send(self) -> Result, Error> { + let Self { + client, + silo_name, + body, + } = self; + let silo_name = silo_name.map_err(Error::InvalidRequest)?; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/login/{}/local", + client.baseurl, + encode_path(&silo_name.to_string()), + ); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200..=299 => Ok(ResponseValue::stream(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientLoginExt::login_saml_begin`] + /// + ///[`ClientLoginExt::login_saml_begin`]: super::ClientLoginExt::login_saml_begin + #[derive(Debug, Clone)] + pub struct LoginSamlBegin<'a> { client: &'a super::Client, silo_name: Result, provider_name: Result, } - impl<'a> Login<'a> { + impl<'a> LoginSamlBegin<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client, @@ -16437,8 +18989,8 @@ pub mod builder { self } - ///Sends a `GET` request to `/login/{silo_name}/{provider_name}` - pub async fn send(self) -> Result, Error> { + ///Sends a `GET` request to `/login/{silo_name}/saml/{provider_name}` + pub async fn send(self) -> Result, Error> { let Self { client, silo_name, @@ -16447,7 +18999,7 @@ pub mod builder { let silo_name = silo_name.map_err(Error::InvalidRequest)?; let provider_name = provider_name.map_err(Error::InvalidRequest)?; let url = format!( - "{}/login/{}/{}", + "{}/login/{}/saml/{}", client.baseurl, encode_path(&silo_name.to_string()), encode_path(&provider_name.to_string()), @@ -16457,23 +19009,29 @@ pub mod builder { let response = result?; match response.status().as_u16() { 200..=299 => Ok(ResponseValue::stream(response)), - _ => Err(Error::ErrorResponse(ResponseValue::stream(response))), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), } } } - ///Builder for [`ClientLoginExt::consume_credentials`] + ///Builder for [`ClientLoginExt::login_saml`] /// - ///[`ClientLoginExt::consume_credentials`]: super::ClientLoginExt::consume_credentials + ///[`ClientLoginExt::login_saml`]: super::ClientLoginExt::login_saml #[derive(Debug)] - pub struct ConsumeCredentials<'a> { + pub struct LoginSaml<'a> { client: &'a super::Client, silo_name: Result, provider_name: Result, body: Result, } - impl<'a> ConsumeCredentials<'a> { + impl<'a> LoginSaml<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client, @@ -16513,8 +19071,8 @@ pub mod builder { self } - ///Sends a `POST` request to `/login/{silo_name}/{provider_name}` - pub async fn send(self) -> Result, Error> { + ///Sends a `POST` request to `/login/{silo_name}/saml/{provider_name}` + pub async fn send(self) -> Result, Error> { let Self { client, silo_name, @@ -16525,7 +19083,7 @@ pub mod builder { let provider_name = provider_name.map_err(Error::InvalidRequest)?; let body = body.map_err(Error::InvalidRequest)?; let url = format!( - "{}/login/{}/{}", + "{}/login/{}/saml/{}", client.baseurl, encode_path(&silo_name.to_string()), encode_path(&provider_name.to_string()), @@ -16543,7 +19101,13 @@ pub mod builder { let response = result?; match response.status().as_u16() { 200..=299 => Ok(ResponseValue::stream(response)), - _ => Err(Error::ErrorResponse(ResponseValue::stream(response))), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), } } } @@ -16562,15 +19126,21 @@ pub mod builder { } ///Sends a `POST` request to `/logout` - pub async fn send(self) -> Result, Error> { + pub async fn send(self) -> Result, Error> { let Self { client } = self; let url = format!("{}/logout", client.baseurl,); let request = client.client.post(url).build()?; let result = client.client.execute(request).await; let response = result?; match response.status().as_u16() { - 200..=299 => Ok(ResponseValue::stream(response)), - _ => Err(Error::ErrorResponse(ResponseValue::stream(response))), + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), } } } @@ -20480,6 +23050,103 @@ pub mod builder { } } + ///Builder for [`ClientInstancesExt::instance_serial_console_stream`] + /// + ///[`ClientInstancesExt::instance_serial_console_stream`]: super::ClientInstancesExt::instance_serial_console_stream + #[derive(Debug, Clone)] + pub struct InstanceSerialConsoleStream<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + instance_name: Result, + } + + impl<'a> InstanceSerialConsoleStream<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + instance_name: Err("instance_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn instance_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance_name = value + .try_into() + .map_err(|_| "conversion to `Name` for instance_name failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/ + /// instances/{instance_name}/serial-console/stream` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + instance_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let instance_name = instance_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/instances/{}/serial-console/stream", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), + ); + let request = client + .client + .get(url) + .header(reqwest::header::CONNECTION, "Upgrade") + .header(reqwest::header::UPGRADE, "websocket") + .header(reqwest::header::SEC_WEBSOCKET_VERSION, "13") + .header( + reqwest::header::SEC_WEBSOCKET_KEY, + base64::Engine::encode( + &base64::engine::general_purpose::STANDARD, + rand::random::<[u8; 16]>(), + ), + ) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 101u16 => ResponseValue::upgrade(response).await, + 200..=299 => ResponseValue::upgrade(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + ///Builder for [`ClientInstancesExt::instance_start`] /// ///[`ClientInstancesExt::instance_start`]: super::ClientInstancesExt::instance_start @@ -24094,9 +26761,9 @@ pub mod builder { } } - ///Builder for [`ClientPolicyExt::policy_view`] + ///Builder for [`ClientSilosExt::policy_view`] /// - ///[`ClientPolicyExt::policy_view`]: super::ClientPolicyExt::policy_view + ///[`ClientSilosExt::policy_view`]: super::ClientSilosExt::policy_view #[derive(Debug, Clone)] pub struct PolicyView<'a> { client: &'a super::Client, @@ -24110,7 +26777,7 @@ pub mod builder { ///Sends a `GET` request to `/policy` pub async fn send( self, - ) -> Result, Error> { + ) -> Result, Error> { let Self { client } = self; let url = format!("{}/policy", client.baseurl,); let request = client.client.get(url).build()?; @@ -24129,13 +26796,13 @@ pub mod builder { } } - ///Builder for [`ClientPolicyExt::policy_update`] + ///Builder for [`ClientSilosExt::policy_update`] /// - ///[`ClientPolicyExt::policy_update`]: super::ClientPolicyExt::policy_update + ///[`ClientSilosExt::policy_update`]: super::ClientSilosExt::policy_update #[derive(Debug, Clone)] pub struct PolicyUpdate<'a> { client: &'a super::Client, - body: Result, + body: Result, } impl<'a> PolicyUpdate<'a> { @@ -24148,18 +26815,18 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where - V: std::convert::TryInto, + V: std::convert::TryInto, { self.body = value .try_into() - .map_err(|_| "conversion to `FleetRolePolicy` for body failed".to_string()); + .map_err(|_| "conversion to `SiloRolePolicy` for body failed".to_string()); self } ///Sends a `PUT` request to `/policy` pub async fn send( self, - ) -> Result, Error> { + ) -> Result, Error> { let Self { client, body } = self; let body = body.map_err(Error::InvalidRequest)?; let url = format!("{}/policy", client.baseurl,); @@ -24352,18 +27019,51 @@ pub mod builder { } } - ///Builder for [`ClientSagasExt::saga_list`] + ///Builder for [`ClientHiddenExt::session_me`] /// - ///[`ClientSagasExt::saga_list`]: super::ClientSagasExt::saga_list + ///[`ClientHiddenExt::session_me`]: super::ClientHiddenExt::session_me #[derive(Debug, Clone)] - pub struct SagaList<'a> { + pub struct SessionMe<'a> { + client: &'a super::Client, + } + + impl<'a> SessionMe<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client } + } + + ///Sends a `GET` request to `/session/me` + pub async fn send(self) -> Result, Error> { + let Self { client } = self; + let url = format!("{}/session/me", client.baseurl,); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientHiddenExt::session_me_groups`] + /// + ///[`ClientHiddenExt::session_me_groups`]: super::ClientHiddenExt::session_me_groups + #[derive(Debug, Clone)] + pub struct SessionMeGroups<'a> { client: &'a super::Client, limit: Result, String>, page_token: Result, String>, sort_by: Result, String>, } - impl<'a> SagaList<'a> { + impl<'a> SessionMeGroups<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client, @@ -24404,10 +27104,10 @@ pub mod builder { self } - ///Sends a `GET` request to `/sagas` + ///Sends a `GET` request to `/session/me/groups` pub async fn send( self, - ) -> Result, Error> { + ) -> Result, Error> { let Self { client, limit, @@ -24417,7 +27117,7 @@ pub mod builder { let limit = limit.map_err(Error::InvalidRequest)?; let page_token = page_token.map_err(Error::InvalidRequest)?; let sort_by = sort_by.map_err(Error::InvalidRequest)?; - let url = format!("{}/sagas", client.baseurl,); + let url = format!("{}/session/me/groups", client.baseurl,); let mut query = Vec::with_capacity(3usize); if let Some(v) = &limit { query.push(("limit", v.to_string())); @@ -24443,10 +27143,10 @@ pub mod builder { } } - ///Streams `GET` requests to `/sagas` + ///Streams `GET` requests to `/session/me/groups` pub fn stream( self, - ) -> impl futures::Stream>> + Unpin + 'a + ) -> impl futures::Stream>> + Unpin + 'a { use futures::StreamExt; use futures::TryFutureExt; @@ -24491,91 +27191,6 @@ pub mod builder { } } - ///Builder for [`ClientSagasExt::saga_view`] - /// - ///[`ClientSagasExt::saga_view`]: super::ClientSagasExt::saga_view - #[derive(Debug, Clone)] - pub struct SagaView<'a> { - client: &'a super::Client, - saga_id: Result, - } - - impl<'a> SagaView<'a> { - pub fn new(client: &'a super::Client) -> Self { - Self { - client, - saga_id: Err("saga_id was not initialized".to_string()), - } - } - - pub fn saga_id(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.saga_id = value - .try_into() - .map_err(|_| "conversion to `uuid :: Uuid` for saga_id failed".to_string()); - self - } - - ///Sends a `GET` request to `/sagas/{saga_id}` - pub async fn send(self) -> Result, Error> { - let Self { client, saga_id } = self; - let saga_id = saga_id.map_err(Error::InvalidRequest)?; - let url = format!( - "{}/sagas/{}", - client.baseurl, - encode_path(&saga_id.to_string()), - ); - let request = client.client.get(url).build()?; - let result = client.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 200u16 => ResponseValue::from_response(response).await, - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - } - - ///Builder for [`ClientHiddenExt::session_me`] - /// - ///[`ClientHiddenExt::session_me`]: super::ClientHiddenExt::session_me - #[derive(Debug, Clone)] - pub struct SessionMe<'a> { - client: &'a super::Client, - } - - impl<'a> SessionMe<'a> { - pub fn new(client: &'a super::Client) -> Self { - Self { client } - } - - ///Sends a `GET` request to `/session/me` - pub async fn send(self) -> Result, Error> { - let Self { client } = self; - let url = format!("{}/session/me", client.baseurl,); - let request = client.client.get(url).build()?; - let result = client.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 200u16 => ResponseValue::from_response(response).await, - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - } - ///Builder for [`ClientSessionExt::session_sshkey_list`] /// ///[`ClientSessionExt::session_sshkey_list`]: super::ClientSessionExt::session_sshkey_list @@ -24873,9 +27488,2733 @@ pub mod builder { } } - ///Builder for [`ClientSilosExt::silo_list`] + ///Builder for [`ClientSystemExt::system_image_view_by_id`] /// - ///[`ClientSilosExt::silo_list`]: super::ClientSilosExt::silo_list + ///[`ClientSystemExt::system_image_view_by_id`]: super::ClientSystemExt::system_image_view_by_id + #[derive(Debug, Clone)] + pub struct SystemImageViewById<'a> { + client: &'a super::Client, + id: Result, + } + + impl<'a> SystemImageViewById<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + id: Err("id was not initialized".to_string()), + } + } + + pub fn id(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.id = value + .try_into() + .map_err(|_| "conversion to `uuid :: Uuid` for id failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/by-id/images/{id}` + pub async fn send(self) -> Result, Error> { + let Self { client, id } = self; + let id = id.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/by-id/images/{}", + client.baseurl, + encode_path(&id.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::ip_pool_view_by_id`] + /// + ///[`ClientSystemExt::ip_pool_view_by_id`]: super::ClientSystemExt::ip_pool_view_by_id + #[derive(Debug, Clone)] + pub struct IpPoolViewById<'a> { + client: &'a super::Client, + id: Result, + } + + impl<'a> IpPoolViewById<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + id: Err("id was not initialized".to_string()), + } + } + + pub fn id(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.id = value + .try_into() + .map_err(|_| "conversion to `uuid :: Uuid` for id failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/by-id/ip-pools/{id}` + pub async fn send(self) -> Result, Error> { + let Self { client, id } = self; + let id = id.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/by-id/ip-pools/{}", + client.baseurl, + encode_path(&id.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::silo_view_by_id`] + /// + ///[`ClientSystemExt::silo_view_by_id`]: super::ClientSystemExt::silo_view_by_id + #[derive(Debug, Clone)] + pub struct SiloViewById<'a> { + client: &'a super::Client, + id: Result, + } + + impl<'a> SiloViewById<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + id: Err("id was not initialized".to_string()), + } + } + + pub fn id(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.id = value + .try_into() + .map_err(|_| "conversion to `uuid :: Uuid` for id failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/by-id/silos/{id}` + pub async fn send(self) -> Result, Error> { + let Self { client, id } = self; + let id = id.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/by-id/silos/{}", + client.baseurl, + encode_path(&id.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::certificate_list`] + /// + ///[`ClientSystemExt::certificate_list`]: super::ClientSystemExt::certificate_list + #[derive(Debug, Clone)] + pub struct CertificateList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> CertificateList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < std :: num :: NonZeroU32 >` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.page_token = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < String >` for page_token failed".to_string()); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameSortMode >` for sort_by failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/system/certificates` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/system/certificates", client.baseurl,); + let mut query = Vec::with_capacity(3usize); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/system/certificates` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + let next = Self { + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().map(Ok)); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`ClientSystemExt::certificate_create`] + /// + ///[`ClientSystemExt::certificate_create`]: super::ClientSystemExt::certificate_create + #[derive(Debug, Clone)] + pub struct CertificateCreate<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> CertificateCreate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + body: Err("body was not initialized".to_string()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `CertificateCreate` for body failed".to_string()); + self + } + + ///Sends a `POST` request to `/system/certificates` + pub async fn send(self) -> Result, Error> { + let Self { client, body } = self; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!("{}/system/certificates", client.baseurl,); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::certificate_view`] + /// + ///[`ClientSystemExt::certificate_view`]: super::ClientSystemExt::certificate_view + #[derive(Debug, Clone)] + pub struct CertificateView<'a> { + client: &'a super::Client, + certificate: Result, + } + + impl<'a> CertificateView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + certificate: Err("certificate was not initialized".to_string()), + } + } + + pub fn certificate(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.certificate = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for certificate failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/certificates/{certificate}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + certificate, + } = self; + let certificate = certificate.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/certificates/{}", + client.baseurl, + encode_path(&certificate.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::certificate_delete`] + /// + ///[`ClientSystemExt::certificate_delete`]: super::ClientSystemExt::certificate_delete + #[derive(Debug, Clone)] + pub struct CertificateDelete<'a> { + client: &'a super::Client, + certificate: Result, + } + + impl<'a> CertificateDelete<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + certificate: Err("certificate was not initialized".to_string()), + } + } + + pub fn certificate(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.certificate = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for certificate failed".to_string()); + self + } + + ///Sends a `DELETE` request to `/system/certificates/{certificate}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + certificate, + } = self; + let certificate = certificate.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/certificates/{}", + client.baseurl, + encode_path(&certificate.to_string()), + ); + let request = client.client.delete(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::physical_disk_list`] + /// + ///[`ClientSystemExt::physical_disk_list`]: super::ClientSystemExt::physical_disk_list + #[derive(Debug, Clone)] + pub struct PhysicalDiskList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> PhysicalDiskList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < std :: num :: NonZeroU32 >` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.page_token = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < String >` for page_token failed".to_string()); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < IdSortMode >` for sort_by failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/system/hardware/disks` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/system/hardware/disks", client.baseurl,); + let mut query = Vec::with_capacity(3usize); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/system/hardware/disks` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + let next = Self { + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().map(Ok)); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`ClientSystemExt::rack_list`] + /// + ///[`ClientSystemExt::rack_list`]: super::ClientSystemExt::rack_list + #[derive(Debug, Clone)] + pub struct RackList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> RackList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < std :: num :: NonZeroU32 >` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.page_token = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < String >` for page_token failed".to_string()); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < IdSortMode >` for sort_by failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/system/hardware/racks` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/system/hardware/racks", client.baseurl,); + let mut query = Vec::with_capacity(3usize); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/system/hardware/racks` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + let next = Self { + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().map(Ok)); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`ClientSystemExt::rack_view`] + /// + ///[`ClientSystemExt::rack_view`]: super::ClientSystemExt::rack_view + #[derive(Debug, Clone)] + pub struct RackView<'a> { + client: &'a super::Client, + rack_id: Result, + } + + impl<'a> RackView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + rack_id: Err("rack_id was not initialized".to_string()), + } + } + + pub fn rack_id(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.rack_id = value + .try_into() + .map_err(|_| "conversion to `uuid :: Uuid` for rack_id failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/hardware/racks/{rack_id}` + pub async fn send(self) -> Result, Error> { + let Self { client, rack_id } = self; + let rack_id = rack_id.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/hardware/racks/{}", + client.baseurl, + encode_path(&rack_id.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::sled_list`] + /// + ///[`ClientSystemExt::sled_list`]: super::ClientSystemExt::sled_list + #[derive(Debug, Clone)] + pub struct SledList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> SledList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < std :: num :: NonZeroU32 >` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.page_token = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < String >` for page_token failed".to_string()); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < IdSortMode >` for sort_by failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/system/hardware/sleds` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/system/hardware/sleds", client.baseurl,); + let mut query = Vec::with_capacity(3usize); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/system/hardware/sleds` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + let next = Self { + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().map(Ok)); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`ClientSystemExt::sled_view`] + /// + ///[`ClientSystemExt::sled_view`]: super::ClientSystemExt::sled_view + #[derive(Debug, Clone)] + pub struct SledView<'a> { + client: &'a super::Client, + sled_id: Result, + } + + impl<'a> SledView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + sled_id: Err("sled_id was not initialized".to_string()), + } + } + + pub fn sled_id(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sled_id = value + .try_into() + .map_err(|_| "conversion to `uuid :: Uuid` for sled_id failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/hardware/sleds/{sled_id}` + pub async fn send(self) -> Result, Error> { + let Self { client, sled_id } = self; + let sled_id = sled_id.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/hardware/sleds/{}", + client.baseurl, + encode_path(&sled_id.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::sled_physical_disk_list`] + /// + ///[`ClientSystemExt::sled_physical_disk_list`]: super::ClientSystemExt::sled_physical_disk_list + #[derive(Debug, Clone)] + pub struct SledPhysicalDiskList<'a> { + client: &'a super::Client, + sled_id: Result, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> SledPhysicalDiskList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + sled_id: Err("sled_id was not initialized".to_string()), + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn sled_id(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sled_id = value + .try_into() + .map_err(|_| "conversion to `uuid :: Uuid` for sled_id failed".to_string()); + self + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < std :: num :: NonZeroU32 >` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.page_token = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < String >` for page_token failed".to_string()); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < IdSortMode >` for sort_by failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/system/hardware/sleds/{sled_id}/disks` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + sled_id, + limit, + page_token, + sort_by, + } = self; + let sled_id = sled_id.map_err(Error::InvalidRequest)?; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/hardware/sleds/{}/disks", + client.baseurl, + encode_path(&sled_id.to_string()), + ); + let mut query = Vec::with_capacity(3usize); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/system/hardware/sleds/{sled_id}/disks` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + let next = Self { + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().map(Ok)); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`ClientSystemExt::system_image_list`] + /// + ///[`ClientSystemExt::system_image_list`]: super::ClientSystemExt::system_image_list + #[derive(Debug, Clone)] + pub struct SystemImageList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> SystemImageList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < std :: num :: NonZeroU32 >` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.page_token = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < String >` for page_token failed".to_string()); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameSortMode >` for sort_by failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/system/images` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/system/images", client.baseurl,); + let mut query = Vec::with_capacity(3usize); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/system/images` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + let next = Self { + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().map(Ok)); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`ClientSystemExt::system_image_create`] + /// + ///[`ClientSystemExt::system_image_create`]: super::ClientSystemExt::system_image_create + #[derive(Debug, Clone)] + pub struct SystemImageCreate<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> SystemImageCreate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + body: Err("body was not initialized".to_string()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `GlobalImageCreate` for body failed".to_string()); + self + } + + ///Sends a `POST` request to `/system/images` + pub async fn send(self) -> Result, Error> { + let Self { client, body } = self; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!("{}/system/images", client.baseurl,); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::system_image_view`] + /// + ///[`ClientSystemExt::system_image_view`]: super::ClientSystemExt::system_image_view + #[derive(Debug, Clone)] + pub struct SystemImageView<'a> { + client: &'a super::Client, + image_name: Result, + } + + impl<'a> SystemImageView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + image_name: Err("image_name was not initialized".to_string()), + } + } + + pub fn image_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.image_name = value + .try_into() + .map_err(|_| "conversion to `Name` for image_name failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/images/{image_name}` + pub async fn send(self) -> Result, Error> { + let Self { client, image_name } = self; + let image_name = image_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/images/{}", + client.baseurl, + encode_path(&image_name.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::system_image_delete`] + /// + ///[`ClientSystemExt::system_image_delete`]: super::ClientSystemExt::system_image_delete + #[derive(Debug, Clone)] + pub struct SystemImageDelete<'a> { + client: &'a super::Client, + image_name: Result, + } + + impl<'a> SystemImageDelete<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + image_name: Err("image_name was not initialized".to_string()), + } + } + + pub fn image_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.image_name = value + .try_into() + .map_err(|_| "conversion to `Name` for image_name failed".to_string()); + self + } + + ///Sends a `DELETE` request to `/system/images/{image_name}` + pub async fn send(self) -> Result, Error> { + let Self { client, image_name } = self; + let image_name = image_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/images/{}", + client.baseurl, + encode_path(&image_name.to_string()), + ); + let request = client.client.delete(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::ip_pool_list`] + /// + ///[`ClientSystemExt::ip_pool_list`]: super::ClientSystemExt::ip_pool_list + #[derive(Debug, Clone)] + pub struct IpPoolList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> IpPoolList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < std :: num :: NonZeroU32 >` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.page_token = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < String >` for page_token failed".to_string()); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameOrIdSortMode >` for sort_by failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/system/ip-pools` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/system/ip-pools", client.baseurl,); + let mut query = Vec::with_capacity(3usize); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/system/ip-pools` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + let next = Self { + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().map(Ok)); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`ClientSystemExt::ip_pool_create`] + /// + ///[`ClientSystemExt::ip_pool_create`]: super::ClientSystemExt::ip_pool_create + #[derive(Debug, Clone)] + pub struct IpPoolCreate<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> IpPoolCreate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + body: Err("body was not initialized".to_string()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `IpPoolCreate` for body failed".to_string()); + self + } + + ///Sends a `POST` request to `/system/ip-pools` + pub async fn send(self) -> Result, Error> { + let Self { client, body } = self; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!("{}/system/ip-pools", client.baseurl,); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::ip_pool_view`] + /// + ///[`ClientSystemExt::ip_pool_view`]: super::ClientSystemExt::ip_pool_view + #[derive(Debug, Clone)] + pub struct IpPoolView<'a> { + client: &'a super::Client, + pool_name: Result, + } + + impl<'a> IpPoolView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + pool_name: Err("pool_name was not initialized".to_string()), + } + } + + pub fn pool_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.pool_name = value + .try_into() + .map_err(|_| "conversion to `Name` for pool_name failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/ip-pools/{pool_name}` + pub async fn send(self) -> Result, Error> { + let Self { client, pool_name } = self; + let pool_name = pool_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/ip-pools/{}", + client.baseurl, + encode_path(&pool_name.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::ip_pool_update`] + /// + ///[`ClientSystemExt::ip_pool_update`]: super::ClientSystemExt::ip_pool_update + #[derive(Debug, Clone)] + pub struct IpPoolUpdate<'a> { + client: &'a super::Client, + pool_name: Result, + body: Result, + } + + impl<'a> IpPoolUpdate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + pool_name: Err("pool_name was not initialized".to_string()), + body: Err("body was not initialized".to_string()), + } + } + + pub fn pool_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.pool_name = value + .try_into() + .map_err(|_| "conversion to `Name` for pool_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `IpPoolUpdate` for body failed".to_string()); + self + } + + ///Sends a `PUT` request to `/system/ip-pools/{pool_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + pool_name, + body, + } = self; + let pool_name = pool_name.map_err(Error::InvalidRequest)?; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/ip-pools/{}", + client.baseurl, + encode_path(&pool_name.to_string()), + ); + let request = client.client.put(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::ip_pool_delete`] + /// + ///[`ClientSystemExt::ip_pool_delete`]: super::ClientSystemExt::ip_pool_delete + #[derive(Debug, Clone)] + pub struct IpPoolDelete<'a> { + client: &'a super::Client, + pool_name: Result, + } + + impl<'a> IpPoolDelete<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + pool_name: Err("pool_name was not initialized".to_string()), + } + } + + pub fn pool_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.pool_name = value + .try_into() + .map_err(|_| "conversion to `Name` for pool_name failed".to_string()); + self + } + + ///Sends a `DELETE` request to `/system/ip-pools/{pool_name}` + pub async fn send(self) -> Result, Error> { + let Self { client, pool_name } = self; + let pool_name = pool_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/ip-pools/{}", + client.baseurl, + encode_path(&pool_name.to_string()), + ); + let request = client.client.delete(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::ip_pool_range_list`] + /// + ///[`ClientSystemExt::ip_pool_range_list`]: super::ClientSystemExt::ip_pool_range_list + #[derive(Debug, Clone)] + pub struct IpPoolRangeList<'a> { + client: &'a super::Client, + pool_name: Result, + limit: Result, String>, + page_token: Result, String>, + } + + impl<'a> IpPoolRangeList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + pool_name: Err("pool_name was not initialized".to_string()), + limit: Ok(None), + page_token: Ok(None), + } + } + + pub fn pool_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.pool_name = value + .try_into() + .map_err(|_| "conversion to `Name` for pool_name failed".to_string()); + self + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < std :: num :: NonZeroU32 >` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.page_token = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < String >` for page_token failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/ip-pools/{pool_name}/ranges` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + pool_name, + limit, + page_token, + } = self; + let pool_name = pool_name.map_err(Error::InvalidRequest)?; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/ip-pools/{}/ranges", + client.baseurl, + encode_path(&pool_name.to_string()), + ); + let mut query = Vec::with_capacity(2usize); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/system/ip-pools/{pool_name}/ranges` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + let next = Self { + limit: Ok(None), + page_token: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().map(Ok)); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`ClientSystemExt::ip_pool_range_add`] + /// + ///[`ClientSystemExt::ip_pool_range_add`]: super::ClientSystemExt::ip_pool_range_add + #[derive(Debug, Clone)] + pub struct IpPoolRangeAdd<'a> { + client: &'a super::Client, + pool_name: Result, + body: Result, + } + + impl<'a> IpPoolRangeAdd<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + pool_name: Err("pool_name was not initialized".to_string()), + body: Err("body was not initialized".to_string()), + } + } + + pub fn pool_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.pool_name = value + .try_into() + .map_err(|_| "conversion to `Name` for pool_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `IpRange` for body failed".to_string()); + self + } + + ///Sends a `POST` request to `/system/ip-pools/{pool_name}/ranges/add` + pub async fn send(self) -> Result, Error> { + let Self { + client, + pool_name, + body, + } = self; + let pool_name = pool_name.map_err(Error::InvalidRequest)?; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/ip-pools/{}/ranges/add", + client.baseurl, + encode_path(&pool_name.to_string()), + ); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::ip_pool_range_remove`] + /// + ///[`ClientSystemExt::ip_pool_range_remove`]: super::ClientSystemExt::ip_pool_range_remove + #[derive(Debug, Clone)] + pub struct IpPoolRangeRemove<'a> { + client: &'a super::Client, + pool_name: Result, + body: Result, + } + + impl<'a> IpPoolRangeRemove<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + pool_name: Err("pool_name was not initialized".to_string()), + body: Err("body was not initialized".to_string()), + } + } + + pub fn pool_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.pool_name = value + .try_into() + .map_err(|_| "conversion to `Name` for pool_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `IpRange` for body failed".to_string()); + self + } + + ///Sends a `POST` request to + /// `/system/ip-pools/{pool_name}/ranges/remove` + pub async fn send(self) -> Result, Error> { + let Self { + client, + pool_name, + body, + } = self; + let pool_name = pool_name.map_err(Error::InvalidRequest)?; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/ip-pools/{}/ranges/remove", + client.baseurl, + encode_path(&pool_name.to_string()), + ); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::ip_pool_service_view`] + /// + ///[`ClientSystemExt::ip_pool_service_view`]: super::ClientSystemExt::ip_pool_service_view + #[derive(Debug, Clone)] + pub struct IpPoolServiceView<'a> { + client: &'a super::Client, + } + + impl<'a> IpPoolServiceView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client } + } + + ///Sends a `GET` request to `/system/ip-pools-service` + pub async fn send(self) -> Result, Error> { + let Self { client } = self; + let url = format!("{}/system/ip-pools-service", client.baseurl,); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::ip_pool_service_range_list`] + /// + ///[`ClientSystemExt::ip_pool_service_range_list`]: super::ClientSystemExt::ip_pool_service_range_list + #[derive(Debug, Clone)] + pub struct IpPoolServiceRangeList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + } + + impl<'a> IpPoolServiceRangeList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + limit: Ok(None), + page_token: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < std :: num :: NonZeroU32 >` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.page_token = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < String >` for page_token failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/ip-pools-service/ranges` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let url = format!("{}/system/ip-pools-service/ranges", client.baseurl,); + let mut query = Vec::with_capacity(2usize); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/system/ip-pools-service/ranges` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + let next = Self { + limit: Ok(None), + page_token: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().map(Ok)); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`ClientSystemExt::ip_pool_service_range_add`] + /// + ///[`ClientSystemExt::ip_pool_service_range_add`]: super::ClientSystemExt::ip_pool_service_range_add + #[derive(Debug, Clone)] + pub struct IpPoolServiceRangeAdd<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> IpPoolServiceRangeAdd<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + body: Err("body was not initialized".to_string()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `IpRange` for body failed".to_string()); + self + } + + ///Sends a `POST` request to `/system/ip-pools-service/ranges/add` + pub async fn send(self) -> Result, Error> { + let Self { client, body } = self; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!("{}/system/ip-pools-service/ranges/add", client.baseurl,); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::ip_pool_service_range_remove`] + /// + ///[`ClientSystemExt::ip_pool_service_range_remove`]: super::ClientSystemExt::ip_pool_service_range_remove + #[derive(Debug, Clone)] + pub struct IpPoolServiceRangeRemove<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> IpPoolServiceRangeRemove<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + body: Err("body was not initialized".to_string()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `IpRange` for body failed".to_string()); + self + } + + ///Sends a `POST` request to `/system/ip-pools-service/ranges/remove` + pub async fn send(self) -> Result, Error> { + let Self { client, body } = self; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!("{}/system/ip-pools-service/ranges/remove", client.baseurl,); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::system_metric`] + /// + ///[`ClientSystemExt::system_metric`]: super::ClientSystemExt::system_metric + #[derive(Debug, Clone)] + pub struct SystemMetric<'a> { + client: &'a super::Client, + metric_name: Result, + end_time: Result>, String>, + id: Result, + limit: Result, String>, + page_token: Result, String>, + start_time: Result>, String>, + } + + impl<'a> SystemMetric<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + metric_name: Err("metric_name was not initialized".to_string()), + end_time: Ok(None), + id: Err("id was not initialized".to_string()), + limit: Ok(None), + page_token: Ok(None), + start_time: Ok(None), + } + } + + pub fn metric_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.metric_name = value + .try_into() + .map_err(|_| "conversion to `SystemMetricName` for metric_name failed".to_string()); + self + } + + pub fn end_time(mut self, value: V) -> Self + where + V: std::convert::TryInto>, + { + self . end_time = value . try_into () . map (Some) . map_err (| _ | "conversion to `Option < chrono :: DateTime < chrono :: offset :: Utc > >` for end_time failed" . to_string ()) ; + self + } + + pub fn id(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.id = value + .try_into() + .map_err(|_| "conversion to `uuid :: Uuid` for id failed".to_string()); + self + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < std :: num :: NonZeroU32 >` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.page_token = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < String >` for page_token failed".to_string()); + self + } + + pub fn start_time(mut self, value: V) -> Self + where + V: std::convert::TryInto>, + { + self . start_time = value . try_into () . map (Some) . map_err (| _ | "conversion to `Option < chrono :: DateTime < chrono :: offset :: Utc > >` for start_time failed" . to_string ()) ; + self + } + + ///Sends a `GET` request to `/system/metrics/{metric_name}` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + metric_name, + end_time, + id, + limit, + page_token, + start_time, + } = self; + let metric_name = metric_name.map_err(Error::InvalidRequest)?; + let end_time = end_time.map_err(Error::InvalidRequest)?; + let id = id.map_err(Error::InvalidRequest)?; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let start_time = start_time.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/metrics/{}", + client.baseurl, + encode_path(&metric_name.to_string()), + ); + let mut query = Vec::with_capacity(5usize); + if let Some(v) = &end_time { + query.push(("end_time", v.to_string())); + } + query.push(("id", id.to_string())); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &start_time { + query.push(("start_time", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientPolicyExt::system_policy_view`] + /// + ///[`ClientPolicyExt::system_policy_view`]: super::ClientPolicyExt::system_policy_view + #[derive(Debug, Clone)] + pub struct SystemPolicyView<'a> { + client: &'a super::Client, + } + + impl<'a> SystemPolicyView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client } + } + + ///Sends a `GET` request to `/system/policy` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client } = self; + let url = format!("{}/system/policy", client.baseurl,); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientPolicyExt::system_policy_update`] + /// + ///[`ClientPolicyExt::system_policy_update`]: super::ClientPolicyExt::system_policy_update + #[derive(Debug, Clone)] + pub struct SystemPolicyUpdate<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> SystemPolicyUpdate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + body: Err("body was not initialized".to_string()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `FleetRolePolicy` for body failed".to_string()); + self + } + + ///Sends a `PUT` request to `/system/policy` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client, body } = self; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!("{}/system/policy", client.baseurl,); + let request = client.client.put(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::saga_list`] + /// + ///[`ClientSystemExt::saga_list`]: super::ClientSystemExt::saga_list + #[derive(Debug, Clone)] + pub struct SagaList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> SagaList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < std :: num :: NonZeroU32 >` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.page_token = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < String >` for page_token failed".to_string()); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < IdSortMode >` for sort_by failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/system/sagas` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/system/sagas", client.baseurl,); + let mut query = Vec::with_capacity(3usize); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/system/sagas` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + let next = Self { + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().map(Ok)); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`ClientSystemExt::saga_view`] + /// + ///[`ClientSystemExt::saga_view`]: super::ClientSystemExt::saga_view + #[derive(Debug, Clone)] + pub struct SagaView<'a> { + client: &'a super::Client, + saga_id: Result, + } + + impl<'a> SagaView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + saga_id: Err("saga_id was not initialized".to_string()), + } + } + + pub fn saga_id(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.saga_id = value + .try_into() + .map_err(|_| "conversion to `uuid :: Uuid` for saga_id failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/sagas/{saga_id}` + pub async fn send(self) -> Result, Error> { + let Self { client, saga_id } = self; + let saga_id = saga_id.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/sagas/{}", + client.baseurl, + encode_path(&saga_id.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::silo_list`] + /// + ///[`ClientSystemExt::silo_list`]: super::ClientSystemExt::silo_list #[derive(Debug, Clone)] pub struct SiloList<'a> { client: &'a super::Client, @@ -24925,7 +30264,7 @@ pub mod builder { self } - ///Sends a `GET` request to `/silos` + ///Sends a `GET` request to `/system/silos` pub async fn send( self, ) -> Result, Error> { @@ -24938,7 +30277,7 @@ pub mod builder { let limit = limit.map_err(Error::InvalidRequest)?; let page_token = page_token.map_err(Error::InvalidRequest)?; let sort_by = sort_by.map_err(Error::InvalidRequest)?; - let url = format!("{}/silos", client.baseurl,); + let url = format!("{}/system/silos", client.baseurl,); let mut query = Vec::with_capacity(3usize); if let Some(v) = &limit { query.push(("limit", v.to_string())); @@ -24964,7 +30303,7 @@ pub mod builder { } } - ///Streams `GET` requests to `/silos` + ///Streams `GET` requests to `/system/silos` pub fn stream( self, ) -> impl futures::Stream>> + Unpin + 'a @@ -25012,9 +30351,9 @@ pub mod builder { } } - ///Builder for [`ClientSilosExt::silo_create`] + ///Builder for [`ClientSystemExt::silo_create`] /// - ///[`ClientSilosExt::silo_create`]: super::ClientSilosExt::silo_create + ///[`ClientSystemExt::silo_create`]: super::ClientSystemExt::silo_create #[derive(Debug, Clone)] pub struct SiloCreate<'a> { client: &'a super::Client, @@ -25039,11 +30378,11 @@ pub mod builder { self } - ///Sends a `POST` request to `/silos` + ///Sends a `POST` request to `/system/silos` pub async fn send(self) -> Result, Error> { let Self { client, body } = self; let body = body.map_err(Error::InvalidRequest)?; - let url = format!("{}/silos", client.baseurl,); + let url = format!("{}/system/silos", client.baseurl,); let request = client.client.post(url).json(&body).build()?; let result = client.client.execute(request).await; let response = result?; @@ -25060,9 +30399,9 @@ pub mod builder { } } - ///Builder for [`ClientSilosExt::silo_view`] + ///Builder for [`ClientSystemExt::silo_view`] /// - ///[`ClientSilosExt::silo_view`]: super::ClientSilosExt::silo_view + ///[`ClientSystemExt::silo_view`]: super::ClientSystemExt::silo_view #[derive(Debug, Clone)] pub struct SiloView<'a> { client: &'a super::Client, @@ -25087,12 +30426,12 @@ pub mod builder { self } - ///Sends a `GET` request to `/silos/{silo_name}` + ///Sends a `GET` request to `/system/silos/{silo_name}` pub async fn send(self) -> Result, Error> { let Self { client, silo_name } = self; let silo_name = silo_name.map_err(Error::InvalidRequest)?; let url = format!( - "{}/silos/{}", + "{}/system/silos/{}", client.baseurl, encode_path(&silo_name.to_string()), ); @@ -25112,9 +30451,9 @@ pub mod builder { } } - ///Builder for [`ClientSilosExt::silo_delete`] + ///Builder for [`ClientSystemExt::silo_delete`] /// - ///[`ClientSilosExt::silo_delete`]: super::ClientSilosExt::silo_delete + ///[`ClientSystemExt::silo_delete`]: super::ClientSystemExt::silo_delete #[derive(Debug, Clone)] pub struct SiloDelete<'a> { client: &'a super::Client, @@ -25139,12 +30478,12 @@ pub mod builder { self } - ///Sends a `DELETE` request to `/silos/{silo_name}` + ///Sends a `DELETE` request to `/system/silos/{silo_name}` pub async fn send(self) -> Result, Error> { let Self { client, silo_name } = self; let silo_name = silo_name.map_err(Error::InvalidRequest)?; let url = format!( - "{}/silos/{}", + "{}/system/silos/{}", client.baseurl, encode_path(&silo_name.to_string()), ); @@ -25164,9 +30503,9 @@ pub mod builder { } } - ///Builder for [`ClientSilosExt::silo_identity_provider_list`] + ///Builder for [`ClientSystemExt::silo_identity_provider_list`] /// - ///[`ClientSilosExt::silo_identity_provider_list`]: super::ClientSilosExt::silo_identity_provider_list + ///[`ClientSystemExt::silo_identity_provider_list`]: super::ClientSystemExt::silo_identity_provider_list #[derive(Debug, Clone)] pub struct SiloIdentityProviderList<'a> { client: &'a super::Client, @@ -25228,7 +30567,8 @@ pub mod builder { self } - ///Sends a `GET` request to `/silos/{silo_name}/identity-providers` + ///Sends a `GET` request to + /// `/system/silos/{silo_name}/identity-providers` pub async fn send( self, ) -> Result, Error> @@ -25245,7 +30585,7 @@ pub mod builder { let page_token = page_token.map_err(Error::InvalidRequest)?; let sort_by = sort_by.map_err(Error::InvalidRequest)?; let url = format!( - "{}/silos/{}/identity-providers", + "{}/system/silos/{}/identity-providers", client.baseurl, encode_path(&silo_name.to_string()), ); @@ -25274,7 +30614,8 @@ pub mod builder { } } - ///Streams `GET` requests to `/silos/{silo_name}/identity-providers` + ///Streams `GET` requests to + /// `/system/silos/{silo_name}/identity-providers` pub fn stream( self, ) -> impl futures::Stream>> + Unpin + 'a @@ -25322,9 +30663,381 @@ pub mod builder { } } - ///Builder for [`ClientSilosExt::silo_policy_view`] + ///Builder for [`ClientSystemExt::local_idp_user_create`] /// - ///[`ClientSilosExt::silo_policy_view`]: super::ClientSilosExt::silo_policy_view + ///[`ClientSystemExt::local_idp_user_create`]: super::ClientSystemExt::local_idp_user_create + #[derive(Debug, Clone)] + pub struct LocalIdpUserCreate<'a> { + client: &'a super::Client, + silo_name: Result, + body: Result, + } + + impl<'a> LocalIdpUserCreate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + silo_name: Err("silo_name was not initialized".to_string()), + body: Err("body was not initialized".to_string()), + } + } + + pub fn silo_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.silo_name = value + .try_into() + .map_err(|_| "conversion to `Name` for silo_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `UserCreate` for body failed".to_string()); + self + } + + ///Sends a `POST` request to + /// `/system/silos/{silo_name}/identity-providers/local/users` + pub async fn send(self) -> Result, Error> { + let Self { + client, + silo_name, + body, + } = self; + let silo_name = silo_name.map_err(Error::InvalidRequest)?; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/silos/{}/identity-providers/local/users", + client.baseurl, + encode_path(&silo_name.to_string()), + ); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::local_idp_user_delete`] + /// + ///[`ClientSystemExt::local_idp_user_delete`]: super::ClientSystemExt::local_idp_user_delete + #[derive(Debug, Clone)] + pub struct LocalIdpUserDelete<'a> { + client: &'a super::Client, + silo_name: Result, + user_id: Result, + } + + impl<'a> LocalIdpUserDelete<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + silo_name: Err("silo_name was not initialized".to_string()), + user_id: Err("user_id was not initialized".to_string()), + } + } + + pub fn silo_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.silo_name = value + .try_into() + .map_err(|_| "conversion to `Name` for silo_name failed".to_string()); + self + } + + pub fn user_id(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.user_id = value + .try_into() + .map_err(|_| "conversion to `uuid :: Uuid` for user_id failed".to_string()); + self + } + + ///Sends a `DELETE` request to + /// `/system/silos/{silo_name}/identity-providers/local/users/{user_id}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + silo_name, + user_id, + } = self; + let silo_name = silo_name.map_err(Error::InvalidRequest)?; + let user_id = user_id.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/silos/{}/identity-providers/local/users/{}", + client.baseurl, + encode_path(&silo_name.to_string()), + encode_path(&user_id.to_string()), + ); + let request = client.client.delete(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::local_idp_user_set_password`] + /// + ///[`ClientSystemExt::local_idp_user_set_password`]: super::ClientSystemExt::local_idp_user_set_password + #[derive(Debug, Clone)] + pub struct LocalIdpUserSetPassword<'a> { + client: &'a super::Client, + silo_name: Result, + user_id: Result, + body: Result, + } + + impl<'a> LocalIdpUserSetPassword<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + silo_name: Err("silo_name was not initialized".to_string()), + user_id: Err("user_id was not initialized".to_string()), + body: Err("body was not initialized".to_string()), + } + } + + pub fn silo_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.silo_name = value + .try_into() + .map_err(|_| "conversion to `Name` for silo_name failed".to_string()); + self + } + + pub fn user_id(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.user_id = value + .try_into() + .map_err(|_| "conversion to `uuid :: Uuid` for user_id failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `UserPassword` for body failed".to_string()); + self + } + + ///Sends a `POST` request to + /// `/system/silos/{silo_name}/identity-providers/local/users/{user_id}/ + /// set-password` + pub async fn send(self) -> Result, Error> { + let Self { + client, + silo_name, + user_id, + body, + } = self; + let silo_name = silo_name.map_err(Error::InvalidRequest)?; + let user_id = user_id.map_err(Error::InvalidRequest)?; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/silos/{}/identity-providers/local/users/{}/set-password", + client.baseurl, + encode_path(&silo_name.to_string()), + encode_path(&user_id.to_string()), + ); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::saml_identity_provider_create`] + /// + ///[`ClientSystemExt::saml_identity_provider_create`]: super::ClientSystemExt::saml_identity_provider_create + #[derive(Debug, Clone)] + pub struct SamlIdentityProviderCreate<'a> { + client: &'a super::Client, + silo_name: Result, + body: Result, + } + + impl<'a> SamlIdentityProviderCreate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + silo_name: Err("silo_name was not initialized".to_string()), + body: Err("body was not initialized".to_string()), + } + } + + pub fn silo_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.silo_name = value + .try_into() + .map_err(|_| "conversion to `Name` for silo_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value.try_into().map_err(|_| { + "conversion to `SamlIdentityProviderCreate` for body failed".to_string() + }); + self + } + + ///Sends a `POST` request to + /// `/system/silos/{silo_name}/identity-providers/saml` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + silo_name, + body, + } = self; + let silo_name = silo_name.map_err(Error::InvalidRequest)?; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/silos/{}/identity-providers/saml", + client.baseurl, + encode_path(&silo_name.to_string()), + ); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::saml_identity_provider_view`] + /// + ///[`ClientSystemExt::saml_identity_provider_view`]: super::ClientSystemExt::saml_identity_provider_view + #[derive(Debug, Clone)] + pub struct SamlIdentityProviderView<'a> { + client: &'a super::Client, + silo_name: Result, + provider_name: Result, + } + + impl<'a> SamlIdentityProviderView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + silo_name: Err("silo_name was not initialized".to_string()), + provider_name: Err("provider_name was not initialized".to_string()), + } + } + + pub fn silo_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.silo_name = value + .try_into() + .map_err(|_| "conversion to `Name` for silo_name failed".to_string()); + self + } + + pub fn provider_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.provider_name = value + .try_into() + .map_err(|_| "conversion to `Name` for provider_name failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/system/silos/{silo_name}/identity-providers/saml/{provider_name}` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + silo_name, + provider_name, + } = self; + let silo_name = silo_name.map_err(Error::InvalidRequest)?; + let provider_name = provider_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/silos/{}/identity-providers/saml/{}", + client.baseurl, + encode_path(&silo_name.to_string()), + encode_path(&provider_name.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::silo_policy_view`] + /// + ///[`ClientSystemExt::silo_policy_view`]: super::ClientSystemExt::silo_policy_view #[derive(Debug, Clone)] pub struct SiloPolicyView<'a> { client: &'a super::Client, @@ -25349,14 +31062,14 @@ pub mod builder { self } - ///Sends a `GET` request to `/silos/{silo_name}/policy` + ///Sends a `GET` request to `/system/silos/{silo_name}/policy` pub async fn send( self, ) -> Result, Error> { let Self { client, silo_name } = self; let silo_name = silo_name.map_err(Error::InvalidRequest)?; let url = format!( - "{}/silos/{}/policy", + "{}/system/silos/{}/policy", client.baseurl, encode_path(&silo_name.to_string()), ); @@ -25376,9 +31089,9 @@ pub mod builder { } } - ///Builder for [`ClientSilosExt::silo_policy_update`] + ///Builder for [`ClientSystemExt::silo_policy_update`] /// - ///[`ClientSilosExt::silo_policy_update`]: super::ClientSilosExt::silo_policy_update + ///[`ClientSystemExt::silo_policy_update`]: super::ClientSystemExt::silo_policy_update #[derive(Debug, Clone)] pub struct SiloPolicyUpdate<'a> { client: &'a super::Client, @@ -25415,7 +31128,7 @@ pub mod builder { self } - ///Sends a `PUT` request to `/silos/{silo_name}/policy` + ///Sends a `PUT` request to `/system/silos/{silo_name}/policy` pub async fn send( self, ) -> Result, Error> { @@ -25427,7 +31140,7 @@ pub mod builder { let silo_name = silo_name.map_err(Error::InvalidRequest)?; let body = body.map_err(Error::InvalidRequest)?; let url = format!( - "{}/silos/{}/policy", + "{}/system/silos/{}/policy", client.baseurl, encode_path(&silo_name.to_string()), ); @@ -25447,22 +31160,26 @@ pub mod builder { } } - ///Builder for [`ClientSilosExt::silo_identity_provider_create`] + ///Builder for [`ClientSystemExt::silo_users_list`] /// - ///[`ClientSilosExt::silo_identity_provider_create`]: super::ClientSilosExt::silo_identity_provider_create + ///[`ClientSystemExt::silo_users_list`]: super::ClientSystemExt::silo_users_list #[derive(Debug, Clone)] - pub struct SiloIdentityProviderCreate<'a> { + pub struct SiloUsersList<'a> { client: &'a super::Client, silo_name: Result, - body: Result, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, } - impl<'a> SiloIdentityProviderCreate<'a> { + impl<'a> SiloUsersList<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client, silo_name: Err("silo_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), } } @@ -25476,38 +31193,72 @@ pub mod builder { self } - pub fn body(mut self, value: V) -> Self + pub fn limit(mut self, value: V) -> Self where - V: std::convert::TryInto, + V: std::convert::TryInto, { - self.body = value.try_into().map_err(|_| { - "conversion to `SamlIdentityProviderCreate` for body failed".to_string() + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < std :: num :: NonZeroU32 >` for limit failed".to_string() }); self } - ///Sends a `POST` request to - /// `/silos/{silo_name}/saml-identity-providers` + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.page_token = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < String >` for page_token failed".to_string()); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < IdSortMode >` for sort_by failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/system/silos/{silo_name}/users/all` pub async fn send( self, - ) -> Result, Error> { + ) -> Result, Error> { let Self { client, silo_name, - body, + limit, + page_token, + sort_by, } = self; let silo_name = silo_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; let url = format!( - "{}/silos/{}/saml-identity-providers", + "{}/system/silos/{}/users/all", client.baseurl, encode_path(&silo_name.to_string()), ); - let request = client.client.post(url).json(&body).build()?; + let mut query = Vec::with_capacity(3usize); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; let result = client.client.execute(request).await; let response = result?; match response.status().as_u16() { - 201u16 => ResponseValue::from_response(response).await, + 200u16 => ResponseValue::from_response(response).await, 400u16..=499u16 => Err(Error::ErrorResponse( ResponseValue::from_response(response).await?, )), @@ -25517,24 +31268,71 @@ pub mod builder { _ => Err(Error::UnexpectedResponse(response)), } } + + ///Streams `GET` requests to `/system/silos/{silo_name}/users/all` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + let next = Self { + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().map(Ok)); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } } - ///Builder for [`ClientSilosExt::silo_identity_provider_view`] + ///Builder for [`ClientSystemExt::silo_user_view`] /// - ///[`ClientSilosExt::silo_identity_provider_view`]: super::ClientSilosExt::silo_identity_provider_view + ///[`ClientSystemExt::silo_user_view`]: super::ClientSystemExt::silo_user_view #[derive(Debug, Clone)] - pub struct SiloIdentityProviderView<'a> { + pub struct SiloUserView<'a> { client: &'a super::Client, silo_name: Result, - provider_name: Result, + user_id: Result, } - impl<'a> SiloIdentityProviderView<'a> { + impl<'a> SiloUserView<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client, silo_name: Err("silo_name was not initialized".to_string()), - provider_name: Err("provider_name was not initialized".to_string()), + user_id: Err("user_id was not initialized".to_string()), } } @@ -25548,33 +31346,31 @@ pub mod builder { self } - pub fn provider_name(mut self, value: V) -> Self + pub fn user_id(mut self, value: V) -> Self where - V: std::convert::TryInto, + V: std::convert::TryInto, { - self.provider_name = value + self.user_id = value .try_into() - .map_err(|_| "conversion to `Name` for provider_name failed".to_string()); + .map_err(|_| "conversion to `uuid :: Uuid` for user_id failed".to_string()); self } ///Sends a `GET` request to - /// `/silos/{silo_name}/saml-identity-providers/{provider_name}` - pub async fn send( - self, - ) -> Result, Error> { + /// `/system/silos/{silo_name}/users/id/{user_id}` + pub async fn send(self) -> Result, Error> { let Self { client, silo_name, - provider_name, + user_id, } = self; let silo_name = silo_name.map_err(Error::InvalidRequest)?; - let provider_name = provider_name.map_err(Error::InvalidRequest)?; + let user_id = user_id.map_err(Error::InvalidRequest)?; let url = format!( - "{}/silos/{}/saml-identity-providers/{}", + "{}/system/silos/{}/users/id/{}", client.baseurl, encode_path(&silo_name.to_string()), - encode_path(&provider_name.to_string()), + encode_path(&user_id.to_string()), ); let request = client.client.get(url).build()?; let result = client.client.execute(request).await; @@ -25905,39 +31701,6 @@ pub mod builder { } } - ///Builder for [`ClientUpdatesExt::updates_refresh`] - /// - ///[`ClientUpdatesExt::updates_refresh`]: super::ClientUpdatesExt::updates_refresh - #[derive(Debug, Clone)] - pub struct UpdatesRefresh<'a> { - client: &'a super::Client, - } - - impl<'a> UpdatesRefresh<'a> { - pub fn new(client: &'a super::Client) -> Self { - Self { client } - } - - ///Sends a `POST` request to `/updates/refresh` - pub async fn send(self) -> Result, Error> { - let Self { client } = self; - let url = format!("{}/updates/refresh", client.baseurl,); - let request = client.client.post(url).build()?; - let result = client.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 204u16 => Ok(ResponseValue::empty(response)), - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - } - ///Builder for [`ClientSilosExt::user_list`] /// ///[`ClientSilosExt::user_list`]: super::ClientSilosExt::user_list @@ -26076,28 +31839,3786 @@ pub mod builder { .boxed() } } + + ///Builder for [`ClientDisksExt::disk_list_v1`] + /// + ///[`ClientDisksExt::disk_list_v1`]: super::ClientDisksExt::disk_list_v1 + #[derive(Debug, Clone)] + pub struct DiskListV1<'a> { + client: &'a super::Client, + limit: Result, String>, + organization: Result, String>, + page_token: Result, String>, + project: Result, String>, + sort_by: Result, String>, + } + + impl<'a> DiskListV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + limit: Ok(None), + organization: Ok(None), + page_token: Ok(None), + project: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < std :: num :: NonZeroU32 >` for limit failed".to_string() + }); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameOrId >` for organization failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.page_token = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < String >` for page_token failed".to_string()); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < NameOrId >` for project failed".to_string()); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameOrIdSortMode >` for sort_by failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/v1/disks` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + organization, + page_token, + project, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/disks", client.baseurl,); + let mut query = Vec::with_capacity(5usize); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &project { + query.push(("project", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/v1/disks` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + let next = Self { + limit: Ok(None), + organization: Ok(None), + page_token: Ok(None), + project: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().map(Ok)); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`ClientDisksExt::disk_create_v1`] + /// + ///[`ClientDisksExt::disk_create_v1`]: super::ClientDisksExt::disk_create_v1 + #[derive(Debug, Clone)] + pub struct DiskCreateV1<'a> { + client: &'a super::Client, + organization: Result, String>, + project: Result, + body: Result, + } + + impl<'a> DiskCreateV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization: Ok(None), + project: Err("project was not initialized".to_string()), + body: Err("body was not initialized".to_string()), + } + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameOrId >` for organization failed".to_string() + }); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for project failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `DiskCreate` for body failed".to_string()); + self + } + + ///Sends a `POST` request to `/v1/disks` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization, + project, + body, + } = self; + let organization = organization.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/disks", client.baseurl,); + let mut query = Vec::with_capacity(2usize); + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + query.push(("project", project.to_string())); + let request = client.client.post(url).json(&body).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientDisksExt::disk_view_v1`] + /// + ///[`ClientDisksExt::disk_view_v1`]: super::ClientDisksExt::disk_view_v1 + #[derive(Debug, Clone)] + pub struct DiskViewV1<'a> { + client: &'a super::Client, + disk: Result, + organization: Result, String>, + project: Result, String>, + } + + impl<'a> DiskViewV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + disk: Err("disk was not initialized".to_string()), + organization: Ok(None), + project: Ok(None), + } + } + + pub fn disk(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.disk = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for disk failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameOrId >` for organization failed".to_string() + }); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < NameOrId >` for project failed".to_string()); + self + } + + ///Sends a `GET` request to `/v1/disks/{disk}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + disk, + organization, + project, + } = self; + let disk = disk.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/disks/{}", + client.baseurl, + encode_path(&disk.to_string()), + ); + let mut query = Vec::with_capacity(2usize); + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + if let Some(v) = &project { + query.push(("project", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientDisksExt::disk_delete_v1`] + /// + ///[`ClientDisksExt::disk_delete_v1`]: super::ClientDisksExt::disk_delete_v1 + #[derive(Debug, Clone)] + pub struct DiskDeleteV1<'a> { + client: &'a super::Client, + disk: Result, + organization: Result, String>, + project: Result, String>, + } + + impl<'a> DiskDeleteV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + disk: Err("disk was not initialized".to_string()), + organization: Ok(None), + project: Ok(None), + } + } + + pub fn disk(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.disk = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for disk failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameOrId >` for organization failed".to_string() + }); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < NameOrId >` for project failed".to_string()); + self + } + + ///Sends a `DELETE` request to `/v1/disks/{disk}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + disk, + organization, + project, + } = self; + let disk = disk.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/disks/{}", + client.baseurl, + encode_path(&disk.to_string()), + ); + let mut query = Vec::with_capacity(2usize); + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + if let Some(v) = &project { + query.push(("project", v.to_string())); + } + let request = client.client.delete(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientInstancesExt::instance_list_v1`] + /// + ///[`ClientInstancesExt::instance_list_v1`]: super::ClientInstancesExt::instance_list_v1 + #[derive(Debug, Clone)] + pub struct InstanceListV1<'a> { + client: &'a super::Client, + limit: Result, String>, + organization: Result, String>, + page_token: Result, String>, + project: Result, String>, + sort_by: Result, String>, + } + + impl<'a> InstanceListV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + limit: Ok(None), + organization: Ok(None), + page_token: Ok(None), + project: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < std :: num :: NonZeroU32 >` for limit failed".to_string() + }); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameOrId >` for organization failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.page_token = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < String >` for page_token failed".to_string()); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < NameOrId >` for project failed".to_string()); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameOrIdSortMode >` for sort_by failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/v1/instances` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + organization, + page_token, + project, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/instances", client.baseurl,); + let mut query = Vec::with_capacity(5usize); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &project { + query.push(("project", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/v1/instances` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + let next = Self { + limit: Ok(None), + organization: Ok(None), + page_token: Ok(None), + project: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().map(Ok)); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`ClientInstancesExt::instance_create_v1`] + /// + ///[`ClientInstancesExt::instance_create_v1`]: super::ClientInstancesExt::instance_create_v1 + #[derive(Debug, Clone)] + pub struct InstanceCreateV1<'a> { + client: &'a super::Client, + organization: Result, String>, + project: Result, + body: Result, + } + + impl<'a> InstanceCreateV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization: Ok(None), + project: Err("project was not initialized".to_string()), + body: Err("body was not initialized".to_string()), + } + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameOrId >` for organization failed".to_string() + }); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for project failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `InstanceCreate` for body failed".to_string()); + self + } + + ///Sends a `POST` request to `/v1/instances` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization, + project, + body, + } = self; + let organization = organization.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/instances", client.baseurl,); + let mut query = Vec::with_capacity(2usize); + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + query.push(("project", project.to_string())); + let request = client.client.post(url).json(&body).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientInstancesExt::instance_view_v1`] + /// + ///[`ClientInstancesExt::instance_view_v1`]: super::ClientInstancesExt::instance_view_v1 + #[derive(Debug, Clone)] + pub struct InstanceViewV1<'a> { + client: &'a super::Client, + instance: Result, + organization: Result, String>, + project: Result, String>, + } + + impl<'a> InstanceViewV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + instance: Err("instance was not initialized".to_string()), + organization: Ok(None), + project: Ok(None), + } + } + + pub fn instance(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for instance failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameOrId >` for organization failed".to_string() + }); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < NameOrId >` for project failed".to_string()); + self + } + + ///Sends a `GET` request to `/v1/instances/{instance}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + instance, + organization, + project, + } = self; + let instance = instance.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/instances/{}", + client.baseurl, + encode_path(&instance.to_string()), + ); + let mut query = Vec::with_capacity(2usize); + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + if let Some(v) = &project { + query.push(("project", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientInstancesExt::instance_delete_v1`] + /// + ///[`ClientInstancesExt::instance_delete_v1`]: super::ClientInstancesExt::instance_delete_v1 + #[derive(Debug, Clone)] + pub struct InstanceDeleteV1<'a> { + client: &'a super::Client, + instance: Result, + organization: Result, String>, + project: Result, String>, + } + + impl<'a> InstanceDeleteV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + instance: Err("instance was not initialized".to_string()), + organization: Ok(None), + project: Ok(None), + } + } + + pub fn instance(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for instance failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameOrId >` for organization failed".to_string() + }); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < NameOrId >` for project failed".to_string()); + self + } + + ///Sends a `DELETE` request to `/v1/instances/{instance}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + instance, + organization, + project, + } = self; + let instance = instance.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/instances/{}", + client.baseurl, + encode_path(&instance.to_string()), + ); + let mut query = Vec::with_capacity(2usize); + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + if let Some(v) = &project { + query.push(("project", v.to_string())); + } + let request = client.client.delete(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientInstancesExt::instance_disk_list_v1`] + /// + ///[`ClientInstancesExt::instance_disk_list_v1`]: super::ClientInstancesExt::instance_disk_list_v1 + #[derive(Debug, Clone)] + pub struct InstanceDiskListV1<'a> { + client: &'a super::Client, + instance: Result, + limit: Result, String>, + organization: Result, String>, + page_token: Result, String>, + project: Result, String>, + sort_by: Result, String>, + } + + impl<'a> InstanceDiskListV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + instance: Err("instance was not initialized".to_string()), + limit: Ok(None), + organization: Ok(None), + page_token: Ok(None), + project: Ok(None), + sort_by: Ok(None), + } + } + + pub fn instance(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for instance failed".to_string()); + self + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < std :: num :: NonZeroU32 >` for limit failed".to_string() + }); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameOrId >` for organization failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.page_token = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < String >` for page_token failed".to_string()); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < NameOrId >` for project failed".to_string()); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameOrIdSortMode >` for sort_by failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/v1/instances/{instance}/disks` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + instance, + limit, + organization, + page_token, + project, + sort_by, + } = self; + let instance = instance.map_err(Error::InvalidRequest)?; + let limit = limit.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/instances/{}/disks", + client.baseurl, + encode_path(&instance.to_string()), + ); + let mut query = Vec::with_capacity(5usize); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &project { + query.push(("project", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/v1/instances/{instance}/disks` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + let next = Self { + limit: Ok(None), + organization: Ok(None), + page_token: Ok(None), + project: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().map(Ok)); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`ClientInstancesExt::instance_disk_attach_v1`] + /// + ///[`ClientInstancesExt::instance_disk_attach_v1`]: super::ClientInstancesExt::instance_disk_attach_v1 + #[derive(Debug, Clone)] + pub struct InstanceDiskAttachV1<'a> { + client: &'a super::Client, + instance: Result, + organization: Result, String>, + project: Result, String>, + body: Result, + } + + impl<'a> InstanceDiskAttachV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + instance: Err("instance was not initialized".to_string()), + organization: Ok(None), + project: Ok(None), + body: Err("body was not initialized".to_string()), + } + } + + pub fn instance(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for instance failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameOrId >` for organization failed".to_string() + }); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < NameOrId >` for project failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `DiskPath` for body failed".to_string()); + self + } + + ///Sends a `POST` request to `/v1/instances/{instance}/disks/attach` + pub async fn send(self) -> Result, Error> { + let Self { + client, + instance, + organization, + project, + body, + } = self; + let instance = instance.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/instances/{}/disks/attach", + client.baseurl, + encode_path(&instance.to_string()), + ); + let mut query = Vec::with_capacity(2usize); + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + if let Some(v) = &project { + query.push(("project", v.to_string())); + } + let request = client.client.post(url).json(&body).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 202u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientInstancesExt::instance_disk_detach_v1`] + /// + ///[`ClientInstancesExt::instance_disk_detach_v1`]: super::ClientInstancesExt::instance_disk_detach_v1 + #[derive(Debug, Clone)] + pub struct InstanceDiskDetachV1<'a> { + client: &'a super::Client, + instance: Result, + organization: Result, String>, + project: Result, String>, + body: Result, + } + + impl<'a> InstanceDiskDetachV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + instance: Err("instance was not initialized".to_string()), + organization: Ok(None), + project: Ok(None), + body: Err("body was not initialized".to_string()), + } + } + + pub fn instance(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for instance failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameOrId >` for organization failed".to_string() + }); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < NameOrId >` for project failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `DiskPath` for body failed".to_string()); + self + } + + ///Sends a `POST` request to `/v1/instances/{instance}/disks/detach` + pub async fn send(self) -> Result, Error> { + let Self { + client, + instance, + organization, + project, + body, + } = self; + let instance = instance.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/instances/{}/disks/detach", + client.baseurl, + encode_path(&instance.to_string()), + ); + let mut query = Vec::with_capacity(2usize); + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + if let Some(v) = &project { + query.push(("project", v.to_string())); + } + let request = client.client.post(url).json(&body).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 202u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientInstancesExt::instance_migrate_v1`] + /// + ///[`ClientInstancesExt::instance_migrate_v1`]: super::ClientInstancesExt::instance_migrate_v1 + #[derive(Debug, Clone)] + pub struct InstanceMigrateV1<'a> { + client: &'a super::Client, + instance: Result, + organization: Result, String>, + project: Result, String>, + body: Result, + } + + impl<'a> InstanceMigrateV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + instance: Err("instance was not initialized".to_string()), + organization: Ok(None), + project: Ok(None), + body: Err("body was not initialized".to_string()), + } + } + + pub fn instance(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for instance failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameOrId >` for organization failed".to_string() + }); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < NameOrId >` for project failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `InstanceMigrate` for body failed".to_string()); + self + } + + ///Sends a `POST` request to `/v1/instances/{instance}/migrate` + pub async fn send(self) -> Result, Error> { + let Self { + client, + instance, + organization, + project, + body, + } = self; + let instance = instance.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/instances/{}/migrate", + client.baseurl, + encode_path(&instance.to_string()), + ); + let mut query = Vec::with_capacity(2usize); + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + if let Some(v) = &project { + query.push(("project", v.to_string())); + } + let request = client.client.post(url).json(&body).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientInstancesExt::instance_reboot_v1`] + /// + ///[`ClientInstancesExt::instance_reboot_v1`]: super::ClientInstancesExt::instance_reboot_v1 + #[derive(Debug, Clone)] + pub struct InstanceRebootV1<'a> { + client: &'a super::Client, + instance: Result, + organization: Result, String>, + project: Result, String>, + } + + impl<'a> InstanceRebootV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + instance: Err("instance was not initialized".to_string()), + organization: Ok(None), + project: Ok(None), + } + } + + pub fn instance(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for instance failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameOrId >` for organization failed".to_string() + }); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < NameOrId >` for project failed".to_string()); + self + } + + ///Sends a `POST` request to `/v1/instances/{instance}/reboot` + pub async fn send(self) -> Result, Error> { + let Self { + client, + instance, + organization, + project, + } = self; + let instance = instance.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/instances/{}/reboot", + client.baseurl, + encode_path(&instance.to_string()), + ); + let mut query = Vec::with_capacity(2usize); + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + if let Some(v) = &project { + query.push(("project", v.to_string())); + } + let request = client.client.post(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 202u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientInstancesExt::instance_serial_console_v1`] + /// + ///[`ClientInstancesExt::instance_serial_console_v1`]: super::ClientInstancesExt::instance_serial_console_v1 + #[derive(Debug, Clone)] + pub struct InstanceSerialConsoleV1<'a> { + client: &'a super::Client, + instance: Result, + from_start: Result, String>, + max_bytes: Result, String>, + most_recent: Result, String>, + organization: Result, String>, + project: Result, String>, + } + + impl<'a> InstanceSerialConsoleV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + instance: Err("instance was not initialized".to_string()), + from_start: Ok(None), + max_bytes: Ok(None), + most_recent: Ok(None), + organization: Ok(None), + project: Ok(None), + } + } + + pub fn instance(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for instance failed".to_string()); + self + } + + pub fn from_start(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.from_start = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < u64 >` for from_start failed".to_string()); + self + } + + pub fn max_bytes(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.max_bytes = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < u64 >` for max_bytes failed".to_string()); + self + } + + pub fn most_recent(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.most_recent = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < u64 >` for most_recent failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameOrId >` for organization failed".to_string() + }); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < NameOrId >` for project failed".to_string()); + self + } + + ///Sends a `GET` request to `/v1/instances/{instance}/serial-console` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + instance, + from_start, + max_bytes, + most_recent, + organization, + project, + } = self; + let instance = instance.map_err(Error::InvalidRequest)?; + let from_start = from_start.map_err(Error::InvalidRequest)?; + let max_bytes = max_bytes.map_err(Error::InvalidRequest)?; + let most_recent = most_recent.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/instances/{}/serial-console", + client.baseurl, + encode_path(&instance.to_string()), + ); + let mut query = Vec::with_capacity(5usize); + if let Some(v) = &from_start { + query.push(("from_start", v.to_string())); + } + if let Some(v) = &max_bytes { + query.push(("max_bytes", v.to_string())); + } + if let Some(v) = &most_recent { + query.push(("most_recent", v.to_string())); + } + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + if let Some(v) = &project { + query.push(("project", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientInstancesExt::instance_serial_console_stream_v1`] + /// + ///[`ClientInstancesExt::instance_serial_console_stream_v1`]: super::ClientInstancesExt::instance_serial_console_stream_v1 + #[derive(Debug, Clone)] + pub struct InstanceSerialConsoleStreamV1<'a> { + client: &'a super::Client, + instance: Result, + organization: Result, String>, + project: Result, String>, + } + + impl<'a> InstanceSerialConsoleStreamV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + instance: Err("instance was not initialized".to_string()), + organization: Ok(None), + project: Ok(None), + } + } + + pub fn instance(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for instance failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameOrId >` for organization failed".to_string() + }); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < NameOrId >` for project failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/v1/instances/{instance}/serial-console/stream` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + instance, + organization, + project, + } = self; + let instance = instance.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/instances/{}/serial-console/stream", + client.baseurl, + encode_path(&instance.to_string()), + ); + let mut query = Vec::with_capacity(2usize); + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + if let Some(v) = &project { + query.push(("project", v.to_string())); + } + let request = client + .client + .get(url) + .query(&query) + .header(reqwest::header::CONNECTION, "Upgrade") + .header(reqwest::header::UPGRADE, "websocket") + .header(reqwest::header::SEC_WEBSOCKET_VERSION, "13") + .header( + reqwest::header::SEC_WEBSOCKET_KEY, + base64::Engine::encode( + &base64::engine::general_purpose::STANDARD, + rand::random::<[u8; 16]>(), + ), + ) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 101u16 => ResponseValue::upgrade(response).await, + 200..=299 => ResponseValue::upgrade(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientInstancesExt::instance_start_v1`] + /// + ///[`ClientInstancesExt::instance_start_v1`]: super::ClientInstancesExt::instance_start_v1 + #[derive(Debug, Clone)] + pub struct InstanceStartV1<'a> { + client: &'a super::Client, + instance: Result, + organization: Result, String>, + project: Result, String>, + } + + impl<'a> InstanceStartV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + instance: Err("instance was not initialized".to_string()), + organization: Ok(None), + project: Ok(None), + } + } + + pub fn instance(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for instance failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameOrId >` for organization failed".to_string() + }); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < NameOrId >` for project failed".to_string()); + self + } + + ///Sends a `POST` request to `/v1/instances/{instance}/start` + pub async fn send(self) -> Result, Error> { + let Self { + client, + instance, + organization, + project, + } = self; + let instance = instance.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/instances/{}/start", + client.baseurl, + encode_path(&instance.to_string()), + ); + let mut query = Vec::with_capacity(2usize); + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + if let Some(v) = &project { + query.push(("project", v.to_string())); + } + let request = client.client.post(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 202u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientInstancesExt::instance_stop_v1`] + /// + ///[`ClientInstancesExt::instance_stop_v1`]: super::ClientInstancesExt::instance_stop_v1 + #[derive(Debug, Clone)] + pub struct InstanceStopV1<'a> { + client: &'a super::Client, + instance: Result, + organization: Result, String>, + project: Result, String>, + } + + impl<'a> InstanceStopV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + instance: Err("instance was not initialized".to_string()), + organization: Ok(None), + project: Ok(None), + } + } + + pub fn instance(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for instance failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameOrId >` for organization failed".to_string() + }); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < NameOrId >` for project failed".to_string()); + self + } + + ///Sends a `POST` request to `/v1/instances/{instance}/stop` + pub async fn send(self) -> Result, Error> { + let Self { + client, + instance, + organization, + project, + } = self; + let instance = instance.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/instances/{}/stop", + client.baseurl, + encode_path(&instance.to_string()), + ); + let mut query = Vec::with_capacity(2usize); + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + if let Some(v) = &project { + query.push(("project", v.to_string())); + } + let request = client.client.post(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 202u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientOrganizationsExt::organization_list_v1`] + /// + ///[`ClientOrganizationsExt::organization_list_v1`]: super::ClientOrganizationsExt::organization_list_v1 + #[derive(Debug, Clone)] + pub struct OrganizationListV1<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> OrganizationListV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < std :: num :: NonZeroU32 >` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.page_token = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < String >` for page_token failed".to_string()); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameOrIdSortMode >` for sort_by failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/v1/organizations` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/organizations", client.baseurl,); + let mut query = Vec::with_capacity(3usize); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/v1/organizations` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + let next = Self { + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().map(Ok)); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`ClientOrganizationsExt::organization_create_v1`] + /// + ///[`ClientOrganizationsExt::organization_create_v1`]: super::ClientOrganizationsExt::organization_create_v1 + #[derive(Debug, Clone)] + pub struct OrganizationCreateV1<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> OrganizationCreateV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + body: Err("body was not initialized".to_string()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `OrganizationCreate` for body failed".to_string()); + self + } + + ///Sends a `POST` request to `/v1/organizations` + pub async fn send(self) -> Result, Error> { + let Self { client, body } = self; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/organizations", client.baseurl,); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientOrganizationsExt::organization_view_v1`] + /// + ///[`ClientOrganizationsExt::organization_view_v1`]: super::ClientOrganizationsExt::organization_view_v1 + #[derive(Debug, Clone)] + pub struct OrganizationViewV1<'a> { + client: &'a super::Client, + organization: Result, + } + + impl<'a> OrganizationViewV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization: Err("organization was not initialized".to_string()), + } + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + ///Sends a `GET` request to `/v1/organizations/{organization}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization, + } = self; + let organization = organization.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/organizations/{}", + client.baseurl, + encode_path(&organization.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientOrganizationsExt::organization_update_v1`] + /// + ///[`ClientOrganizationsExt::organization_update_v1`]: super::ClientOrganizationsExt::organization_update_v1 + #[derive(Debug, Clone)] + pub struct OrganizationUpdateV1<'a> { + client: &'a super::Client, + organization: Result, + body: Result, + } + + impl<'a> OrganizationUpdateV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization: Err("organization was not initialized".to_string()), + body: Err("body was not initialized".to_string()), + } + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `OrganizationUpdate` for body failed".to_string()); + self + } + + ///Sends a `PUT` request to `/v1/organizations/{organization}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization, + body, + } = self; + let organization = organization.map_err(Error::InvalidRequest)?; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/organizations/{}", + client.baseurl, + encode_path(&organization.to_string()), + ); + let request = client.client.put(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientOrganizationsExt::organization_delete_v1`] + /// + ///[`ClientOrganizationsExt::organization_delete_v1`]: super::ClientOrganizationsExt::organization_delete_v1 + #[derive(Debug, Clone)] + pub struct OrganizationDeleteV1<'a> { + client: &'a super::Client, + organization: Result, + } + + impl<'a> OrganizationDeleteV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization: Err("organization was not initialized".to_string()), + } + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + ///Sends a `DELETE` request to `/v1/organizations/{organization}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization, + } = self; + let organization = organization.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/organizations/{}", + client.baseurl, + encode_path(&organization.to_string()), + ); + let request = client.client.delete(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientOrganizationsExt::organization_policy_view_v1`] + /// + ///[`ClientOrganizationsExt::organization_policy_view_v1`]: super::ClientOrganizationsExt::organization_policy_view_v1 + #[derive(Debug, Clone)] + pub struct OrganizationPolicyViewV1<'a> { + client: &'a super::Client, + organization: Result, + } + + impl<'a> OrganizationPolicyViewV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization: Err("organization was not initialized".to_string()), + } + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + ///Sends a `GET` request to `/v1/organizations/{organization}/policy` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + organization, + } = self; + let organization = organization.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/organizations/{}/policy", + client.baseurl, + encode_path(&organization.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientOrganizationsExt::organization_policy_update_v1`] + /// + ///[`ClientOrganizationsExt::organization_policy_update_v1`]: super::ClientOrganizationsExt::organization_policy_update_v1 + #[derive(Debug, Clone)] + pub struct OrganizationPolicyUpdateV1<'a> { + client: &'a super::Client, + organization: Result, + body: Result, + } + + impl<'a> OrganizationPolicyUpdateV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization: Err("organization was not initialized".to_string()), + body: Err("body was not initialized".to_string()), + } + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `OrganizationRolePolicy` for body failed".to_string()); + self + } + + ///Sends a `PUT` request to `/v1/organizations/{organization}/policy` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + organization, + body, + } = self; + let organization = organization.map_err(Error::InvalidRequest)?; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/organizations/{}/policy", + client.baseurl, + encode_path(&organization.to_string()), + ); + let request = client.client.put(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientProjectsExt::project_list_v1`] + /// + ///[`ClientProjectsExt::project_list_v1`]: super::ClientProjectsExt::project_list_v1 + #[derive(Debug, Clone)] + pub struct ProjectListV1<'a> { + client: &'a super::Client, + limit: Result, String>, + organization: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> ProjectListV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + limit: Ok(None), + organization: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < std :: num :: NonZeroU32 >` for limit failed".to_string() + }); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameOrId >` for organization failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.page_token = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < String >` for page_token failed".to_string()); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameOrIdSortMode >` for sort_by failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/v1/projects` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + organization, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/projects", client.baseurl,); + let mut query = Vec::with_capacity(4usize); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/v1/projects` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + let next = Self { + limit: Ok(None), + organization: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().map(Ok)); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`ClientProjectsExt::project_create_v1`] + /// + ///[`ClientProjectsExt::project_create_v1`]: super::ClientProjectsExt::project_create_v1 + #[derive(Debug, Clone)] + pub struct ProjectCreateV1<'a> { + client: &'a super::Client, + organization: Result, + body: Result, + } + + impl<'a> ProjectCreateV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization: Err("organization was not initialized".to_string()), + body: Err("body was not initialized".to_string()), + } + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `ProjectCreate` for body failed".to_string()); + self + } + + ///Sends a `POST` request to `/v1/projects` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization, + body, + } = self; + let organization = organization.map_err(Error::InvalidRequest)?; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/projects", client.baseurl,); + let mut query = Vec::with_capacity(1usize); + query.push(("organization", organization.to_string())); + let request = client.client.post(url).json(&body).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientProjectsExt::project_view_v1`] + /// + ///[`ClientProjectsExt::project_view_v1`]: super::ClientProjectsExt::project_view_v1 + #[derive(Debug, Clone)] + pub struct ProjectViewV1<'a> { + client: &'a super::Client, + project: Result, + organization: Result, String>, + } + + impl<'a> ProjectViewV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + project: Err("project was not initialized".to_string()), + organization: Ok(None), + } + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for project failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameOrId >` for organization failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/v1/projects/{project}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + project, + organization, + } = self; + let project = project.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/projects/{}", + client.baseurl, + encode_path(&project.to_string()), + ); + let mut query = Vec::with_capacity(1usize); + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientProjectsExt::project_update_v1`] + /// + ///[`ClientProjectsExt::project_update_v1`]: super::ClientProjectsExt::project_update_v1 + #[derive(Debug, Clone)] + pub struct ProjectUpdateV1<'a> { + client: &'a super::Client, + project: Result, + organization: Result, String>, + body: Result, + } + + impl<'a> ProjectUpdateV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + project: Err("project was not initialized".to_string()), + organization: Ok(None), + body: Err("body was not initialized".to_string()), + } + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for project failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameOrId >` for organization failed".to_string() + }); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `ProjectUpdate` for body failed".to_string()); + self + } + + ///Sends a `PUT` request to `/v1/projects/{project}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + project, + organization, + body, + } = self; + let project = project.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/projects/{}", + client.baseurl, + encode_path(&project.to_string()), + ); + let mut query = Vec::with_capacity(1usize); + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + let request = client.client.put(url).json(&body).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientProjectsExt::project_delete_v1`] + /// + ///[`ClientProjectsExt::project_delete_v1`]: super::ClientProjectsExt::project_delete_v1 + #[derive(Debug, Clone)] + pub struct ProjectDeleteV1<'a> { + client: &'a super::Client, + project: Result, + organization: Result, String>, + } + + impl<'a> ProjectDeleteV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + project: Err("project was not initialized".to_string()), + organization: Ok(None), + } + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for project failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameOrId >` for organization failed".to_string() + }); + self + } + + ///Sends a `DELETE` request to `/v1/projects/{project}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + project, + organization, + } = self; + let project = project.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/projects/{}", + client.baseurl, + encode_path(&project.to_string()), + ); + let mut query = Vec::with_capacity(1usize); + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + let request = client.client.delete(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientProjectsExt::project_policy_view_v1`] + /// + ///[`ClientProjectsExt::project_policy_view_v1`]: super::ClientProjectsExt::project_policy_view_v1 + #[derive(Debug, Clone)] + pub struct ProjectPolicyViewV1<'a> { + client: &'a super::Client, + project: Result, + organization: Result, String>, + } + + impl<'a> ProjectPolicyViewV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + project: Err("project was not initialized".to_string()), + organization: Ok(None), + } + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for project failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameOrId >` for organization failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/v1/projects/{project}/policy` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + project, + organization, + } = self; + let project = project.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/projects/{}/policy", + client.baseurl, + encode_path(&project.to_string()), + ); + let mut query = Vec::with_capacity(1usize); + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientProjectsExt::project_policy_update_v1`] + /// + ///[`ClientProjectsExt::project_policy_update_v1`]: super::ClientProjectsExt::project_policy_update_v1 + #[derive(Debug, Clone)] + pub struct ProjectPolicyUpdateV1<'a> { + client: &'a super::Client, + project: Result, + organization: Result, String>, + body: Result, + } + + impl<'a> ProjectPolicyUpdateV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + project: Err("project was not initialized".to_string()), + organization: Ok(None), + body: Err("body was not initialized".to_string()), + } + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for project failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameOrId >` for organization failed".to_string() + }); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `ProjectRolePolicy` for body failed".to_string()); + self + } + + ///Sends a `PUT` request to `/v1/projects/{project}/policy` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + project, + organization, + body, + } = self; + let project = project.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/projects/{}/policy", + client.baseurl, + encode_path(&project.to_string()), + ); + let mut query = Vec::with_capacity(1usize); + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + let request = client.client.put(url).json(&body).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::system_component_version_list`] + /// + ///[`ClientSystemExt::system_component_version_list`]: super::ClientSystemExt::system_component_version_list + #[derive(Debug, Clone)] + pub struct SystemComponentVersionList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> SystemComponentVersionList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < std :: num :: NonZeroU32 >` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.page_token = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < String >` for page_token failed".to_string()); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < IdSortMode >` for sort_by failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/v1/system/update/components` + pub async fn send( + self, + ) -> Result, Error> + { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/system/update/components", client.baseurl,); + let mut query = Vec::with_capacity(3usize); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/v1/system/update/components` + pub fn stream( + self, + ) -> impl futures::Stream>> + + Unpin + + 'a { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + let next = Self { + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().map(Ok)); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`ClientSystemExt::update_deployments_list`] + /// + ///[`ClientSystemExt::update_deployments_list`]: super::ClientSystemExt::update_deployments_list + #[derive(Debug, Clone)] + pub struct UpdateDeploymentsList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> UpdateDeploymentsList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < std :: num :: NonZeroU32 >` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.page_token = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < String >` for page_token failed".to_string()); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < IdSortMode >` for sort_by failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/v1/system/update/deployments` + pub async fn send( + self, + ) -> Result, Error> + { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/system/update/deployments", client.baseurl,); + let mut query = Vec::with_capacity(3usize); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/v1/system/update/deployments` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + let next = Self { + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().map(Ok)); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`ClientSystemExt::update_deployment_view`] + /// + ///[`ClientSystemExt::update_deployment_view`]: super::ClientSystemExt::update_deployment_view + #[derive(Debug, Clone)] + pub struct UpdateDeploymentView<'a> { + client: &'a super::Client, + id: Result, + } + + impl<'a> UpdateDeploymentView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + id: Err("id was not initialized".to_string()), + } + } + + pub fn id(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.id = value + .try_into() + .map_err(|_| "conversion to `uuid :: Uuid` for id failed".to_string()); + self + } + + ///Sends a `GET` request to `/v1/system/update/deployments/{id}` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client, id } = self; + let id = id.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/system/update/deployments/{}", + client.baseurl, + encode_path(&id.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::system_update_refresh`] + /// + ///[`ClientSystemExt::system_update_refresh`]: super::ClientSystemExt::system_update_refresh + #[derive(Debug, Clone)] + pub struct SystemUpdateRefresh<'a> { + client: &'a super::Client, + } + + impl<'a> SystemUpdateRefresh<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client } + } + + ///Sends a `POST` request to `/v1/system/update/refresh` + pub async fn send(self) -> Result, Error> { + let Self { client } = self; + let url = format!("{}/v1/system/update/refresh", client.baseurl,); + let request = client.client.post(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::system_update_start`] + /// + ///[`ClientSystemExt::system_update_start`]: super::ClientSystemExt::system_update_start + #[derive(Debug, Clone)] + pub struct SystemUpdateStart<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> SystemUpdateStart<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + body: Err("body was not initialized".to_string()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `SystemUpdateStart` for body failed".to_string()); + self + } + + ///Sends a `POST` request to `/v1/system/update/start` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client, body } = self; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/system/update/start", client.baseurl,); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 202u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::system_update_stop`] + /// + ///[`ClientSystemExt::system_update_stop`]: super::ClientSystemExt::system_update_stop + #[derive(Debug, Clone)] + pub struct SystemUpdateStop<'a> { + client: &'a super::Client, + } + + impl<'a> SystemUpdateStop<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client } + } + + ///Sends a `POST` request to `/v1/system/update/stop` + pub async fn send(self) -> Result, Error> { + let Self { client } = self; + let url = format!("{}/v1/system/update/stop", client.baseurl,); + let request = client.client.post(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::system_update_list`] + /// + ///[`ClientSystemExt::system_update_list`]: super::ClientSystemExt::system_update_list + #[derive(Debug, Clone)] + pub struct SystemUpdateList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> SystemUpdateList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < std :: num :: NonZeroU32 >` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.page_token = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < String >` for page_token failed".to_string()); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < IdSortMode >` for sort_by failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/v1/system/update/updates` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/system/update/updates", client.baseurl,); + let mut query = Vec::with_capacity(3usize); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/v1/system/update/updates` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + let next = Self { + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().map(Ok)); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`ClientSystemExt::system_update_view`] + /// + ///[`ClientSystemExt::system_update_view`]: super::ClientSystemExt::system_update_view + #[derive(Debug, Clone)] + pub struct SystemUpdateView<'a> { + client: &'a super::Client, + version: Result, + } + + impl<'a> SystemUpdateView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + version: Err("version was not initialized".to_string()), + } + } + + pub fn version(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.version = value + .try_into() + .map_err(|_| "conversion to `SemverVersion` for version failed".to_string()); + self + } + + ///Sends a `GET` request to `/v1/system/update/updates/{version}` + pub async fn send(self) -> Result, Error> { + let Self { client, version } = self; + let version = version.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/system/update/updates/{}", + client.baseurl, + encode_path(&version.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::system_update_components_list`] + /// + ///[`ClientSystemExt::system_update_components_list`]: super::ClientSystemExt::system_update_components_list + #[derive(Debug, Clone)] + pub struct SystemUpdateComponentsList<'a> { + client: &'a super::Client, + version: Result, + } + + impl<'a> SystemUpdateComponentsList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + version: Err("version was not initialized".to_string()), + } + } + + pub fn version(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.version = value + .try_into() + .map_err(|_| "conversion to `SemverVersion` for version failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/v1/system/update/updates/{version}/components` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client, version } = self; + let version = version.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/system/update/updates/{}/components", + client.baseurl, + encode_path(&version.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::system_version`] + /// + ///[`ClientSystemExt::system_version`]: super::ClientSystemExt::system_version + #[derive(Debug, Clone)] + pub struct SystemVersion<'a> { + client: &'a super::Client, + } + + impl<'a> SystemVersion<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client } + } + + ///Sends a `GET` request to `/v1/system/update/version` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client } = self; + let url = format!("{}/v1/system/update/version", client.baseurl,); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } } pub mod prelude { pub use super::Client; pub use super::ClientDisksExt; - pub use super::ClientHardwareExt; pub use super::ClientHiddenExt; pub use super::ClientImagesExt; - pub use super::ClientImagesGlobalExt; pub use super::ClientInstancesExt; - pub use super::ClientIpPoolsExt; pub use super::ClientLoginExt; pub use super::ClientMetricsExt; pub use super::ClientOrganizationsExt; pub use super::ClientPolicyExt; pub use super::ClientProjectsExt; pub use super::ClientRolesExt; - pub use super::ClientSagasExt; pub use super::ClientSessionExt; pub use super::ClientSilosExt; pub use super::ClientSnapshotsExt; pub use super::ClientSystemExt; - pub use super::ClientUpdatesExt; pub use super::ClientVpcsExt; } diff --git a/progenitor-impl/tests/output/nexus-builder.out b/progenitor-impl/tests/output/nexus-builder.out index ee5db28..2eb6c3b 100644 --- a/progenitor-impl/tests/output/nexus-builder.out +++ b/progenitor-impl/tests/output/nexus-builder.out @@ -7,6 +7,20 @@ pub mod types { use serde::{Deserialize, Serialize}; #[allow(unused_imports)] use std::convert::TryFrom; + ///Describes properties that should uniquely identify a Gimlet. + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct Baseboard { + pub part: String, + pub revision: i64, + pub serial: String, + } + + impl Baseboard { + pub fn builder() -> builder::Baseboard { + builder::Baseboard::default() + } + } + ///A type storing a range over `T`. /// ///This type supports ranges similar to the `RangeTo`, `Range` and @@ -77,7 +91,7 @@ pub mod types { } } - #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + #[derive(Clone, Debug, JsonSchema, Serialize)] pub struct BlockSize(i64); impl std::ops::Deref for BlockSize { type Target = i64; @@ -97,6 +111,16 @@ pub mod types { } } + impl<'de> serde::Deserialize<'de> for BlockSize { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + Self::try_from(i64::deserialize(deserializer)?) + .map_err(|e| ::custom(e.to_string())) + } + } + ///A count of bytes, typically used either for memory or storage capacity /// ///The maximum supported byte count is [`i64::MAX`]. This makes it @@ -113,6 +137,100 @@ pub mod types { } } + ///Client view of a [`Certificate`] + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct Certificate { + ///human-readable free-form text about a resource + pub description: String, + ///unique, immutable, system-controlled identifier for each resource + pub id: uuid::Uuid, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + pub service: ServiceUsingCertificate, + ///timestamp when this resource was created + pub time_created: chrono::DateTime, + ///timestamp when this resource was last modified + pub time_modified: chrono::DateTime, + } + + impl Certificate { + pub fn builder() -> builder::Certificate { + builder::Certificate::default() + } + } + + ///Create-time parameters for a + /// [`Certificate`](crate::external_api::views::Certificate) + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct CertificateCreate { + ///PEM file containing public certificate chain + pub cert: Vec, + pub description: String, + ///PEM file containing private key + pub key: Vec, + pub name: Name, + ///The service using this certificate + pub service: ServiceUsingCertificate, + } + + impl CertificateCreate { + pub fn builder() -> builder::CertificateCreate { + builder::CertificateCreate::default() + } + } + + ///A single page of results + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct CertificateResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + + impl CertificateResultsPage { + pub fn builder() -> builder::CertificateResultsPage { + builder::CertificateResultsPage::default() + } + } + + ///Identity-related metadata that's included in "asset" public API objects + /// (which generally have no name or description) + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct ComponentUpdate { + pub component_type: UpdateableComponentType, + ///unique, immutable, system-controlled identifier for each resource + pub id: uuid::Uuid, + ///timestamp when this resource was created + pub time_created: chrono::DateTime, + ///timestamp when this resource was last modified + pub time_modified: chrono::DateTime, + pub version: SemverVersion, + } + + impl ComponentUpdate { + pub fn builder() -> builder::ComponentUpdate { + builder::ComponentUpdate::default() + } + } + + ///A single page of results + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct ComponentUpdateResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + + impl ComponentUpdateResultsPage { + pub fn builder() -> builder::ComponentUpdateResultsPage { + builder::ComponentUpdateResultsPage::default() + } + } + ///A cumulative or counter data type. #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] pub struct Cumulativedouble { @@ -347,8 +465,9 @@ pub mod types { } } - ///Parameters for the [`Disk`](omicron_common::api::external::Disk) to be - /// attached or detached to an instance + ///TODO-v1: Delete this Parameters for the + /// [`Disk`](omicron_common::api::external::Disk) to be attached or detached + /// to an instance #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] pub struct DiskIdentifier { pub name: Name, @@ -427,6 +546,17 @@ pub mod types { } } + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct DiskPath { + pub disk: NameOrId, + } + + impl DiskPath { + pub fn builder() -> builder::DiskPath { + builder::DiskPath::default() + } + } + ///A single page of results #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] pub struct DiskResultsPage { @@ -818,7 +948,7 @@ pub mod types { } ///Create-time parameters for an - /// [`GlobalImage`](omicron_common::api::external::GlobalImage) + /// [`GlobalImage`](crate::external_api::views::GlobalImage) #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] pub struct GlobalImageCreate { ///block size in bytes @@ -853,6 +983,38 @@ pub mod types { } } + ///Client view of a [`Group`] + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct Group { + ///Human-readable name that can identify the group + pub display_name: String, + pub id: uuid::Uuid, + ///Uuid of the silo to which this group belongs + pub silo_id: uuid::Uuid, + } + + impl Group { + pub fn builder() -> builder::Group { + builder::Group::default() + } + } + + ///A single page of results + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct GroupResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + + impl GroupResultsPage { + pub fn builder() -> builder::GroupResultsPage { + builder::GroupResultsPage::default() + } + } + ///A simple type for managing a histogram metric. /// ///A histogram maintains the count of any number of samples, over a set of @@ -970,6 +1132,7 @@ pub mod types { Clone, Copy, Debug, Deserialize, Eq, Hash, JsonSchema, Ord, PartialEq, PartialOrd, Serialize, )] pub enum IdSortMode { + ///sort in increasing order of "id" #[serde(rename = "id_ascending")] IdAscending, } @@ -1056,6 +1219,7 @@ pub mod types { Clone, Copy, Debug, Deserialize, Eq, Hash, JsonSchema, Ord, PartialEq, PartialOrd, Serialize, )] pub enum IdentityProviderType { + ///SAML identity provider #[serde(rename = "saml")] Saml, } @@ -1106,12 +1270,15 @@ pub mod types { pub enum IdentityType { #[serde(rename = "silo_user")] SiloUser, + #[serde(rename = "silo_group")] + SiloGroup, } impl ToString for IdentityType { fn to_string(&self) -> String { match *self { Self::SiloUser => "silo_user".to_string(), + Self::SiloGroup => "silo_group".to_string(), } } } @@ -1121,6 +1288,7 @@ pub mod types { fn from_str(value: &str) -> Result { match value { "silo_user" => Ok(Self::SiloUser), + "silo_group" => Ok(Self::SiloGroup), _ => Err("invalid value"), } } @@ -1193,7 +1361,7 @@ pub mod types { } ///Create-time parameters for an - /// [`Image`](omicron_common::api::external::Image) + /// [`Image`](crate::external_api::views::Image) #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] pub struct ImageCreate { ///block size in bytes @@ -1302,6 +1470,9 @@ pub mod types { ///The network interfaces to be created for this instance. #[serde(default = "defaults::instance_create_network_interfaces")] pub network_interfaces: InstanceNetworkInterfaceAttachment, + ///Should this instance be started upon creation; true by default. + #[serde(default = "defaults::default_bool::")] + pub start: bool, ///User data for instance initialization systems (such as cloud-init). /// Must be a Base64-encoded string, as specified in RFC 4648 § 4 (+ and /// / characters with padding). Maximum 32 KiB unencoded data. @@ -1409,24 +1580,38 @@ pub mod types { Clone, Copy, Debug, Deserialize, Eq, Hash, JsonSchema, Ord, PartialEq, PartialOrd, Serialize, )] pub enum InstanceState { + ///The instance is being created. #[serde(rename = "creating")] Creating, + ///The instance is currently starting up. #[serde(rename = "starting")] Starting, + ///The instance is currently running. #[serde(rename = "running")] Running, + ///The instance has been requested to stop and a transition to + /// "Stopped" is imminent. #[serde(rename = "stopping")] Stopping, + ///The instance is currently stopped. #[serde(rename = "stopped")] Stopped, + ///The instance is in the process of rebooting - it will remain in the + /// "rebooting" state until the VM is starting once more. #[serde(rename = "rebooting")] Rebooting, + ///The instance is in the process of migrating - it will remain in the + /// "migrating" state until the migration process is complete and the + /// destination propolis is ready to continue execution. #[serde(rename = "migrating")] Migrating, + ///The instance is attempting to recover from a failure. #[serde(rename = "repairing")] Repairing, + ///The instance has encountered a failure. #[serde(rename = "failed")] Failed, + ///The instance has been deleted. #[serde(rename = "destroyed")] Destroyed, } @@ -1600,8 +1785,6 @@ pub mod types { pub id: uuid::Uuid, ///unique, mutable, user-controlled identifier for each resource pub name: Name, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub project_id: Option, ///timestamp when this resource was created pub time_created: chrono::DateTime, ///timestamp when this resource was last modified @@ -1616,15 +1799,11 @@ pub mod types { ///Create-time parameters for an IP Pool. /// - ///See [`IpPool`](omicron_nexus::external_api::views::IpPool) + ///See [`IpPool`](crate::external_api::views::IpPool) #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] pub struct IpPoolCreate { pub description: String, pub name: Name, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub organization: Option, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub project: Option, } impl IpPoolCreate { @@ -1713,7 +1892,7 @@ pub mod types { impl std::str::FromStr for Ipv4Net { type Err = &'static str; fn from_str(value: &str) -> Result { - if regress :: Regex :: new ("^(10\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\/([8-9]|1[0-9]|2[0-9]|3[0-2])|172\\.(1[6-9]|2[0-9]|3[0-1])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\/(1[2-9]|2[0-9]|3[0-2])|192\\.168\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\/(1[6-9]|2[0-9]|3[0-2]))$") . unwrap () . find (value) . is_none () { return Err ("doesn't match pattern \"^(10\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\/([8-9]|1[0-9]|2[0-9]|3[0-2])|172\\.(1[6-9]|2[0-9]|3[0-1])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\/(1[2-9]|2[0-9]|3[0-2])|192\\.168\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\/(1[6-9]|2[0-9]|3[0-2]))$\"") ; } + if regress :: Regex :: new ("^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/([8-9]|1[0-9]|2[0-9]|3[0-2])$") . unwrap () . find (value) . is_none () { return Err ("doesn't match pattern \"^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/([8-9]|1[0-9]|2[0-9]|3[0-2])$\"") ; } Ok(Self(value.to_string())) } } @@ -2039,15 +2218,68 @@ pub mod types { } } + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + #[serde(untagged)] + pub enum NameOrId { + Id(uuid::Uuid), + Name(Name), + } + + impl std::str::FromStr for NameOrId { + type Err = &'static str; + fn from_str(value: &str) -> Result { + if let Ok(v) = value.parse() { + Ok(Self::Id(v)) + } else if let Ok(v) = value.parse() { + Ok(Self::Name(v)) + } else { + Err("string conversion failed for all variants") + } + } + } + + impl std::convert::TryFrom<&str> for NameOrId { + type Error = &'static str; + fn try_from(value: &str) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom<&String> for NameOrId { + type Error = &'static str; + fn try_from(value: &String) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom for NameOrId { + type Error = &'static str; + fn try_from(value: String) -> Result { + value.parse() + } + } + + impl ToString for NameOrId { + fn to_string(&self) -> String { + match self { + Self::Id(x) => x.to_string(), + Self::Name(x) => x.to_string(), + } + } + } + ///Supported set of sort modes for scanning by name or id #[derive( Clone, Copy, Debug, Deserialize, Eq, Hash, JsonSchema, Ord, PartialEq, PartialOrd, Serialize, )] pub enum NameOrIdSortMode { + ///sort in increasing order of "name" #[serde(rename = "name_ascending")] NameAscending, + ///sort in decreasing order of "name" #[serde(rename = "name_descending")] NameDescending, + ///sort in increasing order of "id" #[serde(rename = "id_ascending")] IdAscending, } @@ -2102,6 +2334,7 @@ pub mod types { Clone, Copy, Debug, Deserialize, Eq, Hash, JsonSchema, Ord, PartialEq, PartialOrd, Serialize, )] pub enum NameSortMode { + ///sort in increasing order of "name" #[serde(rename = "name_ascending")] NameAscending, } @@ -2226,6 +2459,8 @@ pub mod types { pub struct NetworkInterfaceUpdate { #[serde(default, skip_serializing_if = "Option::is_none")] pub description: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub name: Option, ///Make a secondary interface the instance's primary interface. /// ///If applied to a secondary interface, that interface will become the @@ -2238,9 +2473,7 @@ pub mod types { /// for an instance. Requests to change the primary interface into a /// secondary will return an error. #[serde(default)] - pub make_primary: bool, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub name: Option, + pub primary: bool, } impl NetworkInterfaceUpdate { @@ -2249,6 +2482,21 @@ pub mod types { } } + ///Unique name for a saga [`Node`] + /// + ///Each node requires a string name that's unique within its DAG. The name + /// is used to identify its output. Nodes that depend on a given node + /// (either directly or indirectly) can access the node's output using its + /// name. + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct NodeName(pub String); + impl std::ops::Deref for NodeName { + type Target = String; + fn deref(&self) -> &String { + &self.0 + } + } + ///Client view of an [`Organization`] #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] pub struct Organization { @@ -2408,6 +2656,149 @@ pub mod types { } } + ///Passwords may be subject to additional constraints. + #[derive(Clone, Debug, JsonSchema, Serialize)] + pub struct Password(String); + impl std::ops::Deref for Password { + type Target = String; + fn deref(&self) -> &String { + &self.0 + } + } + + impl std::str::FromStr for Password { + type Err = &'static str; + fn from_str(value: &str) -> Result { + if value.len() > 512usize { + return Err("longer than 512 characters"); + } + Ok(Self(value.to_string())) + } + } + + impl std::convert::TryFrom<&str> for Password { + type Error = &'static str; + fn try_from(value: &str) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom<&String> for Password { + type Error = &'static str; + fn try_from(value: &String) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom for Password { + type Error = &'static str; + fn try_from(value: String) -> Result { + value.parse() + } + } + + impl<'de> serde::Deserialize<'de> for Password { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + String::deserialize(deserializer)? + .parse() + .map_err(|e: &'static str| ::custom(e.to_string())) + } + } + + ///Client view of a [`PhysicalDisk`] + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct PhysicalDisk { + pub disk_type: PhysicalDiskType, + ///unique, immutable, system-controlled identifier for each resource + pub id: uuid::Uuid, + pub model: String, + pub serial: String, + ///The sled to which this disk is attached, if any. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub sled_id: Option, + ///timestamp when this resource was created + pub time_created: chrono::DateTime, + ///timestamp when this resource was last modified + pub time_modified: chrono::DateTime, + pub vendor: String, + } + + impl PhysicalDisk { + pub fn builder() -> builder::PhysicalDisk { + builder::PhysicalDisk::default() + } + } + + ///A single page of results + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct PhysicalDiskResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + + impl PhysicalDiskResultsPage { + pub fn builder() -> builder::PhysicalDiskResultsPage { + builder::PhysicalDiskResultsPage::default() + } + } + + #[derive( + Clone, Copy, Debug, Deserialize, Eq, Hash, JsonSchema, Ord, PartialEq, PartialOrd, Serialize, + )] + pub enum PhysicalDiskType { + #[serde(rename = "internal")] + Internal, + #[serde(rename = "external")] + External, + } + + impl ToString for PhysicalDiskType { + fn to_string(&self) -> String { + match *self { + Self::Internal => "internal".to_string(), + Self::External => "external".to_string(), + } + } + } + + impl std::str::FromStr for PhysicalDiskType { + type Err = &'static str; + fn from_str(value: &str) -> Result { + match value { + "internal" => Ok(Self::Internal), + "external" => Ok(Self::External), + _ => Err("invalid value"), + } + } + } + + impl std::convert::TryFrom<&str> for PhysicalDiskType { + type Error = &'static str; + fn try_from(value: &str) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom<&String> for PhysicalDiskType { + type Error = &'static str; + fn try_from(value: &String) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom for PhysicalDiskType { + type Error = &'static str; + fn try_from(value: String) -> Result { + value.parse() + } + } + ///Client view of a [`Project`] #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] pub struct Project { @@ -2786,12 +3177,25 @@ pub mod types { Clone, Copy, Debug, Deserialize, Eq, Hash, JsonSchema, Ord, PartialEq, PartialOrd, Serialize, )] pub enum RouterRouteKind { + ///Determines the default destination of traffic, such as whether it + /// goes to the internet or not. + /// + ///`Destination: An Internet Gateway` `Modifiable: true` #[serde(rename = "default")] Default, + ///Automatically added for each VPC Subnet in the VPC + /// + ///`Destination: A VPC Subnet` `Modifiable: false` #[serde(rename = "vpc_subnet")] VpcSubnet, + ///Automatically added when VPC peering is established + /// + ///`Destination: A different VPC` `Modifiable: false` #[serde(rename = "vpc_peering")] VpcPeering, + ///Created by a user See [`RouteTarget`] + /// + ///`Destination: User defined` `Modifiable: true` #[serde(rename = "custom")] Custom, } @@ -2927,7 +3331,7 @@ pub mod types { #[serde(rename = "failed")] Failed { error_info: SagaErrorInfo, - error_node_name: String, + error_node_name: NodeName, }, } @@ -2973,6 +3377,11 @@ pub mod types { ///service provider endpoint where the response will be sent pub acs_url: String, pub description: String, + ///If set, SAML attributes with this name will be considered to denote + /// a user's group membership, where the attribute value(s) should be a + /// comma-separated list of group names. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub group_attribute_name: Option, ///idp's entity id pub idp_entity_id: String, ///the source of an identity provider metadata descriptor @@ -2995,6 +3404,110 @@ pub mod types { } } + #[derive(Clone, Debug, JsonSchema, Serialize)] + pub struct SemverVersion(String); + impl std::ops::Deref for SemverVersion { + type Target = String; + fn deref(&self) -> &String { + &self.0 + } + } + + impl std::str::FromStr for SemverVersion { + type Err = &'static str; + fn from_str(value: &str) -> Result { + if regress::Regex::new("^\\d+\\.\\d+\\.\\d+([\\-\\+].+)?$") + .unwrap() + .find(value) + .is_none() + { + return Err("doesn't match pattern \"^\\d+\\.\\d+\\.\\d+([\\-\\+].+)?$\""); + } + Ok(Self(value.to_string())) + } + } + + impl std::convert::TryFrom<&str> for SemverVersion { + type Error = &'static str; + fn try_from(value: &str) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom<&String> for SemverVersion { + type Error = &'static str; + fn try_from(value: &String) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom for SemverVersion { + type Error = &'static str; + fn try_from(value: String) -> Result { + value.parse() + } + } + + impl<'de> serde::Deserialize<'de> for SemverVersion { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + String::deserialize(deserializer)? + .parse() + .map_err(|e: &'static str| ::custom(e.to_string())) + } + } + + ///The service intended to use this certificate. + #[derive( + Clone, Copy, Debug, Deserialize, Eq, Hash, JsonSchema, Ord, PartialEq, PartialOrd, Serialize, + )] + pub enum ServiceUsingCertificate { + ///This certificate is intended for access to the external API. + #[serde(rename = "external_api")] + ExternalApi, + } + + impl ToString for ServiceUsingCertificate { + fn to_string(&self) -> String { + match *self { + Self::ExternalApi => "external_api".to_string(), + } + } + } + + impl std::str::FromStr for ServiceUsingCertificate { + type Err = &'static str; + fn from_str(value: &str) -> Result { + match value { + "external_api" => Ok(Self::ExternalApi), + _ => Err("invalid value"), + } + } + } + + impl std::convert::TryFrom<&str> for ServiceUsingCertificate { + type Error = &'static str; + fn try_from(value: &str) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom<&String> for ServiceUsingCertificate { + type Error = &'static str; + fn try_from(value: &String) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom for ServiceUsingCertificate { + type Error = &'static str; + fn try_from(value: String) -> Result { + value.parse() + } + } + ///Client view of a ['Silo'] #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] pub struct Silo { @@ -3005,14 +3518,14 @@ pub mod types { pub discoverable: bool, ///unique, immutable, system-controlled identifier for each resource pub id: uuid::Uuid, + ///How users and groups are managed in this Silo + pub identity_mode: SiloIdentityMode, ///unique, mutable, user-controlled identifier for each resource pub name: Name, ///timestamp when this resource was created pub time_created: chrono::DateTime, ///timestamp when this resource was last modified pub time_modified: chrono::DateTime, - ///User provision type - pub user_provision_type: UserProvisionType, } impl Silo { @@ -3024,10 +3537,20 @@ pub mod types { ///Create-time parameters for a [`Silo`](crate::external_api::views::Silo) #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] pub struct SiloCreate { + ///If set, this group will be created during Silo creation and granted + /// the "Silo Admin" role. Identity providers can assert that users + /// belong to this group and those users can log in and further + /// initialize the Silo. + /// + ///Note that if configuring a SAML based identity provider, + /// group_attribute_name must be set for users to be considered part of + /// a group. See [`SamlIdentityProviderCreate`] for more information. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub admin_group_name: Option, pub description: String, pub discoverable: bool, + pub identity_mode: SiloIdentityMode, pub name: Name, - pub user_provision_type: UserProvisionType, } impl SiloCreate { @@ -3036,6 +3559,65 @@ pub mod types { } } + ///Describes how identities are managed and users are authenticated in this + /// Silo + #[derive( + Clone, Copy, Debug, Deserialize, Eq, Hash, JsonSchema, Ord, PartialEq, PartialOrd, Serialize, + )] + pub enum SiloIdentityMode { + ///Users are authenticated with SAML using an external authentication + /// provider. The system updates information about users and groups + /// only during successful authentication (i.e,. "JIT provisioning" of + /// users and groups). + #[serde(rename = "saml_jit")] + SamlJit, + ///The system is the source of truth about users. There is no linkage + /// to an external authentication provider or identity provider. + #[serde(rename = "local_only")] + LocalOnly, + } + + impl ToString for SiloIdentityMode { + fn to_string(&self) -> String { + match *self { + Self::SamlJit => "saml_jit".to_string(), + Self::LocalOnly => "local_only".to_string(), + } + } + } + + impl std::str::FromStr for SiloIdentityMode { + type Err = &'static str; + fn from_str(value: &str) -> Result { + match value { + "saml_jit" => Ok(Self::SamlJit), + "local_only" => Ok(Self::LocalOnly), + _ => Err("invalid value"), + } + } + } + + impl std::convert::TryFrom<&str> for SiloIdentityMode { + type Error = &'static str; + fn try_from(value: &str) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom<&String> for SiloIdentityMode { + type Error = &'static str; + fn try_from(value: &String) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom for SiloIdentityMode { + type Error = &'static str; + fn try_from(value: String) -> Result { + value.parse() + } + } + ///A single page of results #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] pub struct SiloResultsPage { @@ -3144,9 +3726,10 @@ pub mod types { } } - ///Client view of an [`Sled`] + ///Client view of a [`Sled`] #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] pub struct Sled { + pub baseboard: Baseboard, ///unique, immutable, system-controlled identifier for each resource pub id: uuid::Uuid, pub service_address: String, @@ -3190,6 +3773,7 @@ pub mod types { pub name: Name, pub project_id: uuid::Uuid, pub size: ByteCount, + pub state: SnapshotState, ///timestamp when this resource was created pub time_created: chrono::DateTime, ///timestamp when this resource was last modified @@ -3203,7 +3787,7 @@ pub mod types { } ///Create-time parameters for a - /// [`Snapshot`](omicron_common::api::external::Snapshot) + /// [`Snapshot`](crate::external_api::views::Snapshot) #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] pub struct SnapshotCreate { pub description: String, @@ -3234,6 +3818,65 @@ pub mod types { } } + #[derive( + Clone, Copy, Debug, Deserialize, Eq, Hash, JsonSchema, Ord, PartialEq, PartialOrd, Serialize, + )] + pub enum SnapshotState { + #[serde(rename = "creating")] + Creating, + #[serde(rename = "ready")] + Ready, + #[serde(rename = "faulted")] + Faulted, + #[serde(rename = "destroyed")] + Destroyed, + } + + impl ToString for SnapshotState { + fn to_string(&self) -> String { + match *self { + Self::Creating => "creating".to_string(), + Self::Ready => "ready".to_string(), + Self::Faulted => "faulted".to_string(), + Self::Destroyed => "destroyed".to_string(), + } + } + } + + impl std::str::FromStr for SnapshotState { + type Err = &'static str; + fn from_str(value: &str) -> Result { + match value { + "creating" => Ok(Self::Creating), + "ready" => Ok(Self::Ready), + "faulted" => Ok(Self::Faulted), + "destroyed" => Ok(Self::Destroyed), + _ => Err("invalid value"), + } + } + } + + impl std::convert::TryFrom<&str> for SnapshotState { + type Error = &'static str; + fn try_from(value: &str) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom<&String> for SnapshotState { + type Error = &'static str; + fn try_from(value: &String) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom for SnapshotState { + type Error = &'static str; + fn try_from(value: String) -> Result { + value.parse() + } + } + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] pub struct SpoofLoginBody { pub username: String, @@ -3302,6 +3945,119 @@ pub mod types { } } + #[derive( + Clone, Copy, Debug, Deserialize, Eq, Hash, JsonSchema, Ord, PartialEq, PartialOrd, Serialize, + )] + pub enum SystemMetricName { + #[serde(rename = "virtual_disk_space_provisioned")] + VirtualDiskSpaceProvisioned, + #[serde(rename = "cpus_provisioned")] + CpusProvisioned, + #[serde(rename = "ram_provisioned")] + RamProvisioned, + } + + impl ToString for SystemMetricName { + fn to_string(&self) -> String { + match *self { + Self::VirtualDiskSpaceProvisioned => "virtual_disk_space_provisioned".to_string(), + Self::CpusProvisioned => "cpus_provisioned".to_string(), + Self::RamProvisioned => "ram_provisioned".to_string(), + } + } + } + + impl std::str::FromStr for SystemMetricName { + type Err = &'static str; + fn from_str(value: &str) -> Result { + match value { + "virtual_disk_space_provisioned" => Ok(Self::VirtualDiskSpaceProvisioned), + "cpus_provisioned" => Ok(Self::CpusProvisioned), + "ram_provisioned" => Ok(Self::RamProvisioned), + _ => Err("invalid value"), + } + } + } + + impl std::convert::TryFrom<&str> for SystemMetricName { + type Error = &'static str; + fn try_from(value: &str) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom<&String> for SystemMetricName { + type Error = &'static str; + fn try_from(value: &String) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom for SystemMetricName { + type Error = &'static str; + fn try_from(value: String) -> Result { + value.parse() + } + } + + ///Identity-related metadata that's included in "asset" public API objects + /// (which generally have no name or description) + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct SystemUpdate { + ///unique, immutable, system-controlled identifier for each resource + pub id: uuid::Uuid, + ///timestamp when this resource was created + pub time_created: chrono::DateTime, + ///timestamp when this resource was last modified + pub time_modified: chrono::DateTime, + pub version: SemverVersion, + } + + impl SystemUpdate { + pub fn builder() -> builder::SystemUpdate { + builder::SystemUpdate::default() + } + } + + ///A single page of results + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct SystemUpdateResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + + impl SystemUpdateResultsPage { + pub fn builder() -> builder::SystemUpdateResultsPage { + builder::SystemUpdateResultsPage::default() + } + } + + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct SystemUpdateStart { + pub version: SemverVersion, + } + + impl SystemUpdateStart { + pub fn builder() -> builder::SystemUpdateStart { + builder::SystemUpdateStart::default() + } + } + + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct SystemVersion { + pub status: UpdateStatus, + pub version_range: VersionRange, + } + + impl SystemVersion { + pub fn builder() -> builder::SystemVersion { + builder::SystemVersion::default() + } + } + ///Names are constructed by concatenating the target and metric names with /// ':'. Target and metric names must be lowercase alphanumeric characters /// with '_' separating words. @@ -3396,12 +4152,232 @@ pub mod types { } } + ///Identity-related metadata that's included in "asset" public API objects + /// (which generally have no name or description) + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct UpdateDeployment { + ///unique, immutable, system-controlled identifier for each resource + pub id: uuid::Uuid, + pub status: UpdateStatus, + ///timestamp when this resource was created + pub time_created: chrono::DateTime, + ///timestamp when this resource was last modified + pub time_modified: chrono::DateTime, + pub version: SemverVersion, + } + + impl UpdateDeployment { + pub fn builder() -> builder::UpdateDeployment { + builder::UpdateDeployment::default() + } + } + + ///A single page of results + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct UpdateDeploymentResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + + impl UpdateDeploymentResultsPage { + pub fn builder() -> builder::UpdateDeploymentResultsPage { + builder::UpdateDeploymentResultsPage::default() + } + } + + #[derive( + Clone, Copy, Debug, Deserialize, Eq, Hash, JsonSchema, Ord, PartialEq, PartialOrd, Serialize, + )] + #[serde(tag = "status")] + pub enum UpdateStatus { + #[serde(rename = "updating")] + Updating, + #[serde(rename = "steady")] + Steady, + } + + impl ToString for UpdateStatus { + fn to_string(&self) -> String { + match *self { + Self::Updating => "updating".to_string(), + Self::Steady => "steady".to_string(), + } + } + } + + impl std::str::FromStr for UpdateStatus { + type Err = &'static str; + fn from_str(value: &str) -> Result { + match value { + "updating" => Ok(Self::Updating), + "steady" => Ok(Self::Steady), + _ => Err("invalid value"), + } + } + } + + impl std::convert::TryFrom<&str> for UpdateStatus { + type Error = &'static str; + fn try_from(value: &str) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom<&String> for UpdateStatus { + type Error = &'static str; + fn try_from(value: &String) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom for UpdateStatus { + type Error = &'static str; + fn try_from(value: String) -> Result { + value.parse() + } + } + + ///Identity-related metadata that's included in "asset" public API objects + /// (which generally have no name or description) + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct UpdateableComponent { + pub component_type: UpdateableComponentType, + pub device_id: String, + ///unique, immutable, system-controlled identifier for each resource + pub id: uuid::Uuid, + pub status: UpdateStatus, + pub system_version: SemverVersion, + ///timestamp when this resource was created + pub time_created: chrono::DateTime, + ///timestamp when this resource was last modified + pub time_modified: chrono::DateTime, + pub version: SemverVersion, + } + + impl UpdateableComponent { + pub fn builder() -> builder::UpdateableComponent { + builder::UpdateableComponent::default() + } + } + + ///A single page of results + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct UpdateableComponentResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + + impl UpdateableComponentResultsPage { + pub fn builder() -> builder::UpdateableComponentResultsPage { + builder::UpdateableComponentResultsPage::default() + } + } + + #[derive( + Clone, Copy, Debug, Deserialize, Eq, Hash, JsonSchema, Ord, PartialEq, PartialOrd, Serialize, + )] + pub enum UpdateableComponentType { + #[serde(rename = "bootloader_for_rot")] + BootloaderForRot, + #[serde(rename = "bootloader_for_sp")] + BootloaderForSp, + #[serde(rename = "bootloader_for_host_proc")] + BootloaderForHostProc, + #[serde(rename = "hubris_for_psc_rot")] + HubrisForPscRot, + #[serde(rename = "hubris_for_psc_sp")] + HubrisForPscSp, + #[serde(rename = "hubris_for_sidecar_rot")] + HubrisForSidecarRot, + #[serde(rename = "hubris_for_sidecar_sp")] + HubrisForSidecarSp, + #[serde(rename = "hubris_for_gimlet_rot")] + HubrisForGimletRot, + #[serde(rename = "hubris_for_gimlet_sp")] + HubrisForGimletSp, + #[serde(rename = "helios_host_phase1")] + HeliosHostPhase1, + #[serde(rename = "helios_host_phase2")] + HeliosHostPhase2, + #[serde(rename = "host_omicron")] + HostOmicron, + } + + impl ToString for UpdateableComponentType { + fn to_string(&self) -> String { + match *self { + Self::BootloaderForRot => "bootloader_for_rot".to_string(), + Self::BootloaderForSp => "bootloader_for_sp".to_string(), + Self::BootloaderForHostProc => "bootloader_for_host_proc".to_string(), + Self::HubrisForPscRot => "hubris_for_psc_rot".to_string(), + Self::HubrisForPscSp => "hubris_for_psc_sp".to_string(), + Self::HubrisForSidecarRot => "hubris_for_sidecar_rot".to_string(), + Self::HubrisForSidecarSp => "hubris_for_sidecar_sp".to_string(), + Self::HubrisForGimletRot => "hubris_for_gimlet_rot".to_string(), + Self::HubrisForGimletSp => "hubris_for_gimlet_sp".to_string(), + Self::HeliosHostPhase1 => "helios_host_phase1".to_string(), + Self::HeliosHostPhase2 => "helios_host_phase2".to_string(), + Self::HostOmicron => "host_omicron".to_string(), + } + } + } + + impl std::str::FromStr for UpdateableComponentType { + type Err = &'static str; + fn from_str(value: &str) -> Result { + match value { + "bootloader_for_rot" => Ok(Self::BootloaderForRot), + "bootloader_for_sp" => Ok(Self::BootloaderForSp), + "bootloader_for_host_proc" => Ok(Self::BootloaderForHostProc), + "hubris_for_psc_rot" => Ok(Self::HubrisForPscRot), + "hubris_for_psc_sp" => Ok(Self::HubrisForPscSp), + "hubris_for_sidecar_rot" => Ok(Self::HubrisForSidecarRot), + "hubris_for_sidecar_sp" => Ok(Self::HubrisForSidecarSp), + "hubris_for_gimlet_rot" => Ok(Self::HubrisForGimletRot), + "hubris_for_gimlet_sp" => Ok(Self::HubrisForGimletSp), + "helios_host_phase1" => Ok(Self::HeliosHostPhase1), + "helios_host_phase2" => Ok(Self::HeliosHostPhase2), + "host_omicron" => Ok(Self::HostOmicron), + _ => Err("invalid value"), + } + } + } + + impl std::convert::TryFrom<&str> for UpdateableComponentType { + type Error = &'static str; + fn try_from(value: &str) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom<&String> for UpdateableComponentType { + type Error = &'static str; + fn try_from(value: &String) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom for UpdateableComponentType { + type Error = &'static str; + fn try_from(value: String) -> Result { + value.parse() + } + } + ///Client view of a [`User`] #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] pub struct User { ///Human-readable name that can identify the user pub display_name: String, pub id: uuid::Uuid, + ///Uuid of the silo to which this user belongs + pub silo_id: uuid::Uuid, } impl User { @@ -3447,58 +4423,87 @@ pub mod types { } } - ///How users will be provisioned in a silo during authentication. - #[derive( - Clone, Copy, Debug, Deserialize, Eq, Hash, JsonSchema, Ord, PartialEq, PartialOrd, Serialize, - )] - pub enum UserProvisionType { - #[serde(rename = "fixed")] - Fixed, - #[serde(rename = "jit")] - Jit, + ///Create-time parameters for a [`User`](crate::external_api::views::User) + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct UserCreate { + ///username used to log in + pub external_id: UserId, + ///password used to log in + pub password: UserPassword, } - impl ToString for UserProvisionType { - fn to_string(&self) -> String { - match *self { - Self::Fixed => "fixed".to_string(), - Self::Jit => "jit".to_string(), - } + impl UserCreate { + pub fn builder() -> builder::UserCreate { + builder::UserCreate::default() } } - impl std::str::FromStr for UserProvisionType { + ///Names must begin with a lower case ASCII letter, be composed exclusively + /// of lowercase ASCII, uppercase ASCII, numbers, and '-', and may not end + /// with a '-'. Names cannot be a UUID though they may contain a UUID. + #[derive(Clone, Debug, JsonSchema, Serialize)] + pub struct UserId(String); + impl std::ops::Deref for UserId { + type Target = String; + fn deref(&self) -> &String { + &self.0 + } + } + + impl std::str::FromStr for UserId { type Err = &'static str; fn from_str(value: &str) -> Result { - match value { - "fixed" => Ok(Self::Fixed), - "jit" => Ok(Self::Jit), - _ => Err("invalid value"), + if value.len() > 63usize { + return Err("longer than 63 characters"); } + if regress :: Regex :: new ("^(?![0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$)^[a-z][a-z0-9-]*[a-zA-Z0-9]$") . unwrap () . find (value) . is_none () { return Err ("doesn't match pattern \"^(?![0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$)^[a-z][a-z0-9-]*[a-zA-Z0-9]$\"") ; } + Ok(Self(value.to_string())) } } - impl std::convert::TryFrom<&str> for UserProvisionType { + impl std::convert::TryFrom<&str> for UserId { type Error = &'static str; fn try_from(value: &str) -> Result { value.parse() } } - impl std::convert::TryFrom<&String> for UserProvisionType { + impl std::convert::TryFrom<&String> for UserId { type Error = &'static str; fn try_from(value: &String) -> Result { value.parse() } } - impl std::convert::TryFrom for UserProvisionType { + impl std::convert::TryFrom for UserId { type Error = &'static str; fn try_from(value: String) -> Result { value.parse() } } + impl<'de> serde::Deserialize<'de> for UserId { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + String::deserialize(deserializer)? + .parse() + .map_err(|e: &'static str| ::custom(e.to_string())) + } + } + + ///Parameters for setting a user's password + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + #[serde(tag = "user_password_value", content = "details")] + pub enum UserPassword { + ///Sets the user's password to the provided value + #[serde(rename = "password")] + Password(Password), + #[serde(rename = "invalid_password")] + InvalidPassword, + } + ///A single page of results #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] pub struct UserResultsPage { @@ -3515,6 +4520,31 @@ pub mod types { } } + ///Credentials for local user login + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct UsernamePasswordCredentials { + pub password: Password, + pub username: UserId, + } + + impl UsernamePasswordCredentials { + pub fn builder() -> builder::UsernamePasswordCredentials { + builder::UsernamePasswordCredentials::default() + } + } + + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] + pub struct VersionRange { + pub high: SemverVersion, + pub low: SemverVersion, + } + + impl VersionRange { + pub fn builder() -> builder::VersionRange { + builder::VersionRange::default() + } + } + ///Client view of a [`Vpc`] #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] pub struct Vpc { @@ -3918,7 +4948,7 @@ pub mod types { } } - ///Collection of a [`Vpc`]'s firewall rules + ///Collection of a Vpc's firewall rules #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] pub struct VpcFirewallRules { pub rules: Vec, @@ -4174,6 +5204,66 @@ pub mod types { } mod builder { + pub struct Baseboard { + part: Result, + revision: Result, + serial: Result, + } + + impl Default for Baseboard { + fn default() -> Self { + Self { + part: Err("no value supplied for part".to_string()), + revision: Err("no value supplied for revision".to_string()), + serial: Err("no value supplied for serial".to_string()), + } + } + } + + impl Baseboard { + pub fn part(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.part = value + .try_into() + .map_err(|e| format!("error converting supplied value for part: {}", e)); + self + } + pub fn revision(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.revision = value + .try_into() + .map_err(|e| format!("error converting supplied value for revision: {}", e)); + self + } + pub fn serial(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.serial = value + .try_into() + .map_err(|e| format!("error converting supplied value for serial: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::Baseboard { + type Error = String; + fn try_from(value: Baseboard) -> Result { + Ok(Self { + part: value.part?, + revision: value.revision?, + serial: value.serial?, + }) + } + } + pub struct Bindouble { count: Result, range: Result, @@ -4268,6 +5358,371 @@ pub mod types { } } + pub struct Certificate { + description: Result, + id: Result, + name: Result, + service: Result, + time_created: Result, String>, + time_modified: Result, String>, + } + + impl Default for Certificate { + fn default() -> Self { + Self { + description: Err("no value supplied for description".to_string()), + id: Err("no value supplied for id".to_string()), + name: Err("no value supplied for name".to_string()), + service: Err("no value supplied for service".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + } + } + } + + impl Certificate { + pub fn description(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn service(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.service = value + .try_into() + .map_err(|e| format!("error converting supplied value for service: {}", e)); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + } + + impl std::convert::TryFrom for super::Certificate { + type Error = String; + fn try_from(value: Certificate) -> Result { + Ok(Self { + description: value.description?, + id: value.id?, + name: value.name?, + service: value.service?, + time_created: value.time_created?, + time_modified: value.time_modified?, + }) + } + } + + pub struct CertificateCreate { + cert: Result, String>, + description: Result, + key: Result, String>, + name: Result, + service: Result, + } + + impl Default for CertificateCreate { + fn default() -> Self { + Self { + cert: Err("no value supplied for cert".to_string()), + description: Err("no value supplied for description".to_string()), + key: Err("no value supplied for key".to_string()), + name: Err("no value supplied for name".to_string()), + service: Err("no value supplied for service".to_string()), + } + } + } + + impl CertificateCreate { + pub fn cert(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.cert = value + .try_into() + .map_err(|e| format!("error converting supplied value for cert: {}", e)); + self + } + pub fn description(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn key(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.key = value + .try_into() + .map_err(|e| format!("error converting supplied value for key: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn service(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.service = value + .try_into() + .map_err(|e| format!("error converting supplied value for service: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::CertificateCreate { + type Error = String; + fn try_from(value: CertificateCreate) -> Result { + Ok(Self { + cert: value.cert?, + description: value.description?, + key: value.key?, + name: value.name?, + service: value.service?, + }) + } + } + + pub struct CertificateResultsPage { + items: Result, String>, + next_page: Result, String>, + } + + impl Default for CertificateResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl CertificateResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::CertificateResultsPage { + type Error = String; + fn try_from(value: CertificateResultsPage) -> Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + pub struct ComponentUpdate { + component_type: Result, + id: Result, + time_created: Result, String>, + time_modified: Result, String>, + version: Result, + } + + impl Default for ComponentUpdate { + fn default() -> Self { + Self { + component_type: Err("no value supplied for component_type".to_string()), + id: Err("no value supplied for id".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + version: Err("no value supplied for version".to_string()), + } + } + } + + impl ComponentUpdate { + pub fn component_type(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.component_type = value.try_into().map_err(|e| { + format!("error converting supplied value for component_type: {}", e) + }); + self + } + pub fn id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + pub fn version(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.version = value + .try_into() + .map_err(|e| format!("error converting supplied value for version: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::ComponentUpdate { + type Error = String; + fn try_from(value: ComponentUpdate) -> Result { + Ok(Self { + component_type: value.component_type?, + id: value.id?, + time_created: value.time_created?, + time_modified: value.time_modified?, + version: value.version?, + }) + } + } + + pub struct ComponentUpdateResultsPage { + items: Result, String>, + next_page: Result, String>, + } + + impl Default for ComponentUpdateResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl ComponentUpdateResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::ComponentUpdateResultsPage { + type Error = String; + fn try_from(value: ComponentUpdateResultsPage) -> Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + pub struct Cumulativedouble { start_time: Result, String>, value: Result, @@ -4819,6 +6274,38 @@ pub mod types { } } + pub struct DiskPath { + disk: Result, + } + + impl Default for DiskPath { + fn default() -> Self { + Self { + disk: Err("no value supplied for disk".to_string()), + } + } + } + + impl DiskPath { + pub fn disk(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.disk = value + .try_into() + .map_err(|e| format!("error converting supplied value for disk: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::DiskPath { + type Error = String; + fn try_from(value: DiskPath) -> Result { + Ok(Self { disk: value.disk? }) + } + } + pub struct DiskResultsPage { items: Result, String>, next_page: Result, String>, @@ -5521,6 +7008,113 @@ pub mod types { } } + pub struct Group { + display_name: Result, + id: Result, + silo_id: Result, + } + + impl Default for Group { + fn default() -> Self { + Self { + display_name: Err("no value supplied for display_name".to_string()), + id: Err("no value supplied for id".to_string()), + silo_id: Err("no value supplied for silo_id".to_string()), + } + } + } + + impl Group { + pub fn display_name(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.display_name = value.try_into().map_err(|e| { + format!("error converting supplied value for display_name: {}", e) + }); + self + } + pub fn id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn silo_id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.silo_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for silo_id: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::Group { + type Error = String; + fn try_from(value: Group) -> Result { + Ok(Self { + display_name: value.display_name?, + id: value.id?, + silo_id: value.silo_id?, + }) + } + } + + pub struct GroupResultsPage { + items: Result, String>, + next_page: Result, String>, + } + + impl Default for GroupResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl GroupResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::GroupResultsPage { + type Error = String; + fn try_from(value: GroupResultsPage) -> Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + pub struct Histogramdouble { bins: Result, String>, n_samples: Result, @@ -6249,6 +7843,7 @@ pub mod types { name: Result, ncpus: Result, network_interfaces: Result, + start: Result, user_data: Result, } @@ -6263,6 +7858,7 @@ pub mod types { name: Err("no value supplied for name".to_string()), ncpus: Err("no value supplied for ncpus".to_string()), network_interfaces: Ok(super::defaults::instance_create_network_interfaces()), + start: Ok(super::defaults::default_bool::()), user_data: Ok(Default::default()), } } @@ -6352,6 +7948,16 @@ pub mod types { }); self } + pub fn start(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.start = value + .try_into() + .map_err(|e| format!("error converting supplied value for start: {}", e)); + self + } pub fn user_data(mut self, value: T) -> Self where T: std::convert::TryInto, @@ -6376,6 +7982,7 @@ pub mod types { name: value.name?, ncpus: value.ncpus?, network_interfaces: value.network_interfaces?, + start: value.start?, user_data: value.user_data?, }) } @@ -6516,7 +8123,6 @@ pub mod types { description: Result, id: Result, name: Result, - project_id: Result, String>, time_created: Result, String>, time_modified: Result, String>, } @@ -6527,7 +8133,6 @@ pub mod types { description: Err("no value supplied for description".to_string()), id: Err("no value supplied for id".to_string()), name: Err("no value supplied for name".to_string()), - project_id: Ok(Default::default()), time_created: Err("no value supplied for time_created".to_string()), time_modified: Err("no value supplied for time_modified".to_string()), } @@ -6565,16 +8170,6 @@ pub mod types { .map_err(|e| format!("error converting supplied value for name: {}", e)); self } - pub fn project_id(mut self, value: T) -> Self - where - T: std::convert::TryInto>, - T::Error: std::fmt::Display, - { - self.project_id = value - .try_into() - .map_err(|e| format!("error converting supplied value for project_id: {}", e)); - self - } pub fn time_created(mut self, value: T) -> Self where T: std::convert::TryInto>, @@ -6604,7 +8199,6 @@ pub mod types { description: value.description?, id: value.id?, name: value.name?, - project_id: value.project_id?, time_created: value.time_created?, time_modified: value.time_modified?, }) @@ -6614,8 +8208,6 @@ pub mod types { pub struct IpPoolCreate { description: Result, name: Result, - organization: Result, String>, - project: Result, String>, } impl Default for IpPoolCreate { @@ -6623,8 +8215,6 @@ pub mod types { Self { description: Err("no value supplied for description".to_string()), name: Err("no value supplied for name".to_string()), - organization: Ok(Default::default()), - project: Ok(Default::default()), } } } @@ -6650,26 +8240,6 @@ pub mod types { .map_err(|e| format!("error converting supplied value for name: {}", e)); self } - pub fn organization(mut self, value: T) -> Self - where - T: std::convert::TryInto>, - T::Error: std::fmt::Display, - { - self.organization = value.try_into().map_err(|e| { - format!("error converting supplied value for organization: {}", e) - }); - self - } - pub fn project(mut self, value: T) -> Self - where - T: std::convert::TryInto>, - T::Error: std::fmt::Display, - { - self.project = value - .try_into() - .map_err(|e| format!("error converting supplied value for project: {}", e)); - self - } } impl std::convert::TryFrom for super::IpPoolCreate { @@ -6678,8 +8248,6 @@ pub mod types { Ok(Self { description: value.description?, name: value.name?, - organization: value.organization?, - project: value.project?, }) } } @@ -7372,16 +8940,16 @@ pub mod types { pub struct NetworkInterfaceUpdate { description: Result, String>, - make_primary: Result, name: Result, String>, + primary: Result, } impl Default for NetworkInterfaceUpdate { fn default() -> Self { Self { description: Ok(Default::default()), - make_primary: Ok(Default::default()), name: Ok(Default::default()), + primary: Ok(Default::default()), } } } @@ -7397,16 +8965,6 @@ pub mod types { .map_err(|e| format!("error converting supplied value for description: {}", e)); self } - pub fn make_primary(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.make_primary = value.try_into().map_err(|e| { - format!("error converting supplied value for make_primary: {}", e) - }); - self - } pub fn name(mut self, value: T) -> Self where T: std::convert::TryInto>, @@ -7417,6 +8975,16 @@ pub mod types { .map_err(|e| format!("error converting supplied value for name: {}", e)); self } + pub fn primary(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.primary = value + .try_into() + .map_err(|e| format!("error converting supplied value for primary: {}", e)); + self + } } impl std::convert::TryFrom for super::NetworkInterfaceUpdate { @@ -7424,8 +8992,8 @@ pub mod types { fn try_from(value: NetworkInterfaceUpdate) -> Result { Ok(Self { description: value.description?, - make_primary: value.make_primary?, name: value.name?, + primary: value.primary?, }) } } @@ -7756,6 +9324,178 @@ pub mod types { } } + pub struct PhysicalDisk { + disk_type: Result, + id: Result, + model: Result, + serial: Result, + sled_id: Result, String>, + time_created: Result, String>, + time_modified: Result, String>, + vendor: Result, + } + + impl Default for PhysicalDisk { + fn default() -> Self { + Self { + disk_type: Err("no value supplied for disk_type".to_string()), + id: Err("no value supplied for id".to_string()), + model: Err("no value supplied for model".to_string()), + serial: Err("no value supplied for serial".to_string()), + sled_id: Ok(Default::default()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + vendor: Err("no value supplied for vendor".to_string()), + } + } + } + + impl PhysicalDisk { + pub fn disk_type(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.disk_type = value + .try_into() + .map_err(|e| format!("error converting supplied value for disk_type: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn model(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.model = value + .try_into() + .map_err(|e| format!("error converting supplied value for model: {}", e)); + self + } + pub fn serial(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.serial = value + .try_into() + .map_err(|e| format!("error converting supplied value for serial: {}", e)); + self + } + pub fn sled_id(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.sled_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for sled_id: {}", e)); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + pub fn vendor(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.vendor = value + .try_into() + .map_err(|e| format!("error converting supplied value for vendor: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::PhysicalDisk { + type Error = String; + fn try_from(value: PhysicalDisk) -> Result { + Ok(Self { + disk_type: value.disk_type?, + id: value.id?, + model: value.model?, + serial: value.serial?, + sled_id: value.sled_id?, + time_created: value.time_created?, + time_modified: value.time_modified?, + vendor: value.vendor?, + }) + } + } + + pub struct PhysicalDiskResultsPage { + items: Result, String>, + next_page: Result, String>, + } + + impl Default for PhysicalDiskResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl PhysicalDiskResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::PhysicalDiskResultsPage { + type Error = String; + fn try_from(value: PhysicalDiskResultsPage) -> Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + pub struct Project { description: Result, id: Result, @@ -8891,6 +10631,7 @@ pub mod types { pub struct SamlIdentityProviderCreate { acs_url: Result, description: Result, + group_attribute_name: Result, String>, idp_entity_id: Result, idp_metadata_source: Result, name: Result, @@ -8905,6 +10646,7 @@ pub mod types { Self { acs_url: Err("no value supplied for acs_url".to_string()), description: Err("no value supplied for description".to_string()), + group_attribute_name: Ok(Default::default()), idp_entity_id: Err("no value supplied for idp_entity_id".to_string()), idp_metadata_source: Err( "no value supplied for idp_metadata_source".to_string() @@ -8941,6 +10683,19 @@ pub mod types { .map_err(|e| format!("error converting supplied value for description: {}", e)); self } + pub fn group_attribute_name(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.group_attribute_name = value.try_into().map_err(|e| { + format!( + "error converting supplied value for group_attribute_name: {}", + e + ) + }); + self + } pub fn idp_entity_id(mut self, value: T) -> Self where T: std::convert::TryInto, @@ -9025,6 +10780,7 @@ pub mod types { Ok(Self { acs_url: value.acs_url?, description: value.description?, + group_attribute_name: value.group_attribute_name?, idp_entity_id: value.idp_entity_id?, idp_metadata_source: value.idp_metadata_source?, name: value.name?, @@ -9040,10 +10796,10 @@ pub mod types { description: Result, discoverable: Result, id: Result, + identity_mode: Result, name: Result, time_created: Result, String>, time_modified: Result, String>, - user_provision_type: Result, } impl Default for Silo { @@ -9052,12 +10808,10 @@ pub mod types { description: Err("no value supplied for description".to_string()), discoverable: Err("no value supplied for discoverable".to_string()), id: Err("no value supplied for id".to_string()), + identity_mode: Err("no value supplied for identity_mode".to_string()), name: Err("no value supplied for name".to_string()), time_created: Err("no value supplied for time_created".to_string()), time_modified: Err("no value supplied for time_modified".to_string()), - user_provision_type: Err( - "no value supplied for user_provision_type".to_string() - ), } } } @@ -9093,6 +10847,16 @@ pub mod types { .map_err(|e| format!("error converting supplied value for id: {}", e)); self } + pub fn identity_mode(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.identity_mode = value.try_into().map_err(|e| { + format!("error converting supplied value for identity_mode: {}", e) + }); + self + } pub fn name(mut self, value: T) -> Self where T: std::convert::TryInto, @@ -9123,19 +10887,6 @@ pub mod types { }); self } - pub fn user_provision_type(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.user_provision_type = value.try_into().map_err(|e| { - format!( - "error converting supplied value for user_provision_type: {}", - e - ) - }); - self - } } impl std::convert::TryFrom for super::Silo { @@ -9145,35 +10896,48 @@ pub mod types { description: value.description?, discoverable: value.discoverable?, id: value.id?, + identity_mode: value.identity_mode?, name: value.name?, time_created: value.time_created?, time_modified: value.time_modified?, - user_provision_type: value.user_provision_type?, }) } } pub struct SiloCreate { + admin_group_name: Result, String>, description: Result, discoverable: Result, + identity_mode: Result, name: Result, - user_provision_type: Result, } impl Default for SiloCreate { fn default() -> Self { Self { + admin_group_name: Ok(Default::default()), description: Err("no value supplied for description".to_string()), discoverable: Err("no value supplied for discoverable".to_string()), + identity_mode: Err("no value supplied for identity_mode".to_string()), name: Err("no value supplied for name".to_string()), - user_provision_type: Err( - "no value supplied for user_provision_type".to_string() - ), } } } impl SiloCreate { + pub fn admin_group_name(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.admin_group_name = value.try_into().map_err(|e| { + format!( + "error converting supplied value for admin_group_name: {}", + e + ) + }); + self + } pub fn description(mut self, value: T) -> Self where T: std::convert::TryInto, @@ -9194,6 +10958,16 @@ pub mod types { }); self } + pub fn identity_mode(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.identity_mode = value.try_into().map_err(|e| { + format!("error converting supplied value for identity_mode: {}", e) + }); + self + } pub fn name(mut self, value: T) -> Self where T: std::convert::TryInto, @@ -9204,29 +10978,17 @@ pub mod types { .map_err(|e| format!("error converting supplied value for name: {}", e)); self } - pub fn user_provision_type(mut self, value: T) -> Self - where - T: std::convert::TryInto, - T::Error: std::fmt::Display, - { - self.user_provision_type = value.try_into().map_err(|e| { - format!( - "error converting supplied value for user_provision_type: {}", - e - ) - }); - self - } } impl std::convert::TryFrom for super::SiloCreate { type Error = String; fn try_from(value: SiloCreate) -> Result { Ok(Self { + admin_group_name: value.admin_group_name?, description: value.description?, discoverable: value.discoverable?, + identity_mode: value.identity_mode?, name: value.name?, - user_provision_type: value.user_provision_type?, }) } } @@ -9376,6 +11138,7 @@ pub mod types { } pub struct Sled { + baseboard: Result, id: Result, service_address: Result, time_created: Result, String>, @@ -9385,6 +11148,7 @@ pub mod types { impl Default for Sled { fn default() -> Self { Self { + baseboard: Err("no value supplied for baseboard".to_string()), id: Err("no value supplied for id".to_string()), service_address: Err("no value supplied for service_address".to_string()), time_created: Err("no value supplied for time_created".to_string()), @@ -9394,6 +11158,16 @@ pub mod types { } impl Sled { + pub fn baseboard(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.baseboard = value + .try_into() + .map_err(|e| format!("error converting supplied value for baseboard: {}", e)); + self + } pub fn id(mut self, value: T) -> Self where T: std::convert::TryInto, @@ -9440,6 +11214,7 @@ pub mod types { type Error = String; fn try_from(value: Sled) -> Result { Ok(Self { + baseboard: value.baseboard?, id: value.id?, service_address: value.service_address?, time_created: value.time_created?, @@ -9502,6 +11277,7 @@ pub mod types { name: Result, project_id: Result, size: Result, + state: Result, time_created: Result, String>, time_modified: Result, String>, } @@ -9515,6 +11291,7 @@ pub mod types { name: Err("no value supplied for name".to_string()), project_id: Err("no value supplied for project_id".to_string()), size: Err("no value supplied for size".to_string()), + state: Err("no value supplied for state".to_string()), time_created: Err("no value supplied for time_created".to_string()), time_modified: Err("no value supplied for time_modified".to_string()), } @@ -9582,6 +11359,16 @@ pub mod types { .map_err(|e| format!("error converting supplied value for size: {}", e)); self } + pub fn state(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.state = value + .try_into() + .map_err(|e| format!("error converting supplied value for state: {}", e)); + self + } pub fn time_created(mut self, value: T) -> Self where T: std::convert::TryInto>, @@ -9614,6 +11401,7 @@ pub mod types { name: value.name?, project_id: value.project_id?, size: value.size?, + state: value.state?, time_created: value.time_created?, time_modified: value.time_modified?, }) @@ -9980,6 +11768,207 @@ pub mod types { } } + pub struct SystemUpdate { + id: Result, + time_created: Result, String>, + time_modified: Result, String>, + version: Result, + } + + impl Default for SystemUpdate { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + version: Err("no value supplied for version".to_string()), + } + } + } + + impl SystemUpdate { + pub fn id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + pub fn version(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.version = value + .try_into() + .map_err(|e| format!("error converting supplied value for version: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::SystemUpdate { + type Error = String; + fn try_from(value: SystemUpdate) -> Result { + Ok(Self { + id: value.id?, + time_created: value.time_created?, + time_modified: value.time_modified?, + version: value.version?, + }) + } + } + + pub struct SystemUpdateResultsPage { + items: Result, String>, + next_page: Result, String>, + } + + impl Default for SystemUpdateResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl SystemUpdateResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::SystemUpdateResultsPage { + type Error = String; + fn try_from(value: SystemUpdateResultsPage) -> Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + pub struct SystemUpdateStart { + version: Result, + } + + impl Default for SystemUpdateStart { + fn default() -> Self { + Self { + version: Err("no value supplied for version".to_string()), + } + } + } + + impl SystemUpdateStart { + pub fn version(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.version = value + .try_into() + .map_err(|e| format!("error converting supplied value for version: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::SystemUpdateStart { + type Error = String; + fn try_from(value: SystemUpdateStart) -> Result { + Ok(Self { + version: value.version?, + }) + } + } + + pub struct SystemVersion { + status: Result, + version_range: Result, + } + + impl Default for SystemVersion { + fn default() -> Self { + Self { + status: Err("no value supplied for status".to_string()), + version_range: Err("no value supplied for version_range".to_string()), + } + } + } + + impl SystemVersion { + pub fn status(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.status = value + .try_into() + .map_err(|e| format!("error converting supplied value for status: {}", e)); + self + } + pub fn version_range(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.version_range = value.try_into().map_err(|e| { + format!("error converting supplied value for version_range: {}", e) + }); + self + } + } + + impl std::convert::TryFrom for super::SystemVersion { + type Error = String; + fn try_from(value: SystemVersion) -> Result { + Ok(Self { + status: value.status?, + version_range: value.version_range?, + }) + } + } + pub struct TimeseriesSchema { created: Result, String>, datum_type: Result, @@ -10100,9 +12089,317 @@ pub mod types { } } + pub struct UpdateDeployment { + id: Result, + status: Result, + time_created: Result, String>, + time_modified: Result, String>, + version: Result, + } + + impl Default for UpdateDeployment { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + status: Err("no value supplied for status".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + version: Err("no value supplied for version".to_string()), + } + } + } + + impl UpdateDeployment { + pub fn id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn status(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.status = value + .try_into() + .map_err(|e| format!("error converting supplied value for status: {}", e)); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + pub fn version(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.version = value + .try_into() + .map_err(|e| format!("error converting supplied value for version: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::UpdateDeployment { + type Error = String; + fn try_from(value: UpdateDeployment) -> Result { + Ok(Self { + id: value.id?, + status: value.status?, + time_created: value.time_created?, + time_modified: value.time_modified?, + version: value.version?, + }) + } + } + + pub struct UpdateDeploymentResultsPage { + items: Result, String>, + next_page: Result, String>, + } + + impl Default for UpdateDeploymentResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl UpdateDeploymentResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::UpdateDeploymentResultsPage { + type Error = String; + fn try_from(value: UpdateDeploymentResultsPage) -> Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + pub struct UpdateableComponent { + component_type: Result, + device_id: Result, + id: Result, + status: Result, + system_version: Result, + time_created: Result, String>, + time_modified: Result, String>, + version: Result, + } + + impl Default for UpdateableComponent { + fn default() -> Self { + Self { + component_type: Err("no value supplied for component_type".to_string()), + device_id: Err("no value supplied for device_id".to_string()), + id: Err("no value supplied for id".to_string()), + status: Err("no value supplied for status".to_string()), + system_version: Err("no value supplied for system_version".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + version: Err("no value supplied for version".to_string()), + } + } + } + + impl UpdateableComponent { + pub fn component_type(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.component_type = value.try_into().map_err(|e| { + format!("error converting supplied value for component_type: {}", e) + }); + self + } + pub fn device_id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.device_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for device_id: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn status(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.status = value + .try_into() + .map_err(|e| format!("error converting supplied value for status: {}", e)); + self + } + pub fn system_version(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.system_version = value.try_into().map_err(|e| { + format!("error converting supplied value for system_version: {}", e) + }); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + pub fn version(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.version = value + .try_into() + .map_err(|e| format!("error converting supplied value for version: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::UpdateableComponent { + type Error = String; + fn try_from(value: UpdateableComponent) -> Result { + Ok(Self { + component_type: value.component_type?, + device_id: value.device_id?, + id: value.id?, + status: value.status?, + system_version: value.system_version?, + time_created: value.time_created?, + time_modified: value.time_modified?, + version: value.version?, + }) + } + } + + pub struct UpdateableComponentResultsPage { + items: Result, String>, + next_page: Result, String>, + } + + impl Default for UpdateableComponentResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl UpdateableComponentResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl std::convert::TryFrom + for super::UpdateableComponentResultsPage + { + type Error = String; + fn try_from(value: UpdateableComponentResultsPage) -> Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + pub struct User { display_name: Result, id: Result, + silo_id: Result, } impl Default for User { @@ -10110,6 +12407,7 @@ pub mod types { Self { display_name: Err("no value supplied for display_name".to_string()), id: Err("no value supplied for id".to_string()), + silo_id: Err("no value supplied for silo_id".to_string()), } } } @@ -10135,6 +12433,16 @@ pub mod types { .map_err(|e| format!("error converting supplied value for id: {}", e)); self } + pub fn silo_id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.silo_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for silo_id: {}", e)); + self + } } impl std::convert::TryFrom for super::User { @@ -10143,6 +12451,7 @@ pub mod types { Ok(Self { display_name: value.display_name?, id: value.id?, + silo_id: value.silo_id?, }) } } @@ -10280,6 +12589,53 @@ pub mod types { } } + pub struct UserCreate { + external_id: Result, + password: Result, + } + + impl Default for UserCreate { + fn default() -> Self { + Self { + external_id: Err("no value supplied for external_id".to_string()), + password: Err("no value supplied for password".to_string()), + } + } + } + + impl UserCreate { + pub fn external_id(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.external_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for external_id: {}", e)); + self + } + pub fn password(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.password = value + .try_into() + .map_err(|e| format!("error converting supplied value for password: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::UserCreate { + type Error = String; + fn try_from(value: UserCreate) -> Result { + Ok(Self { + external_id: value.external_id?, + password: value.password?, + }) + } + } + pub struct UserResultsPage { items: Result, String>, next_page: Result, String>, @@ -10327,6 +12683,100 @@ pub mod types { } } + pub struct UsernamePasswordCredentials { + password: Result, + username: Result, + } + + impl Default for UsernamePasswordCredentials { + fn default() -> Self { + Self { + password: Err("no value supplied for password".to_string()), + username: Err("no value supplied for username".to_string()), + } + } + } + + impl UsernamePasswordCredentials { + pub fn password(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.password = value + .try_into() + .map_err(|e| format!("error converting supplied value for password: {}", e)); + self + } + pub fn username(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.username = value + .try_into() + .map_err(|e| format!("error converting supplied value for username: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::UsernamePasswordCredentials { + type Error = String; + fn try_from(value: UsernamePasswordCredentials) -> Result { + Ok(Self { + password: value.password?, + username: value.username?, + }) + } + } + + pub struct VersionRange { + high: Result, + low: Result, + } + + impl Default for VersionRange { + fn default() -> Self { + Self { + high: Err("no value supplied for high".to_string()), + low: Err("no value supplied for low".to_string()), + } + } + } + + impl VersionRange { + pub fn high(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.high = value + .try_into() + .map_err(|e| format!("error converting supplied value for high: {}", e)); + self + } + pub fn low(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.low = value + .try_into() + .map_err(|e| format!("error converting supplied value for low: {}", e)); + self + } + } + + impl std::convert::TryFrom for super::VersionRange { + type Error = String; + fn try_from(value: VersionRange) -> Result { + Ok(Self { + high: value.high?, + low: value.low?, + }) + } + } + pub struct Vpc { description: Result, dns_name: Result, @@ -11625,6 +14075,10 @@ pub mod types { } mod defaults { + pub(super) fn default_bool() -> bool { + V + } + pub(super) fn instance_create_network_interfaces( ) -> super::InstanceNetworkInterfaceAttachment { super::InstanceNetworkInterfaceAttachment::Default @@ -11682,7 +14136,9 @@ impl Client { } impl Client { - ///Get a disk by id + ///Fetch a disk by id + /// + ///Use `GET /v1/disks/{disk}` instead /// ///Sends a `GET` request to `/by-id/disks/{id}` /// @@ -11696,20 +14152,6 @@ impl Client { builder::DiskViewById::new(self) } - ///Get a global image by id - /// - ///Sends a `GET` request to `/by-id/global-images/{id}` - /// - ///```ignore - /// let response = client.image_global_view_by_id() - /// .id(id) - /// .send() - /// .await; - /// ``` - pub fn image_global_view_by_id(&self) -> builder::ImageGlobalViewById { - builder::ImageGlobalViewById::new(self) - } - ///Fetch an image by id /// ///Sends a `GET` request to `/by-id/images/{id}` @@ -11724,7 +14166,7 @@ impl Client { builder::ImageViewById::new(self) } - ///Get an instance by id + ///Fetch an instance by id /// ///Sends a `GET` request to `/by-id/instances/{id}` /// @@ -11738,7 +14180,7 @@ impl Client { builder::InstanceViewById::new(self) } - ///Get an instance's network interface by id + ///Fetch a network interface by id /// ///Sends a `GET` request to `/by-id/network-interfaces/{id}` /// @@ -11754,7 +14196,9 @@ impl Client { builder::InstanceNetworkInterfaceViewById::new(self) } - ///Get an organization by id + ///Fetch an organization by id + /// + ///Use `GET /v1/organizations/{organization}` instead /// ///Sends a `GET` request to `/by-id/organizations/{id}` /// @@ -11768,7 +14212,9 @@ impl Client { builder::OrganizationViewById::new(self) } - ///Get a project by id + ///Fetch a project by id + /// + ///Use `GET /v1/projects/{project}` instead /// ///Sends a `GET` request to `/by-id/projects/{id}` /// @@ -11782,7 +14228,7 @@ impl Client { builder::ProjectViewById::new(self) } - ///Get a snapshot by id + ///Fetch a snapshot by id /// ///Sends a `GET` request to `/by-id/snapshots/{id}` /// @@ -11796,7 +14242,7 @@ impl Client { builder::SnapshotViewById::new(self) } - ///Get a vpc router route by id + ///Fetch a route by id /// ///Sends a `GET` request to `/by-id/vpc-router-routes/{id}` /// @@ -11810,7 +14256,7 @@ impl Client { builder::VpcRouterRouteViewById::new(self) } - ///Get a VPC Router by id + ///Get a router by id /// ///Sends a `GET` request to `/by-id/vpc-routers/{id}` /// @@ -11824,7 +14270,7 @@ impl Client { builder::VpcRouterViewById::new(self) } - ///Get a VPC subnet by id + ///Fetch a subnet by id /// ///Sends a `GET` request to `/by-id/vpc-subnets/{id}` /// @@ -11838,7 +14284,7 @@ impl Client { builder::VpcSubnetViewById::new(self) } - ///Get a VPC by id + ///Fetch a VPC /// ///Sends a `GET` request to `/by-id/vpcs/{id}` /// @@ -11906,9 +14352,9 @@ impl Client { builder::DeviceAccessToken::new(self) } - ///List racks in the system + ///List groups /// - ///Sends a `GET` request to `/hardware/racks` + ///Sends a `GET` request to `/groups` /// ///Arguments: /// - `limit`: Maximum number of items returned by a single call @@ -11916,324 +14362,76 @@ impl Client { /// subsequent page /// - `sort_by` ///```ignore - /// let response = client.rack_list() + /// let response = client.group_list() /// .limit(limit) /// .page_token(page_token) /// .sort_by(sort_by) /// .send() /// .await; /// ``` - pub fn rack_list(&self) -> builder::RackList { - builder::RackList::new(self) - } - - ///Fetch information about a particular rack - /// - ///Sends a `GET` request to `/hardware/racks/{rack_id}` - /// - ///Arguments: - /// - `rack_id`: The rack's unique ID. - ///```ignore - /// let response = client.rack_view() - /// .rack_id(rack_id) - /// .send() - /// .await; - /// ``` - pub fn rack_view(&self) -> builder::RackView { - builder::RackView::new(self) - } - - ///List sleds in the system - /// - ///Sends a `GET` request to `/hardware/sleds` - /// - ///Arguments: - /// - `limit`: Maximum number of items returned by a single call - /// - `page_token`: Token returned by previous call to retrieve the - /// subsequent page - /// - `sort_by` - ///```ignore - /// let response = client.sled_list() - /// .limit(limit) - /// .page_token(page_token) - /// .sort_by(sort_by) - /// .send() - /// .await; - /// ``` - pub fn sled_list(&self) -> builder::SledList { - builder::SledList::new(self) - } - - ///Fetch information about a sled in the system - /// - ///Sends a `GET` request to `/hardware/sleds/{sled_id}` - /// - ///Arguments: - /// - `sled_id`: The sled's unique ID. - ///```ignore - /// let response = client.sled_view() - /// .sled_id(sled_id) - /// .send() - /// .await; - /// ``` - pub fn sled_view(&self) -> builder::SledView { - builder::SledView::new(self) - } - - ///List global images - /// - ///Returns a list of all the global images. Global images are returned - /// sorted by creation date, with the most recent images appearing first. - /// - ///Sends a `GET` request to `/images` - /// - ///Arguments: - /// - `limit`: Maximum number of items returned by a single call - /// - `page_token`: Token returned by previous call to retrieve the - /// subsequent page - /// - `sort_by` - ///```ignore - /// let response = client.image_global_list() - /// .limit(limit) - /// .page_token(page_token) - /// .sort_by(sort_by) - /// .send() - /// .await; - /// ``` - pub fn image_global_list(&self) -> builder::ImageGlobalList { - builder::ImageGlobalList::new(self) - } - - ///Create a global image - /// - ///Create a new global image. This image can then be used by any user as a - /// base for instances. - /// - ///Sends a `POST` request to `/images` - /// - ///```ignore - /// let response = client.image_global_create() - /// .body(body) - /// .send() - /// .await; - /// ``` - pub fn image_global_create(&self) -> builder::ImageGlobalCreate { - builder::ImageGlobalCreate::new(self) - } - - ///Get a global image - /// - ///Returns the details of a specific global image. - /// - ///Sends a `GET` request to `/images/{image_name}` - /// - ///```ignore - /// let response = client.image_global_view() - /// .image_name(image_name) - /// .send() - /// .await; - /// ``` - pub fn image_global_view(&self) -> builder::ImageGlobalView { - builder::ImageGlobalView::new(self) - } - - ///Delete a global image - /// - ///Permanently delete a global image. This operation cannot be undone. Any - /// instances using the global image will continue to run, however new - /// instances can not be created with this image. - /// - ///Sends a `DELETE` request to `/images/{image_name}` - /// - ///```ignore - /// let response = client.image_global_delete() - /// .image_name(image_name) - /// .send() - /// .await; - /// ``` - pub fn image_global_delete(&self) -> builder::ImageGlobalDelete { - builder::ImageGlobalDelete::new(self) - } - - ///List IP Pools - /// - ///Sends a `GET` request to `/ip-pools` - /// - ///Arguments: - /// - `limit`: Maximum number of items returned by a single call - /// - `page_token`: Token returned by previous call to retrieve the - /// subsequent page - /// - `sort_by` - ///```ignore - /// let response = client.ip_pool_list() - /// .limit(limit) - /// .page_token(page_token) - /// .sort_by(sort_by) - /// .send() - /// .await; - /// ``` - pub fn ip_pool_list(&self) -> builder::IpPoolList { - builder::IpPoolList::new(self) - } - - ///Create a new IP Pool - /// - ///Sends a `POST` request to `/ip-pools` - /// - ///```ignore - /// let response = client.ip_pool_create() - /// .body(body) - /// .send() - /// .await; - /// ``` - pub fn ip_pool_create(&self) -> builder::IpPoolCreate { - builder::IpPoolCreate::new(self) - } - - ///Fetch a single IP Pool - /// - ///Sends a `GET` request to `/ip-pools/{pool_name}` - /// - ///```ignore - /// let response = client.ip_pool_view() - /// .pool_name(pool_name) - /// .send() - /// .await; - /// ``` - pub fn ip_pool_view(&self) -> builder::IpPoolView { - builder::IpPoolView::new(self) - } - - ///Update an IP Pool - /// - ///Sends a `PUT` request to `/ip-pools/{pool_name}` - /// - ///```ignore - /// let response = client.ip_pool_update() - /// .pool_name(pool_name) - /// .body(body) - /// .send() - /// .await; - /// ``` - pub fn ip_pool_update(&self) -> builder::IpPoolUpdate { - builder::IpPoolUpdate::new(self) - } - - ///Delete an IP Pool - /// - ///Sends a `DELETE` request to `/ip-pools/{pool_name}` - /// - ///```ignore - /// let response = client.ip_pool_delete() - /// .pool_name(pool_name) - /// .send() - /// .await; - /// ``` - pub fn ip_pool_delete(&self) -> builder::IpPoolDelete { - builder::IpPoolDelete::new(self) - } - - ///List the ranges of IP addresses within an existing IP Pool - /// - ///Note that ranges are listed sorted by their first address. - /// - ///Sends a `GET` request to `/ip-pools/{pool_name}/ranges` - /// - ///Arguments: - /// - `pool_name` - /// - `limit`: Maximum number of items returned by a single call - /// - `page_token`: Token returned by previous call to retrieve the - /// subsequent page - ///```ignore - /// let response = client.ip_pool_range_list() - /// .pool_name(pool_name) - /// .limit(limit) - /// .page_token(page_token) - /// .send() - /// .await; - /// ``` - pub fn ip_pool_range_list(&self) -> builder::IpPoolRangeList { - builder::IpPoolRangeList::new(self) - } - - ///Add a new range to an existing IP Pool - /// - ///Sends a `POST` request to `/ip-pools/{pool_name}/ranges/add` - /// - ///```ignore - /// let response = client.ip_pool_range_add() - /// .pool_name(pool_name) - /// .body(body) - /// .send() - /// .await; - /// ``` - pub fn ip_pool_range_add(&self) -> builder::IpPoolRangeAdd { - builder::IpPoolRangeAdd::new(self) - } - - ///Remove a range from an existing IP Pool - /// - ///Sends a `POST` request to `/ip-pools/{pool_name}/ranges/remove` - /// - ///```ignore - /// let response = client.ip_pool_range_remove() - /// .pool_name(pool_name) - /// .body(body) - /// .send() - /// .await; - /// ``` - pub fn ip_pool_range_remove(&self) -> builder::IpPoolRangeRemove { - builder::IpPoolRangeRemove::new(self) + pub fn group_list(&self) -> builder::GroupList { + builder::GroupList::new(self) } ///Sends a `POST` request to `/login` /// ///```ignore - /// let response = client.spoof_login() + /// let response = client.login_spoof() /// .body(body) /// .send() /// .await; /// ``` - pub fn spoof_login(&self) -> builder::SpoofLogin { - builder::SpoofLogin::new(self) + pub fn login_spoof(&self) -> builder::LoginSpoof { + builder::LoginSpoof::new(self) } - ///Ask the user to login to their identity provider + ///Authenticate a user (i.e., log in) via username and password + /// + ///Sends a `POST` request to `/login/{silo_name}/local` + /// + ///```ignore + /// let response = client.login_local() + /// .silo_name(silo_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn login_local(&self) -> builder::LoginLocal { + builder::LoginLocal::new(self) + } + + ///Prompt user login /// ///Either display a page asking a user for their credentials, or redirect /// them to their identity provider. /// - ///Sends a `GET` request to `/login/{silo_name}/{provider_name}` + ///Sends a `GET` request to `/login/{silo_name}/saml/{provider_name}` /// ///```ignore - /// let response = client.login() + /// let response = client.login_saml_begin() /// .silo_name(silo_name) /// .provider_name(provider_name) /// .send() /// .await; /// ``` - pub fn login(&self) -> builder::Login { - builder::Login::new(self) + pub fn login_saml_begin(&self) -> builder::LoginSamlBegin { + builder::LoginSamlBegin::new(self) } - ///Consume some sort of credentials, and authenticate a user + ///Authenticate a user (i.e., log in) via SAML /// - ///Either receive a username and password, or some sort of identity - /// provider data (like a SAMLResponse). Use these to set the user's session - /// cookie. - /// - ///Sends a `POST` request to `/login/{silo_name}/{provider_name}` + ///Sends a `POST` request to `/login/{silo_name}/saml/{provider_name}` /// ///```ignore - /// let response = client.consume_credentials() + /// let response = client.login_saml() /// .silo_name(silo_name) /// .provider_name(provider_name) /// .body(body) /// .send() /// .await; /// ``` - pub fn consume_credentials(&self) -> builder::ConsumeCredentials { - builder::ConsumeCredentials::new(self) + pub fn login_saml(&self) -> builder::LoginSaml { + builder::LoginSaml::new(self) } ///Sends a `POST` request to `/logout` @@ -12247,7 +14445,9 @@ impl Client { builder::Logout::new(self) } - ///List all organizations + ///List organizations + /// + ///Use `GET /v1/organizations` instead /// ///Sends a `GET` request to `/organizations` /// @@ -12268,7 +14468,9 @@ impl Client { builder::OrganizationList::new(self) } - ///Create a new organization + ///Create an organization + /// + ///Use `POST /v1/organizations` instead /// ///Sends a `POST` request to `/organizations` /// @@ -12282,7 +14484,9 @@ impl Client { builder::OrganizationCreate::new(self) } - ///Fetch a specific organization + ///Fetch an organization + /// + ///Use `GET /v1/organizations/{organization}` instead /// ///Sends a `GET` request to `/organizations/{organization_name}` /// @@ -12298,7 +14502,9 @@ impl Client { builder::OrganizationView::new(self) } - ///Update a specific organization + ///Update an organization + /// + ///Use `PUT /v1/organizations/{organization}` instead /// ///Sends a `PUT` request to `/organizations/{organization_name}` /// @@ -12316,7 +14522,9 @@ impl Client { builder::OrganizationUpdate::new(self) } - ///Delete a specific organization + ///Delete an organization + /// + ///Use `DELETE /v1/organizations/{organization}` instead /// ///Sends a `DELETE` request to `/organizations/{organization_name}` /// @@ -12332,7 +14540,9 @@ impl Client { builder::OrganizationDelete::new(self) } - ///Fetch the IAM policy for this Organization + ///Fetch an organization's IAM policy + /// + ///Use `GET /v1/organizations/{organization}/policy` instead /// ///Sends a `GET` request to `/organizations/{organization_name}/policy` /// @@ -12348,7 +14558,9 @@ impl Client { builder::OrganizationPolicyView::new(self) } - ///Update the IAM policy for this Organization + ///Update an organization's IAM policy + /// + ///Use `PUT /v1/organizations/{organization}/policy` instead /// ///Sends a `PUT` request to `/organizations/{organization_name}/policy` /// @@ -12366,7 +14578,9 @@ impl Client { builder::OrganizationPolicyUpdate::new(self) } - ///List all projects + ///List projects + /// + ///Use `GET /v1/projects` instead /// ///Sends a `GET` request to `/organizations/{organization_name}/projects` /// @@ -12389,7 +14603,9 @@ impl Client { builder::ProjectList::new(self) } - ///Create a new project + ///Create a project + /// + ///Use `POST /v1/projects` instead /// ///Sends a `POST` request to `/organizations/{organization_name}/projects` /// @@ -12407,7 +14623,9 @@ impl Client { builder::ProjectCreate::new(self) } - ///Fetch a specific project + ///Fetch a project + /// + ///Use `GET /v1/projects/{project}` instead /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}` @@ -12426,7 +14644,9 @@ impl Client { builder::ProjectView::new(self) } - ///Update a specific project + ///Update a project + /// + ///Use `PUT /v1/projects/{project}` instead /// ///Sends a `PUT` request to /// `/organizations/{organization_name}/projects/{project_name}` @@ -12447,7 +14667,9 @@ impl Client { builder::ProjectUpdate::new(self) } - ///Delete a specific project + ///Delete a project + /// + ///Use `DELETE /v1/projects/{project}` instead /// ///Sends a `DELETE` request to /// `/organizations/{organization_name}/projects/{project_name}` @@ -12466,7 +14688,9 @@ impl Client { builder::ProjectDelete::new(self) } - ///List disks in a project + ///List disks + /// + ///Use `GET /v1/disks` instead /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/disks` @@ -12492,7 +14716,7 @@ impl Client { builder::DiskList::new(self) } - ///Create a disk in a project + ///Use `POST /v1/disks` instead /// ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/disks` @@ -12513,7 +14737,9 @@ impl Client { builder::DiskCreate::new(self) } - ///Get a single disk in a project + ///Fetch a disk + /// + ///Use `GET /v1/disks/{disk}` instead /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/disks/ @@ -12531,7 +14757,7 @@ impl Client { builder::DiskView::new(self) } - ///Delete a disk from a project + ///Use `DELETE /v1/disks/{disk}` instead /// ///Sends a `DELETE` request to /// `/organizations/{organization_name}/projects/{project_name}/disks/ @@ -12549,7 +14775,7 @@ impl Client { builder::DiskDelete::new(self) } - ///Fetch metrics for a disk + ///Fetch disk metrics /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/disks/ @@ -12634,9 +14860,9 @@ impl Client { builder::ImageCreate::new(self) } - ///Get an image + ///Fetch an image /// - ///Get the details of a specific image in a project. + ///Fetch the details for a specific image in a project. /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/images/ @@ -12676,7 +14902,7 @@ impl Client { builder::ImageDelete::new(self) } - ///List instances in a project + ///List instances /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/instances` @@ -12702,7 +14928,9 @@ impl Client { builder::InstanceList::new(self) } - ///Create an instance in a project + ///Create an instance + /// + ///Use `POST /v1/instances` instead /// ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/instances` @@ -12723,7 +14951,9 @@ impl Client { builder::InstanceCreate::new(self) } - ///Get an instance in a project + ///Fetch an instance + /// + ///Use `GET /v1/instances/{instance}` instead /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/instances/ @@ -12741,7 +14971,7 @@ impl Client { builder::InstanceView::new(self) } - ///Delete an instance from a project + ///Delete an instance /// ///Sends a `DELETE` request to /// `/organizations/{organization_name}/projects/{project_name}/instances/ @@ -12759,7 +14989,9 @@ impl Client { builder::InstanceDelete::new(self) } - ///List disks attached to this instance + ///List an instance's disks + /// + ///Use `GET /v1/instances/{instance}/disks` instead /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/instances/ @@ -12788,6 +15020,10 @@ impl Client { builder::InstanceDiskList::new(self) } + ///Attach a disk to an instance + /// + ///Use `POST /v1/instances/{instance}/disks/attach` instead + /// ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/instances/ /// {instance_name}/disks/attach` @@ -12805,6 +15041,10 @@ impl Client { builder::InstanceDiskAttach::new(self) } + ///Detach a disk from an instance + /// + ///Use `POST /v1/disks/{disk}/detach` instead + /// ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/instances/ /// {instance_name}/disks/detach` @@ -12822,7 +15062,7 @@ impl Client { builder::InstanceDiskDetach::new(self) } - ///List external IP addresses associated with an instance + ///List external IP addresses /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/instances/ @@ -12840,8 +15080,9 @@ impl Client { builder::InstanceExternalIpList::new(self) } - ///Migrate an instance to a different propolis-server, possibly on a - /// different sled + ///Migrate an instance + /// + ///Use `POST /v1/instances/{instance}/migrate` instead /// ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/instances/ @@ -12860,7 +15101,7 @@ impl Client { builder::InstanceMigrate::new(self) } - ///List network interfaces attached to this instance + ///List network interfaces /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/instances/ @@ -12889,7 +15130,7 @@ impl Client { builder::InstanceNetworkInterfaceList::new(self) } - ///Create a network interface for an instance + ///Create a network interface /// ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/instances/ @@ -12908,7 +15149,7 @@ impl Client { builder::InstanceNetworkInterfaceCreate::new(self) } - ///Get an interface attached to an instance + ///Fetch a network interface /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/instances/ @@ -12927,7 +15168,7 @@ impl Client { builder::InstanceNetworkInterfaceView::new(self) } - ///Update information about an instance's network interface + ///Update a network interface /// ///Sends a `PUT` request to /// `/organizations/{organization_name}/projects/{project_name}/instances/ @@ -12947,7 +15188,7 @@ impl Client { builder::InstanceNetworkInterfaceUpdate::new(self) } - ///Detach a network interface from an instance + ///Delete a network interface /// ///Note that the primary interface for an instance cannot be deleted if /// there are any secondary interfaces. A new primary interface must be @@ -12973,6 +15214,8 @@ impl Client { ///Reboot an instance /// + ///Use `POST /v1/instances/{instance}/reboot` instead + /// ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/instances/ /// {instance_name}/reboot` @@ -12989,7 +15232,9 @@ impl Client { builder::InstanceReboot::new(self) } - ///Get contents of an instance's serial console + ///Fetch an instance's serial console + /// + ///Use `GET /v1/instances/{instance}/serial-console` instead /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/instances/ @@ -13025,8 +15270,30 @@ impl Client { builder::InstanceSerialConsole::new(self) } + ///Connect to an instance's serial console + /// + ///Use `GET /v1/instances/{instance}/serial-console/stream` instead + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/serial-console/stream` + /// + ///```ignore + /// let response = client.instance_serial_console_stream() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .instance_name(instance_name) + /// .send() + /// .await; + /// ``` + pub fn instance_serial_console_stream(&self) -> builder::InstanceSerialConsoleStream { + builder::InstanceSerialConsoleStream::new(self) + } + ///Boot an instance /// + ///Use `POST /v1/instances/{instance}/start` instead + /// ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/instances/ /// {instance_name}/start` @@ -13045,6 +15312,8 @@ impl Client { ///Halt an instance /// + ///Use `POST /v1/instances/{instance}/stop` instead + /// ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/instances/ /// {instance_name}/stop` @@ -13061,7 +15330,9 @@ impl Client { builder::InstanceStop::new(self) } - ///Fetch the IAM policy for this Project + ///Fetch a project's IAM policy + /// + ///Use `GET /v1/projects/{project}/policy` instead /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/policy` @@ -13080,7 +15351,7 @@ impl Client { builder::ProjectPolicyView::new(self) } - ///Update the IAM policy for this Project + ///Update a project's IAM policy /// ///Sends a `PUT` request to /// `/organizations/{organization_name}/projects/{project_name}/policy` @@ -13101,7 +15372,7 @@ impl Client { builder::ProjectPolicyUpdate::new(self) } - ///List snapshots in a project + ///List snapshots /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/snapshots` @@ -13127,7 +15398,9 @@ impl Client { builder::SnapshotList::new(self) } - ///Create a snapshot of a disk + ///Create a snapshot + /// + ///Creates a point-in-time snapshot from a disk. /// ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/snapshots` @@ -13148,7 +15421,7 @@ impl Client { builder::SnapshotCreate::new(self) } - ///Get a snapshot in a project + ///Fetch a snapshot /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/snapshots/ @@ -13166,7 +15439,7 @@ impl Client { builder::SnapshotView::new(self) } - ///Delete a snapshot from a project + ///Delete a snapshot /// ///Sends a `DELETE` request to /// `/organizations/{organization_name}/projects/{project_name}/snapshots/ @@ -13184,7 +15457,7 @@ impl Client { builder::SnapshotDelete::new(self) } - ///List VPCs in a project + ///List VPCs /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs` @@ -13210,7 +15483,7 @@ impl Client { builder::VpcList::new(self) } - ///Create a VPC in a project + ///Create a VPC /// ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs` @@ -13231,7 +15504,7 @@ impl Client { builder::VpcCreate::new(self) } - ///Get a VPC in a project + ///Fetch a VPC /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -13268,7 +15541,7 @@ impl Client { builder::VpcUpdate::new(self) } - ///Delete a vpc from a project + ///Delete a VPC /// ///Sends a `DELETE` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -13286,7 +15559,7 @@ impl Client { builder::VpcDelete::new(self) } - ///List firewall rules for a VPC + ///List firewall rules /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -13304,7 +15577,7 @@ impl Client { builder::VpcFirewallRulesView::new(self) } - ///Replace the firewall rules for a VPC + ///Replace firewall rules /// ///Sends a `PUT` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -13323,7 +15596,7 @@ impl Client { builder::VpcFirewallRulesUpdate::new(self) } - ///List VPC Custom and System Routers + ///List routers /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -13352,7 +15625,7 @@ impl Client { builder::VpcRouterList::new(self) } - ///Create a VPC Router + ///Create a router /// ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -13371,7 +15644,7 @@ impl Client { builder::VpcRouterCreate::new(self) } - ///Get a VPC Router + ///Get a router /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -13390,7 +15663,7 @@ impl Client { builder::VpcRouterView::new(self) } - ///Update a VPC Router + ///Update a router /// ///Sends a `PUT` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -13410,7 +15683,7 @@ impl Client { builder::VpcRouterUpdate::new(self) } - ///Delete a router from its VPC + ///Delete a router /// ///Sends a `DELETE` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -13429,7 +15702,9 @@ impl Client { builder::VpcRouterDelete::new(self) } - ///List a Router's routes + ///List routes + /// + ///List the routes associated with a router in a particular VPC. /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -13460,7 +15735,7 @@ impl Client { builder::VpcRouterRouteList::new(self) } - ///Create a VPC Router + ///Create a router /// ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -13480,7 +15755,7 @@ impl Client { builder::VpcRouterRouteCreate::new(self) } - ///Get a VPC Router route + ///Fetch a route /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -13500,7 +15775,7 @@ impl Client { builder::VpcRouterRouteView::new(self) } - ///Update a Router route + ///Update a route /// ///Sends a `PUT` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -13521,7 +15796,7 @@ impl Client { builder::VpcRouterRouteUpdate::new(self) } - ///Delete a route from its router + ///Delete a route /// ///Sends a `DELETE` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -13541,7 +15816,7 @@ impl Client { builder::VpcRouterRouteDelete::new(self) } - ///List subnets in a VPC + ///List subnets /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -13570,7 +15845,7 @@ impl Client { builder::VpcSubnetList::new(self) } - ///Create a subnet in a VPC + ///Create a subnet /// ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -13589,7 +15864,7 @@ impl Client { builder::VpcSubnetCreate::new(self) } - ///Get subnet in a VPC + ///Fetch a subnet /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -13608,7 +15883,7 @@ impl Client { builder::VpcSubnetView::new(self) } - ///Update a VPC Subnet + ///Update a subnet /// ///Sends a `PUT` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -13628,7 +15903,7 @@ impl Client { builder::VpcSubnetUpdate::new(self) } - ///Delete a subnet from a VPC + ///Delete a subnet /// ///Sends a `DELETE` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -13647,7 +15922,7 @@ impl Client { builder::VpcSubnetDelete::new(self) } - ///List network interfaces in a VPC subnet + ///List network interfaces /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -13678,7 +15953,7 @@ impl Client { builder::VpcSubnetListNetworkInterfaces::new(self) } - ///Fetch the top-level IAM policy + ///Fetch the current silo's IAM policy /// ///Sends a `GET` request to `/policy` /// @@ -13691,7 +15966,7 @@ impl Client { builder::PolicyView::new(self) } - ///Update the top-level IAM policy + ///Update the current silo's IAM policy /// ///Sends a `PUT` request to `/policy` /// @@ -13705,7 +15980,7 @@ impl Client { builder::PolicyUpdate::new(self) } - ///List the built-in roles + ///List built-in roles /// ///Sends a `GET` request to `/roles` /// @@ -13724,7 +15999,7 @@ impl Client { builder::RoleList::new(self) } - ///Fetch a specific built-in role + ///Fetch a built-in role /// ///Sends a `GET` request to `/roles/{role_name}` /// @@ -13740,41 +16015,6 @@ impl Client { builder::RoleView::new(self) } - ///List all sagas (for debugging) - /// - ///Sends a `GET` request to `/sagas` - /// - ///Arguments: - /// - `limit`: Maximum number of items returned by a single call - /// - `page_token`: Token returned by previous call to retrieve the - /// subsequent page - /// - `sort_by` - ///```ignore - /// let response = client.saga_list() - /// .limit(limit) - /// .page_token(page_token) - /// .sort_by(sort_by) - /// .send() - /// .await; - /// ``` - pub fn saga_list(&self) -> builder::SagaList { - builder::SagaList::new(self) - } - - ///Fetch information about a single saga (for debugging) - /// - ///Sends a `GET` request to `/sagas/{saga_id}` - /// - ///```ignore - /// let response = client.saga_view() - /// .saga_id(saga_id) - /// .send() - /// .await; - /// ``` - pub fn saga_view(&self) -> builder::SagaView { - builder::SagaView::new(self) - } - ///Fetch the user associated with the current session /// ///Sends a `GET` request to `/session/me` @@ -13788,7 +16028,30 @@ impl Client { builder::SessionMe::new(self) } - ///List the current user's SSH public keys + ///Fetch the silo groups the current user belongs to + /// + ///Sends a `GET` request to `/session/me/groups` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.session_me_groups() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn session_me_groups(&self) -> builder::SessionMeGroups { + builder::SessionMeGroups::new(self) + } + + ///List SSH public keys + /// + ///Lists SSH public keys for the currently authenticated user. /// ///Sends a `GET` request to `/session/me/sshkeys` /// @@ -13809,7 +16072,9 @@ impl Client { builder::SessionSshkeyList::new(self) } - ///Create a new SSH public key for the current user + ///Create an SSH public key + /// + ///Create an SSH public key for the currently authenticated user. /// ///Sends a `POST` request to `/session/me/sshkeys` /// @@ -13823,7 +16088,10 @@ impl Client { builder::SessionSshkeyCreate::new(self) } - ///Get (by name) an SSH public key belonging to the current user + ///Fetch an SSH public key + /// + ///Fetch an SSH public key associated with the currently authenticated + /// user. /// ///Sends a `GET` request to `/session/me/sshkeys/{ssh_key_name}` /// @@ -13837,7 +16105,10 @@ impl Client { builder::SessionSshkeyView::new(self) } - ///Delete (by name) an SSH public key belonging to the current user + ///Delete an SSH public key + /// + ///Delete an SSH public key associated with the currently authenticated + /// user. /// ///Sends a `DELETE` request to `/session/me/sshkeys/{ssh_key_name}` /// @@ -13851,7 +16122,603 @@ impl Client { builder::SessionSshkeyDelete::new(self) } - ///Sends a `GET` request to `/silos` + ///Fetch a system-wide image by id + /// + ///Sends a `GET` request to `/system/by-id/images/{id}` + /// + ///```ignore + /// let response = client.system_image_view_by_id() + /// .id(id) + /// .send() + /// .await; + /// ``` + pub fn system_image_view_by_id(&self) -> builder::SystemImageViewById { + builder::SystemImageViewById::new(self) + } + + ///Fetch an IP pool by id + /// + ///Sends a `GET` request to `/system/by-id/ip-pools/{id}` + /// + ///```ignore + /// let response = client.ip_pool_view_by_id() + /// .id(id) + /// .send() + /// .await; + /// ``` + pub fn ip_pool_view_by_id(&self) -> builder::IpPoolViewById { + builder::IpPoolViewById::new(self) + } + + ///Fetch a silo by id + /// + ///Sends a `GET` request to `/system/by-id/silos/{id}` + /// + ///```ignore + /// let response = client.silo_view_by_id() + /// .id(id) + /// .send() + /// .await; + /// ``` + pub fn silo_view_by_id(&self) -> builder::SiloViewById { + builder::SiloViewById::new(self) + } + + ///List system-wide certificates + /// + ///Returns a list of all the system-wide certificates. System-wide + /// certificates are returned sorted by creation date, with the most recent + /// certificates appearing first. + /// + ///Sends a `GET` request to `/system/certificates` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.certificate_list() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn certificate_list(&self) -> builder::CertificateList { + builder::CertificateList::new(self) + } + + ///Create a new system-wide x.509 certificate + /// + ///This certificate is automatically used by the Oxide Control plane to + /// serve external connections. + /// + ///Sends a `POST` request to `/system/certificates` + /// + ///```ignore + /// let response = client.certificate_create() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn certificate_create(&self) -> builder::CertificateCreate { + builder::CertificateCreate::new(self) + } + + ///Fetch a certificate + /// + ///Returns the details of a specific certificate + /// + ///Sends a `GET` request to `/system/certificates/{certificate}` + /// + ///```ignore + /// let response = client.certificate_view() + /// .certificate(certificate) + /// .send() + /// .await; + /// ``` + pub fn certificate_view(&self) -> builder::CertificateView { + builder::CertificateView::new(self) + } + + ///Delete a certificate + /// + ///Permanently delete a certificate. This operation cannot be undone. + /// + ///Sends a `DELETE` request to `/system/certificates/{certificate}` + /// + ///```ignore + /// let response = client.certificate_delete() + /// .certificate(certificate) + /// .send() + /// .await; + /// ``` + pub fn certificate_delete(&self) -> builder::CertificateDelete { + builder::CertificateDelete::new(self) + } + + ///List physical disks + /// + ///Sends a `GET` request to `/system/hardware/disks` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.physical_disk_list() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn physical_disk_list(&self) -> builder::PhysicalDiskList { + builder::PhysicalDiskList::new(self) + } + + ///List racks + /// + ///Sends a `GET` request to `/system/hardware/racks` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.rack_list() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn rack_list(&self) -> builder::RackList { + builder::RackList::new(self) + } + + ///Fetch a rack + /// + ///Sends a `GET` request to `/system/hardware/racks/{rack_id}` + /// + ///Arguments: + /// - `rack_id`: The rack's unique ID. + ///```ignore + /// let response = client.rack_view() + /// .rack_id(rack_id) + /// .send() + /// .await; + /// ``` + pub fn rack_view(&self) -> builder::RackView { + builder::RackView::new(self) + } + + ///List sleds + /// + ///Sends a `GET` request to `/system/hardware/sleds` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.sled_list() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn sled_list(&self) -> builder::SledList { + builder::SledList::new(self) + } + + ///Fetch a sled + /// + ///Sends a `GET` request to `/system/hardware/sleds/{sled_id}` + /// + ///Arguments: + /// - `sled_id`: The sled's unique ID. + ///```ignore + /// let response = client.sled_view() + /// .sled_id(sled_id) + /// .send() + /// .await; + /// ``` + pub fn sled_view(&self) -> builder::SledView { + builder::SledView::new(self) + } + + ///List physical disks attached to sleds + /// + ///Sends a `GET` request to `/system/hardware/sleds/{sled_id}/disks` + /// + ///Arguments: + /// - `sled_id`: The sled's unique ID. + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.sled_physical_disk_list() + /// .sled_id(sled_id) + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn sled_physical_disk_list(&self) -> builder::SledPhysicalDiskList { + builder::SledPhysicalDiskList::new(self) + } + + ///List system-wide images + /// + ///Returns a list of all the system-wide images. System-wide images are + /// returned sorted by creation date, with the most recent images appearing + /// first. + /// + ///Sends a `GET` request to `/system/images` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.system_image_list() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn system_image_list(&self) -> builder::SystemImageList { + builder::SystemImageList::new(self) + } + + ///Create a system-wide image + /// + ///Create a new system-wide image. This image can then be used by any user + /// in any silo as a base for instances. + /// + ///Sends a `POST` request to `/system/images` + /// + ///```ignore + /// let response = client.system_image_create() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn system_image_create(&self) -> builder::SystemImageCreate { + builder::SystemImageCreate::new(self) + } + + ///Fetch a system-wide image + /// + ///Returns the details of a specific system-wide image. + /// + ///Sends a `GET` request to `/system/images/{image_name}` + /// + ///```ignore + /// let response = client.system_image_view() + /// .image_name(image_name) + /// .send() + /// .await; + /// ``` + pub fn system_image_view(&self) -> builder::SystemImageView { + builder::SystemImageView::new(self) + } + + ///Delete a system-wide image + /// + ///Permanently delete a system-wide image. This operation cannot be undone. + /// Any instances using the system-wide image will continue to run, however + /// new instances can not be created with this image. + /// + ///Sends a `DELETE` request to `/system/images/{image_name}` + /// + ///```ignore + /// let response = client.system_image_delete() + /// .image_name(image_name) + /// .send() + /// .await; + /// ``` + pub fn system_image_delete(&self) -> builder::SystemImageDelete { + builder::SystemImageDelete::new(self) + } + + ///List IP pools + /// + ///Sends a `GET` request to `/system/ip-pools` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.ip_pool_list() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn ip_pool_list(&self) -> builder::IpPoolList { + builder::IpPoolList::new(self) + } + + ///Create an IP pool + /// + ///Sends a `POST` request to `/system/ip-pools` + /// + ///```ignore + /// let response = client.ip_pool_create() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn ip_pool_create(&self) -> builder::IpPoolCreate { + builder::IpPoolCreate::new(self) + } + + ///Fetch an IP pool + /// + ///Sends a `GET` request to `/system/ip-pools/{pool_name}` + /// + ///```ignore + /// let response = client.ip_pool_view() + /// .pool_name(pool_name) + /// .send() + /// .await; + /// ``` + pub fn ip_pool_view(&self) -> builder::IpPoolView { + builder::IpPoolView::new(self) + } + + ///Update an IP Pool + /// + ///Sends a `PUT` request to `/system/ip-pools/{pool_name}` + /// + ///```ignore + /// let response = client.ip_pool_update() + /// .pool_name(pool_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn ip_pool_update(&self) -> builder::IpPoolUpdate { + builder::IpPoolUpdate::new(self) + } + + ///Delete an IP Pool + /// + ///Sends a `DELETE` request to `/system/ip-pools/{pool_name}` + /// + ///```ignore + /// let response = client.ip_pool_delete() + /// .pool_name(pool_name) + /// .send() + /// .await; + /// ``` + pub fn ip_pool_delete(&self) -> builder::IpPoolDelete { + builder::IpPoolDelete::new(self) + } + + ///List ranges for an IP pool + /// + ///Ranges are ordered by their first address. + /// + ///Sends a `GET` request to `/system/ip-pools/{pool_name}/ranges` + /// + ///Arguments: + /// - `pool_name` + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + ///```ignore + /// let response = client.ip_pool_range_list() + /// .pool_name(pool_name) + /// .limit(limit) + /// .page_token(page_token) + /// .send() + /// .await; + /// ``` + pub fn ip_pool_range_list(&self) -> builder::IpPoolRangeList { + builder::IpPoolRangeList::new(self) + } + + ///Add a range to an IP pool + /// + ///Sends a `POST` request to `/system/ip-pools/{pool_name}/ranges/add` + /// + ///```ignore + /// let response = client.ip_pool_range_add() + /// .pool_name(pool_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn ip_pool_range_add(&self) -> builder::IpPoolRangeAdd { + builder::IpPoolRangeAdd::new(self) + } + + ///Remove a range from an IP pool + /// + ///Sends a `POST` request to `/system/ip-pools/{pool_name}/ranges/remove` + /// + ///```ignore + /// let response = client.ip_pool_range_remove() + /// .pool_name(pool_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn ip_pool_range_remove(&self) -> builder::IpPoolRangeRemove { + builder::IpPoolRangeRemove::new(self) + } + + ///Fetch the IP pool used for Oxide services + /// + ///Sends a `GET` request to `/system/ip-pools-service` + /// + ///```ignore + /// let response = client.ip_pool_service_view() + /// .send() + /// .await; + /// ``` + pub fn ip_pool_service_view(&self) -> builder::IpPoolServiceView { + builder::IpPoolServiceView::new(self) + } + + ///List ranges for the IP pool used for Oxide services + /// + ///Ranges are ordered by their first address. + /// + ///Sends a `GET` request to `/system/ip-pools-service/ranges` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + ///```ignore + /// let response = client.ip_pool_service_range_list() + /// .limit(limit) + /// .page_token(page_token) + /// .send() + /// .await; + /// ``` + pub fn ip_pool_service_range_list(&self) -> builder::IpPoolServiceRangeList { + builder::IpPoolServiceRangeList::new(self) + } + + ///Add a range to an IP pool used for Oxide services + /// + ///Sends a `POST` request to `/system/ip-pools-service/ranges/add` + /// + ///```ignore + /// let response = client.ip_pool_service_range_add() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn ip_pool_service_range_add(&self) -> builder::IpPoolServiceRangeAdd { + builder::IpPoolServiceRangeAdd::new(self) + } + + ///Remove a range from an IP pool used for Oxide services + /// + ///Sends a `POST` request to `/system/ip-pools-service/ranges/remove` + /// + ///```ignore + /// let response = client.ip_pool_service_range_remove() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn ip_pool_service_range_remove(&self) -> builder::IpPoolServiceRangeRemove { + builder::IpPoolServiceRangeRemove::new(self) + } + + ///Access metrics data + /// + ///Sends a `GET` request to `/system/metrics/{metric_name}` + /// + ///Arguments: + /// - `metric_name` + /// - `end_time`: An exclusive end time of metrics. + /// - `id`: The UUID of the container being queried + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `start_time`: An inclusive start time of metrics. + ///```ignore + /// let response = client.system_metric() + /// .metric_name(metric_name) + /// .end_time(end_time) + /// .id(id) + /// .limit(limit) + /// .page_token(page_token) + /// .start_time(start_time) + /// .send() + /// .await; + /// ``` + pub fn system_metric(&self) -> builder::SystemMetric { + builder::SystemMetric::new(self) + } + + ///Fetch the top-level IAM policy + /// + ///Sends a `GET` request to `/system/policy` + /// + ///```ignore + /// let response = client.system_policy_view() + /// .send() + /// .await; + /// ``` + pub fn system_policy_view(&self) -> builder::SystemPolicyView { + builder::SystemPolicyView::new(self) + } + + ///Update the top-level IAM policy + /// + ///Sends a `PUT` request to `/system/policy` + /// + ///```ignore + /// let response = client.system_policy_update() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn system_policy_update(&self) -> builder::SystemPolicyUpdate { + builder::SystemPolicyUpdate::new(self) + } + + ///List sagas + /// + ///Sends a `GET` request to `/system/sagas` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.saga_list() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn saga_list(&self) -> builder::SagaList { + builder::SagaList::new(self) + } + + ///Fetch a saga + /// + ///Sends a `GET` request to `/system/sagas/{saga_id}` + /// + ///```ignore + /// let response = client.saga_view() + /// .saga_id(saga_id) + /// .send() + /// .await; + /// ``` + pub fn saga_view(&self) -> builder::SagaView { + builder::SagaView::new(self) + } + + ///List silos + /// + ///Lists silos that are discoverable based on the current permissions. + /// + ///Sends a `GET` request to `/system/silos` /// ///Arguments: /// - `limit`: Maximum number of items returned by a single call @@ -13870,9 +16737,9 @@ impl Client { builder::SiloList::new(self) } - ///Create a new silo + ///Create a silo /// - ///Sends a `POST` request to `/silos` + ///Sends a `POST` request to `/system/silos` /// ///```ignore /// let response = client.silo_create() @@ -13884,9 +16751,11 @@ impl Client { builder::SiloCreate::new(self) } - ///Fetch a specific silo + ///Fetch a silo /// - ///Sends a `GET` request to `/silos/{silo_name}` + ///Fetch a silo by name. + /// + ///Sends a `GET` request to `/system/silos/{silo_name}` /// ///Arguments: /// - `silo_name`: The silo's unique name. @@ -13900,9 +16769,11 @@ impl Client { builder::SiloView::new(self) } - ///Delete a specific silo + ///Delete a silo /// - ///Sends a `DELETE` request to `/silos/{silo_name}` + ///Delete a silo by name. + /// + ///Sends a `DELETE` request to `/system/silos/{silo_name}` /// ///Arguments: /// - `silo_name`: The silo's unique name. @@ -13916,9 +16787,9 @@ impl Client { builder::SiloDelete::new(self) } - ///List Silo identity providers + ///List a silo's IDPs /// - ///Sends a `GET` request to `/silos/{silo_name}/identity-providers` + ///Sends a `GET` request to `/system/silos/{silo_name}/identity-providers` /// ///Arguments: /// - `silo_name`: The silo's unique name. @@ -13939,9 +16810,114 @@ impl Client { builder::SiloIdentityProviderList::new(self) } - ///Fetch the IAM policy for this Silo + ///Create a user /// - ///Sends a `GET` request to `/silos/{silo_name}/policy` + ///Users can only be created in Silos with `provision_type` == `Fixed`. + /// Otherwise, Silo users are just-in-time (JIT) provisioned when a user + /// first logs in using an external Identity Provider. + /// + ///Sends a `POST` request to + /// `/system/silos/{silo_name}/identity-providers/local/users` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + /// - `body` + ///```ignore + /// let response = client.local_idp_user_create() + /// .silo_name(silo_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn local_idp_user_create(&self) -> builder::LocalIdpUserCreate { + builder::LocalIdpUserCreate::new(self) + } + + ///Delete a user + /// + ///Sends a `DELETE` request to + /// `/system/silos/{silo_name}/identity-providers/local/users/{user_id}` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + /// - `user_id`: The user's internal id + ///```ignore + /// let response = client.local_idp_user_delete() + /// .silo_name(silo_name) + /// .user_id(user_id) + /// .send() + /// .await; + /// ``` + pub fn local_idp_user_delete(&self) -> builder::LocalIdpUserDelete { + builder::LocalIdpUserDelete::new(self) + } + + ///Set or invalidate a user's password + /// + ///Passwords can only be updated for users in Silos with identity mode + /// `LocalOnly`. + /// + ///Sends a `POST` request to + /// `/system/silos/{silo_name}/identity-providers/local/users/{user_id}/ + /// set-password` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + /// - `user_id`: The user's internal id + /// - `body` + ///```ignore + /// let response = client.local_idp_user_set_password() + /// .silo_name(silo_name) + /// .user_id(user_id) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn local_idp_user_set_password(&self) -> builder::LocalIdpUserSetPassword { + builder::LocalIdpUserSetPassword::new(self) + } + + ///Create a SAML IDP + /// + ///Sends a `POST` request to + /// `/system/silos/{silo_name}/identity-providers/saml` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + /// - `body` + ///```ignore + /// let response = client.saml_identity_provider_create() + /// .silo_name(silo_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn saml_identity_provider_create(&self) -> builder::SamlIdentityProviderCreate { + builder::SamlIdentityProviderCreate::new(self) + } + + ///Fetch a SAML IDP + /// + ///Sends a `GET` request to + /// `/system/silos/{silo_name}/identity-providers/saml/{provider_name}` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + /// - `provider_name`: The SAML identity provider's name + ///```ignore + /// let response = client.saml_identity_provider_view() + /// .silo_name(silo_name) + /// .provider_name(provider_name) + /// .send() + /// .await; + /// ``` + pub fn saml_identity_provider_view(&self) -> builder::SamlIdentityProviderView { + builder::SamlIdentityProviderView::new(self) + } + + ///Fetch a silo's IAM policy + /// + ///Sends a `GET` request to `/system/silos/{silo_name}/policy` /// ///Arguments: /// - `silo_name`: The silo's unique name. @@ -13955,9 +16931,9 @@ impl Client { builder::SiloPolicyView::new(self) } - ///Update the IAM policy for this Silo + ///Update a silo's IAM policy /// - ///Sends a `PUT` request to `/silos/{silo_name}/policy` + ///Sends a `PUT` request to `/system/silos/{silo_name}/policy` /// ///Arguments: /// - `silo_name`: The silo's unique name. @@ -13973,44 +16949,48 @@ impl Client { builder::SiloPolicyUpdate::new(self) } - ///Create a new SAML identity provider for a silo + ///List users in a silo /// - ///Sends a `POST` request to `/silos/{silo_name}/saml-identity-providers` + ///Sends a `GET` request to `/system/silos/{silo_name}/users/all` /// ///Arguments: /// - `silo_name`: The silo's unique name. - /// - `body` + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` ///```ignore - /// let response = client.silo_identity_provider_create() + /// let response = client.silo_users_list() /// .silo_name(silo_name) - /// .body(body) + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) /// .send() /// .await; /// ``` - pub fn silo_identity_provider_create(&self) -> builder::SiloIdentityProviderCreate { - builder::SiloIdentityProviderCreate::new(self) + pub fn silo_users_list(&self) -> builder::SiloUsersList { + builder::SiloUsersList::new(self) } - ///GET a silo's SAML identity provider + ///Fetch a user /// - ///Sends a `GET` request to - /// `/silos/{silo_name}/saml-identity-providers/{provider_name}` + ///Sends a `GET` request to `/system/silos/{silo_name}/users/id/{user_id}` /// ///Arguments: /// - `silo_name`: The silo's unique name. - /// - `provider_name`: The SAML identity provider's name + /// - `user_id`: The user's internal id ///```ignore - /// let response = client.silo_identity_provider_view() + /// let response = client.silo_user_view() /// .silo_name(silo_name) - /// .provider_name(provider_name) + /// .user_id(user_id) /// .send() /// .await; /// ``` - pub fn silo_identity_provider_view(&self) -> builder::SiloIdentityProviderView { - builder::SiloIdentityProviderView::new(self) + pub fn silo_user_view(&self) -> builder::SiloUserView { + builder::SiloUserView::new(self) } - ///List the built-in system users + ///List built-in users /// ///Sends a `GET` request to `/system/user` /// @@ -14031,7 +17011,7 @@ impl Client { builder::SystemUserList::new(self) } - ///Fetch a specific built-in system user + ///Fetch a built-in user /// ///Sends a `GET` request to `/system/user/{user_name}` /// @@ -14047,7 +17027,7 @@ impl Client { builder::SystemUserView::new(self) } - ///List all timeseries schema + ///List timeseries schema /// ///Sends a `GET` request to `/timeseries/schema` /// @@ -14066,19 +17046,6 @@ impl Client { builder::TimeseriesSchemaGet::new(self) } - ///Refresh update metadata - /// - ///Sends a `POST` request to `/updates/refresh` - /// - ///```ignore - /// let response = client.updates_refresh() - /// .send() - /// .await; - /// ``` - pub fn updates_refresh(&self) -> builder::UpdatesRefresh { - builder::UpdatesRefresh::new(self) - } - ///List users /// ///Sends a `GET` request to `/users` @@ -14099,6 +17066,712 @@ impl Client { pub fn user_list(&self) -> builder::UserList { builder::UserList::new(self) } + + ///List disks + /// + ///Sends a `GET` request to `/v1/disks` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `organization` + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `project` + /// - `sort_by` + ///```ignore + /// let response = client.disk_list_v1() + /// .limit(limit) + /// .organization(organization) + /// .page_token(page_token) + /// .project(project) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn disk_list_v1(&self) -> builder::DiskListV1 { + builder::DiskListV1::new(self) + } + + ///Create a disk + /// + ///Sends a `POST` request to `/v1/disks` + /// + ///```ignore + /// let response = client.disk_create_v1() + /// .organization(organization) + /// .project(project) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn disk_create_v1(&self) -> builder::DiskCreateV1 { + builder::DiskCreateV1::new(self) + } + + ///Fetch a disk + /// + ///Sends a `GET` request to `/v1/disks/{disk}` + /// + ///```ignore + /// let response = client.disk_view_v1() + /// .disk(disk) + /// .organization(organization) + /// .project(project) + /// .send() + /// .await; + /// ``` + pub fn disk_view_v1(&self) -> builder::DiskViewV1 { + builder::DiskViewV1::new(self) + } + + ///Delete a disk + /// + ///Sends a `DELETE` request to `/v1/disks/{disk}` + /// + ///```ignore + /// let response = client.disk_delete_v1() + /// .disk(disk) + /// .organization(organization) + /// .project(project) + /// .send() + /// .await; + /// ``` + pub fn disk_delete_v1(&self) -> builder::DiskDeleteV1 { + builder::DiskDeleteV1::new(self) + } + + ///List instances + /// + ///Sends a `GET` request to `/v1/instances` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `organization` + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `project` + /// - `sort_by` + ///```ignore + /// let response = client.instance_list_v1() + /// .limit(limit) + /// .organization(organization) + /// .page_token(page_token) + /// .project(project) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn instance_list_v1(&self) -> builder::InstanceListV1 { + builder::InstanceListV1::new(self) + } + + ///Create an instance + /// + ///Sends a `POST` request to `/v1/instances` + /// + ///```ignore + /// let response = client.instance_create_v1() + /// .organization(organization) + /// .project(project) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn instance_create_v1(&self) -> builder::InstanceCreateV1 { + builder::InstanceCreateV1::new(self) + } + + ///Fetch an instance + /// + ///Sends a `GET` request to `/v1/instances/{instance}` + /// + ///```ignore + /// let response = client.instance_view_v1() + /// .instance(instance) + /// .organization(organization) + /// .project(project) + /// .send() + /// .await; + /// ``` + pub fn instance_view_v1(&self) -> builder::InstanceViewV1 { + builder::InstanceViewV1::new(self) + } + + ///Delete an instance + /// + ///Sends a `DELETE` request to `/v1/instances/{instance}` + /// + ///```ignore + /// let response = client.instance_delete_v1() + /// .instance(instance) + /// .organization(organization) + /// .project(project) + /// .send() + /// .await; + /// ``` + pub fn instance_delete_v1(&self) -> builder::InstanceDeleteV1 { + builder::InstanceDeleteV1::new(self) + } + + ///List an instance's disks + /// + ///Sends a `GET` request to `/v1/instances/{instance}/disks` + /// + ///Arguments: + /// - `instance` + /// - `limit`: Maximum number of items returned by a single call + /// - `organization` + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `project` + /// - `sort_by` + ///```ignore + /// let response = client.instance_disk_list_v1() + /// .instance(instance) + /// .limit(limit) + /// .organization(organization) + /// .page_token(page_token) + /// .project(project) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn instance_disk_list_v1(&self) -> builder::InstanceDiskListV1 { + builder::InstanceDiskListV1::new(self) + } + + ///Attach a disk to an instance + /// + ///Sends a `POST` request to `/v1/instances/{instance}/disks/attach` + /// + ///```ignore + /// let response = client.instance_disk_attach_v1() + /// .instance(instance) + /// .organization(organization) + /// .project(project) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn instance_disk_attach_v1(&self) -> builder::InstanceDiskAttachV1 { + builder::InstanceDiskAttachV1::new(self) + } + + ///Detach a disk from an instance + /// + ///Sends a `POST` request to `/v1/instances/{instance}/disks/detach` + /// + ///```ignore + /// let response = client.instance_disk_detach_v1() + /// .instance(instance) + /// .organization(organization) + /// .project(project) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn instance_disk_detach_v1(&self) -> builder::InstanceDiskDetachV1 { + builder::InstanceDiskDetachV1::new(self) + } + + ///Migrate an instance + /// + ///Sends a `POST` request to `/v1/instances/{instance}/migrate` + /// + ///```ignore + /// let response = client.instance_migrate_v1() + /// .instance(instance) + /// .organization(organization) + /// .project(project) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn instance_migrate_v1(&self) -> builder::InstanceMigrateV1 { + builder::InstanceMigrateV1::new(self) + } + + ///Reboot an instance + /// + ///Sends a `POST` request to `/v1/instances/{instance}/reboot` + /// + ///```ignore + /// let response = client.instance_reboot_v1() + /// .instance(instance) + /// .organization(organization) + /// .project(project) + /// .send() + /// .await; + /// ``` + pub fn instance_reboot_v1(&self) -> builder::InstanceRebootV1 { + builder::InstanceRebootV1::new(self) + } + + ///Fetch an instance's serial console + /// + ///Sends a `GET` request to `/v1/instances/{instance}/serial-console` + /// + ///Arguments: + /// - `instance` + /// - `from_start`: Character index in the serial buffer from which to read, + /// counting the bytes output since instance start. If this is not + /// provided, `most_recent` must be provided, and if this *is* provided, + /// `most_recent` must *not* be provided. + /// - `max_bytes`: Maximum number of bytes of buffered serial console + /// contents to return. If the requested range runs to the end of the + /// available buffer, the data returned will be shorter than `max_bytes`. + /// - `most_recent`: Character index in the serial buffer from which to + /// read, counting *backward* from the most recently buffered data + /// retrieved from the instance. (See note on `from_start` about mutual + /// exclusivity) + /// - `organization` + /// - `project` + ///```ignore + /// let response = client.instance_serial_console_v1() + /// .instance(instance) + /// .from_start(from_start) + /// .max_bytes(max_bytes) + /// .most_recent(most_recent) + /// .organization(organization) + /// .project(project) + /// .send() + /// .await; + /// ``` + pub fn instance_serial_console_v1(&self) -> builder::InstanceSerialConsoleV1 { + builder::InstanceSerialConsoleV1::new(self) + } + + ///Stream an instance's serial console + /// + ///Sends a `GET` request to + /// `/v1/instances/{instance}/serial-console/stream` + /// + ///```ignore + /// let response = client.instance_serial_console_stream_v1() + /// .instance(instance) + /// .organization(organization) + /// .project(project) + /// .send() + /// .await; + /// ``` + pub fn instance_serial_console_stream_v1(&self) -> builder::InstanceSerialConsoleStreamV1 { + builder::InstanceSerialConsoleStreamV1::new(self) + } + + ///Boot an instance + /// + ///Sends a `POST` request to `/v1/instances/{instance}/start` + /// + ///```ignore + /// let response = client.instance_start_v1() + /// .instance(instance) + /// .organization(organization) + /// .project(project) + /// .send() + /// .await; + /// ``` + pub fn instance_start_v1(&self) -> builder::InstanceStartV1 { + builder::InstanceStartV1::new(self) + } + + ///Stop an instance + /// + ///Sends a `POST` request to `/v1/instances/{instance}/stop` + /// + ///```ignore + /// let response = client.instance_stop_v1() + /// .instance(instance) + /// .organization(organization) + /// .project(project) + /// .send() + /// .await; + /// ``` + pub fn instance_stop_v1(&self) -> builder::InstanceStopV1 { + builder::InstanceStopV1::new(self) + } + + ///List organizations + /// + ///Sends a `GET` request to `/v1/organizations` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.organization_list_v1() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn organization_list_v1(&self) -> builder::OrganizationListV1 { + builder::OrganizationListV1::new(self) + } + + ///Create an organization + /// + ///Sends a `POST` request to `/v1/organizations` + /// + ///```ignore + /// let response = client.organization_create_v1() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn organization_create_v1(&self) -> builder::OrganizationCreateV1 { + builder::OrganizationCreateV1::new(self) + } + + ///Fetch an organization + /// + ///Sends a `GET` request to `/v1/organizations/{organization}` + /// + ///```ignore + /// let response = client.organization_view_v1() + /// .organization(organization) + /// .send() + /// .await; + /// ``` + pub fn organization_view_v1(&self) -> builder::OrganizationViewV1 { + builder::OrganizationViewV1::new(self) + } + + ///Update an organization + /// + ///Sends a `PUT` request to `/v1/organizations/{organization}` + /// + ///```ignore + /// let response = client.organization_update_v1() + /// .organization(organization) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn organization_update_v1(&self) -> builder::OrganizationUpdateV1 { + builder::OrganizationUpdateV1::new(self) + } + + ///Delete an organization + /// + ///Sends a `DELETE` request to `/v1/organizations/{organization}` + /// + ///```ignore + /// let response = client.organization_delete_v1() + /// .organization(organization) + /// .send() + /// .await; + /// ``` + pub fn organization_delete_v1(&self) -> builder::OrganizationDeleteV1 { + builder::OrganizationDeleteV1::new(self) + } + + ///Fetch an organization's IAM policy + /// + ///Sends a `GET` request to `/v1/organizations/{organization}/policy` + /// + ///```ignore + /// let response = client.organization_policy_view_v1() + /// .organization(organization) + /// .send() + /// .await; + /// ``` + pub fn organization_policy_view_v1(&self) -> builder::OrganizationPolicyViewV1 { + builder::OrganizationPolicyViewV1::new(self) + } + + ///Update an organization's IAM policy + /// + ///Sends a `PUT` request to `/v1/organizations/{organization}/policy` + /// + ///```ignore + /// let response = client.organization_policy_update_v1() + /// .organization(organization) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn organization_policy_update_v1(&self) -> builder::OrganizationPolicyUpdateV1 { + builder::OrganizationPolicyUpdateV1::new(self) + } + + ///List projects + /// + ///Sends a `GET` request to `/v1/projects` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `organization` + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.project_list_v1() + /// .limit(limit) + /// .organization(organization) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn project_list_v1(&self) -> builder::ProjectListV1 { + builder::ProjectListV1::new(self) + } + + ///Create a project + /// + ///Sends a `POST` request to `/v1/projects` + /// + ///```ignore + /// let response = client.project_create_v1() + /// .organization(organization) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn project_create_v1(&self) -> builder::ProjectCreateV1 { + builder::ProjectCreateV1::new(self) + } + + ///Fetch a project + /// + ///Sends a `GET` request to `/v1/projects/{project}` + /// + ///```ignore + /// let response = client.project_view_v1() + /// .project(project) + /// .organization(organization) + /// .send() + /// .await; + /// ``` + pub fn project_view_v1(&self) -> builder::ProjectViewV1 { + builder::ProjectViewV1::new(self) + } + + ///Update a project + /// + ///Sends a `PUT` request to `/v1/projects/{project}` + /// + ///```ignore + /// let response = client.project_update_v1() + /// .project(project) + /// .organization(organization) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn project_update_v1(&self) -> builder::ProjectUpdateV1 { + builder::ProjectUpdateV1::new(self) + } + + ///Delete a project + /// + ///Sends a `DELETE` request to `/v1/projects/{project}` + /// + ///```ignore + /// let response = client.project_delete_v1() + /// .project(project) + /// .organization(organization) + /// .send() + /// .await; + /// ``` + pub fn project_delete_v1(&self) -> builder::ProjectDeleteV1 { + builder::ProjectDeleteV1::new(self) + } + + ///Fetch a project's IAM policy + /// + ///Sends a `GET` request to `/v1/projects/{project}/policy` + /// + ///```ignore + /// let response = client.project_policy_view_v1() + /// .project(project) + /// .organization(organization) + /// .send() + /// .await; + /// ``` + pub fn project_policy_view_v1(&self) -> builder::ProjectPolicyViewV1 { + builder::ProjectPolicyViewV1::new(self) + } + + ///Update a project's IAM policy + /// + ///Sends a `PUT` request to `/v1/projects/{project}/policy` + /// + ///```ignore + /// let response = client.project_policy_update_v1() + /// .project(project) + /// .organization(organization) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn project_policy_update_v1(&self) -> builder::ProjectPolicyUpdateV1 { + builder::ProjectPolicyUpdateV1::new(self) + } + + ///View version and update status of component tree + /// + ///Sends a `GET` request to `/v1/system/update/components` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.system_component_version_list() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn system_component_version_list(&self) -> builder::SystemComponentVersionList { + builder::SystemComponentVersionList::new(self) + } + + ///List all update deployments + /// + ///Sends a `GET` request to `/v1/system/update/deployments` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.update_deployments_list() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn update_deployments_list(&self) -> builder::UpdateDeploymentsList { + builder::UpdateDeploymentsList::new(self) + } + + ///Fetch a system update deployment + /// + ///Sends a `GET` request to `/v1/system/update/deployments/{id}` + /// + ///```ignore + /// let response = client.update_deployment_view() + /// .id(id) + /// .send() + /// .await; + /// ``` + pub fn update_deployment_view(&self) -> builder::UpdateDeploymentView { + builder::UpdateDeploymentView::new(self) + } + + ///Refresh update data + /// + ///Sends a `POST` request to `/v1/system/update/refresh` + /// + ///```ignore + /// let response = client.system_update_refresh() + /// .send() + /// .await; + /// ``` + pub fn system_update_refresh(&self) -> builder::SystemUpdateRefresh { + builder::SystemUpdateRefresh::new(self) + } + + ///Start system update + /// + ///Sends a `POST` request to `/v1/system/update/start` + /// + ///```ignore + /// let response = client.system_update_start() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn system_update_start(&self) -> builder::SystemUpdateStart { + builder::SystemUpdateStart::new(self) + } + + ///Stop system update + /// + ///If there is no update in progress, do nothing. + /// + ///Sends a `POST` request to `/v1/system/update/stop` + /// + ///```ignore + /// let response = client.system_update_stop() + /// .send() + /// .await; + /// ``` + pub fn system_update_stop(&self) -> builder::SystemUpdateStop { + builder::SystemUpdateStop::new(self) + } + + ///List all updates + /// + ///Sends a `GET` request to `/v1/system/update/updates` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.system_update_list() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn system_update_list(&self) -> builder::SystemUpdateList { + builder::SystemUpdateList::new(self) + } + + ///View system update + /// + ///Sends a `GET` request to `/v1/system/update/updates/{version}` + /// + ///```ignore + /// let response = client.system_update_view() + /// .version(version) + /// .send() + /// .await; + /// ``` + pub fn system_update_view(&self) -> builder::SystemUpdateView { + builder::SystemUpdateView::new(self) + } + + ///View system update component tree + /// + ///Sends a `GET` request to + /// `/v1/system/update/updates/{version}/components` + /// + ///```ignore + /// let response = client.system_update_components_list() + /// .version(version) + /// .send() + /// .await; + /// ``` + pub fn system_update_components_list(&self) -> builder::SystemUpdateComponentsList { + builder::SystemUpdateComponentsList::new(self) + } + + ///View system version and update status + /// + ///Sends a `GET` request to `/v1/system/update/version` + /// + ///```ignore + /// let response = client.system_version() + /// .send() + /// .await; + /// ``` + pub fn system_version(&self) -> builder::SystemVersion { + builder::SystemVersion::new(self) + } } pub mod builder { @@ -14159,58 +17832,6 @@ pub mod builder { } } - ///Builder for [`Client::image_global_view_by_id`] - /// - ///[`Client::image_global_view_by_id`]: super::Client::image_global_view_by_id - #[derive(Debug, Clone)] - pub struct ImageGlobalViewById<'a> { - client: &'a super::Client, - id: Result, - } - - impl<'a> ImageGlobalViewById<'a> { - pub fn new(client: &'a super::Client) -> Self { - Self { - client, - id: Err("id was not initialized".to_string()), - } - } - - pub fn id(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.id = value - .try_into() - .map_err(|_| "conversion to `uuid :: Uuid` for id failed".to_string()); - self - } - - ///Sends a `GET` request to `/by-id/global-images/{id}` - pub async fn send(self) -> Result, Error> { - let Self { client, id } = self; - let id = id.map_err(Error::InvalidRequest)?; - let url = format!( - "{}/by-id/global-images/{}", - client.baseurl, - encode_path(&id.to_string()), - ); - let request = client.client.get(url).build()?; - let result = client.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 200u16 => ResponseValue::from_response(response).await, - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - } - ///Builder for [`Client::image_view_by_id`] /// ///[`Client::image_view_by_id`]: super::Client::image_view_by_id @@ -14865,18 +18486,18 @@ pub mod builder { } } - ///Builder for [`Client::rack_list`] + ///Builder for [`Client::group_list`] /// - ///[`Client::rack_list`]: super::Client::rack_list + ///[`Client::group_list`]: super::Client::group_list #[derive(Debug, Clone)] - pub struct RackList<'a> { + pub struct GroupList<'a> { client: &'a super::Client, limit: Result, String>, page_token: Result, String>, sort_by: Result, String>, } - impl<'a> RackList<'a> { + impl<'a> GroupList<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client, @@ -14917,10 +18538,10 @@ pub mod builder { self } - ///Sends a `GET` request to `/hardware/racks` + ///Sends a `GET` request to `/groups` pub async fn send( self, - ) -> Result, Error> { + ) -> Result, Error> { let Self { client, limit, @@ -14930,7 +18551,7 @@ pub mod builder { let limit = limit.map_err(Error::InvalidRequest)?; let page_token = page_token.map_err(Error::InvalidRequest)?; let sort_by = sort_by.map_err(Error::InvalidRequest)?; - let url = format!("{}/hardware/racks", client.baseurl,); + let url = format!("{}/groups", client.baseurl,); let mut query = Vec::with_capacity(3usize); if let Some(v) = &limit { query.push(("limit", v.to_string())); @@ -14956,10 +18577,10 @@ pub mod builder { } } - ///Streams `GET` requests to `/hardware/racks` + ///Streams `GET` requests to `/groups` pub fn stream( self, - ) -> impl futures::Stream>> + Unpin + 'a + ) -> impl futures::Stream>> + Unpin + 'a { use futures::StreamExt; use futures::TryFutureExt; @@ -15004,1187 +18625,16 @@ pub mod builder { } } - ///Builder for [`Client::rack_view`] + ///Builder for [`Client::login_spoof`] /// - ///[`Client::rack_view`]: super::Client::rack_view + ///[`Client::login_spoof`]: super::Client::login_spoof #[derive(Debug, Clone)] - pub struct RackView<'a> { - client: &'a super::Client, - rack_id: Result, - } - - impl<'a> RackView<'a> { - pub fn new(client: &'a super::Client) -> Self { - Self { - client, - rack_id: Err("rack_id was not initialized".to_string()), - } - } - - pub fn rack_id(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.rack_id = value - .try_into() - .map_err(|_| "conversion to `uuid :: Uuid` for rack_id failed".to_string()); - self - } - - ///Sends a `GET` request to `/hardware/racks/{rack_id}` - pub async fn send(self) -> Result, Error> { - let Self { client, rack_id } = self; - let rack_id = rack_id.map_err(Error::InvalidRequest)?; - let url = format!( - "{}/hardware/racks/{}", - client.baseurl, - encode_path(&rack_id.to_string()), - ); - let request = client.client.get(url).build()?; - let result = client.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 200u16 => ResponseValue::from_response(response).await, - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - } - - ///Builder for [`Client::sled_list`] - /// - ///[`Client::sled_list`]: super::Client::sled_list - #[derive(Debug, Clone)] - pub struct SledList<'a> { - client: &'a super::Client, - limit: Result, String>, - page_token: Result, String>, - sort_by: Result, String>, - } - - impl<'a> SledList<'a> { - pub fn new(client: &'a super::Client) -> Self { - Self { - client, - limit: Ok(None), - page_token: Ok(None), - sort_by: Ok(None), - } - } - - pub fn limit(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.limit = value.try_into().map(Some).map_err(|_| { - "conversion to `Option < std :: num :: NonZeroU32 >` for limit failed".to_string() - }); - self - } - - pub fn page_token(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.page_token = value - .try_into() - .map(Some) - .map_err(|_| "conversion to `Option < String >` for page_token failed".to_string()); - self - } - - pub fn sort_by(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.sort_by = value.try_into().map(Some).map_err(|_| { - "conversion to `Option < IdSortMode >` for sort_by failed".to_string() - }); - self - } - - ///Sends a `GET` request to `/hardware/sleds` - pub async fn send( - self, - ) -> Result, Error> { - let Self { - client, - limit, - page_token, - sort_by, - } = self; - let limit = limit.map_err(Error::InvalidRequest)?; - let page_token = page_token.map_err(Error::InvalidRequest)?; - let sort_by = sort_by.map_err(Error::InvalidRequest)?; - let url = format!("{}/hardware/sleds", client.baseurl,); - let mut query = Vec::with_capacity(3usize); - if let Some(v) = &limit { - query.push(("limit", v.to_string())); - } - if let Some(v) = &page_token { - query.push(("page_token", v.to_string())); - } - if let Some(v) = &sort_by { - query.push(("sort_by", v.to_string())); - } - let request = client.client.get(url).query(&query).build()?; - let result = client.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 200u16 => ResponseValue::from_response(response).await, - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - - ///Streams `GET` requests to `/hardware/sleds` - pub fn stream( - self, - ) -> impl futures::Stream>> + Unpin + 'a - { - use futures::StreamExt; - use futures::TryFutureExt; - use futures::TryStreamExt; - let next = Self { - limit: Ok(None), - page_token: Ok(None), - sort_by: Ok(None), - ..self.clone() - }; - self.send() - .map_ok(move |page| { - let page = page.into_inner(); - let first = futures::stream::iter(page.items.into_iter().map(Ok)); - let rest = futures::stream::try_unfold( - (page.next_page, next), - |(next_page, next)| async { - if next_page.is_none() { - Ok(None) - } else { - Self { - page_token: Ok(next_page), - ..next.clone() - } - .send() - .map_ok(|page| { - let page = page.into_inner(); - Some(( - futures::stream::iter(page.items.into_iter().map(Ok)), - (page.next_page, next), - )) - }) - .await - } - }, - ) - .try_flatten(); - first.chain(rest) - }) - .try_flatten_stream() - .boxed() - } - } - - ///Builder for [`Client::sled_view`] - /// - ///[`Client::sled_view`]: super::Client::sled_view - #[derive(Debug, Clone)] - pub struct SledView<'a> { - client: &'a super::Client, - sled_id: Result, - } - - impl<'a> SledView<'a> { - pub fn new(client: &'a super::Client) -> Self { - Self { - client, - sled_id: Err("sled_id was not initialized".to_string()), - } - } - - pub fn sled_id(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.sled_id = value - .try_into() - .map_err(|_| "conversion to `uuid :: Uuid` for sled_id failed".to_string()); - self - } - - ///Sends a `GET` request to `/hardware/sleds/{sled_id}` - pub async fn send(self) -> Result, Error> { - let Self { client, sled_id } = self; - let sled_id = sled_id.map_err(Error::InvalidRequest)?; - let url = format!( - "{}/hardware/sleds/{}", - client.baseurl, - encode_path(&sled_id.to_string()), - ); - let request = client.client.get(url).build()?; - let result = client.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 200u16 => ResponseValue::from_response(response).await, - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - } - - ///Builder for [`Client::image_global_list`] - /// - ///[`Client::image_global_list`]: super::Client::image_global_list - #[derive(Debug, Clone)] - pub struct ImageGlobalList<'a> { - client: &'a super::Client, - limit: Result, String>, - page_token: Result, String>, - sort_by: Result, String>, - } - - impl<'a> ImageGlobalList<'a> { - pub fn new(client: &'a super::Client) -> Self { - Self { - client, - limit: Ok(None), - page_token: Ok(None), - sort_by: Ok(None), - } - } - - pub fn limit(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.limit = value.try_into().map(Some).map_err(|_| { - "conversion to `Option < std :: num :: NonZeroU32 >` for limit failed".to_string() - }); - self - } - - pub fn page_token(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.page_token = value - .try_into() - .map(Some) - .map_err(|_| "conversion to `Option < String >` for page_token failed".to_string()); - self - } - - pub fn sort_by(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.sort_by = value.try_into().map(Some).map_err(|_| { - "conversion to `Option < NameSortMode >` for sort_by failed".to_string() - }); - self - } - - ///Sends a `GET` request to `/images` - pub async fn send( - self, - ) -> Result, Error> { - let Self { - client, - limit, - page_token, - sort_by, - } = self; - let limit = limit.map_err(Error::InvalidRequest)?; - let page_token = page_token.map_err(Error::InvalidRequest)?; - let sort_by = sort_by.map_err(Error::InvalidRequest)?; - let url = format!("{}/images", client.baseurl,); - let mut query = Vec::with_capacity(3usize); - if let Some(v) = &limit { - query.push(("limit", v.to_string())); - } - if let Some(v) = &page_token { - query.push(("page_token", v.to_string())); - } - if let Some(v) = &sort_by { - query.push(("sort_by", v.to_string())); - } - let request = client.client.get(url).query(&query).build()?; - let result = client.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 200u16 => ResponseValue::from_response(response).await, - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - - ///Streams `GET` requests to `/images` - pub fn stream( - self, - ) -> impl futures::Stream>> + Unpin + 'a - { - use futures::StreamExt; - use futures::TryFutureExt; - use futures::TryStreamExt; - let next = Self { - limit: Ok(None), - page_token: Ok(None), - sort_by: Ok(None), - ..self.clone() - }; - self.send() - .map_ok(move |page| { - let page = page.into_inner(); - let first = futures::stream::iter(page.items.into_iter().map(Ok)); - let rest = futures::stream::try_unfold( - (page.next_page, next), - |(next_page, next)| async { - if next_page.is_none() { - Ok(None) - } else { - Self { - page_token: Ok(next_page), - ..next.clone() - } - .send() - .map_ok(|page| { - let page = page.into_inner(); - Some(( - futures::stream::iter(page.items.into_iter().map(Ok)), - (page.next_page, next), - )) - }) - .await - } - }, - ) - .try_flatten(); - first.chain(rest) - }) - .try_flatten_stream() - .boxed() - } - } - - ///Builder for [`Client::image_global_create`] - /// - ///[`Client::image_global_create`]: super::Client::image_global_create - #[derive(Debug, Clone)] - pub struct ImageGlobalCreate<'a> { - client: &'a super::Client, - body: Result, - } - - impl<'a> ImageGlobalCreate<'a> { - pub fn new(client: &'a super::Client) -> Self { - Self { - client, - body: Err("body was not initialized".to_string()), - } - } - - pub fn body(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.body = value - .try_into() - .map_err(|_| "conversion to `GlobalImageCreate` for body failed".to_string()); - self - } - - ///Sends a `POST` request to `/images` - pub async fn send(self) -> Result, Error> { - let Self { client, body } = self; - let body = body.map_err(Error::InvalidRequest)?; - let url = format!("{}/images", client.baseurl,); - let request = client.client.post(url).json(&body).build()?; - let result = client.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 201u16 => ResponseValue::from_response(response).await, - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - } - - ///Builder for [`Client::image_global_view`] - /// - ///[`Client::image_global_view`]: super::Client::image_global_view - #[derive(Debug, Clone)] - pub struct ImageGlobalView<'a> { - client: &'a super::Client, - image_name: Result, - } - - impl<'a> ImageGlobalView<'a> { - pub fn new(client: &'a super::Client) -> Self { - Self { - client, - image_name: Err("image_name was not initialized".to_string()), - } - } - - pub fn image_name(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.image_name = value - .try_into() - .map_err(|_| "conversion to `Name` for image_name failed".to_string()); - self - } - - ///Sends a `GET` request to `/images/{image_name}` - pub async fn send(self) -> Result, Error> { - let Self { client, image_name } = self; - let image_name = image_name.map_err(Error::InvalidRequest)?; - let url = format!( - "{}/images/{}", - client.baseurl, - encode_path(&image_name.to_string()), - ); - let request = client.client.get(url).build()?; - let result = client.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 200u16 => ResponseValue::from_response(response).await, - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - } - - ///Builder for [`Client::image_global_delete`] - /// - ///[`Client::image_global_delete`]: super::Client::image_global_delete - #[derive(Debug, Clone)] - pub struct ImageGlobalDelete<'a> { - client: &'a super::Client, - image_name: Result, - } - - impl<'a> ImageGlobalDelete<'a> { - pub fn new(client: &'a super::Client) -> Self { - Self { - client, - image_name: Err("image_name was not initialized".to_string()), - } - } - - pub fn image_name(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.image_name = value - .try_into() - .map_err(|_| "conversion to `Name` for image_name failed".to_string()); - self - } - - ///Sends a `DELETE` request to `/images/{image_name}` - pub async fn send(self) -> Result, Error> { - let Self { client, image_name } = self; - let image_name = image_name.map_err(Error::InvalidRequest)?; - let url = format!( - "{}/images/{}", - client.baseurl, - encode_path(&image_name.to_string()), - ); - let request = client.client.delete(url).build()?; - let result = client.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 204u16 => Ok(ResponseValue::empty(response)), - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - } - - ///Builder for [`Client::ip_pool_list`] - /// - ///[`Client::ip_pool_list`]: super::Client::ip_pool_list - #[derive(Debug, Clone)] - pub struct IpPoolList<'a> { - client: &'a super::Client, - limit: Result, String>, - page_token: Result, String>, - sort_by: Result, String>, - } - - impl<'a> IpPoolList<'a> { - pub fn new(client: &'a super::Client) -> Self { - Self { - client, - limit: Ok(None), - page_token: Ok(None), - sort_by: Ok(None), - } - } - - pub fn limit(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.limit = value.try_into().map(Some).map_err(|_| { - "conversion to `Option < std :: num :: NonZeroU32 >` for limit failed".to_string() - }); - self - } - - pub fn page_token(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.page_token = value - .try_into() - .map(Some) - .map_err(|_| "conversion to `Option < String >` for page_token failed".to_string()); - self - } - - pub fn sort_by(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.sort_by = value.try_into().map(Some).map_err(|_| { - "conversion to `Option < NameOrIdSortMode >` for sort_by failed".to_string() - }); - self - } - - ///Sends a `GET` request to `/ip-pools` - pub async fn send( - self, - ) -> Result, Error> { - let Self { - client, - limit, - page_token, - sort_by, - } = self; - let limit = limit.map_err(Error::InvalidRequest)?; - let page_token = page_token.map_err(Error::InvalidRequest)?; - let sort_by = sort_by.map_err(Error::InvalidRequest)?; - let url = format!("{}/ip-pools", client.baseurl,); - let mut query = Vec::with_capacity(3usize); - if let Some(v) = &limit { - query.push(("limit", v.to_string())); - } - if let Some(v) = &page_token { - query.push(("page_token", v.to_string())); - } - if let Some(v) = &sort_by { - query.push(("sort_by", v.to_string())); - } - let request = client.client.get(url).query(&query).build()?; - let result = client.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 200u16 => ResponseValue::from_response(response).await, - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - - ///Streams `GET` requests to `/ip-pools` - pub fn stream( - self, - ) -> impl futures::Stream>> + Unpin + 'a - { - use futures::StreamExt; - use futures::TryFutureExt; - use futures::TryStreamExt; - let next = Self { - limit: Ok(None), - page_token: Ok(None), - sort_by: Ok(None), - ..self.clone() - }; - self.send() - .map_ok(move |page| { - let page = page.into_inner(); - let first = futures::stream::iter(page.items.into_iter().map(Ok)); - let rest = futures::stream::try_unfold( - (page.next_page, next), - |(next_page, next)| async { - if next_page.is_none() { - Ok(None) - } else { - Self { - page_token: Ok(next_page), - ..next.clone() - } - .send() - .map_ok(|page| { - let page = page.into_inner(); - Some(( - futures::stream::iter(page.items.into_iter().map(Ok)), - (page.next_page, next), - )) - }) - .await - } - }, - ) - .try_flatten(); - first.chain(rest) - }) - .try_flatten_stream() - .boxed() - } - } - - ///Builder for [`Client::ip_pool_create`] - /// - ///[`Client::ip_pool_create`]: super::Client::ip_pool_create - #[derive(Debug, Clone)] - pub struct IpPoolCreate<'a> { - client: &'a super::Client, - body: Result, - } - - impl<'a> IpPoolCreate<'a> { - pub fn new(client: &'a super::Client) -> Self { - Self { - client, - body: Err("body was not initialized".to_string()), - } - } - - pub fn body(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.body = value - .try_into() - .map_err(|_| "conversion to `IpPoolCreate` for body failed".to_string()); - self - } - - ///Sends a `POST` request to `/ip-pools` - pub async fn send(self) -> Result, Error> { - let Self { client, body } = self; - let body = body.map_err(Error::InvalidRequest)?; - let url = format!("{}/ip-pools", client.baseurl,); - let request = client.client.post(url).json(&body).build()?; - let result = client.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 201u16 => ResponseValue::from_response(response).await, - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - } - - ///Builder for [`Client::ip_pool_view`] - /// - ///[`Client::ip_pool_view`]: super::Client::ip_pool_view - #[derive(Debug, Clone)] - pub struct IpPoolView<'a> { - client: &'a super::Client, - pool_name: Result, - } - - impl<'a> IpPoolView<'a> { - pub fn new(client: &'a super::Client) -> Self { - Self { - client, - pool_name: Err("pool_name was not initialized".to_string()), - } - } - - pub fn pool_name(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.pool_name = value - .try_into() - .map_err(|_| "conversion to `Name` for pool_name failed".to_string()); - self - } - - ///Sends a `GET` request to `/ip-pools/{pool_name}` - pub async fn send(self) -> Result, Error> { - let Self { client, pool_name } = self; - let pool_name = pool_name.map_err(Error::InvalidRequest)?; - let url = format!( - "{}/ip-pools/{}", - client.baseurl, - encode_path(&pool_name.to_string()), - ); - let request = client.client.get(url).build()?; - let result = client.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 200u16 => ResponseValue::from_response(response).await, - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - } - - ///Builder for [`Client::ip_pool_update`] - /// - ///[`Client::ip_pool_update`]: super::Client::ip_pool_update - #[derive(Debug, Clone)] - pub struct IpPoolUpdate<'a> { - client: &'a super::Client, - pool_name: Result, - body: Result, - } - - impl<'a> IpPoolUpdate<'a> { - pub fn new(client: &'a super::Client) -> Self { - Self { - client, - pool_name: Err("pool_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), - } - } - - pub fn pool_name(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.pool_name = value - .try_into() - .map_err(|_| "conversion to `Name` for pool_name failed".to_string()); - self - } - - pub fn body(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.body = value - .try_into() - .map_err(|_| "conversion to `IpPoolUpdate` for body failed".to_string()); - self - } - - ///Sends a `PUT` request to `/ip-pools/{pool_name}` - pub async fn send(self) -> Result, Error> { - let Self { - client, - pool_name, - body, - } = self; - let pool_name = pool_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; - let url = format!( - "{}/ip-pools/{}", - client.baseurl, - encode_path(&pool_name.to_string()), - ); - let request = client.client.put(url).json(&body).build()?; - let result = client.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 200u16 => ResponseValue::from_response(response).await, - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - } - - ///Builder for [`Client::ip_pool_delete`] - /// - ///[`Client::ip_pool_delete`]: super::Client::ip_pool_delete - #[derive(Debug, Clone)] - pub struct IpPoolDelete<'a> { - client: &'a super::Client, - pool_name: Result, - } - - impl<'a> IpPoolDelete<'a> { - pub fn new(client: &'a super::Client) -> Self { - Self { - client, - pool_name: Err("pool_name was not initialized".to_string()), - } - } - - pub fn pool_name(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.pool_name = value - .try_into() - .map_err(|_| "conversion to `Name` for pool_name failed".to_string()); - self - } - - ///Sends a `DELETE` request to `/ip-pools/{pool_name}` - pub async fn send(self) -> Result, Error> { - let Self { client, pool_name } = self; - let pool_name = pool_name.map_err(Error::InvalidRequest)?; - let url = format!( - "{}/ip-pools/{}", - client.baseurl, - encode_path(&pool_name.to_string()), - ); - let request = client.client.delete(url).build()?; - let result = client.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 204u16 => Ok(ResponseValue::empty(response)), - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - } - - ///Builder for [`Client::ip_pool_range_list`] - /// - ///[`Client::ip_pool_range_list`]: super::Client::ip_pool_range_list - #[derive(Debug, Clone)] - pub struct IpPoolRangeList<'a> { - client: &'a super::Client, - pool_name: Result, - limit: Result, String>, - page_token: Result, String>, - } - - impl<'a> IpPoolRangeList<'a> { - pub fn new(client: &'a super::Client) -> Self { - Self { - client, - pool_name: Err("pool_name was not initialized".to_string()), - limit: Ok(None), - page_token: Ok(None), - } - } - - pub fn pool_name(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.pool_name = value - .try_into() - .map_err(|_| "conversion to `Name` for pool_name failed".to_string()); - self - } - - pub fn limit(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.limit = value.try_into().map(Some).map_err(|_| { - "conversion to `Option < std :: num :: NonZeroU32 >` for limit failed".to_string() - }); - self - } - - pub fn page_token(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.page_token = value - .try_into() - .map(Some) - .map_err(|_| "conversion to `Option < String >` for page_token failed".to_string()); - self - } - - ///Sends a `GET` request to `/ip-pools/{pool_name}/ranges` - pub async fn send( - self, - ) -> Result, Error> { - let Self { - client, - pool_name, - limit, - page_token, - } = self; - let pool_name = pool_name.map_err(Error::InvalidRequest)?; - let limit = limit.map_err(Error::InvalidRequest)?; - let page_token = page_token.map_err(Error::InvalidRequest)?; - let url = format!( - "{}/ip-pools/{}/ranges", - client.baseurl, - encode_path(&pool_name.to_string()), - ); - let mut query = Vec::with_capacity(2usize); - if let Some(v) = &limit { - query.push(("limit", v.to_string())); - } - if let Some(v) = &page_token { - query.push(("page_token", v.to_string())); - } - let request = client.client.get(url).query(&query).build()?; - let result = client.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 200u16 => ResponseValue::from_response(response).await, - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - - ///Streams `GET` requests to `/ip-pools/{pool_name}/ranges` - pub fn stream( - self, - ) -> impl futures::Stream>> + Unpin + 'a - { - use futures::StreamExt; - use futures::TryFutureExt; - use futures::TryStreamExt; - let next = Self { - limit: Ok(None), - page_token: Ok(None), - ..self.clone() - }; - self.send() - .map_ok(move |page| { - let page = page.into_inner(); - let first = futures::stream::iter(page.items.into_iter().map(Ok)); - let rest = futures::stream::try_unfold( - (page.next_page, next), - |(next_page, next)| async { - if next_page.is_none() { - Ok(None) - } else { - Self { - page_token: Ok(next_page), - ..next.clone() - } - .send() - .map_ok(|page| { - let page = page.into_inner(); - Some(( - futures::stream::iter(page.items.into_iter().map(Ok)), - (page.next_page, next), - )) - }) - .await - } - }, - ) - .try_flatten(); - first.chain(rest) - }) - .try_flatten_stream() - .boxed() - } - } - - ///Builder for [`Client::ip_pool_range_add`] - /// - ///[`Client::ip_pool_range_add`]: super::Client::ip_pool_range_add - #[derive(Debug, Clone)] - pub struct IpPoolRangeAdd<'a> { - client: &'a super::Client, - pool_name: Result, - body: Result, - } - - impl<'a> IpPoolRangeAdd<'a> { - pub fn new(client: &'a super::Client) -> Self { - Self { - client, - pool_name: Err("pool_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), - } - } - - pub fn pool_name(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.pool_name = value - .try_into() - .map_err(|_| "conversion to `Name` for pool_name failed".to_string()); - self - } - - pub fn body(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.body = value - .try_into() - .map_err(|_| "conversion to `IpRange` for body failed".to_string()); - self - } - - ///Sends a `POST` request to `/ip-pools/{pool_name}/ranges/add` - pub async fn send(self) -> Result, Error> { - let Self { - client, - pool_name, - body, - } = self; - let pool_name = pool_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; - let url = format!( - "{}/ip-pools/{}/ranges/add", - client.baseurl, - encode_path(&pool_name.to_string()), - ); - let request = client.client.post(url).json(&body).build()?; - let result = client.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 201u16 => ResponseValue::from_response(response).await, - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - } - - ///Builder for [`Client::ip_pool_range_remove`] - /// - ///[`Client::ip_pool_range_remove`]: super::Client::ip_pool_range_remove - #[derive(Debug, Clone)] - pub struct IpPoolRangeRemove<'a> { - client: &'a super::Client, - pool_name: Result, - body: Result, - } - - impl<'a> IpPoolRangeRemove<'a> { - pub fn new(client: &'a super::Client) -> Self { - Self { - client, - pool_name: Err("pool_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), - } - } - - pub fn pool_name(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.pool_name = value - .try_into() - .map_err(|_| "conversion to `Name` for pool_name failed".to_string()); - self - } - - pub fn body(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.body = value - .try_into() - .map_err(|_| "conversion to `IpRange` for body failed".to_string()); - self - } - - ///Sends a `POST` request to `/ip-pools/{pool_name}/ranges/remove` - pub async fn send(self) -> Result, Error> { - let Self { - client, - pool_name, - body, - } = self; - let pool_name = pool_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; - let url = format!( - "{}/ip-pools/{}/ranges/remove", - client.baseurl, - encode_path(&pool_name.to_string()), - ); - let request = client.client.post(url).json(&body).build()?; - let result = client.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 204u16 => Ok(ResponseValue::empty(response)), - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - } - - ///Builder for [`Client::spoof_login`] - /// - ///[`Client::spoof_login`]: super::Client::spoof_login - #[derive(Debug, Clone)] - pub struct SpoofLogin<'a> { + pub struct LoginSpoof<'a> { client: &'a super::Client, body: Result, } - impl<'a> SpoofLogin<'a> { + impl<'a> LoginSpoof<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client, @@ -16203,7 +18653,7 @@ pub mod builder { } ///Sends a `POST` request to `/login` - pub async fn send(self) -> Result, Error> { + pub async fn send(self) -> Result, Error> { let Self { client, body } = self; let body = body.map_err(Error::InvalidRequest)?; let url = format!("{}/login", client.baseurl,); @@ -16211,23 +18661,98 @@ pub mod builder { let result = client.client.execute(request).await; let response = result?; match response.status().as_u16() { - 200..=299 => Ok(ResponseValue::stream(response)), - _ => Err(Error::ErrorResponse(ResponseValue::stream(response))), + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), } } } - ///Builder for [`Client::login`] + ///Builder for [`Client::login_local`] /// - ///[`Client::login`]: super::Client::login + ///[`Client::login_local`]: super::Client::login_local #[derive(Debug, Clone)] - pub struct Login<'a> { + pub struct LoginLocal<'a> { + client: &'a super::Client, + silo_name: Result, + body: Result, + } + + impl<'a> LoginLocal<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + silo_name: Err("silo_name was not initialized".to_string()), + body: Err("body was not initialized".to_string()), + } + } + + pub fn silo_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.silo_name = value + .try_into() + .map_err(|_| "conversion to `Name` for silo_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value.try_into().map_err(|_| { + "conversion to `UsernamePasswordCredentials` for body failed".to_string() + }); + self + } + + ///Sends a `POST` request to `/login/{silo_name}/local` + pub async fn send(self) -> Result, Error> { + let Self { + client, + silo_name, + body, + } = self; + let silo_name = silo_name.map_err(Error::InvalidRequest)?; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/login/{}/local", + client.baseurl, + encode_path(&silo_name.to_string()), + ); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200..=299 => Ok(ResponseValue::stream(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::login_saml_begin`] + /// + ///[`Client::login_saml_begin`]: super::Client::login_saml_begin + #[derive(Debug, Clone)] + pub struct LoginSamlBegin<'a> { client: &'a super::Client, silo_name: Result, provider_name: Result, } - impl<'a> Login<'a> { + impl<'a> LoginSamlBegin<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client, @@ -16256,8 +18781,8 @@ pub mod builder { self } - ///Sends a `GET` request to `/login/{silo_name}/{provider_name}` - pub async fn send(self) -> Result, Error> { + ///Sends a `GET` request to `/login/{silo_name}/saml/{provider_name}` + pub async fn send(self) -> Result, Error> { let Self { client, silo_name, @@ -16266,7 +18791,7 @@ pub mod builder { let silo_name = silo_name.map_err(Error::InvalidRequest)?; let provider_name = provider_name.map_err(Error::InvalidRequest)?; let url = format!( - "{}/login/{}/{}", + "{}/login/{}/saml/{}", client.baseurl, encode_path(&silo_name.to_string()), encode_path(&provider_name.to_string()), @@ -16276,23 +18801,29 @@ pub mod builder { let response = result?; match response.status().as_u16() { 200..=299 => Ok(ResponseValue::stream(response)), - _ => Err(Error::ErrorResponse(ResponseValue::stream(response))), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), } } } - ///Builder for [`Client::consume_credentials`] + ///Builder for [`Client::login_saml`] /// - ///[`Client::consume_credentials`]: super::Client::consume_credentials + ///[`Client::login_saml`]: super::Client::login_saml #[derive(Debug)] - pub struct ConsumeCredentials<'a> { + pub struct LoginSaml<'a> { client: &'a super::Client, silo_name: Result, provider_name: Result, body: Result, } - impl<'a> ConsumeCredentials<'a> { + impl<'a> LoginSaml<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client, @@ -16332,8 +18863,8 @@ pub mod builder { self } - ///Sends a `POST` request to `/login/{silo_name}/{provider_name}` - pub async fn send(self) -> Result, Error> { + ///Sends a `POST` request to `/login/{silo_name}/saml/{provider_name}` + pub async fn send(self) -> Result, Error> { let Self { client, silo_name, @@ -16344,7 +18875,7 @@ pub mod builder { let provider_name = provider_name.map_err(Error::InvalidRequest)?; let body = body.map_err(Error::InvalidRequest)?; let url = format!( - "{}/login/{}/{}", + "{}/login/{}/saml/{}", client.baseurl, encode_path(&silo_name.to_string()), encode_path(&provider_name.to_string()), @@ -16362,7 +18893,13 @@ pub mod builder { let response = result?; match response.status().as_u16() { 200..=299 => Ok(ResponseValue::stream(response)), - _ => Err(Error::ErrorResponse(ResponseValue::stream(response))), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), } } } @@ -16381,15 +18918,21 @@ pub mod builder { } ///Sends a `POST` request to `/logout` - pub async fn send(self) -> Result, Error> { + pub async fn send(self) -> Result, Error> { let Self { client } = self; let url = format!("{}/logout", client.baseurl,); let request = client.client.post(url).build()?; let result = client.client.execute(request).await; let response = result?; match response.status().as_u16() { - 200..=299 => Ok(ResponseValue::stream(response)), - _ => Err(Error::ErrorResponse(ResponseValue::stream(response))), + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), } } } @@ -20299,6 +22842,103 @@ pub mod builder { } } + ///Builder for [`Client::instance_serial_console_stream`] + /// + ///[`Client::instance_serial_console_stream`]: super::Client::instance_serial_console_stream + #[derive(Debug, Clone)] + pub struct InstanceSerialConsoleStream<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + instance_name: Result, + } + + impl<'a> InstanceSerialConsoleStream<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + instance_name: Err("instance_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn instance_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance_name = value + .try_into() + .map_err(|_| "conversion to `Name` for instance_name failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/ + /// instances/{instance_name}/serial-console/stream` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + instance_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let instance_name = instance_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/instances/{}/serial-console/stream", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), + ); + let request = client + .client + .get(url) + .header(reqwest::header::CONNECTION, "Upgrade") + .header(reqwest::header::UPGRADE, "websocket") + .header(reqwest::header::SEC_WEBSOCKET_VERSION, "13") + .header( + reqwest::header::SEC_WEBSOCKET_KEY, + base64::Engine::encode( + &base64::engine::general_purpose::STANDARD, + rand::random::<[u8; 16]>(), + ), + ) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 101u16 => ResponseValue::upgrade(response).await, + 200..=299 => ResponseValue::upgrade(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + ///Builder for [`Client::instance_start`] /// ///[`Client::instance_start`]: super::Client::instance_start @@ -23929,7 +26569,7 @@ pub mod builder { ///Sends a `GET` request to `/policy` pub async fn send( self, - ) -> Result, Error> { + ) -> Result, Error> { let Self { client } = self; let url = format!("{}/policy", client.baseurl,); let request = client.client.get(url).build()?; @@ -23954,7 +26594,7 @@ pub mod builder { #[derive(Debug, Clone)] pub struct PolicyUpdate<'a> { client: &'a super::Client, - body: Result, + body: Result, } impl<'a> PolicyUpdate<'a> { @@ -23967,18 +26607,18 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where - V: std::convert::TryInto, + V: std::convert::TryInto, { self.body = value .try_into() - .map_err(|_| "conversion to `FleetRolePolicy` for body failed".to_string()); + .map_err(|_| "conversion to `SiloRolePolicy` for body failed".to_string()); self } ///Sends a `PUT` request to `/policy` pub async fn send( self, - ) -> Result, Error> { + ) -> Result, Error> { let Self { client, body } = self; let body = body.map_err(Error::InvalidRequest)?; let url = format!("{}/policy", client.baseurl,); @@ -24171,18 +26811,51 @@ pub mod builder { } } - ///Builder for [`Client::saga_list`] + ///Builder for [`Client::session_me`] /// - ///[`Client::saga_list`]: super::Client::saga_list + ///[`Client::session_me`]: super::Client::session_me #[derive(Debug, Clone)] - pub struct SagaList<'a> { + pub struct SessionMe<'a> { + client: &'a super::Client, + } + + impl<'a> SessionMe<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client } + } + + ///Sends a `GET` request to `/session/me` + pub async fn send(self) -> Result, Error> { + let Self { client } = self; + let url = format!("{}/session/me", client.baseurl,); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::session_me_groups`] + /// + ///[`Client::session_me_groups`]: super::Client::session_me_groups + #[derive(Debug, Clone)] + pub struct SessionMeGroups<'a> { client: &'a super::Client, limit: Result, String>, page_token: Result, String>, sort_by: Result, String>, } - impl<'a> SagaList<'a> { + impl<'a> SessionMeGroups<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client, @@ -24223,10 +26896,10 @@ pub mod builder { self } - ///Sends a `GET` request to `/sagas` + ///Sends a `GET` request to `/session/me/groups` pub async fn send( self, - ) -> Result, Error> { + ) -> Result, Error> { let Self { client, limit, @@ -24236,7 +26909,7 @@ pub mod builder { let limit = limit.map_err(Error::InvalidRequest)?; let page_token = page_token.map_err(Error::InvalidRequest)?; let sort_by = sort_by.map_err(Error::InvalidRequest)?; - let url = format!("{}/sagas", client.baseurl,); + let url = format!("{}/session/me/groups", client.baseurl,); let mut query = Vec::with_capacity(3usize); if let Some(v) = &limit { query.push(("limit", v.to_string())); @@ -24262,10 +26935,10 @@ pub mod builder { } } - ///Streams `GET` requests to `/sagas` + ///Streams `GET` requests to `/session/me/groups` pub fn stream( self, - ) -> impl futures::Stream>> + Unpin + 'a + ) -> impl futures::Stream>> + Unpin + 'a { use futures::StreamExt; use futures::TryFutureExt; @@ -24310,91 +26983,6 @@ pub mod builder { } } - ///Builder for [`Client::saga_view`] - /// - ///[`Client::saga_view`]: super::Client::saga_view - #[derive(Debug, Clone)] - pub struct SagaView<'a> { - client: &'a super::Client, - saga_id: Result, - } - - impl<'a> SagaView<'a> { - pub fn new(client: &'a super::Client) -> Self { - Self { - client, - saga_id: Err("saga_id was not initialized".to_string()), - } - } - - pub fn saga_id(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.saga_id = value - .try_into() - .map_err(|_| "conversion to `uuid :: Uuid` for saga_id failed".to_string()); - self - } - - ///Sends a `GET` request to `/sagas/{saga_id}` - pub async fn send(self) -> Result, Error> { - let Self { client, saga_id } = self; - let saga_id = saga_id.map_err(Error::InvalidRequest)?; - let url = format!( - "{}/sagas/{}", - client.baseurl, - encode_path(&saga_id.to_string()), - ); - let request = client.client.get(url).build()?; - let result = client.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 200u16 => ResponseValue::from_response(response).await, - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - } - - ///Builder for [`Client::session_me`] - /// - ///[`Client::session_me`]: super::Client::session_me - #[derive(Debug, Clone)] - pub struct SessionMe<'a> { - client: &'a super::Client, - } - - impl<'a> SessionMe<'a> { - pub fn new(client: &'a super::Client) -> Self { - Self { client } - } - - ///Sends a `GET` request to `/session/me` - pub async fn send(self) -> Result, Error> { - let Self { client } = self; - let url = format!("{}/session/me", client.baseurl,); - let request = client.client.get(url).build()?; - let result = client.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 200u16 => ResponseValue::from_response(response).await, - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - } - ///Builder for [`Client::session_sshkey_list`] /// ///[`Client::session_sshkey_list`]: super::Client::session_sshkey_list @@ -24692,6 +27280,2730 @@ pub mod builder { } } + ///Builder for [`Client::system_image_view_by_id`] + /// + ///[`Client::system_image_view_by_id`]: super::Client::system_image_view_by_id + #[derive(Debug, Clone)] + pub struct SystemImageViewById<'a> { + client: &'a super::Client, + id: Result, + } + + impl<'a> SystemImageViewById<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + id: Err("id was not initialized".to_string()), + } + } + + pub fn id(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.id = value + .try_into() + .map_err(|_| "conversion to `uuid :: Uuid` for id failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/by-id/images/{id}` + pub async fn send(self) -> Result, Error> { + let Self { client, id } = self; + let id = id.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/by-id/images/{}", + client.baseurl, + encode_path(&id.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::ip_pool_view_by_id`] + /// + ///[`Client::ip_pool_view_by_id`]: super::Client::ip_pool_view_by_id + #[derive(Debug, Clone)] + pub struct IpPoolViewById<'a> { + client: &'a super::Client, + id: Result, + } + + impl<'a> IpPoolViewById<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + id: Err("id was not initialized".to_string()), + } + } + + pub fn id(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.id = value + .try_into() + .map_err(|_| "conversion to `uuid :: Uuid` for id failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/by-id/ip-pools/{id}` + pub async fn send(self) -> Result, Error> { + let Self { client, id } = self; + let id = id.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/by-id/ip-pools/{}", + client.baseurl, + encode_path(&id.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::silo_view_by_id`] + /// + ///[`Client::silo_view_by_id`]: super::Client::silo_view_by_id + #[derive(Debug, Clone)] + pub struct SiloViewById<'a> { + client: &'a super::Client, + id: Result, + } + + impl<'a> SiloViewById<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + id: Err("id was not initialized".to_string()), + } + } + + pub fn id(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.id = value + .try_into() + .map_err(|_| "conversion to `uuid :: Uuid` for id failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/by-id/silos/{id}` + pub async fn send(self) -> Result, Error> { + let Self { client, id } = self; + let id = id.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/by-id/silos/{}", + client.baseurl, + encode_path(&id.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::certificate_list`] + /// + ///[`Client::certificate_list`]: super::Client::certificate_list + #[derive(Debug, Clone)] + pub struct CertificateList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> CertificateList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < std :: num :: NonZeroU32 >` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.page_token = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < String >` for page_token failed".to_string()); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameSortMode >` for sort_by failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/system/certificates` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/system/certificates", client.baseurl,); + let mut query = Vec::with_capacity(3usize); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/system/certificates` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + let next = Self { + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().map(Ok)); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`Client::certificate_create`] + /// + ///[`Client::certificate_create`]: super::Client::certificate_create + #[derive(Debug, Clone)] + pub struct CertificateCreate<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> CertificateCreate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + body: Err("body was not initialized".to_string()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `CertificateCreate` for body failed".to_string()); + self + } + + ///Sends a `POST` request to `/system/certificates` + pub async fn send(self) -> Result, Error> { + let Self { client, body } = self; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!("{}/system/certificates", client.baseurl,); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::certificate_view`] + /// + ///[`Client::certificate_view`]: super::Client::certificate_view + #[derive(Debug, Clone)] + pub struct CertificateView<'a> { + client: &'a super::Client, + certificate: Result, + } + + impl<'a> CertificateView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + certificate: Err("certificate was not initialized".to_string()), + } + } + + pub fn certificate(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.certificate = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for certificate failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/certificates/{certificate}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + certificate, + } = self; + let certificate = certificate.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/certificates/{}", + client.baseurl, + encode_path(&certificate.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::certificate_delete`] + /// + ///[`Client::certificate_delete`]: super::Client::certificate_delete + #[derive(Debug, Clone)] + pub struct CertificateDelete<'a> { + client: &'a super::Client, + certificate: Result, + } + + impl<'a> CertificateDelete<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + certificate: Err("certificate was not initialized".to_string()), + } + } + + pub fn certificate(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.certificate = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for certificate failed".to_string()); + self + } + + ///Sends a `DELETE` request to `/system/certificates/{certificate}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + certificate, + } = self; + let certificate = certificate.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/certificates/{}", + client.baseurl, + encode_path(&certificate.to_string()), + ); + let request = client.client.delete(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::physical_disk_list`] + /// + ///[`Client::physical_disk_list`]: super::Client::physical_disk_list + #[derive(Debug, Clone)] + pub struct PhysicalDiskList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> PhysicalDiskList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < std :: num :: NonZeroU32 >` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.page_token = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < String >` for page_token failed".to_string()); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < IdSortMode >` for sort_by failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/system/hardware/disks` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/system/hardware/disks", client.baseurl,); + let mut query = Vec::with_capacity(3usize); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/system/hardware/disks` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + let next = Self { + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().map(Ok)); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`Client::rack_list`] + /// + ///[`Client::rack_list`]: super::Client::rack_list + #[derive(Debug, Clone)] + pub struct RackList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> RackList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < std :: num :: NonZeroU32 >` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.page_token = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < String >` for page_token failed".to_string()); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < IdSortMode >` for sort_by failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/system/hardware/racks` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/system/hardware/racks", client.baseurl,); + let mut query = Vec::with_capacity(3usize); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/system/hardware/racks` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + let next = Self { + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().map(Ok)); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`Client::rack_view`] + /// + ///[`Client::rack_view`]: super::Client::rack_view + #[derive(Debug, Clone)] + pub struct RackView<'a> { + client: &'a super::Client, + rack_id: Result, + } + + impl<'a> RackView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + rack_id: Err("rack_id was not initialized".to_string()), + } + } + + pub fn rack_id(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.rack_id = value + .try_into() + .map_err(|_| "conversion to `uuid :: Uuid` for rack_id failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/hardware/racks/{rack_id}` + pub async fn send(self) -> Result, Error> { + let Self { client, rack_id } = self; + let rack_id = rack_id.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/hardware/racks/{}", + client.baseurl, + encode_path(&rack_id.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::sled_list`] + /// + ///[`Client::sled_list`]: super::Client::sled_list + #[derive(Debug, Clone)] + pub struct SledList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> SledList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < std :: num :: NonZeroU32 >` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.page_token = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < String >` for page_token failed".to_string()); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < IdSortMode >` for sort_by failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/system/hardware/sleds` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/system/hardware/sleds", client.baseurl,); + let mut query = Vec::with_capacity(3usize); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/system/hardware/sleds` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + let next = Self { + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().map(Ok)); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`Client::sled_view`] + /// + ///[`Client::sled_view`]: super::Client::sled_view + #[derive(Debug, Clone)] + pub struct SledView<'a> { + client: &'a super::Client, + sled_id: Result, + } + + impl<'a> SledView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + sled_id: Err("sled_id was not initialized".to_string()), + } + } + + pub fn sled_id(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sled_id = value + .try_into() + .map_err(|_| "conversion to `uuid :: Uuid` for sled_id failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/hardware/sleds/{sled_id}` + pub async fn send(self) -> Result, Error> { + let Self { client, sled_id } = self; + let sled_id = sled_id.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/hardware/sleds/{}", + client.baseurl, + encode_path(&sled_id.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::sled_physical_disk_list`] + /// + ///[`Client::sled_physical_disk_list`]: super::Client::sled_physical_disk_list + #[derive(Debug, Clone)] + pub struct SledPhysicalDiskList<'a> { + client: &'a super::Client, + sled_id: Result, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> SledPhysicalDiskList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + sled_id: Err("sled_id was not initialized".to_string()), + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn sled_id(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sled_id = value + .try_into() + .map_err(|_| "conversion to `uuid :: Uuid` for sled_id failed".to_string()); + self + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < std :: num :: NonZeroU32 >` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.page_token = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < String >` for page_token failed".to_string()); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < IdSortMode >` for sort_by failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/system/hardware/sleds/{sled_id}/disks` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + sled_id, + limit, + page_token, + sort_by, + } = self; + let sled_id = sled_id.map_err(Error::InvalidRequest)?; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/hardware/sleds/{}/disks", + client.baseurl, + encode_path(&sled_id.to_string()), + ); + let mut query = Vec::with_capacity(3usize); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/system/hardware/sleds/{sled_id}/disks` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + let next = Self { + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().map(Ok)); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`Client::system_image_list`] + /// + ///[`Client::system_image_list`]: super::Client::system_image_list + #[derive(Debug, Clone)] + pub struct SystemImageList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> SystemImageList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < std :: num :: NonZeroU32 >` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.page_token = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < String >` for page_token failed".to_string()); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameSortMode >` for sort_by failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/system/images` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/system/images", client.baseurl,); + let mut query = Vec::with_capacity(3usize); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/system/images` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + let next = Self { + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().map(Ok)); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`Client::system_image_create`] + /// + ///[`Client::system_image_create`]: super::Client::system_image_create + #[derive(Debug, Clone)] + pub struct SystemImageCreate<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> SystemImageCreate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + body: Err("body was not initialized".to_string()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `GlobalImageCreate` for body failed".to_string()); + self + } + + ///Sends a `POST` request to `/system/images` + pub async fn send(self) -> Result, Error> { + let Self { client, body } = self; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!("{}/system/images", client.baseurl,); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::system_image_view`] + /// + ///[`Client::system_image_view`]: super::Client::system_image_view + #[derive(Debug, Clone)] + pub struct SystemImageView<'a> { + client: &'a super::Client, + image_name: Result, + } + + impl<'a> SystemImageView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + image_name: Err("image_name was not initialized".to_string()), + } + } + + pub fn image_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.image_name = value + .try_into() + .map_err(|_| "conversion to `Name` for image_name failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/images/{image_name}` + pub async fn send(self) -> Result, Error> { + let Self { client, image_name } = self; + let image_name = image_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/images/{}", + client.baseurl, + encode_path(&image_name.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::system_image_delete`] + /// + ///[`Client::system_image_delete`]: super::Client::system_image_delete + #[derive(Debug, Clone)] + pub struct SystemImageDelete<'a> { + client: &'a super::Client, + image_name: Result, + } + + impl<'a> SystemImageDelete<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + image_name: Err("image_name was not initialized".to_string()), + } + } + + pub fn image_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.image_name = value + .try_into() + .map_err(|_| "conversion to `Name` for image_name failed".to_string()); + self + } + + ///Sends a `DELETE` request to `/system/images/{image_name}` + pub async fn send(self) -> Result, Error> { + let Self { client, image_name } = self; + let image_name = image_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/images/{}", + client.baseurl, + encode_path(&image_name.to_string()), + ); + let request = client.client.delete(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::ip_pool_list`] + /// + ///[`Client::ip_pool_list`]: super::Client::ip_pool_list + #[derive(Debug, Clone)] + pub struct IpPoolList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> IpPoolList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < std :: num :: NonZeroU32 >` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.page_token = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < String >` for page_token failed".to_string()); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameOrIdSortMode >` for sort_by failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/system/ip-pools` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/system/ip-pools", client.baseurl,); + let mut query = Vec::with_capacity(3usize); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/system/ip-pools` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + let next = Self { + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().map(Ok)); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`Client::ip_pool_create`] + /// + ///[`Client::ip_pool_create`]: super::Client::ip_pool_create + #[derive(Debug, Clone)] + pub struct IpPoolCreate<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> IpPoolCreate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + body: Err("body was not initialized".to_string()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `IpPoolCreate` for body failed".to_string()); + self + } + + ///Sends a `POST` request to `/system/ip-pools` + pub async fn send(self) -> Result, Error> { + let Self { client, body } = self; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!("{}/system/ip-pools", client.baseurl,); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::ip_pool_view`] + /// + ///[`Client::ip_pool_view`]: super::Client::ip_pool_view + #[derive(Debug, Clone)] + pub struct IpPoolView<'a> { + client: &'a super::Client, + pool_name: Result, + } + + impl<'a> IpPoolView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + pool_name: Err("pool_name was not initialized".to_string()), + } + } + + pub fn pool_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.pool_name = value + .try_into() + .map_err(|_| "conversion to `Name` for pool_name failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/ip-pools/{pool_name}` + pub async fn send(self) -> Result, Error> { + let Self { client, pool_name } = self; + let pool_name = pool_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/ip-pools/{}", + client.baseurl, + encode_path(&pool_name.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::ip_pool_update`] + /// + ///[`Client::ip_pool_update`]: super::Client::ip_pool_update + #[derive(Debug, Clone)] + pub struct IpPoolUpdate<'a> { + client: &'a super::Client, + pool_name: Result, + body: Result, + } + + impl<'a> IpPoolUpdate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + pool_name: Err("pool_name was not initialized".to_string()), + body: Err("body was not initialized".to_string()), + } + } + + pub fn pool_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.pool_name = value + .try_into() + .map_err(|_| "conversion to `Name` for pool_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `IpPoolUpdate` for body failed".to_string()); + self + } + + ///Sends a `PUT` request to `/system/ip-pools/{pool_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + pool_name, + body, + } = self; + let pool_name = pool_name.map_err(Error::InvalidRequest)?; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/ip-pools/{}", + client.baseurl, + encode_path(&pool_name.to_string()), + ); + let request = client.client.put(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::ip_pool_delete`] + /// + ///[`Client::ip_pool_delete`]: super::Client::ip_pool_delete + #[derive(Debug, Clone)] + pub struct IpPoolDelete<'a> { + client: &'a super::Client, + pool_name: Result, + } + + impl<'a> IpPoolDelete<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + pool_name: Err("pool_name was not initialized".to_string()), + } + } + + pub fn pool_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.pool_name = value + .try_into() + .map_err(|_| "conversion to `Name` for pool_name failed".to_string()); + self + } + + ///Sends a `DELETE` request to `/system/ip-pools/{pool_name}` + pub async fn send(self) -> Result, Error> { + let Self { client, pool_name } = self; + let pool_name = pool_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/ip-pools/{}", + client.baseurl, + encode_path(&pool_name.to_string()), + ); + let request = client.client.delete(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::ip_pool_range_list`] + /// + ///[`Client::ip_pool_range_list`]: super::Client::ip_pool_range_list + #[derive(Debug, Clone)] + pub struct IpPoolRangeList<'a> { + client: &'a super::Client, + pool_name: Result, + limit: Result, String>, + page_token: Result, String>, + } + + impl<'a> IpPoolRangeList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + pool_name: Err("pool_name was not initialized".to_string()), + limit: Ok(None), + page_token: Ok(None), + } + } + + pub fn pool_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.pool_name = value + .try_into() + .map_err(|_| "conversion to `Name` for pool_name failed".to_string()); + self + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < std :: num :: NonZeroU32 >` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.page_token = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < String >` for page_token failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/ip-pools/{pool_name}/ranges` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + pool_name, + limit, + page_token, + } = self; + let pool_name = pool_name.map_err(Error::InvalidRequest)?; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/ip-pools/{}/ranges", + client.baseurl, + encode_path(&pool_name.to_string()), + ); + let mut query = Vec::with_capacity(2usize); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/system/ip-pools/{pool_name}/ranges` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + let next = Self { + limit: Ok(None), + page_token: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().map(Ok)); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`Client::ip_pool_range_add`] + /// + ///[`Client::ip_pool_range_add`]: super::Client::ip_pool_range_add + #[derive(Debug, Clone)] + pub struct IpPoolRangeAdd<'a> { + client: &'a super::Client, + pool_name: Result, + body: Result, + } + + impl<'a> IpPoolRangeAdd<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + pool_name: Err("pool_name was not initialized".to_string()), + body: Err("body was not initialized".to_string()), + } + } + + pub fn pool_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.pool_name = value + .try_into() + .map_err(|_| "conversion to `Name` for pool_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `IpRange` for body failed".to_string()); + self + } + + ///Sends a `POST` request to `/system/ip-pools/{pool_name}/ranges/add` + pub async fn send(self) -> Result, Error> { + let Self { + client, + pool_name, + body, + } = self; + let pool_name = pool_name.map_err(Error::InvalidRequest)?; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/ip-pools/{}/ranges/add", + client.baseurl, + encode_path(&pool_name.to_string()), + ); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::ip_pool_range_remove`] + /// + ///[`Client::ip_pool_range_remove`]: super::Client::ip_pool_range_remove + #[derive(Debug, Clone)] + pub struct IpPoolRangeRemove<'a> { + client: &'a super::Client, + pool_name: Result, + body: Result, + } + + impl<'a> IpPoolRangeRemove<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + pool_name: Err("pool_name was not initialized".to_string()), + body: Err("body was not initialized".to_string()), + } + } + + pub fn pool_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.pool_name = value + .try_into() + .map_err(|_| "conversion to `Name` for pool_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `IpRange` for body failed".to_string()); + self + } + + ///Sends a `POST` request to + /// `/system/ip-pools/{pool_name}/ranges/remove` + pub async fn send(self) -> Result, Error> { + let Self { + client, + pool_name, + body, + } = self; + let pool_name = pool_name.map_err(Error::InvalidRequest)?; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/ip-pools/{}/ranges/remove", + client.baseurl, + encode_path(&pool_name.to_string()), + ); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::ip_pool_service_view`] + /// + ///[`Client::ip_pool_service_view`]: super::Client::ip_pool_service_view + #[derive(Debug, Clone)] + pub struct IpPoolServiceView<'a> { + client: &'a super::Client, + } + + impl<'a> IpPoolServiceView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client } + } + + ///Sends a `GET` request to `/system/ip-pools-service` + pub async fn send(self) -> Result, Error> { + let Self { client } = self; + let url = format!("{}/system/ip-pools-service", client.baseurl,); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::ip_pool_service_range_list`] + /// + ///[`Client::ip_pool_service_range_list`]: super::Client::ip_pool_service_range_list + #[derive(Debug, Clone)] + pub struct IpPoolServiceRangeList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + } + + impl<'a> IpPoolServiceRangeList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + limit: Ok(None), + page_token: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < std :: num :: NonZeroU32 >` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.page_token = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < String >` for page_token failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/ip-pools-service/ranges` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let url = format!("{}/system/ip-pools-service/ranges", client.baseurl,); + let mut query = Vec::with_capacity(2usize); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/system/ip-pools-service/ranges` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + let next = Self { + limit: Ok(None), + page_token: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().map(Ok)); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`Client::ip_pool_service_range_add`] + /// + ///[`Client::ip_pool_service_range_add`]: super::Client::ip_pool_service_range_add + #[derive(Debug, Clone)] + pub struct IpPoolServiceRangeAdd<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> IpPoolServiceRangeAdd<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + body: Err("body was not initialized".to_string()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `IpRange` for body failed".to_string()); + self + } + + ///Sends a `POST` request to `/system/ip-pools-service/ranges/add` + pub async fn send(self) -> Result, Error> { + let Self { client, body } = self; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!("{}/system/ip-pools-service/ranges/add", client.baseurl,); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::ip_pool_service_range_remove`] + /// + ///[`Client::ip_pool_service_range_remove`]: super::Client::ip_pool_service_range_remove + #[derive(Debug, Clone)] + pub struct IpPoolServiceRangeRemove<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> IpPoolServiceRangeRemove<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + body: Err("body was not initialized".to_string()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `IpRange` for body failed".to_string()); + self + } + + ///Sends a `POST` request to `/system/ip-pools-service/ranges/remove` + pub async fn send(self) -> Result, Error> { + let Self { client, body } = self; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!("{}/system/ip-pools-service/ranges/remove", client.baseurl,); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::system_metric`] + /// + ///[`Client::system_metric`]: super::Client::system_metric + #[derive(Debug, Clone)] + pub struct SystemMetric<'a> { + client: &'a super::Client, + metric_name: Result, + end_time: Result>, String>, + id: Result, + limit: Result, String>, + page_token: Result, String>, + start_time: Result>, String>, + } + + impl<'a> SystemMetric<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + metric_name: Err("metric_name was not initialized".to_string()), + end_time: Ok(None), + id: Err("id was not initialized".to_string()), + limit: Ok(None), + page_token: Ok(None), + start_time: Ok(None), + } + } + + pub fn metric_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.metric_name = value + .try_into() + .map_err(|_| "conversion to `SystemMetricName` for metric_name failed".to_string()); + self + } + + pub fn end_time(mut self, value: V) -> Self + where + V: std::convert::TryInto>, + { + self . end_time = value . try_into () . map (Some) . map_err (| _ | "conversion to `Option < chrono :: DateTime < chrono :: offset :: Utc > >` for end_time failed" . to_string ()) ; + self + } + + pub fn id(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.id = value + .try_into() + .map_err(|_| "conversion to `uuid :: Uuid` for id failed".to_string()); + self + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < std :: num :: NonZeroU32 >` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.page_token = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < String >` for page_token failed".to_string()); + self + } + + pub fn start_time(mut self, value: V) -> Self + where + V: std::convert::TryInto>, + { + self . start_time = value . try_into () . map (Some) . map_err (| _ | "conversion to `Option < chrono :: DateTime < chrono :: offset :: Utc > >` for start_time failed" . to_string ()) ; + self + } + + ///Sends a `GET` request to `/system/metrics/{metric_name}` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + metric_name, + end_time, + id, + limit, + page_token, + start_time, + } = self; + let metric_name = metric_name.map_err(Error::InvalidRequest)?; + let end_time = end_time.map_err(Error::InvalidRequest)?; + let id = id.map_err(Error::InvalidRequest)?; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let start_time = start_time.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/metrics/{}", + client.baseurl, + encode_path(&metric_name.to_string()), + ); + let mut query = Vec::with_capacity(5usize); + if let Some(v) = &end_time { + query.push(("end_time", v.to_string())); + } + query.push(("id", id.to_string())); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &start_time { + query.push(("start_time", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::system_policy_view`] + /// + ///[`Client::system_policy_view`]: super::Client::system_policy_view + #[derive(Debug, Clone)] + pub struct SystemPolicyView<'a> { + client: &'a super::Client, + } + + impl<'a> SystemPolicyView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client } + } + + ///Sends a `GET` request to `/system/policy` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client } = self; + let url = format!("{}/system/policy", client.baseurl,); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::system_policy_update`] + /// + ///[`Client::system_policy_update`]: super::Client::system_policy_update + #[derive(Debug, Clone)] + pub struct SystemPolicyUpdate<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> SystemPolicyUpdate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + body: Err("body was not initialized".to_string()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `FleetRolePolicy` for body failed".to_string()); + self + } + + ///Sends a `PUT` request to `/system/policy` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client, body } = self; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!("{}/system/policy", client.baseurl,); + let request = client.client.put(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::saga_list`] + /// + ///[`Client::saga_list`]: super::Client::saga_list + #[derive(Debug, Clone)] + pub struct SagaList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> SagaList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < std :: num :: NonZeroU32 >` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.page_token = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < String >` for page_token failed".to_string()); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < IdSortMode >` for sort_by failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/system/sagas` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/system/sagas", client.baseurl,); + let mut query = Vec::with_capacity(3usize); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/system/sagas` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + let next = Self { + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().map(Ok)); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`Client::saga_view`] + /// + ///[`Client::saga_view`]: super::Client::saga_view + #[derive(Debug, Clone)] + pub struct SagaView<'a> { + client: &'a super::Client, + saga_id: Result, + } + + impl<'a> SagaView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + saga_id: Err("saga_id was not initialized".to_string()), + } + } + + pub fn saga_id(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.saga_id = value + .try_into() + .map_err(|_| "conversion to `uuid :: Uuid` for saga_id failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/sagas/{saga_id}` + pub async fn send(self) -> Result, Error> { + let Self { client, saga_id } = self; + let saga_id = saga_id.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/sagas/{}", + client.baseurl, + encode_path(&saga_id.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + ///Builder for [`Client::silo_list`] /// ///[`Client::silo_list`]: super::Client::silo_list @@ -24744,7 +30056,7 @@ pub mod builder { self } - ///Sends a `GET` request to `/silos` + ///Sends a `GET` request to `/system/silos` pub async fn send( self, ) -> Result, Error> { @@ -24757,7 +30069,7 @@ pub mod builder { let limit = limit.map_err(Error::InvalidRequest)?; let page_token = page_token.map_err(Error::InvalidRequest)?; let sort_by = sort_by.map_err(Error::InvalidRequest)?; - let url = format!("{}/silos", client.baseurl,); + let url = format!("{}/system/silos", client.baseurl,); let mut query = Vec::with_capacity(3usize); if let Some(v) = &limit { query.push(("limit", v.to_string())); @@ -24783,7 +30095,7 @@ pub mod builder { } } - ///Streams `GET` requests to `/silos` + ///Streams `GET` requests to `/system/silos` pub fn stream( self, ) -> impl futures::Stream>> + Unpin + 'a @@ -24858,11 +30170,11 @@ pub mod builder { self } - ///Sends a `POST` request to `/silos` + ///Sends a `POST` request to `/system/silos` pub async fn send(self) -> Result, Error> { let Self { client, body } = self; let body = body.map_err(Error::InvalidRequest)?; - let url = format!("{}/silos", client.baseurl,); + let url = format!("{}/system/silos", client.baseurl,); let request = client.client.post(url).json(&body).build()?; let result = client.client.execute(request).await; let response = result?; @@ -24906,12 +30218,12 @@ pub mod builder { self } - ///Sends a `GET` request to `/silos/{silo_name}` + ///Sends a `GET` request to `/system/silos/{silo_name}` pub async fn send(self) -> Result, Error> { let Self { client, silo_name } = self; let silo_name = silo_name.map_err(Error::InvalidRequest)?; let url = format!( - "{}/silos/{}", + "{}/system/silos/{}", client.baseurl, encode_path(&silo_name.to_string()), ); @@ -24958,12 +30270,12 @@ pub mod builder { self } - ///Sends a `DELETE` request to `/silos/{silo_name}` + ///Sends a `DELETE` request to `/system/silos/{silo_name}` pub async fn send(self) -> Result, Error> { let Self { client, silo_name } = self; let silo_name = silo_name.map_err(Error::InvalidRequest)?; let url = format!( - "{}/silos/{}", + "{}/system/silos/{}", client.baseurl, encode_path(&silo_name.to_string()), ); @@ -25047,7 +30359,8 @@ pub mod builder { self } - ///Sends a `GET` request to `/silos/{silo_name}/identity-providers` + ///Sends a `GET` request to + /// `/system/silos/{silo_name}/identity-providers` pub async fn send( self, ) -> Result, Error> @@ -25064,7 +30377,7 @@ pub mod builder { let page_token = page_token.map_err(Error::InvalidRequest)?; let sort_by = sort_by.map_err(Error::InvalidRequest)?; let url = format!( - "{}/silos/{}/identity-providers", + "{}/system/silos/{}/identity-providers", client.baseurl, encode_path(&silo_name.to_string()), ); @@ -25093,7 +30406,8 @@ pub mod builder { } } - ///Streams `GET` requests to `/silos/{silo_name}/identity-providers` + ///Streams `GET` requests to + /// `/system/silos/{silo_name}/identity-providers` pub fn stream( self, ) -> impl futures::Stream>> + Unpin + 'a @@ -25141,6 +30455,378 @@ pub mod builder { } } + ///Builder for [`Client::local_idp_user_create`] + /// + ///[`Client::local_idp_user_create`]: super::Client::local_idp_user_create + #[derive(Debug, Clone)] + pub struct LocalIdpUserCreate<'a> { + client: &'a super::Client, + silo_name: Result, + body: Result, + } + + impl<'a> LocalIdpUserCreate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + silo_name: Err("silo_name was not initialized".to_string()), + body: Err("body was not initialized".to_string()), + } + } + + pub fn silo_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.silo_name = value + .try_into() + .map_err(|_| "conversion to `Name` for silo_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `UserCreate` for body failed".to_string()); + self + } + + ///Sends a `POST` request to + /// `/system/silos/{silo_name}/identity-providers/local/users` + pub async fn send(self) -> Result, Error> { + let Self { + client, + silo_name, + body, + } = self; + let silo_name = silo_name.map_err(Error::InvalidRequest)?; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/silos/{}/identity-providers/local/users", + client.baseurl, + encode_path(&silo_name.to_string()), + ); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::local_idp_user_delete`] + /// + ///[`Client::local_idp_user_delete`]: super::Client::local_idp_user_delete + #[derive(Debug, Clone)] + pub struct LocalIdpUserDelete<'a> { + client: &'a super::Client, + silo_name: Result, + user_id: Result, + } + + impl<'a> LocalIdpUserDelete<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + silo_name: Err("silo_name was not initialized".to_string()), + user_id: Err("user_id was not initialized".to_string()), + } + } + + pub fn silo_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.silo_name = value + .try_into() + .map_err(|_| "conversion to `Name` for silo_name failed".to_string()); + self + } + + pub fn user_id(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.user_id = value + .try_into() + .map_err(|_| "conversion to `uuid :: Uuid` for user_id failed".to_string()); + self + } + + ///Sends a `DELETE` request to + /// `/system/silos/{silo_name}/identity-providers/local/users/{user_id}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + silo_name, + user_id, + } = self; + let silo_name = silo_name.map_err(Error::InvalidRequest)?; + let user_id = user_id.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/silos/{}/identity-providers/local/users/{}", + client.baseurl, + encode_path(&silo_name.to_string()), + encode_path(&user_id.to_string()), + ); + let request = client.client.delete(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::local_idp_user_set_password`] + /// + ///[`Client::local_idp_user_set_password`]: super::Client::local_idp_user_set_password + #[derive(Debug, Clone)] + pub struct LocalIdpUserSetPassword<'a> { + client: &'a super::Client, + silo_name: Result, + user_id: Result, + body: Result, + } + + impl<'a> LocalIdpUserSetPassword<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + silo_name: Err("silo_name was not initialized".to_string()), + user_id: Err("user_id was not initialized".to_string()), + body: Err("body was not initialized".to_string()), + } + } + + pub fn silo_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.silo_name = value + .try_into() + .map_err(|_| "conversion to `Name` for silo_name failed".to_string()); + self + } + + pub fn user_id(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.user_id = value + .try_into() + .map_err(|_| "conversion to `uuid :: Uuid` for user_id failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `UserPassword` for body failed".to_string()); + self + } + + ///Sends a `POST` request to + /// `/system/silos/{silo_name}/identity-providers/local/users/{user_id}/ + /// set-password` + pub async fn send(self) -> Result, Error> { + let Self { + client, + silo_name, + user_id, + body, + } = self; + let silo_name = silo_name.map_err(Error::InvalidRequest)?; + let user_id = user_id.map_err(Error::InvalidRequest)?; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/silos/{}/identity-providers/local/users/{}/set-password", + client.baseurl, + encode_path(&silo_name.to_string()), + encode_path(&user_id.to_string()), + ); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::saml_identity_provider_create`] + /// + ///[`Client::saml_identity_provider_create`]: super::Client::saml_identity_provider_create + #[derive(Debug, Clone)] + pub struct SamlIdentityProviderCreate<'a> { + client: &'a super::Client, + silo_name: Result, + body: Result, + } + + impl<'a> SamlIdentityProviderCreate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + silo_name: Err("silo_name was not initialized".to_string()), + body: Err("body was not initialized".to_string()), + } + } + + pub fn silo_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.silo_name = value + .try_into() + .map_err(|_| "conversion to `Name` for silo_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value.try_into().map_err(|_| { + "conversion to `SamlIdentityProviderCreate` for body failed".to_string() + }); + self + } + + ///Sends a `POST` request to + /// `/system/silos/{silo_name}/identity-providers/saml` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + silo_name, + body, + } = self; + let silo_name = silo_name.map_err(Error::InvalidRequest)?; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/silos/{}/identity-providers/saml", + client.baseurl, + encode_path(&silo_name.to_string()), + ); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::saml_identity_provider_view`] + /// + ///[`Client::saml_identity_provider_view`]: super::Client::saml_identity_provider_view + #[derive(Debug, Clone)] + pub struct SamlIdentityProviderView<'a> { + client: &'a super::Client, + silo_name: Result, + provider_name: Result, + } + + impl<'a> SamlIdentityProviderView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + silo_name: Err("silo_name was not initialized".to_string()), + provider_name: Err("provider_name was not initialized".to_string()), + } + } + + pub fn silo_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.silo_name = value + .try_into() + .map_err(|_| "conversion to `Name` for silo_name failed".to_string()); + self + } + + pub fn provider_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.provider_name = value + .try_into() + .map_err(|_| "conversion to `Name` for provider_name failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/system/silos/{silo_name}/identity-providers/saml/{provider_name}` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + silo_name, + provider_name, + } = self; + let silo_name = silo_name.map_err(Error::InvalidRequest)?; + let provider_name = provider_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/silos/{}/identity-providers/saml/{}", + client.baseurl, + encode_path(&silo_name.to_string()), + encode_path(&provider_name.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + ///Builder for [`Client::silo_policy_view`] /// ///[`Client::silo_policy_view`]: super::Client::silo_policy_view @@ -25168,14 +30854,14 @@ pub mod builder { self } - ///Sends a `GET` request to `/silos/{silo_name}/policy` + ///Sends a `GET` request to `/system/silos/{silo_name}/policy` pub async fn send( self, ) -> Result, Error> { let Self { client, silo_name } = self; let silo_name = silo_name.map_err(Error::InvalidRequest)?; let url = format!( - "{}/silos/{}/policy", + "{}/system/silos/{}/policy", client.baseurl, encode_path(&silo_name.to_string()), ); @@ -25234,7 +30920,7 @@ pub mod builder { self } - ///Sends a `PUT` request to `/silos/{silo_name}/policy` + ///Sends a `PUT` request to `/system/silos/{silo_name}/policy` pub async fn send( self, ) -> Result, Error> { @@ -25246,7 +30932,7 @@ pub mod builder { let silo_name = silo_name.map_err(Error::InvalidRequest)?; let body = body.map_err(Error::InvalidRequest)?; let url = format!( - "{}/silos/{}/policy", + "{}/system/silos/{}/policy", client.baseurl, encode_path(&silo_name.to_string()), ); @@ -25266,22 +30952,26 @@ pub mod builder { } } - ///Builder for [`Client::silo_identity_provider_create`] + ///Builder for [`Client::silo_users_list`] /// - ///[`Client::silo_identity_provider_create`]: super::Client::silo_identity_provider_create + ///[`Client::silo_users_list`]: super::Client::silo_users_list #[derive(Debug, Clone)] - pub struct SiloIdentityProviderCreate<'a> { + pub struct SiloUsersList<'a> { client: &'a super::Client, silo_name: Result, - body: Result, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, } - impl<'a> SiloIdentityProviderCreate<'a> { + impl<'a> SiloUsersList<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client, silo_name: Err("silo_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), } } @@ -25295,38 +30985,72 @@ pub mod builder { self } - pub fn body(mut self, value: V) -> Self + pub fn limit(mut self, value: V) -> Self where - V: std::convert::TryInto, + V: std::convert::TryInto, { - self.body = value.try_into().map_err(|_| { - "conversion to `SamlIdentityProviderCreate` for body failed".to_string() + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < std :: num :: NonZeroU32 >` for limit failed".to_string() }); self } - ///Sends a `POST` request to - /// `/silos/{silo_name}/saml-identity-providers` + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.page_token = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < String >` for page_token failed".to_string()); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < IdSortMode >` for sort_by failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/system/silos/{silo_name}/users/all` pub async fn send( self, - ) -> Result, Error> { + ) -> Result, Error> { let Self { client, silo_name, - body, + limit, + page_token, + sort_by, } = self; let silo_name = silo_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; let url = format!( - "{}/silos/{}/saml-identity-providers", + "{}/system/silos/{}/users/all", client.baseurl, encode_path(&silo_name.to_string()), ); - let request = client.client.post(url).json(&body).build()?; + let mut query = Vec::with_capacity(3usize); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; let result = client.client.execute(request).await; let response = result?; match response.status().as_u16() { - 201u16 => ResponseValue::from_response(response).await, + 200u16 => ResponseValue::from_response(response).await, 400u16..=499u16 => Err(Error::ErrorResponse( ResponseValue::from_response(response).await?, )), @@ -25336,24 +31060,71 @@ pub mod builder { _ => Err(Error::UnexpectedResponse(response)), } } + + ///Streams `GET` requests to `/system/silos/{silo_name}/users/all` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + let next = Self { + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().map(Ok)); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } } - ///Builder for [`Client::silo_identity_provider_view`] + ///Builder for [`Client::silo_user_view`] /// - ///[`Client::silo_identity_provider_view`]: super::Client::silo_identity_provider_view + ///[`Client::silo_user_view`]: super::Client::silo_user_view #[derive(Debug, Clone)] - pub struct SiloIdentityProviderView<'a> { + pub struct SiloUserView<'a> { client: &'a super::Client, silo_name: Result, - provider_name: Result, + user_id: Result, } - impl<'a> SiloIdentityProviderView<'a> { + impl<'a> SiloUserView<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client, silo_name: Err("silo_name was not initialized".to_string()), - provider_name: Err("provider_name was not initialized".to_string()), + user_id: Err("user_id was not initialized".to_string()), } } @@ -25367,33 +31138,31 @@ pub mod builder { self } - pub fn provider_name(mut self, value: V) -> Self + pub fn user_id(mut self, value: V) -> Self where - V: std::convert::TryInto, + V: std::convert::TryInto, { - self.provider_name = value + self.user_id = value .try_into() - .map_err(|_| "conversion to `Name` for provider_name failed".to_string()); + .map_err(|_| "conversion to `uuid :: Uuid` for user_id failed".to_string()); self } ///Sends a `GET` request to - /// `/silos/{silo_name}/saml-identity-providers/{provider_name}` - pub async fn send( - self, - ) -> Result, Error> { + /// `/system/silos/{silo_name}/users/id/{user_id}` + pub async fn send(self) -> Result, Error> { let Self { client, silo_name, - provider_name, + user_id, } = self; let silo_name = silo_name.map_err(Error::InvalidRequest)?; - let provider_name = provider_name.map_err(Error::InvalidRequest)?; + let user_id = user_id.map_err(Error::InvalidRequest)?; let url = format!( - "{}/silos/{}/saml-identity-providers/{}", + "{}/system/silos/{}/users/id/{}", client.baseurl, encode_path(&silo_name.to_string()), - encode_path(&provider_name.to_string()), + encode_path(&user_id.to_string()), ); let request = client.client.get(url).build()?; let result = client.client.execute(request).await; @@ -25724,39 +31493,6 @@ pub mod builder { } } - ///Builder for [`Client::updates_refresh`] - /// - ///[`Client::updates_refresh`]: super::Client::updates_refresh - #[derive(Debug, Clone)] - pub struct UpdatesRefresh<'a> { - client: &'a super::Client, - } - - impl<'a> UpdatesRefresh<'a> { - pub fn new(client: &'a super::Client) -> Self { - Self { client } - } - - ///Sends a `POST` request to `/updates/refresh` - pub async fn send(self) -> Result, Error> { - let Self { client } = self; - let url = format!("{}/updates/refresh", client.baseurl,); - let request = client.client.post(url).build()?; - let result = client.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 204u16 => Ok(ResponseValue::empty(response)), - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - } - ///Builder for [`Client::user_list`] /// ///[`Client::user_list`]: super::Client::user_list @@ -25895,6 +31631,3769 @@ pub mod builder { .boxed() } } + + ///Builder for [`Client::disk_list_v1`] + /// + ///[`Client::disk_list_v1`]: super::Client::disk_list_v1 + #[derive(Debug, Clone)] + pub struct DiskListV1<'a> { + client: &'a super::Client, + limit: Result, String>, + organization: Result, String>, + page_token: Result, String>, + project: Result, String>, + sort_by: Result, String>, + } + + impl<'a> DiskListV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + limit: Ok(None), + organization: Ok(None), + page_token: Ok(None), + project: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < std :: num :: NonZeroU32 >` for limit failed".to_string() + }); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameOrId >` for organization failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.page_token = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < String >` for page_token failed".to_string()); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < NameOrId >` for project failed".to_string()); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameOrIdSortMode >` for sort_by failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/v1/disks` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + organization, + page_token, + project, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/disks", client.baseurl,); + let mut query = Vec::with_capacity(5usize); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &project { + query.push(("project", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/v1/disks` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + let next = Self { + limit: Ok(None), + organization: Ok(None), + page_token: Ok(None), + project: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().map(Ok)); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`Client::disk_create_v1`] + /// + ///[`Client::disk_create_v1`]: super::Client::disk_create_v1 + #[derive(Debug, Clone)] + pub struct DiskCreateV1<'a> { + client: &'a super::Client, + organization: Result, String>, + project: Result, + body: Result, + } + + impl<'a> DiskCreateV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization: Ok(None), + project: Err("project was not initialized".to_string()), + body: Err("body was not initialized".to_string()), + } + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameOrId >` for organization failed".to_string() + }); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for project failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `DiskCreate` for body failed".to_string()); + self + } + + ///Sends a `POST` request to `/v1/disks` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization, + project, + body, + } = self; + let organization = organization.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/disks", client.baseurl,); + let mut query = Vec::with_capacity(2usize); + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + query.push(("project", project.to_string())); + let request = client.client.post(url).json(&body).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::disk_view_v1`] + /// + ///[`Client::disk_view_v1`]: super::Client::disk_view_v1 + #[derive(Debug, Clone)] + pub struct DiskViewV1<'a> { + client: &'a super::Client, + disk: Result, + organization: Result, String>, + project: Result, String>, + } + + impl<'a> DiskViewV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + disk: Err("disk was not initialized".to_string()), + organization: Ok(None), + project: Ok(None), + } + } + + pub fn disk(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.disk = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for disk failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameOrId >` for organization failed".to_string() + }); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < NameOrId >` for project failed".to_string()); + self + } + + ///Sends a `GET` request to `/v1/disks/{disk}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + disk, + organization, + project, + } = self; + let disk = disk.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/disks/{}", + client.baseurl, + encode_path(&disk.to_string()), + ); + let mut query = Vec::with_capacity(2usize); + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + if let Some(v) = &project { + query.push(("project", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::disk_delete_v1`] + /// + ///[`Client::disk_delete_v1`]: super::Client::disk_delete_v1 + #[derive(Debug, Clone)] + pub struct DiskDeleteV1<'a> { + client: &'a super::Client, + disk: Result, + organization: Result, String>, + project: Result, String>, + } + + impl<'a> DiskDeleteV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + disk: Err("disk was not initialized".to_string()), + organization: Ok(None), + project: Ok(None), + } + } + + pub fn disk(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.disk = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for disk failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameOrId >` for organization failed".to_string() + }); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < NameOrId >` for project failed".to_string()); + self + } + + ///Sends a `DELETE` request to `/v1/disks/{disk}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + disk, + organization, + project, + } = self; + let disk = disk.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/disks/{}", + client.baseurl, + encode_path(&disk.to_string()), + ); + let mut query = Vec::with_capacity(2usize); + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + if let Some(v) = &project { + query.push(("project", v.to_string())); + } + let request = client.client.delete(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::instance_list_v1`] + /// + ///[`Client::instance_list_v1`]: super::Client::instance_list_v1 + #[derive(Debug, Clone)] + pub struct InstanceListV1<'a> { + client: &'a super::Client, + limit: Result, String>, + organization: Result, String>, + page_token: Result, String>, + project: Result, String>, + sort_by: Result, String>, + } + + impl<'a> InstanceListV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + limit: Ok(None), + organization: Ok(None), + page_token: Ok(None), + project: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < std :: num :: NonZeroU32 >` for limit failed".to_string() + }); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameOrId >` for organization failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.page_token = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < String >` for page_token failed".to_string()); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < NameOrId >` for project failed".to_string()); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameOrIdSortMode >` for sort_by failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/v1/instances` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + organization, + page_token, + project, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/instances", client.baseurl,); + let mut query = Vec::with_capacity(5usize); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &project { + query.push(("project", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/v1/instances` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + let next = Self { + limit: Ok(None), + organization: Ok(None), + page_token: Ok(None), + project: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().map(Ok)); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`Client::instance_create_v1`] + /// + ///[`Client::instance_create_v1`]: super::Client::instance_create_v1 + #[derive(Debug, Clone)] + pub struct InstanceCreateV1<'a> { + client: &'a super::Client, + organization: Result, String>, + project: Result, + body: Result, + } + + impl<'a> InstanceCreateV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization: Ok(None), + project: Err("project was not initialized".to_string()), + body: Err("body was not initialized".to_string()), + } + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameOrId >` for organization failed".to_string() + }); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for project failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `InstanceCreate` for body failed".to_string()); + self + } + + ///Sends a `POST` request to `/v1/instances` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization, + project, + body, + } = self; + let organization = organization.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/instances", client.baseurl,); + let mut query = Vec::with_capacity(2usize); + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + query.push(("project", project.to_string())); + let request = client.client.post(url).json(&body).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::instance_view_v1`] + /// + ///[`Client::instance_view_v1`]: super::Client::instance_view_v1 + #[derive(Debug, Clone)] + pub struct InstanceViewV1<'a> { + client: &'a super::Client, + instance: Result, + organization: Result, String>, + project: Result, String>, + } + + impl<'a> InstanceViewV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + instance: Err("instance was not initialized".to_string()), + organization: Ok(None), + project: Ok(None), + } + } + + pub fn instance(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for instance failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameOrId >` for organization failed".to_string() + }); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < NameOrId >` for project failed".to_string()); + self + } + + ///Sends a `GET` request to `/v1/instances/{instance}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + instance, + organization, + project, + } = self; + let instance = instance.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/instances/{}", + client.baseurl, + encode_path(&instance.to_string()), + ); + let mut query = Vec::with_capacity(2usize); + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + if let Some(v) = &project { + query.push(("project", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::instance_delete_v1`] + /// + ///[`Client::instance_delete_v1`]: super::Client::instance_delete_v1 + #[derive(Debug, Clone)] + pub struct InstanceDeleteV1<'a> { + client: &'a super::Client, + instance: Result, + organization: Result, String>, + project: Result, String>, + } + + impl<'a> InstanceDeleteV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + instance: Err("instance was not initialized".to_string()), + organization: Ok(None), + project: Ok(None), + } + } + + pub fn instance(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for instance failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameOrId >` for organization failed".to_string() + }); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < NameOrId >` for project failed".to_string()); + self + } + + ///Sends a `DELETE` request to `/v1/instances/{instance}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + instance, + organization, + project, + } = self; + let instance = instance.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/instances/{}", + client.baseurl, + encode_path(&instance.to_string()), + ); + let mut query = Vec::with_capacity(2usize); + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + if let Some(v) = &project { + query.push(("project", v.to_string())); + } + let request = client.client.delete(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::instance_disk_list_v1`] + /// + ///[`Client::instance_disk_list_v1`]: super::Client::instance_disk_list_v1 + #[derive(Debug, Clone)] + pub struct InstanceDiskListV1<'a> { + client: &'a super::Client, + instance: Result, + limit: Result, String>, + organization: Result, String>, + page_token: Result, String>, + project: Result, String>, + sort_by: Result, String>, + } + + impl<'a> InstanceDiskListV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + instance: Err("instance was not initialized".to_string()), + limit: Ok(None), + organization: Ok(None), + page_token: Ok(None), + project: Ok(None), + sort_by: Ok(None), + } + } + + pub fn instance(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for instance failed".to_string()); + self + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < std :: num :: NonZeroU32 >` for limit failed".to_string() + }); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameOrId >` for organization failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.page_token = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < String >` for page_token failed".to_string()); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < NameOrId >` for project failed".to_string()); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameOrIdSortMode >` for sort_by failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/v1/instances/{instance}/disks` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + instance, + limit, + organization, + page_token, + project, + sort_by, + } = self; + let instance = instance.map_err(Error::InvalidRequest)?; + let limit = limit.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/instances/{}/disks", + client.baseurl, + encode_path(&instance.to_string()), + ); + let mut query = Vec::with_capacity(5usize); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &project { + query.push(("project", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/v1/instances/{instance}/disks` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + let next = Self { + limit: Ok(None), + organization: Ok(None), + page_token: Ok(None), + project: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().map(Ok)); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`Client::instance_disk_attach_v1`] + /// + ///[`Client::instance_disk_attach_v1`]: super::Client::instance_disk_attach_v1 + #[derive(Debug, Clone)] + pub struct InstanceDiskAttachV1<'a> { + client: &'a super::Client, + instance: Result, + organization: Result, String>, + project: Result, String>, + body: Result, + } + + impl<'a> InstanceDiskAttachV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + instance: Err("instance was not initialized".to_string()), + organization: Ok(None), + project: Ok(None), + body: Err("body was not initialized".to_string()), + } + } + + pub fn instance(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for instance failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameOrId >` for organization failed".to_string() + }); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < NameOrId >` for project failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `DiskPath` for body failed".to_string()); + self + } + + ///Sends a `POST` request to `/v1/instances/{instance}/disks/attach` + pub async fn send(self) -> Result, Error> { + let Self { + client, + instance, + organization, + project, + body, + } = self; + let instance = instance.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/instances/{}/disks/attach", + client.baseurl, + encode_path(&instance.to_string()), + ); + let mut query = Vec::with_capacity(2usize); + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + if let Some(v) = &project { + query.push(("project", v.to_string())); + } + let request = client.client.post(url).json(&body).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 202u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::instance_disk_detach_v1`] + /// + ///[`Client::instance_disk_detach_v1`]: super::Client::instance_disk_detach_v1 + #[derive(Debug, Clone)] + pub struct InstanceDiskDetachV1<'a> { + client: &'a super::Client, + instance: Result, + organization: Result, String>, + project: Result, String>, + body: Result, + } + + impl<'a> InstanceDiskDetachV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + instance: Err("instance was not initialized".to_string()), + organization: Ok(None), + project: Ok(None), + body: Err("body was not initialized".to_string()), + } + } + + pub fn instance(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for instance failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameOrId >` for organization failed".to_string() + }); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < NameOrId >` for project failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `DiskPath` for body failed".to_string()); + self + } + + ///Sends a `POST` request to `/v1/instances/{instance}/disks/detach` + pub async fn send(self) -> Result, Error> { + let Self { + client, + instance, + organization, + project, + body, + } = self; + let instance = instance.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/instances/{}/disks/detach", + client.baseurl, + encode_path(&instance.to_string()), + ); + let mut query = Vec::with_capacity(2usize); + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + if let Some(v) = &project { + query.push(("project", v.to_string())); + } + let request = client.client.post(url).json(&body).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 202u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::instance_migrate_v1`] + /// + ///[`Client::instance_migrate_v1`]: super::Client::instance_migrate_v1 + #[derive(Debug, Clone)] + pub struct InstanceMigrateV1<'a> { + client: &'a super::Client, + instance: Result, + organization: Result, String>, + project: Result, String>, + body: Result, + } + + impl<'a> InstanceMigrateV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + instance: Err("instance was not initialized".to_string()), + organization: Ok(None), + project: Ok(None), + body: Err("body was not initialized".to_string()), + } + } + + pub fn instance(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for instance failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameOrId >` for organization failed".to_string() + }); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < NameOrId >` for project failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `InstanceMigrate` for body failed".to_string()); + self + } + + ///Sends a `POST` request to `/v1/instances/{instance}/migrate` + pub async fn send(self) -> Result, Error> { + let Self { + client, + instance, + organization, + project, + body, + } = self; + let instance = instance.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/instances/{}/migrate", + client.baseurl, + encode_path(&instance.to_string()), + ); + let mut query = Vec::with_capacity(2usize); + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + if let Some(v) = &project { + query.push(("project", v.to_string())); + } + let request = client.client.post(url).json(&body).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::instance_reboot_v1`] + /// + ///[`Client::instance_reboot_v1`]: super::Client::instance_reboot_v1 + #[derive(Debug, Clone)] + pub struct InstanceRebootV1<'a> { + client: &'a super::Client, + instance: Result, + organization: Result, String>, + project: Result, String>, + } + + impl<'a> InstanceRebootV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + instance: Err("instance was not initialized".to_string()), + organization: Ok(None), + project: Ok(None), + } + } + + pub fn instance(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for instance failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameOrId >` for organization failed".to_string() + }); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < NameOrId >` for project failed".to_string()); + self + } + + ///Sends a `POST` request to `/v1/instances/{instance}/reboot` + pub async fn send(self) -> Result, Error> { + let Self { + client, + instance, + organization, + project, + } = self; + let instance = instance.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/instances/{}/reboot", + client.baseurl, + encode_path(&instance.to_string()), + ); + let mut query = Vec::with_capacity(2usize); + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + if let Some(v) = &project { + query.push(("project", v.to_string())); + } + let request = client.client.post(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 202u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::instance_serial_console_v1`] + /// + ///[`Client::instance_serial_console_v1`]: super::Client::instance_serial_console_v1 + #[derive(Debug, Clone)] + pub struct InstanceSerialConsoleV1<'a> { + client: &'a super::Client, + instance: Result, + from_start: Result, String>, + max_bytes: Result, String>, + most_recent: Result, String>, + organization: Result, String>, + project: Result, String>, + } + + impl<'a> InstanceSerialConsoleV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + instance: Err("instance was not initialized".to_string()), + from_start: Ok(None), + max_bytes: Ok(None), + most_recent: Ok(None), + organization: Ok(None), + project: Ok(None), + } + } + + pub fn instance(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for instance failed".to_string()); + self + } + + pub fn from_start(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.from_start = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < u64 >` for from_start failed".to_string()); + self + } + + pub fn max_bytes(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.max_bytes = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < u64 >` for max_bytes failed".to_string()); + self + } + + pub fn most_recent(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.most_recent = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < u64 >` for most_recent failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameOrId >` for organization failed".to_string() + }); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < NameOrId >` for project failed".to_string()); + self + } + + ///Sends a `GET` request to `/v1/instances/{instance}/serial-console` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + instance, + from_start, + max_bytes, + most_recent, + organization, + project, + } = self; + let instance = instance.map_err(Error::InvalidRequest)?; + let from_start = from_start.map_err(Error::InvalidRequest)?; + let max_bytes = max_bytes.map_err(Error::InvalidRequest)?; + let most_recent = most_recent.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/instances/{}/serial-console", + client.baseurl, + encode_path(&instance.to_string()), + ); + let mut query = Vec::with_capacity(5usize); + if let Some(v) = &from_start { + query.push(("from_start", v.to_string())); + } + if let Some(v) = &max_bytes { + query.push(("max_bytes", v.to_string())); + } + if let Some(v) = &most_recent { + query.push(("most_recent", v.to_string())); + } + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + if let Some(v) = &project { + query.push(("project", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::instance_serial_console_stream_v1`] + /// + ///[`Client::instance_serial_console_stream_v1`]: super::Client::instance_serial_console_stream_v1 + #[derive(Debug, Clone)] + pub struct InstanceSerialConsoleStreamV1<'a> { + client: &'a super::Client, + instance: Result, + organization: Result, String>, + project: Result, String>, + } + + impl<'a> InstanceSerialConsoleStreamV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + instance: Err("instance was not initialized".to_string()), + organization: Ok(None), + project: Ok(None), + } + } + + pub fn instance(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for instance failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameOrId >` for organization failed".to_string() + }); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < NameOrId >` for project failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/v1/instances/{instance}/serial-console/stream` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + instance, + organization, + project, + } = self; + let instance = instance.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/instances/{}/serial-console/stream", + client.baseurl, + encode_path(&instance.to_string()), + ); + let mut query = Vec::with_capacity(2usize); + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + if let Some(v) = &project { + query.push(("project", v.to_string())); + } + let request = client + .client + .get(url) + .query(&query) + .header(reqwest::header::CONNECTION, "Upgrade") + .header(reqwest::header::UPGRADE, "websocket") + .header(reqwest::header::SEC_WEBSOCKET_VERSION, "13") + .header( + reqwest::header::SEC_WEBSOCKET_KEY, + base64::Engine::encode( + &base64::engine::general_purpose::STANDARD, + rand::random::<[u8; 16]>(), + ), + ) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 101u16 => ResponseValue::upgrade(response).await, + 200..=299 => ResponseValue::upgrade(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::instance_start_v1`] + /// + ///[`Client::instance_start_v1`]: super::Client::instance_start_v1 + #[derive(Debug, Clone)] + pub struct InstanceStartV1<'a> { + client: &'a super::Client, + instance: Result, + organization: Result, String>, + project: Result, String>, + } + + impl<'a> InstanceStartV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + instance: Err("instance was not initialized".to_string()), + organization: Ok(None), + project: Ok(None), + } + } + + pub fn instance(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for instance failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameOrId >` for organization failed".to_string() + }); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < NameOrId >` for project failed".to_string()); + self + } + + ///Sends a `POST` request to `/v1/instances/{instance}/start` + pub async fn send(self) -> Result, Error> { + let Self { + client, + instance, + organization, + project, + } = self; + let instance = instance.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/instances/{}/start", + client.baseurl, + encode_path(&instance.to_string()), + ); + let mut query = Vec::with_capacity(2usize); + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + if let Some(v) = &project { + query.push(("project", v.to_string())); + } + let request = client.client.post(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 202u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::instance_stop_v1`] + /// + ///[`Client::instance_stop_v1`]: super::Client::instance_stop_v1 + #[derive(Debug, Clone)] + pub struct InstanceStopV1<'a> { + client: &'a super::Client, + instance: Result, + organization: Result, String>, + project: Result, String>, + } + + impl<'a> InstanceStopV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + instance: Err("instance was not initialized".to_string()), + organization: Ok(None), + project: Ok(None), + } + } + + pub fn instance(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for instance failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameOrId >` for organization failed".to_string() + }); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < NameOrId >` for project failed".to_string()); + self + } + + ///Sends a `POST` request to `/v1/instances/{instance}/stop` + pub async fn send(self) -> Result, Error> { + let Self { + client, + instance, + organization, + project, + } = self; + let instance = instance.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/instances/{}/stop", + client.baseurl, + encode_path(&instance.to_string()), + ); + let mut query = Vec::with_capacity(2usize); + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + if let Some(v) = &project { + query.push(("project", v.to_string())); + } + let request = client.client.post(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 202u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::organization_list_v1`] + /// + ///[`Client::organization_list_v1`]: super::Client::organization_list_v1 + #[derive(Debug, Clone)] + pub struct OrganizationListV1<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> OrganizationListV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < std :: num :: NonZeroU32 >` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.page_token = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < String >` for page_token failed".to_string()); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameOrIdSortMode >` for sort_by failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/v1/organizations` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/organizations", client.baseurl,); + let mut query = Vec::with_capacity(3usize); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/v1/organizations` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + let next = Self { + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().map(Ok)); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`Client::organization_create_v1`] + /// + ///[`Client::organization_create_v1`]: super::Client::organization_create_v1 + #[derive(Debug, Clone)] + pub struct OrganizationCreateV1<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> OrganizationCreateV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + body: Err("body was not initialized".to_string()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `OrganizationCreate` for body failed".to_string()); + self + } + + ///Sends a `POST` request to `/v1/organizations` + pub async fn send(self) -> Result, Error> { + let Self { client, body } = self; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/organizations", client.baseurl,); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::organization_view_v1`] + /// + ///[`Client::organization_view_v1`]: super::Client::organization_view_v1 + #[derive(Debug, Clone)] + pub struct OrganizationViewV1<'a> { + client: &'a super::Client, + organization: Result, + } + + impl<'a> OrganizationViewV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization: Err("organization was not initialized".to_string()), + } + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + ///Sends a `GET` request to `/v1/organizations/{organization}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization, + } = self; + let organization = organization.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/organizations/{}", + client.baseurl, + encode_path(&organization.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::organization_update_v1`] + /// + ///[`Client::organization_update_v1`]: super::Client::organization_update_v1 + #[derive(Debug, Clone)] + pub struct OrganizationUpdateV1<'a> { + client: &'a super::Client, + organization: Result, + body: Result, + } + + impl<'a> OrganizationUpdateV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization: Err("organization was not initialized".to_string()), + body: Err("body was not initialized".to_string()), + } + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `OrganizationUpdate` for body failed".to_string()); + self + } + + ///Sends a `PUT` request to `/v1/organizations/{organization}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization, + body, + } = self; + let organization = organization.map_err(Error::InvalidRequest)?; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/organizations/{}", + client.baseurl, + encode_path(&organization.to_string()), + ); + let request = client.client.put(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::organization_delete_v1`] + /// + ///[`Client::organization_delete_v1`]: super::Client::organization_delete_v1 + #[derive(Debug, Clone)] + pub struct OrganizationDeleteV1<'a> { + client: &'a super::Client, + organization: Result, + } + + impl<'a> OrganizationDeleteV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization: Err("organization was not initialized".to_string()), + } + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + ///Sends a `DELETE` request to `/v1/organizations/{organization}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization, + } = self; + let organization = organization.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/organizations/{}", + client.baseurl, + encode_path(&organization.to_string()), + ); + let request = client.client.delete(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::organization_policy_view_v1`] + /// + ///[`Client::organization_policy_view_v1`]: super::Client::organization_policy_view_v1 + #[derive(Debug, Clone)] + pub struct OrganizationPolicyViewV1<'a> { + client: &'a super::Client, + organization: Result, + } + + impl<'a> OrganizationPolicyViewV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization: Err("organization was not initialized".to_string()), + } + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + ///Sends a `GET` request to `/v1/organizations/{organization}/policy` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + organization, + } = self; + let organization = organization.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/organizations/{}/policy", + client.baseurl, + encode_path(&organization.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::organization_policy_update_v1`] + /// + ///[`Client::organization_policy_update_v1`]: super::Client::organization_policy_update_v1 + #[derive(Debug, Clone)] + pub struct OrganizationPolicyUpdateV1<'a> { + client: &'a super::Client, + organization: Result, + body: Result, + } + + impl<'a> OrganizationPolicyUpdateV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization: Err("organization was not initialized".to_string()), + body: Err("body was not initialized".to_string()), + } + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `OrganizationRolePolicy` for body failed".to_string()); + self + } + + ///Sends a `PUT` request to `/v1/organizations/{organization}/policy` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + organization, + body, + } = self; + let organization = organization.map_err(Error::InvalidRequest)?; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/organizations/{}/policy", + client.baseurl, + encode_path(&organization.to_string()), + ); + let request = client.client.put(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::project_list_v1`] + /// + ///[`Client::project_list_v1`]: super::Client::project_list_v1 + #[derive(Debug, Clone)] + pub struct ProjectListV1<'a> { + client: &'a super::Client, + limit: Result, String>, + organization: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> ProjectListV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + limit: Ok(None), + organization: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < std :: num :: NonZeroU32 >` for limit failed".to_string() + }); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameOrId >` for organization failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.page_token = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < String >` for page_token failed".to_string()); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameOrIdSortMode >` for sort_by failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/v1/projects` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + organization, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/projects", client.baseurl,); + let mut query = Vec::with_capacity(4usize); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/v1/projects` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + let next = Self { + limit: Ok(None), + organization: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().map(Ok)); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`Client::project_create_v1`] + /// + ///[`Client::project_create_v1`]: super::Client::project_create_v1 + #[derive(Debug, Clone)] + pub struct ProjectCreateV1<'a> { + client: &'a super::Client, + organization: Result, + body: Result, + } + + impl<'a> ProjectCreateV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization: Err("organization was not initialized".to_string()), + body: Err("body was not initialized".to_string()), + } + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `ProjectCreate` for body failed".to_string()); + self + } + + ///Sends a `POST` request to `/v1/projects` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization, + body, + } = self; + let organization = organization.map_err(Error::InvalidRequest)?; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/projects", client.baseurl,); + let mut query = Vec::with_capacity(1usize); + query.push(("organization", organization.to_string())); + let request = client.client.post(url).json(&body).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::project_view_v1`] + /// + ///[`Client::project_view_v1`]: super::Client::project_view_v1 + #[derive(Debug, Clone)] + pub struct ProjectViewV1<'a> { + client: &'a super::Client, + project: Result, + organization: Result, String>, + } + + impl<'a> ProjectViewV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + project: Err("project was not initialized".to_string()), + organization: Ok(None), + } + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for project failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameOrId >` for organization failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/v1/projects/{project}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + project, + organization, + } = self; + let project = project.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/projects/{}", + client.baseurl, + encode_path(&project.to_string()), + ); + let mut query = Vec::with_capacity(1usize); + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::project_update_v1`] + /// + ///[`Client::project_update_v1`]: super::Client::project_update_v1 + #[derive(Debug, Clone)] + pub struct ProjectUpdateV1<'a> { + client: &'a super::Client, + project: Result, + organization: Result, String>, + body: Result, + } + + impl<'a> ProjectUpdateV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + project: Err("project was not initialized".to_string()), + organization: Ok(None), + body: Err("body was not initialized".to_string()), + } + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for project failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameOrId >` for organization failed".to_string() + }); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `ProjectUpdate` for body failed".to_string()); + self + } + + ///Sends a `PUT` request to `/v1/projects/{project}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + project, + organization, + body, + } = self; + let project = project.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/projects/{}", + client.baseurl, + encode_path(&project.to_string()), + ); + let mut query = Vec::with_capacity(1usize); + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + let request = client.client.put(url).json(&body).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::project_delete_v1`] + /// + ///[`Client::project_delete_v1`]: super::Client::project_delete_v1 + #[derive(Debug, Clone)] + pub struct ProjectDeleteV1<'a> { + client: &'a super::Client, + project: Result, + organization: Result, String>, + } + + impl<'a> ProjectDeleteV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + project: Err("project was not initialized".to_string()), + organization: Ok(None), + } + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for project failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameOrId >` for organization failed".to_string() + }); + self + } + + ///Sends a `DELETE` request to `/v1/projects/{project}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + project, + organization, + } = self; + let project = project.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/projects/{}", + client.baseurl, + encode_path(&project.to_string()), + ); + let mut query = Vec::with_capacity(1usize); + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + let request = client.client.delete(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::project_policy_view_v1`] + /// + ///[`Client::project_policy_view_v1`]: super::Client::project_policy_view_v1 + #[derive(Debug, Clone)] + pub struct ProjectPolicyViewV1<'a> { + client: &'a super::Client, + project: Result, + organization: Result, String>, + } + + impl<'a> ProjectPolicyViewV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + project: Err("project was not initialized".to_string()), + organization: Ok(None), + } + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for project failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameOrId >` for organization failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/v1/projects/{project}/policy` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + project, + organization, + } = self; + let project = project.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/projects/{}/policy", + client.baseurl, + encode_path(&project.to_string()), + ); + let mut query = Vec::with_capacity(1usize); + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::project_policy_update_v1`] + /// + ///[`Client::project_policy_update_v1`]: super::Client::project_policy_update_v1 + #[derive(Debug, Clone)] + pub struct ProjectPolicyUpdateV1<'a> { + client: &'a super::Client, + project: Result, + organization: Result, String>, + body: Result, + } + + impl<'a> ProjectPolicyUpdateV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + project: Err("project was not initialized".to_string()), + organization: Ok(None), + body: Err("body was not initialized".to_string()), + } + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for project failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < NameOrId >` for organization failed".to_string() + }); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `ProjectRolePolicy` for body failed".to_string()); + self + } + + ///Sends a `PUT` request to `/v1/projects/{project}/policy` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + project, + organization, + body, + } = self; + let project = project.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/projects/{}/policy", + client.baseurl, + encode_path(&project.to_string()), + ); + let mut query = Vec::with_capacity(1usize); + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + let request = client.client.put(url).json(&body).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::system_component_version_list`] + /// + ///[`Client::system_component_version_list`]: super::Client::system_component_version_list + #[derive(Debug, Clone)] + pub struct SystemComponentVersionList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> SystemComponentVersionList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < std :: num :: NonZeroU32 >` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.page_token = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < String >` for page_token failed".to_string()); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < IdSortMode >` for sort_by failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/v1/system/update/components` + pub async fn send( + self, + ) -> Result, Error> + { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/system/update/components", client.baseurl,); + let mut query = Vec::with_capacity(3usize); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/v1/system/update/components` + pub fn stream( + self, + ) -> impl futures::Stream>> + + Unpin + + 'a { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + let next = Self { + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().map(Ok)); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`Client::update_deployments_list`] + /// + ///[`Client::update_deployments_list`]: super::Client::update_deployments_list + #[derive(Debug, Clone)] + pub struct UpdateDeploymentsList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> UpdateDeploymentsList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < std :: num :: NonZeroU32 >` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.page_token = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < String >` for page_token failed".to_string()); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < IdSortMode >` for sort_by failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/v1/system/update/deployments` + pub async fn send( + self, + ) -> Result, Error> + { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/system/update/deployments", client.baseurl,); + let mut query = Vec::with_capacity(3usize); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/v1/system/update/deployments` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + let next = Self { + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().map(Ok)); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`Client::update_deployment_view`] + /// + ///[`Client::update_deployment_view`]: super::Client::update_deployment_view + #[derive(Debug, Clone)] + pub struct UpdateDeploymentView<'a> { + client: &'a super::Client, + id: Result, + } + + impl<'a> UpdateDeploymentView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + id: Err("id was not initialized".to_string()), + } + } + + pub fn id(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.id = value + .try_into() + .map_err(|_| "conversion to `uuid :: Uuid` for id failed".to_string()); + self + } + + ///Sends a `GET` request to `/v1/system/update/deployments/{id}` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client, id } = self; + let id = id.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/system/update/deployments/{}", + client.baseurl, + encode_path(&id.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::system_update_refresh`] + /// + ///[`Client::system_update_refresh`]: super::Client::system_update_refresh + #[derive(Debug, Clone)] + pub struct SystemUpdateRefresh<'a> { + client: &'a super::Client, + } + + impl<'a> SystemUpdateRefresh<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client } + } + + ///Sends a `POST` request to `/v1/system/update/refresh` + pub async fn send(self) -> Result, Error> { + let Self { client } = self; + let url = format!("{}/v1/system/update/refresh", client.baseurl,); + let request = client.client.post(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::system_update_start`] + /// + ///[`Client::system_update_start`]: super::Client::system_update_start + #[derive(Debug, Clone)] + pub struct SystemUpdateStart<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> SystemUpdateStart<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + body: Err("body was not initialized".to_string()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `SystemUpdateStart` for body failed".to_string()); + self + } + + ///Sends a `POST` request to `/v1/system/update/start` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client, body } = self; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/system/update/start", client.baseurl,); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 202u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::system_update_stop`] + /// + ///[`Client::system_update_stop`]: super::Client::system_update_stop + #[derive(Debug, Clone)] + pub struct SystemUpdateStop<'a> { + client: &'a super::Client, + } + + impl<'a> SystemUpdateStop<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client } + } + + ///Sends a `POST` request to `/v1/system/update/stop` + pub async fn send(self) -> Result, Error> { + let Self { client } = self; + let url = format!("{}/v1/system/update/stop", client.baseurl,); + let request = client.client.post(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::system_update_list`] + /// + ///[`Client::system_update_list`]: super::Client::system_update_list + #[derive(Debug, Clone)] + pub struct SystemUpdateList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> SystemUpdateList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < std :: num :: NonZeroU32 >` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.page_token = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `Option < String >` for page_token failed".to_string()); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value.try_into().map(Some).map_err(|_| { + "conversion to `Option < IdSortMode >` for sort_by failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/v1/system/update/updates` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/system/update/updates", client.baseurl,); + let mut query = Vec::with_capacity(3usize); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/v1/system/update/updates` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + let next = Self { + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().map(Ok)); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`Client::system_update_view`] + /// + ///[`Client::system_update_view`]: super::Client::system_update_view + #[derive(Debug, Clone)] + pub struct SystemUpdateView<'a> { + client: &'a super::Client, + version: Result, + } + + impl<'a> SystemUpdateView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + version: Err("version was not initialized".to_string()), + } + } + + pub fn version(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.version = value + .try_into() + .map_err(|_| "conversion to `SemverVersion` for version failed".to_string()); + self + } + + ///Sends a `GET` request to `/v1/system/update/updates/{version}` + pub async fn send(self) -> Result, Error> { + let Self { client, version } = self; + let version = version.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/system/update/updates/{}", + client.baseurl, + encode_path(&version.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::system_update_components_list`] + /// + ///[`Client::system_update_components_list`]: super::Client::system_update_components_list + #[derive(Debug, Clone)] + pub struct SystemUpdateComponentsList<'a> { + client: &'a super::Client, + version: Result, + } + + impl<'a> SystemUpdateComponentsList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + version: Err("version was not initialized".to_string()), + } + } + + pub fn version(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.version = value + .try_into() + .map_err(|_| "conversion to `SemverVersion` for version failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/v1/system/update/updates/{version}/components` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client, version } = self; + let version = version.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/system/update/updates/{}/components", + client.baseurl, + encode_path(&version.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::system_version`] + /// + ///[`Client::system_version`]: super::Client::system_version + #[derive(Debug, Clone)] + pub struct SystemVersion<'a> { + client: &'a super::Client, + } + + impl<'a> SystemVersion<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client } + } + + ///Sends a `GET` request to `/v1/system/update/version` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client } = self; + let url = format!("{}/v1/system/update/version", client.baseurl,); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } } pub mod prelude { diff --git a/progenitor-impl/tests/output/nexus-positional.out b/progenitor-impl/tests/output/nexus-positional.out index a424c95..2380fb8 100644 --- a/progenitor-impl/tests/output/nexus-positional.out +++ b/progenitor-impl/tests/output/nexus-positional.out @@ -7,6 +7,14 @@ pub mod types { use serde::{Deserialize, Serialize}; #[allow(unused_imports)] use std::convert::TryFrom; + ///Describes properties that should uniquely identify a Gimlet. + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct Baseboard { + pub part: String, + pub revision: i64, + pub serial: String, + } + ///A type storing a range over `T`. /// ///This type supports ranges similar to the `RangeTo`, `Range` and @@ -65,7 +73,7 @@ pub mod types { pub range: BinRangeint64, } - #[derive(Clone, Debug, Deserialize, Serialize)] + #[derive(Clone, Debug, Serialize)] pub struct BlockSize(i64); impl std::ops::Deref for BlockSize { type Target = i64; @@ -85,6 +93,16 @@ pub mod types { } } + impl<'de> serde::Deserialize<'de> for BlockSize { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + Self::try_from(i64::deserialize(deserializer)?) + .map_err(|e| ::custom(e.to_string())) + } + } + ///A count of bytes, typically used either for memory or storage capacity /// ///The maximum supported byte count is [`i64::MAX`]. This makes it @@ -101,6 +119,70 @@ pub mod types { } } + ///Client view of a [`Certificate`] + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct Certificate { + ///human-readable free-form text about a resource + pub description: String, + ///unique, immutable, system-controlled identifier for each resource + pub id: uuid::Uuid, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + pub service: ServiceUsingCertificate, + ///timestamp when this resource was created + pub time_created: chrono::DateTime, + ///timestamp when this resource was last modified + pub time_modified: chrono::DateTime, + } + + ///Create-time parameters for a + /// [`Certificate`](crate::external_api::views::Certificate) + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct CertificateCreate { + ///PEM file containing public certificate chain + pub cert: Vec, + pub description: String, + ///PEM file containing private key + pub key: Vec, + pub name: Name, + ///The service using this certificate + pub service: ServiceUsingCertificate, + } + + ///A single page of results + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct CertificateResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + + ///Identity-related metadata that's included in "asset" public API objects + /// (which generally have no name or description) + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct ComponentUpdate { + pub component_type: UpdateableComponentType, + ///unique, immutable, system-controlled identifier for each resource + pub id: uuid::Uuid, + ///timestamp when this resource was created + pub time_created: chrono::DateTime, + ///timestamp when this resource was last modified + pub time_modified: chrono::DateTime, + pub version: SemverVersion, + } + + ///A single page of results + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct ComponentUpdateResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + ///A cumulative or counter data type. #[derive(Clone, Debug, Deserialize, Serialize)] pub struct Cumulativedouble { @@ -285,8 +367,9 @@ pub mod types { pub size: ByteCount, } - ///Parameters for the [`Disk`](omicron_common::api::external::Disk) to be - /// attached or detached to an instance + ///TODO-v1: Delete this Parameters for the + /// [`Disk`](omicron_common::api::external::Disk) to be attached or detached + /// to an instance #[derive(Clone, Debug, Deserialize, Serialize)] pub struct DiskIdentifier { pub name: Name, @@ -357,6 +440,11 @@ pub mod types { } } + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct DiskPath { + pub disk: NameOrId, + } + ///A single page of results #[derive(Clone, Debug, Deserialize, Serialize)] pub struct DiskResultsPage { @@ -688,7 +776,7 @@ pub mod types { } ///Create-time parameters for an - /// [`GlobalImage`](omicron_common::api::external::GlobalImage) + /// [`GlobalImage`](crate::external_api::views::GlobalImage) #[derive(Clone, Debug, Deserialize, Serialize)] pub struct GlobalImageCreate { ///block size in bytes @@ -711,6 +799,26 @@ pub mod types { pub next_page: Option, } + ///Client view of a [`Group`] + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct Group { + ///Human-readable name that can identify the group + pub display_name: String, + pub id: uuid::Uuid, + ///Uuid of the silo to which this group belongs + pub silo_id: uuid::Uuid, + } + + ///A single page of results + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct GroupResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + ///A simple type for managing a histogram metric. /// ///A histogram maintains the count of any number of samples, over a set of @@ -814,6 +922,7 @@ pub mod types { ///Currently, we only support scanning in ascending order. #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] pub enum IdSortMode { + ///sort in increasing order of "id" #[serde(rename = "id_ascending")] IdAscending, } @@ -886,6 +995,7 @@ pub mod types { #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] pub enum IdentityProviderType { + ///SAML identity provider #[serde(rename = "saml")] Saml, } @@ -934,12 +1044,15 @@ pub mod types { pub enum IdentityType { #[serde(rename = "silo_user")] SiloUser, + #[serde(rename = "silo_group")] + SiloGroup, } impl ToString for IdentityType { fn to_string(&self) -> String { match *self { Self::SiloUser => "silo_user".to_string(), + Self::SiloGroup => "silo_group".to_string(), } } } @@ -949,6 +1062,7 @@ pub mod types { fn from_str(value: &str) -> Result { match value { "silo_user" => Ok(Self::SiloUser), + "silo_group" => Ok(Self::SiloGroup), _ => Err("invalid value"), } } @@ -1015,7 +1129,7 @@ pub mod types { } ///Create-time parameters for an - /// [`Image`](omicron_common::api::external::Image) + /// [`Image`](crate::external_api::views::Image) #[derive(Clone, Debug, Deserialize, Serialize)] pub struct ImageCreate { ///block size in bytes @@ -1106,6 +1220,9 @@ pub mod types { ///The network interfaces to be created for this instance. #[serde(default = "defaults::instance_create_network_interfaces")] pub network_interfaces: InstanceNetworkInterfaceAttachment, + ///Should this instance be started upon creation; true by default. + #[serde(default = "defaults::default_bool::")] + pub start: bool, ///User data for instance initialization systems (such as cloud-init). /// Must be a Base64-encoded string, as specified in RFC 4648 § 4 (+ and /// / characters with padding). Maximum 32 KiB unencoded data. @@ -1187,24 +1304,38 @@ pub mod types { /// stopped, but also includes states related to the Instance's lifecycle #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] pub enum InstanceState { + ///The instance is being created. #[serde(rename = "creating")] Creating, + ///The instance is currently starting up. #[serde(rename = "starting")] Starting, + ///The instance is currently running. #[serde(rename = "running")] Running, + ///The instance has been requested to stop and a transition to + /// "Stopped" is imminent. #[serde(rename = "stopping")] Stopping, + ///The instance is currently stopped. #[serde(rename = "stopped")] Stopped, + ///The instance is in the process of rebooting - it will remain in the + /// "rebooting" state until the VM is starting once more. #[serde(rename = "rebooting")] Rebooting, + ///The instance is in the process of migrating - it will remain in the + /// "migrating" state until the migration process is complete and the + /// destination propolis is ready to continue execution. #[serde(rename = "migrating")] Migrating, + ///The instance is attempting to recover from a failure. #[serde(rename = "repairing")] Repairing, + ///The instance has encountered a failure. #[serde(rename = "failed")] Failed, + ///The instance has been deleted. #[serde(rename = "destroyed")] Destroyed, } @@ -1376,8 +1507,6 @@ pub mod types { pub id: uuid::Uuid, ///unique, mutable, user-controlled identifier for each resource pub name: Name, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub project_id: Option, ///timestamp when this resource was created pub time_created: chrono::DateTime, ///timestamp when this resource was last modified @@ -1386,15 +1515,11 @@ pub mod types { ///Create-time parameters for an IP Pool. /// - ///See [`IpPool`](omicron_nexus::external_api::views::IpPool) + ///See [`IpPool`](crate::external_api::views::IpPool) #[derive(Clone, Debug, Deserialize, Serialize)] pub struct IpPoolCreate { pub description: String, pub name: Name, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub organization: Option, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub project: Option, } #[derive(Clone, Debug, Deserialize, Serialize)] @@ -1453,7 +1578,7 @@ pub mod types { impl std::str::FromStr for Ipv4Net { type Err = &'static str; fn from_str(value: &str) -> Result { - if regress :: Regex :: new ("^(10\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\/([8-9]|1[0-9]|2[0-9]|3[0-2])|172\\.(1[6-9]|2[0-9]|3[0-1])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\/(1[2-9]|2[0-9]|3[0-2])|192\\.168\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\/(1[6-9]|2[0-9]|3[0-2]))$") . unwrap () . find (value) . is_none () { return Err ("doesn't match pattern \"^(10\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\/([8-9]|1[0-9]|2[0-9]|3[0-2])|172\\.(1[6-9]|2[0-9]|3[0-1])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\/(1[2-9]|2[0-9]|3[0-2])|192\\.168\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\/(1[6-9]|2[0-9]|3[0-2]))$\"") ; } + if regress :: Regex :: new ("^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/([8-9]|1[0-9]|2[0-9]|3[0-2])$") . unwrap () . find (value) . is_none () { return Err ("doesn't match pattern \"^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/([8-9]|1[0-9]|2[0-9]|3[0-2])$\"") ; } Ok(Self(value.to_string())) } } @@ -1755,13 +1880,66 @@ pub mod types { } } + #[derive(Clone, Debug, Deserialize, Serialize)] + #[serde(untagged)] + pub enum NameOrId { + Id(uuid::Uuid), + Name(Name), + } + + impl std::str::FromStr for NameOrId { + type Err = &'static str; + fn from_str(value: &str) -> Result { + if let Ok(v) = value.parse() { + Ok(Self::Id(v)) + } else if let Ok(v) = value.parse() { + Ok(Self::Name(v)) + } else { + Err("string conversion failed for all variants") + } + } + } + + impl std::convert::TryFrom<&str> for NameOrId { + type Error = &'static str; + fn try_from(value: &str) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom<&String> for NameOrId { + type Error = &'static str; + fn try_from(value: &String) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom for NameOrId { + type Error = &'static str; + fn try_from(value: String) -> Result { + value.parse() + } + } + + impl ToString for NameOrId { + fn to_string(&self) -> String { + match self { + Self::Id(x) => x.to_string(), + Self::Name(x) => x.to_string(), + } + } + } + ///Supported set of sort modes for scanning by name or id #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] pub enum NameOrIdSortMode { + ///sort in increasing order of "name" #[serde(rename = "name_ascending")] NameAscending, + ///sort in decreasing order of "name" #[serde(rename = "name_descending")] NameDescending, + ///sort in increasing order of "id" #[serde(rename = "id_ascending")] IdAscending, } @@ -1814,6 +1992,7 @@ pub mod types { ///Currently, we only support scanning in ascending order. #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] pub enum NameSortMode { + ///sort in increasing order of "name" #[serde(rename = "name_ascending")] NameAscending, } @@ -1920,6 +2099,8 @@ pub mod types { pub struct NetworkInterfaceUpdate { #[serde(default, skip_serializing_if = "Option::is_none")] pub description: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub name: Option, ///Make a secondary interface the instance's primary interface. /// ///If applied to a secondary interface, that interface will become the @@ -1932,9 +2113,22 @@ pub mod types { /// for an instance. Requests to change the primary interface into a /// secondary will return an error. #[serde(default)] - pub make_primary: bool, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub name: Option, + pub primary: bool, + } + + ///Unique name for a saga [`Node`] + /// + ///Each node requires a string name that's unique within its DAG. The name + /// is used to identify its output. Nodes that depend on a given node + /// (either directly or indirectly) can access the node's output using its + /// name. + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct NodeName(pub String); + impl std::ops::Deref for NodeName { + type Target = String; + fn deref(&self) -> &String { + &self.0 + } } ///Client view of an [`Organization`] @@ -2058,6 +2252,135 @@ pub mod types { pub name: Option, } + ///Passwords may be subject to additional constraints. + #[derive(Clone, Debug, Serialize)] + pub struct Password(String); + impl std::ops::Deref for Password { + type Target = String; + fn deref(&self) -> &String { + &self.0 + } + } + + impl std::str::FromStr for Password { + type Err = &'static str; + fn from_str(value: &str) -> Result { + if value.len() > 512usize { + return Err("longer than 512 characters"); + } + Ok(Self(value.to_string())) + } + } + + impl std::convert::TryFrom<&str> for Password { + type Error = &'static str; + fn try_from(value: &str) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom<&String> for Password { + type Error = &'static str; + fn try_from(value: &String) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom for Password { + type Error = &'static str; + fn try_from(value: String) -> Result { + value.parse() + } + } + + impl<'de> serde::Deserialize<'de> for Password { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + String::deserialize(deserializer)? + .parse() + .map_err(|e: &'static str| ::custom(e.to_string())) + } + } + + ///Client view of a [`PhysicalDisk`] + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct PhysicalDisk { + pub disk_type: PhysicalDiskType, + ///unique, immutable, system-controlled identifier for each resource + pub id: uuid::Uuid, + pub model: String, + pub serial: String, + ///The sled to which this disk is attached, if any. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub sled_id: Option, + ///timestamp when this resource was created + pub time_created: chrono::DateTime, + ///timestamp when this resource was last modified + pub time_modified: chrono::DateTime, + pub vendor: String, + } + + ///A single page of results + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct PhysicalDiskResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + + #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] + pub enum PhysicalDiskType { + #[serde(rename = "internal")] + Internal, + #[serde(rename = "external")] + External, + } + + impl ToString for PhysicalDiskType { + fn to_string(&self) -> String { + match *self { + Self::Internal => "internal".to_string(), + Self::External => "external".to_string(), + } + } + } + + impl std::str::FromStr for PhysicalDiskType { + type Err = &'static str; + fn from_str(value: &str) -> Result { + match value { + "internal" => Ok(Self::Internal), + "external" => Ok(Self::External), + _ => Err("invalid value"), + } + } + } + + impl std::convert::TryFrom<&str> for PhysicalDiskType { + type Error = &'static str; + fn try_from(value: &str) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom<&String> for PhysicalDiskType { + type Error = &'static str; + fn try_from(value: &String) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom for PhysicalDiskType { + type Error = &'static str; + fn try_from(value: String) -> Result { + value.parse() + } + } + ///Client view of a [`Project`] #[derive(Clone, Debug, Deserialize, Serialize)] pub struct Project { @@ -2360,12 +2683,25 @@ pub mod types { ///See [RFD-21](https://rfd.shared.oxide.computer/rfd/0021#concept-router) for more context #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] pub enum RouterRouteKind { + ///Determines the default destination of traffic, such as whether it + /// goes to the internet or not. + /// + ///`Destination: An Internet Gateway` `Modifiable: true` #[serde(rename = "default")] Default, + ///Automatically added for each VPC Subnet in the VPC + /// + ///`Destination: A VPC Subnet` `Modifiable: false` #[serde(rename = "vpc_subnet")] VpcSubnet, + ///Automatically added when VPC peering is established + /// + ///`Destination: A different VPC` `Modifiable: false` #[serde(rename = "vpc_peering")] VpcPeering, + ///Created by a user See [`RouteTarget`] + /// + ///`Destination: User defined` `Modifiable: true` #[serde(rename = "custom")] Custom, } @@ -2477,7 +2813,7 @@ pub mod types { #[serde(rename = "failed")] Failed { error_info: SagaErrorInfo, - error_node_name: String, + error_node_name: NodeName, }, } @@ -2517,6 +2853,11 @@ pub mod types { ///service provider endpoint where the response will be sent pub acs_url: String, pub description: String, + ///If set, SAML attributes with this name will be considered to denote + /// a user's group membership, where the attribute value(s) should be a + /// comma-separated list of group names. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub group_attribute_name: Option, ///idp's entity id pub idp_entity_id: String, ///the source of an identity provider metadata descriptor @@ -2533,6 +2874,108 @@ pub mod types { pub technical_contact_email: String, } + #[derive(Clone, Debug, Serialize)] + pub struct SemverVersion(String); + impl std::ops::Deref for SemverVersion { + type Target = String; + fn deref(&self) -> &String { + &self.0 + } + } + + impl std::str::FromStr for SemverVersion { + type Err = &'static str; + fn from_str(value: &str) -> Result { + if regress::Regex::new("^\\d+\\.\\d+\\.\\d+([\\-\\+].+)?$") + .unwrap() + .find(value) + .is_none() + { + return Err("doesn't match pattern \"^\\d+\\.\\d+\\.\\d+([\\-\\+].+)?$\""); + } + Ok(Self(value.to_string())) + } + } + + impl std::convert::TryFrom<&str> for SemverVersion { + type Error = &'static str; + fn try_from(value: &str) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom<&String> for SemverVersion { + type Error = &'static str; + fn try_from(value: &String) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom for SemverVersion { + type Error = &'static str; + fn try_from(value: String) -> Result { + value.parse() + } + } + + impl<'de> serde::Deserialize<'de> for SemverVersion { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + String::deserialize(deserializer)? + .parse() + .map_err(|e: &'static str| ::custom(e.to_string())) + } + } + + ///The service intended to use this certificate. + #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] + pub enum ServiceUsingCertificate { + ///This certificate is intended for access to the external API. + #[serde(rename = "external_api")] + ExternalApi, + } + + impl ToString for ServiceUsingCertificate { + fn to_string(&self) -> String { + match *self { + Self::ExternalApi => "external_api".to_string(), + } + } + } + + impl std::str::FromStr for ServiceUsingCertificate { + type Err = &'static str; + fn from_str(value: &str) -> Result { + match value { + "external_api" => Ok(Self::ExternalApi), + _ => Err("invalid value"), + } + } + } + + impl std::convert::TryFrom<&str> for ServiceUsingCertificate { + type Error = &'static str; + fn try_from(value: &str) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom<&String> for ServiceUsingCertificate { + type Error = &'static str; + fn try_from(value: &String) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom for ServiceUsingCertificate { + type Error = &'static str; + fn try_from(value: String) -> Result { + value.parse() + } + } + ///Client view of a ['Silo'] #[derive(Clone, Debug, Deserialize, Serialize)] pub struct Silo { @@ -2543,23 +2986,90 @@ pub mod types { pub discoverable: bool, ///unique, immutable, system-controlled identifier for each resource pub id: uuid::Uuid, + ///How users and groups are managed in this Silo + pub identity_mode: SiloIdentityMode, ///unique, mutable, user-controlled identifier for each resource pub name: Name, ///timestamp when this resource was created pub time_created: chrono::DateTime, ///timestamp when this resource was last modified pub time_modified: chrono::DateTime, - ///User provision type - pub user_provision_type: UserProvisionType, } ///Create-time parameters for a [`Silo`](crate::external_api::views::Silo) #[derive(Clone, Debug, Deserialize, Serialize)] pub struct SiloCreate { + ///If set, this group will be created during Silo creation and granted + /// the "Silo Admin" role. Identity providers can assert that users + /// belong to this group and those users can log in and further + /// initialize the Silo. + /// + ///Note that if configuring a SAML based identity provider, + /// group_attribute_name must be set for users to be considered part of + /// a group. See [`SamlIdentityProviderCreate`] for more information. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub admin_group_name: Option, pub description: String, pub discoverable: bool, + pub identity_mode: SiloIdentityMode, pub name: Name, - pub user_provision_type: UserProvisionType, + } + + ///Describes how identities are managed and users are authenticated in this + /// Silo + #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] + pub enum SiloIdentityMode { + ///Users are authenticated with SAML using an external authentication + /// provider. The system updates information about users and groups + /// only during successful authentication (i.e,. "JIT provisioning" of + /// users and groups). + #[serde(rename = "saml_jit")] + SamlJit, + ///The system is the source of truth about users. There is no linkage + /// to an external authentication provider or identity provider. + #[serde(rename = "local_only")] + LocalOnly, + } + + impl ToString for SiloIdentityMode { + fn to_string(&self) -> String { + match *self { + Self::SamlJit => "saml_jit".to_string(), + Self::LocalOnly => "local_only".to_string(), + } + } + } + + impl std::str::FromStr for SiloIdentityMode { + type Err = &'static str; + fn from_str(value: &str) -> Result { + match value { + "saml_jit" => Ok(Self::SamlJit), + "local_only" => Ok(Self::LocalOnly), + _ => Err("invalid value"), + } + } + } + + impl std::convert::TryFrom<&str> for SiloIdentityMode { + type Error = &'static str; + fn try_from(value: &str) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom<&String> for SiloIdentityMode { + type Error = &'static str; + fn try_from(value: &String) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom for SiloIdentityMode { + type Error = &'static str; + fn try_from(value: String) -> Result { + value.parse() + } } ///A single page of results @@ -2650,9 +3160,10 @@ pub mod types { pub role_name: SiloRole, } - ///Client view of an [`Sled`] + ///Client view of a [`Sled`] #[derive(Clone, Debug, Deserialize, Serialize)] pub struct Sled { + pub baseboard: Baseboard, ///unique, immutable, system-controlled identifier for each resource pub id: uuid::Uuid, pub service_address: String, @@ -2684,6 +3195,7 @@ pub mod types { pub name: Name, pub project_id: uuid::Uuid, pub size: ByteCount, + pub state: SnapshotState, ///timestamp when this resource was created pub time_created: chrono::DateTime, ///timestamp when this resource was last modified @@ -2691,7 +3203,7 @@ pub mod types { } ///Create-time parameters for a - /// [`Snapshot`](omicron_common::api::external::Snapshot) + /// [`Snapshot`](crate::external_api::views::Snapshot) #[derive(Clone, Debug, Deserialize, Serialize)] pub struct SnapshotCreate { pub description: String, @@ -2710,6 +3222,63 @@ pub mod types { pub next_page: Option, } + #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] + pub enum SnapshotState { + #[serde(rename = "creating")] + Creating, + #[serde(rename = "ready")] + Ready, + #[serde(rename = "faulted")] + Faulted, + #[serde(rename = "destroyed")] + Destroyed, + } + + impl ToString for SnapshotState { + fn to_string(&self) -> String { + match *self { + Self::Creating => "creating".to_string(), + Self::Ready => "ready".to_string(), + Self::Faulted => "faulted".to_string(), + Self::Destroyed => "destroyed".to_string(), + } + } + } + + impl std::str::FromStr for SnapshotState { + type Err = &'static str; + fn from_str(value: &str) -> Result { + match value { + "creating" => Ok(Self::Creating), + "ready" => Ok(Self::Ready), + "faulted" => Ok(Self::Faulted), + "destroyed" => Ok(Self::Destroyed), + _ => Err("invalid value"), + } + } + } + + impl std::convert::TryFrom<&str> for SnapshotState { + type Error = &'static str; + fn try_from(value: &str) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom<&String> for SnapshotState { + type Error = &'static str; + fn try_from(value: &String) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom for SnapshotState { + type Error = &'static str; + fn try_from(value: String) -> Result { + value.parse() + } + } + #[derive(Clone, Debug, Deserialize, Serialize)] pub struct SpoofLoginBody { pub username: String, @@ -2754,6 +3323,93 @@ pub mod types { pub next_page: Option, } + #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] + pub enum SystemMetricName { + #[serde(rename = "virtual_disk_space_provisioned")] + VirtualDiskSpaceProvisioned, + #[serde(rename = "cpus_provisioned")] + CpusProvisioned, + #[serde(rename = "ram_provisioned")] + RamProvisioned, + } + + impl ToString for SystemMetricName { + fn to_string(&self) -> String { + match *self { + Self::VirtualDiskSpaceProvisioned => "virtual_disk_space_provisioned".to_string(), + Self::CpusProvisioned => "cpus_provisioned".to_string(), + Self::RamProvisioned => "ram_provisioned".to_string(), + } + } + } + + impl std::str::FromStr for SystemMetricName { + type Err = &'static str; + fn from_str(value: &str) -> Result { + match value { + "virtual_disk_space_provisioned" => Ok(Self::VirtualDiskSpaceProvisioned), + "cpus_provisioned" => Ok(Self::CpusProvisioned), + "ram_provisioned" => Ok(Self::RamProvisioned), + _ => Err("invalid value"), + } + } + } + + impl std::convert::TryFrom<&str> for SystemMetricName { + type Error = &'static str; + fn try_from(value: &str) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom<&String> for SystemMetricName { + type Error = &'static str; + fn try_from(value: &String) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom for SystemMetricName { + type Error = &'static str; + fn try_from(value: String) -> Result { + value.parse() + } + } + + ///Identity-related metadata that's included in "asset" public API objects + /// (which generally have no name or description) + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct SystemUpdate { + ///unique, immutable, system-controlled identifier for each resource + pub id: uuid::Uuid, + ///timestamp when this resource was created + pub time_created: chrono::DateTime, + ///timestamp when this resource was last modified + pub time_modified: chrono::DateTime, + pub version: SemverVersion, + } + + ///A single page of results + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct SystemUpdateResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct SystemUpdateStart { + pub version: SemverVersion, + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct SystemVersion { + pub status: UpdateStatus, + pub version_range: VersionRange, + } + ///Names are constructed by concatenating the target and metric names with /// ':'. Target and metric names must be lowercase alphanumeric characters /// with '_' separating words. @@ -2836,12 +3492,204 @@ pub mod types { pub next_page: Option, } + ///Identity-related metadata that's included in "asset" public API objects + /// (which generally have no name or description) + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct UpdateDeployment { + ///unique, immutable, system-controlled identifier for each resource + pub id: uuid::Uuid, + pub status: UpdateStatus, + ///timestamp when this resource was created + pub time_created: chrono::DateTime, + ///timestamp when this resource was last modified + pub time_modified: chrono::DateTime, + pub version: SemverVersion, + } + + ///A single page of results + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct UpdateDeploymentResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + + #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] + #[serde(tag = "status")] + pub enum UpdateStatus { + #[serde(rename = "updating")] + Updating, + #[serde(rename = "steady")] + Steady, + } + + impl ToString for UpdateStatus { + fn to_string(&self) -> String { + match *self { + Self::Updating => "updating".to_string(), + Self::Steady => "steady".to_string(), + } + } + } + + impl std::str::FromStr for UpdateStatus { + type Err = &'static str; + fn from_str(value: &str) -> Result { + match value { + "updating" => Ok(Self::Updating), + "steady" => Ok(Self::Steady), + _ => Err("invalid value"), + } + } + } + + impl std::convert::TryFrom<&str> for UpdateStatus { + type Error = &'static str; + fn try_from(value: &str) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom<&String> for UpdateStatus { + type Error = &'static str; + fn try_from(value: &String) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom for UpdateStatus { + type Error = &'static str; + fn try_from(value: String) -> Result { + value.parse() + } + } + + ///Identity-related metadata that's included in "asset" public API objects + /// (which generally have no name or description) + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct UpdateableComponent { + pub component_type: UpdateableComponentType, + pub device_id: String, + ///unique, immutable, system-controlled identifier for each resource + pub id: uuid::Uuid, + pub status: UpdateStatus, + pub system_version: SemverVersion, + ///timestamp when this resource was created + pub time_created: chrono::DateTime, + ///timestamp when this resource was last modified + pub time_modified: chrono::DateTime, + pub version: SemverVersion, + } + + ///A single page of results + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct UpdateableComponentResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + + #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] + pub enum UpdateableComponentType { + #[serde(rename = "bootloader_for_rot")] + BootloaderForRot, + #[serde(rename = "bootloader_for_sp")] + BootloaderForSp, + #[serde(rename = "bootloader_for_host_proc")] + BootloaderForHostProc, + #[serde(rename = "hubris_for_psc_rot")] + HubrisForPscRot, + #[serde(rename = "hubris_for_psc_sp")] + HubrisForPscSp, + #[serde(rename = "hubris_for_sidecar_rot")] + HubrisForSidecarRot, + #[serde(rename = "hubris_for_sidecar_sp")] + HubrisForSidecarSp, + #[serde(rename = "hubris_for_gimlet_rot")] + HubrisForGimletRot, + #[serde(rename = "hubris_for_gimlet_sp")] + HubrisForGimletSp, + #[serde(rename = "helios_host_phase1")] + HeliosHostPhase1, + #[serde(rename = "helios_host_phase2")] + HeliosHostPhase2, + #[serde(rename = "host_omicron")] + HostOmicron, + } + + impl ToString for UpdateableComponentType { + fn to_string(&self) -> String { + match *self { + Self::BootloaderForRot => "bootloader_for_rot".to_string(), + Self::BootloaderForSp => "bootloader_for_sp".to_string(), + Self::BootloaderForHostProc => "bootloader_for_host_proc".to_string(), + Self::HubrisForPscRot => "hubris_for_psc_rot".to_string(), + Self::HubrisForPscSp => "hubris_for_psc_sp".to_string(), + Self::HubrisForSidecarRot => "hubris_for_sidecar_rot".to_string(), + Self::HubrisForSidecarSp => "hubris_for_sidecar_sp".to_string(), + Self::HubrisForGimletRot => "hubris_for_gimlet_rot".to_string(), + Self::HubrisForGimletSp => "hubris_for_gimlet_sp".to_string(), + Self::HeliosHostPhase1 => "helios_host_phase1".to_string(), + Self::HeliosHostPhase2 => "helios_host_phase2".to_string(), + Self::HostOmicron => "host_omicron".to_string(), + } + } + } + + impl std::str::FromStr for UpdateableComponentType { + type Err = &'static str; + fn from_str(value: &str) -> Result { + match value { + "bootloader_for_rot" => Ok(Self::BootloaderForRot), + "bootloader_for_sp" => Ok(Self::BootloaderForSp), + "bootloader_for_host_proc" => Ok(Self::BootloaderForHostProc), + "hubris_for_psc_rot" => Ok(Self::HubrisForPscRot), + "hubris_for_psc_sp" => Ok(Self::HubrisForPscSp), + "hubris_for_sidecar_rot" => Ok(Self::HubrisForSidecarRot), + "hubris_for_sidecar_sp" => Ok(Self::HubrisForSidecarSp), + "hubris_for_gimlet_rot" => Ok(Self::HubrisForGimletRot), + "hubris_for_gimlet_sp" => Ok(Self::HubrisForGimletSp), + "helios_host_phase1" => Ok(Self::HeliosHostPhase1), + "helios_host_phase2" => Ok(Self::HeliosHostPhase2), + "host_omicron" => Ok(Self::HostOmicron), + _ => Err("invalid value"), + } + } + } + + impl std::convert::TryFrom<&str> for UpdateableComponentType { + type Error = &'static str; + fn try_from(value: &str) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom<&String> for UpdateableComponentType { + type Error = &'static str; + fn try_from(value: &String) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom for UpdateableComponentType { + type Error = &'static str; + fn try_from(value: String) -> Result { + value.parse() + } + } + ///Client view of a [`User`] #[derive(Clone, Debug, Deserialize, Serialize)] pub struct User { ///Human-readable name that can identify the user pub display_name: String, pub id: uuid::Uuid, + ///Uuid of the silo to which this user belongs + pub silo_id: uuid::Uuid, } ///Client view of a [`UserBuiltin`] @@ -2869,56 +3717,81 @@ pub mod types { pub next_page: Option, } - ///How users will be provisioned in a silo during authentication. - #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] - pub enum UserProvisionType { - #[serde(rename = "fixed")] - Fixed, - #[serde(rename = "jit")] - Jit, + ///Create-time parameters for a [`User`](crate::external_api::views::User) + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct UserCreate { + ///username used to log in + pub external_id: UserId, + ///password used to log in + pub password: UserPassword, } - impl ToString for UserProvisionType { - fn to_string(&self) -> String { - match *self { - Self::Fixed => "fixed".to_string(), - Self::Jit => "jit".to_string(), - } + ///Names must begin with a lower case ASCII letter, be composed exclusively + /// of lowercase ASCII, uppercase ASCII, numbers, and '-', and may not end + /// with a '-'. Names cannot be a UUID though they may contain a UUID. + #[derive(Clone, Debug, Serialize)] + pub struct UserId(String); + impl std::ops::Deref for UserId { + type Target = String; + fn deref(&self) -> &String { + &self.0 } } - impl std::str::FromStr for UserProvisionType { + impl std::str::FromStr for UserId { type Err = &'static str; fn from_str(value: &str) -> Result { - match value { - "fixed" => Ok(Self::Fixed), - "jit" => Ok(Self::Jit), - _ => Err("invalid value"), + if value.len() > 63usize { + return Err("longer than 63 characters"); } + if regress :: Regex :: new ("^(?![0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$)^[a-z][a-z0-9-]*[a-zA-Z0-9]$") . unwrap () . find (value) . is_none () { return Err ("doesn't match pattern \"^(?![0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$)^[a-z][a-z0-9-]*[a-zA-Z0-9]$\"") ; } + Ok(Self(value.to_string())) } } - impl std::convert::TryFrom<&str> for UserProvisionType { + impl std::convert::TryFrom<&str> for UserId { type Error = &'static str; fn try_from(value: &str) -> Result { value.parse() } } - impl std::convert::TryFrom<&String> for UserProvisionType { + impl std::convert::TryFrom<&String> for UserId { type Error = &'static str; fn try_from(value: &String) -> Result { value.parse() } } - impl std::convert::TryFrom for UserProvisionType { + impl std::convert::TryFrom for UserId { type Error = &'static str; fn try_from(value: String) -> Result { value.parse() } } + impl<'de> serde::Deserialize<'de> for UserId { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + String::deserialize(deserializer)? + .parse() + .map_err(|e: &'static str| ::custom(e.to_string())) + } + } + + ///Parameters for setting a user's password + #[derive(Clone, Debug, Deserialize, Serialize)] + #[serde(tag = "user_password_value", content = "details")] + pub enum UserPassword { + ///Sets the user's password to the provided value + #[serde(rename = "password")] + Password(Password), + #[serde(rename = "invalid_password")] + InvalidPassword, + } + ///A single page of results #[derive(Clone, Debug, Deserialize, Serialize)] pub struct UserResultsPage { @@ -2929,6 +3802,19 @@ pub mod types { pub next_page: Option, } + ///Credentials for local user login + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct UsernamePasswordCredentials { + pub password: Password, + pub username: UserId, + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct VersionRange { + pub high: SemverVersion, + pub low: SemverVersion, + } + ///Client view of a [`Vpc`] #[derive(Clone, Debug, Deserialize, Serialize)] pub struct Vpc { @@ -3288,7 +4174,7 @@ pub mod types { pub rules: Vec, } - ///Collection of a [`Vpc`]'s firewall rules + ///Collection of a Vpc's firewall rules #[derive(Clone, Debug, Deserialize, Serialize)] pub struct VpcFirewallRules { pub rules: Vec, @@ -3476,6 +4362,10 @@ pub mod types { } mod defaults { + pub(super) fn default_bool() -> bool { + V + } + pub(super) fn instance_create_network_interfaces( ) -> super::InstanceNetworkInterfaceAttachment { super::InstanceNetworkInterfaceAttachment::Default @@ -3533,7 +4423,9 @@ impl Client { } impl Client { - ///Get a disk by id + ///Fetch a disk by id + /// + ///Use `GET /v1/disks/{disk}` instead /// ///Sends a `GET` request to `/by-id/disks/{id}` pub async fn disk_view_by_id<'a>( @@ -3560,33 +4452,6 @@ impl Client { } } - ///Get a global image by id - /// - ///Sends a `GET` request to `/by-id/global-images/{id}` - pub async fn image_global_view_by_id<'a>( - &'a self, - id: &'a uuid::Uuid, - ) -> Result, Error> { - let url = format!( - "{}/by-id/global-images/{}", - self.baseurl, - encode_path(&id.to_string()), - ); - let request = self.client.get(url).build()?; - let result = self.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 200u16 => ResponseValue::from_response(response).await, - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - ///Fetch an image by id /// ///Sends a `GET` request to `/by-id/images/{id}` @@ -3614,7 +4479,7 @@ impl Client { } } - ///Get an instance by id + ///Fetch an instance by id /// ///Sends a `GET` request to `/by-id/instances/{id}` pub async fn instance_view_by_id<'a>( @@ -3641,7 +4506,7 @@ impl Client { } } - ///Get an instance's network interface by id + ///Fetch a network interface by id /// ///Sends a `GET` request to `/by-id/network-interfaces/{id}` pub async fn instance_network_interface_view_by_id<'a>( @@ -3668,7 +4533,9 @@ impl Client { } } - ///Get an organization by id + ///Fetch an organization by id + /// + ///Use `GET /v1/organizations/{organization}` instead /// ///Sends a `GET` request to `/by-id/organizations/{id}` pub async fn organization_view_by_id<'a>( @@ -3695,7 +4562,9 @@ impl Client { } } - ///Get a project by id + ///Fetch a project by id + /// + ///Use `GET /v1/projects/{project}` instead /// ///Sends a `GET` request to `/by-id/projects/{id}` pub async fn project_view_by_id<'a>( @@ -3722,7 +4591,7 @@ impl Client { } } - ///Get a snapshot by id + ///Fetch a snapshot by id /// ///Sends a `GET` request to `/by-id/snapshots/{id}` pub async fn snapshot_view_by_id<'a>( @@ -3749,7 +4618,7 @@ impl Client { } } - ///Get a vpc router route by id + ///Fetch a route by id /// ///Sends a `GET` request to `/by-id/vpc-router-routes/{id}` pub async fn vpc_router_route_view_by_id<'a>( @@ -3776,7 +4645,7 @@ impl Client { } } - ///Get a VPC Router by id + ///Get a router by id /// ///Sends a `GET` request to `/by-id/vpc-routers/{id}` pub async fn vpc_router_view_by_id<'a>( @@ -3803,7 +4672,7 @@ impl Client { } } - ///Get a VPC subnet by id + ///Fetch a subnet by id /// ///Sends a `GET` request to `/by-id/vpc-subnets/{id}` pub async fn vpc_subnet_view_by_id<'a>( @@ -3830,7 +4699,7 @@ impl Client { } } - ///Get a VPC by id + ///Fetch a VPC /// ///Sends a `GET` request to `/by-id/vpcs/{id}` pub async fn vpc_view_by_id<'a>( @@ -3926,22 +4795,22 @@ impl Client { } } - ///List racks in the system + ///List groups /// - ///Sends a `GET` request to `/hardware/racks` + ///Sends a `GET` request to `/groups` /// ///Arguments: /// - `limit`: Maximum number of items returned by a single call /// - `page_token`: Token returned by previous call to retrieve the /// subsequent page /// - `sort_by` - pub async fn rack_list<'a>( + pub async fn group_list<'a>( &'a self, limit: Option, page_token: Option<&'a str>, sort_by: Option, - ) -> Result, Error> { - let url = format!("{}/hardware/racks", self.baseurl,); + ) -> Result, Error> { + let url = format!("{}/groups", self.baseurl,); let mut query = Vec::with_capacity(3usize); if let Some(v) = &limit { query.push(("limit", v.to_string())); @@ -3970,262 +4839,23 @@ impl Client { } } - ///List racks in the system as a Stream + ///List groups as a Stream /// - ///Sends repeated `GET` requests to `/hardware/racks` until there are no - /// more results. - /// - ///Arguments: - /// - `limit`: Maximum number of items returned by a single call - /// - `sort_by` - pub fn rack_list_stream<'a>( - &'a self, - limit: Option, - sort_by: Option, - ) -> impl futures::Stream>> + Unpin + '_ { - use futures::StreamExt; - use futures::TryFutureExt; - use futures::TryStreamExt; - self.rack_list(limit, None, sort_by) - .map_ok(move |page| { - let page = page.into_inner(); - let first = futures::stream::iter(page.items.into_iter().map(Ok)); - let rest = futures::stream::try_unfold(page.next_page, move |state| async move { - if state.is_none() { - Ok(None) - } else { - self.rack_list(None, state.as_deref(), None) - .map_ok(|page| { - let page = page.into_inner(); - Some(( - futures::stream::iter(page.items.into_iter().map(Ok)), - page.next_page, - )) - }) - .await - } - }) - .try_flatten(); - first.chain(rest) - }) - .try_flatten_stream() - .boxed() - } - - ///Fetch information about a particular rack - /// - ///Sends a `GET` request to `/hardware/racks/{rack_id}` - /// - ///Arguments: - /// - `rack_id`: The rack's unique ID. - pub async fn rack_view<'a>( - &'a self, - rack_id: &'a uuid::Uuid, - ) -> Result, Error> { - let url = format!( - "{}/hardware/racks/{}", - self.baseurl, - encode_path(&rack_id.to_string()), - ); - let request = self.client.get(url).build()?; - let result = self.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 200u16 => ResponseValue::from_response(response).await, - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - - ///List sleds in the system - /// - ///Sends a `GET` request to `/hardware/sleds` - /// - ///Arguments: - /// - `limit`: Maximum number of items returned by a single call - /// - `page_token`: Token returned by previous call to retrieve the - /// subsequent page - /// - `sort_by` - pub async fn sled_list<'a>( - &'a self, - limit: Option, - page_token: Option<&'a str>, - sort_by: Option, - ) -> Result, Error> { - let url = format!("{}/hardware/sleds", self.baseurl,); - let mut query = Vec::with_capacity(3usize); - if let Some(v) = &limit { - query.push(("limit", v.to_string())); - } - - if let Some(v) = &page_token { - query.push(("page_token", v.to_string())); - } - - if let Some(v) = &sort_by { - query.push(("sort_by", v.to_string())); - } - - let request = self.client.get(url).query(&query).build()?; - let result = self.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 200u16 => ResponseValue::from_response(response).await, - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - - ///List sleds in the system as a Stream - /// - ///Sends repeated `GET` requests to `/hardware/sleds` until there are no - /// more results. - /// - ///Arguments: - /// - `limit`: Maximum number of items returned by a single call - /// - `sort_by` - pub fn sled_list_stream<'a>( - &'a self, - limit: Option, - sort_by: Option, - ) -> impl futures::Stream>> + Unpin + '_ { - use futures::StreamExt; - use futures::TryFutureExt; - use futures::TryStreamExt; - self.sled_list(limit, None, sort_by) - .map_ok(move |page| { - let page = page.into_inner(); - let first = futures::stream::iter(page.items.into_iter().map(Ok)); - let rest = futures::stream::try_unfold(page.next_page, move |state| async move { - if state.is_none() { - Ok(None) - } else { - self.sled_list(None, state.as_deref(), None) - .map_ok(|page| { - let page = page.into_inner(); - Some(( - futures::stream::iter(page.items.into_iter().map(Ok)), - page.next_page, - )) - }) - .await - } - }) - .try_flatten(); - first.chain(rest) - }) - .try_flatten_stream() - .boxed() - } - - ///Fetch information about a sled in the system - /// - ///Sends a `GET` request to `/hardware/sleds/{sled_id}` - /// - ///Arguments: - /// - `sled_id`: The sled's unique ID. - pub async fn sled_view<'a>( - &'a self, - sled_id: &'a uuid::Uuid, - ) -> Result, Error> { - let url = format!( - "{}/hardware/sleds/{}", - self.baseurl, - encode_path(&sled_id.to_string()), - ); - let request = self.client.get(url).build()?; - let result = self.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 200u16 => ResponseValue::from_response(response).await, - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - - ///List global images - /// - ///Returns a list of all the global images. Global images are returned - /// sorted by creation date, with the most recent images appearing first. - /// - ///Sends a `GET` request to `/images` - /// - ///Arguments: - /// - `limit`: Maximum number of items returned by a single call - /// - `page_token`: Token returned by previous call to retrieve the - /// subsequent page - /// - `sort_by` - pub async fn image_global_list<'a>( - &'a self, - limit: Option, - page_token: Option<&'a str>, - sort_by: Option, - ) -> Result, Error> { - let url = format!("{}/images", self.baseurl,); - let mut query = Vec::with_capacity(3usize); - if let Some(v) = &limit { - query.push(("limit", v.to_string())); - } - - if let Some(v) = &page_token { - query.push(("page_token", v.to_string())); - } - - if let Some(v) = &sort_by { - query.push(("sort_by", v.to_string())); - } - - let request = self.client.get(url).query(&query).build()?; - let result = self.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 200u16 => ResponseValue::from_response(response).await, - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - - ///List global images as a Stream - /// - ///Returns a list of all the global images. Global images are returned - /// sorted by creation date, with the most recent images appearing first. - /// - ///Sends repeated `GET` requests to `/images` until there are no more + ///Sends repeated `GET` requests to `/groups` until there are no more /// results. /// ///Arguments: /// - `limit`: Maximum number of items returned by a single call /// - `sort_by` - pub fn image_global_list_stream<'a>( + pub fn group_list_stream<'a>( &'a self, limit: Option, - sort_by: Option, - ) -> impl futures::Stream>> + Unpin + '_ - { + sort_by: Option, + ) -> impl futures::Stream>> + Unpin + '_ { use futures::StreamExt; use futures::TryFutureExt; use futures::TryStreamExt; - self.image_global_list(limit, None, sort_by) + self.group_list(limit, None, sort_by) .map_ok(move |page| { let page = page.into_inner(); let first = futures::stream::iter(page.items.into_iter().map(Ok)); @@ -4233,7 +4863,7 @@ impl Client { if state.is_none() { Ok(None) } else { - self.image_global_list(None, state.as_deref(), None) + self.group_list(None, state.as_deref(), None) .map_ok(|page| { let page = page.into_inner(); Some(( @@ -4251,458 +4881,68 @@ impl Client { .boxed() } - ///Create a global image - /// - ///Create a new global image. This image can then be used by any user as a - /// base for instances. - /// - ///Sends a `POST` request to `/images` - pub async fn image_global_create<'a>( - &'a self, - body: &'a types::GlobalImageCreate, - ) -> Result, Error> { - let url = format!("{}/images", self.baseurl,); - let request = self.client.post(url).json(&body).build()?; - let result = self.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 201u16 => ResponseValue::from_response(response).await, - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - - ///Get a global image - /// - ///Returns the details of a specific global image. - /// - ///Sends a `GET` request to `/images/{image_name}` - pub async fn image_global_view<'a>( - &'a self, - image_name: &'a types::Name, - ) -> Result, Error> { - let url = format!( - "{}/images/{}", - self.baseurl, - encode_path(&image_name.to_string()), - ); - let request = self.client.get(url).build()?; - let result = self.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 200u16 => ResponseValue::from_response(response).await, - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - - ///Delete a global image - /// - ///Permanently delete a global image. This operation cannot be undone. Any - /// instances using the global image will continue to run, however new - /// instances can not be created with this image. - /// - ///Sends a `DELETE` request to `/images/{image_name}` - pub async fn image_global_delete<'a>( - &'a self, - image_name: &'a types::Name, - ) -> Result, Error> { - let url = format!( - "{}/images/{}", - self.baseurl, - encode_path(&image_name.to_string()), - ); - let request = self.client.delete(url).build()?; - let result = self.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 204u16 => Ok(ResponseValue::empty(response)), - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - - ///List IP Pools - /// - ///Sends a `GET` request to `/ip-pools` - /// - ///Arguments: - /// - `limit`: Maximum number of items returned by a single call - /// - `page_token`: Token returned by previous call to retrieve the - /// subsequent page - /// - `sort_by` - pub async fn ip_pool_list<'a>( - &'a self, - limit: Option, - page_token: Option<&'a str>, - sort_by: Option, - ) -> Result, Error> { - let url = format!("{}/ip-pools", self.baseurl,); - let mut query = Vec::with_capacity(3usize); - if let Some(v) = &limit { - query.push(("limit", v.to_string())); - } - - if let Some(v) = &page_token { - query.push(("page_token", v.to_string())); - } - - if let Some(v) = &sort_by { - query.push(("sort_by", v.to_string())); - } - - let request = self.client.get(url).query(&query).build()?; - let result = self.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 200u16 => ResponseValue::from_response(response).await, - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - - ///List IP Pools as a Stream - /// - ///Sends repeated `GET` requests to `/ip-pools` until there are no more - /// results. - /// - ///Arguments: - /// - `limit`: Maximum number of items returned by a single call - /// - `sort_by` - pub fn ip_pool_list_stream<'a>( - &'a self, - limit: Option, - sort_by: Option, - ) -> impl futures::Stream>> + Unpin + '_ { - use futures::StreamExt; - use futures::TryFutureExt; - use futures::TryStreamExt; - self.ip_pool_list(limit, None, sort_by) - .map_ok(move |page| { - let page = page.into_inner(); - let first = futures::stream::iter(page.items.into_iter().map(Ok)); - let rest = futures::stream::try_unfold(page.next_page, move |state| async move { - if state.is_none() { - Ok(None) - } else { - self.ip_pool_list(None, state.as_deref(), None) - .map_ok(|page| { - let page = page.into_inner(); - Some(( - futures::stream::iter(page.items.into_iter().map(Ok)), - page.next_page, - )) - }) - .await - } - }) - .try_flatten(); - first.chain(rest) - }) - .try_flatten_stream() - .boxed() - } - - ///Create a new IP Pool - /// - ///Sends a `POST` request to `/ip-pools` - pub async fn ip_pool_create<'a>( - &'a self, - body: &'a types::IpPoolCreate, - ) -> Result, Error> { - let url = format!("{}/ip-pools", self.baseurl,); - let request = self.client.post(url).json(&body).build()?; - let result = self.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 201u16 => ResponseValue::from_response(response).await, - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - - ///Fetch a single IP Pool - /// - ///Sends a `GET` request to `/ip-pools/{pool_name}` - pub async fn ip_pool_view<'a>( - &'a self, - pool_name: &'a types::Name, - ) -> Result, Error> { - let url = format!( - "{}/ip-pools/{}", - self.baseurl, - encode_path(&pool_name.to_string()), - ); - let request = self.client.get(url).build()?; - let result = self.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 200u16 => ResponseValue::from_response(response).await, - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - - ///Update an IP Pool - /// - ///Sends a `PUT` request to `/ip-pools/{pool_name}` - pub async fn ip_pool_update<'a>( - &'a self, - pool_name: &'a types::Name, - body: &'a types::IpPoolUpdate, - ) -> Result, Error> { - let url = format!( - "{}/ip-pools/{}", - self.baseurl, - encode_path(&pool_name.to_string()), - ); - let request = self.client.put(url).json(&body).build()?; - let result = self.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 200u16 => ResponseValue::from_response(response).await, - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - - ///Delete an IP Pool - /// - ///Sends a `DELETE` request to `/ip-pools/{pool_name}` - pub async fn ip_pool_delete<'a>( - &'a self, - pool_name: &'a types::Name, - ) -> Result, Error> { - let url = format!( - "{}/ip-pools/{}", - self.baseurl, - encode_path(&pool_name.to_string()), - ); - let request = self.client.delete(url).build()?; - let result = self.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 204u16 => Ok(ResponseValue::empty(response)), - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - - ///List the ranges of IP addresses within an existing IP Pool - /// - ///Note that ranges are listed sorted by their first address. - /// - ///Sends a `GET` request to `/ip-pools/{pool_name}/ranges` - /// - ///Arguments: - /// - `pool_name` - /// - `limit`: Maximum number of items returned by a single call - /// - `page_token`: Token returned by previous call to retrieve the - /// subsequent page - pub async fn ip_pool_range_list<'a>( - &'a self, - pool_name: &'a types::Name, - limit: Option, - page_token: Option<&'a str>, - ) -> Result, Error> { - let url = format!( - "{}/ip-pools/{}/ranges", - self.baseurl, - encode_path(&pool_name.to_string()), - ); - let mut query = Vec::with_capacity(2usize); - if let Some(v) = &limit { - query.push(("limit", v.to_string())); - } - - if let Some(v) = &page_token { - query.push(("page_token", v.to_string())); - } - - let request = self.client.get(url).query(&query).build()?; - let result = self.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 200u16 => ResponseValue::from_response(response).await, - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - - ///List the ranges of IP addresses within an existing IP Pool as a Stream - /// - ///Note that ranges are listed sorted by their first address. - /// - ///Sends repeated `GET` requests to `/ip-pools/{pool_name}/ranges` until - /// there are no more results. - /// - ///Arguments: - /// - `pool_name` - /// - `limit`: Maximum number of items returned by a single call - pub fn ip_pool_range_list_stream<'a>( - &'a self, - pool_name: &'a types::Name, - limit: Option, - ) -> impl futures::Stream>> + Unpin + '_ - { - use futures::StreamExt; - use futures::TryFutureExt; - use futures::TryStreamExt; - self.ip_pool_range_list(pool_name, limit, None) - .map_ok(move |page| { - let page = page.into_inner(); - let first = futures::stream::iter(page.items.into_iter().map(Ok)); - let rest = futures::stream::try_unfold(page.next_page, move |state| async move { - if state.is_none() { - Ok(None) - } else { - self.ip_pool_range_list(pool_name, None, state.as_deref()) - .map_ok(|page| { - let page = page.into_inner(); - Some(( - futures::stream::iter(page.items.into_iter().map(Ok)), - page.next_page, - )) - }) - .await - } - }) - .try_flatten(); - first.chain(rest) - }) - .try_flatten_stream() - .boxed() - } - - ///Add a new range to an existing IP Pool - /// - ///Sends a `POST` request to `/ip-pools/{pool_name}/ranges/add` - pub async fn ip_pool_range_add<'a>( - &'a self, - pool_name: &'a types::Name, - body: &'a types::IpRange, - ) -> Result, Error> { - let url = format!( - "{}/ip-pools/{}/ranges/add", - self.baseurl, - encode_path(&pool_name.to_string()), - ); - let request = self.client.post(url).json(&body).build()?; - let result = self.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 201u16 => ResponseValue::from_response(response).await, - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - - ///Remove a range from an existing IP Pool - /// - ///Sends a `POST` request to `/ip-pools/{pool_name}/ranges/remove` - pub async fn ip_pool_range_remove<'a>( - &'a self, - pool_name: &'a types::Name, - body: &'a types::IpRange, - ) -> Result, Error> { - let url = format!( - "{}/ip-pools/{}/ranges/remove", - self.baseurl, - encode_path(&pool_name.to_string()), - ); - let request = self.client.post(url).json(&body).build()?; - let result = self.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 204u16 => Ok(ResponseValue::empty(response)), - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - ///Sends a `POST` request to `/login` - pub async fn spoof_login<'a>( + pub async fn login_spoof<'a>( &'a self, body: &'a types::SpoofLoginBody, - ) -> Result, Error> { + ) -> Result, Error> { let url = format!("{}/login", self.baseurl,); let request = self.client.post(url).json(&body).build()?; let result = self.client.execute(request).await; let response = result?; match response.status().as_u16() { - 200..=299 => Ok(ResponseValue::stream(response)), - _ => Err(Error::ErrorResponse(ResponseValue::stream(response))), + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), } } - ///Ask the user to login to their identity provider + ///Authenticate a user (i.e., log in) via username and password + /// + ///Sends a `POST` request to `/login/{silo_name}/local` + pub async fn login_local<'a>( + &'a self, + silo_name: &'a types::Name, + body: &'a types::UsernamePasswordCredentials, + ) -> Result, Error> { + let url = format!( + "{}/login/{}/local", + self.baseurl, + encode_path(&silo_name.to_string()), + ); + let request = self.client.post(url).json(&body).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200..=299 => Ok(ResponseValue::stream(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Prompt user login /// ///Either display a page asking a user for their credentials, or redirect /// them to their identity provider. /// - ///Sends a `GET` request to `/login/{silo_name}/{provider_name}` - pub async fn login<'a>( + ///Sends a `GET` request to `/login/{silo_name}/saml/{provider_name}` + pub async fn login_saml_begin<'a>( &'a self, silo_name: &'a types::Name, provider_name: &'a types::Name, - ) -> Result, Error> { + ) -> Result, Error> { let url = format!( - "{}/login/{}/{}", + "{}/login/{}/saml/{}", self.baseurl, encode_path(&silo_name.to_string()), encode_path(&provider_name.to_string()), @@ -4712,25 +4952,27 @@ impl Client { let response = result?; match response.status().as_u16() { 200..=299 => Ok(ResponseValue::stream(response)), - _ => Err(Error::ErrorResponse(ResponseValue::stream(response))), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), } } - ///Consume some sort of credentials, and authenticate a user + ///Authenticate a user (i.e., log in) via SAML /// - ///Either receive a username and password, or some sort of identity - /// provider data (like a SAMLResponse). Use these to set the user's session - /// cookie. - /// - ///Sends a `POST` request to `/login/{silo_name}/{provider_name}` - pub async fn consume_credentials<'a, B: Into>( + ///Sends a `POST` request to `/login/{silo_name}/saml/{provider_name}` + pub async fn login_saml<'a, B: Into>( &'a self, silo_name: &'a types::Name, provider_name: &'a types::Name, body: B, - ) -> Result, Error> { + ) -> Result, Error> { let url = format!( - "{}/login/{}/{}", + "{}/login/{}/saml/{}", self.baseurl, encode_path(&silo_name.to_string()), encode_path(&provider_name.to_string()), @@ -4748,23 +4990,37 @@ impl Client { let response = result?; match response.status().as_u16() { 200..=299 => Ok(ResponseValue::stream(response)), - _ => Err(Error::ErrorResponse(ResponseValue::stream(response))), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), } } ///Sends a `POST` request to `/logout` - pub async fn logout<'a>(&'a self) -> Result, Error> { + pub async fn logout<'a>(&'a self) -> Result, Error> { let url = format!("{}/logout", self.baseurl,); let request = self.client.post(url).build()?; let result = self.client.execute(request).await; let response = result?; match response.status().as_u16() { - 200..=299 => Ok(ResponseValue::stream(response)), - _ => Err(Error::ErrorResponse(ResponseValue::stream(response))), + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), } } - ///List all organizations + ///List organizations + /// + ///Use `GET /v1/organizations` instead /// ///Sends a `GET` request to `/organizations` /// @@ -4808,7 +5064,9 @@ impl Client { } } - ///List all organizations as a Stream + ///List organizations as a Stream + /// + ///Use `GET /v1/organizations` instead /// ///Sends repeated `GET` requests to `/organizations` until there are no /// more results. @@ -4851,7 +5109,9 @@ impl Client { .boxed() } - ///Create a new organization + ///Create an organization + /// + ///Use `POST /v1/organizations` instead /// ///Sends a `POST` request to `/organizations` pub async fn organization_create<'a>( @@ -4874,7 +5134,9 @@ impl Client { } } - ///Fetch a specific organization + ///Fetch an organization + /// + ///Use `GET /v1/organizations/{organization}` instead /// ///Sends a `GET` request to `/organizations/{organization_name}` /// @@ -4904,7 +5166,9 @@ impl Client { } } - ///Update a specific organization + ///Update an organization + /// + ///Use `PUT /v1/organizations/{organization}` instead /// ///Sends a `PUT` request to `/organizations/{organization_name}` /// @@ -4936,7 +5200,9 @@ impl Client { } } - ///Delete a specific organization + ///Delete an organization + /// + ///Use `DELETE /v1/organizations/{organization}` instead /// ///Sends a `DELETE` request to `/organizations/{organization_name}` /// @@ -4966,7 +5232,9 @@ impl Client { } } - ///Fetch the IAM policy for this Organization + ///Fetch an organization's IAM policy + /// + ///Use `GET /v1/organizations/{organization}/policy` instead /// ///Sends a `GET` request to `/organizations/{organization_name}/policy` /// @@ -4996,7 +5264,9 @@ impl Client { } } - ///Update the IAM policy for this Organization + ///Update an organization's IAM policy + /// + ///Use `PUT /v1/organizations/{organization}/policy` instead /// ///Sends a `PUT` request to `/organizations/{organization_name}/policy` /// @@ -5028,7 +5298,9 @@ impl Client { } } - ///List all projects + ///List projects + /// + ///Use `GET /v1/projects` instead /// ///Sends a `GET` request to `/organizations/{organization_name}/projects` /// @@ -5078,7 +5350,9 @@ impl Client { } } - ///List all projects as a Stream + ///List projects as a Stream + /// + ///Use `GET /v1/projects` instead /// ///Sends repeated `GET` requests to /// `/organizations/{organization_name}/projects` until there are no more @@ -5123,7 +5397,9 @@ impl Client { .boxed() } - ///Create a new project + ///Create a project + /// + ///Use `POST /v1/projects` instead /// ///Sends a `POST` request to `/organizations/{organization_name}/projects` /// @@ -5155,7 +5431,9 @@ impl Client { } } - ///Fetch a specific project + ///Fetch a project + /// + ///Use `GET /v1/projects/{project}` instead /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}` @@ -5189,7 +5467,9 @@ impl Client { } } - ///Update a specific project + ///Update a project + /// + ///Use `PUT /v1/projects/{project}` instead /// ///Sends a `PUT` request to /// `/organizations/{organization_name}/projects/{project_name}` @@ -5225,7 +5505,9 @@ impl Client { } } - ///Delete a specific project + ///Delete a project + /// + ///Use `DELETE /v1/projects/{project}` instead /// ///Sends a `DELETE` request to /// `/organizations/{organization_name}/projects/{project_name}` @@ -5259,7 +5541,9 @@ impl Client { } } - ///List disks in a project + ///List disks + /// + ///Use `GET /v1/disks` instead /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/disks` @@ -5313,7 +5597,9 @@ impl Client { } } - ///List disks in a project as a Stream + ///List disks as a Stream + /// + ///Use `GET /v1/disks` instead /// ///Sends repeated `GET` requests to /// `/organizations/{organization_name}/projects/{project_name}/disks` until @@ -5366,7 +5652,7 @@ impl Client { .boxed() } - ///Create a disk in a project + ///Use `POST /v1/disks` instead /// ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/disks` @@ -5402,7 +5688,9 @@ impl Client { } } - ///Get a single disk in a project + ///Fetch a disk + /// + ///Use `GET /v1/disks/{disk}` instead /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/disks/ @@ -5435,7 +5723,7 @@ impl Client { } } - ///Delete a disk from a project + ///Use `DELETE /v1/disks/{disk}` instead /// ///Sends a `DELETE` request to /// `/organizations/{organization_name}/projects/{project_name}/disks/ @@ -5468,7 +5756,7 @@ impl Client { } } - ///Fetch metrics for a disk + ///Fetch disk metrics /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/disks/ @@ -5535,7 +5823,7 @@ impl Client { } } - ///Fetch metrics for a disk as a Stream + ///Fetch disk metrics as a Stream /// ///Sends repeated `GET` requests to /// `/organizations/{organization_name}/projects/{project_name}/disks/ @@ -5758,9 +6046,9 @@ impl Client { } } - ///Get an image + ///Fetch an image /// - ///Get the details of a specific image in a project. + ///Fetch the details for a specific image in a project. /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/images/ @@ -5830,7 +6118,7 @@ impl Client { } } - ///List instances in a project + ///List instances /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/instances` @@ -5884,7 +6172,7 @@ impl Client { } } - ///List instances in a project as a Stream + ///List instances as a Stream /// ///Sends repeated `GET` requests to /// `/organizations/{organization_name}/projects/{project_name}/instances` @@ -5938,7 +6226,9 @@ impl Client { .boxed() } - ///Create an instance in a project + ///Create an instance + /// + ///Use `POST /v1/instances` instead /// ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/instances` @@ -5974,7 +6264,9 @@ impl Client { } } - ///Get an instance in a project + ///Fetch an instance + /// + ///Use `GET /v1/instances/{instance}` instead /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/instances/ @@ -6007,7 +6299,7 @@ impl Client { } } - ///Delete an instance from a project + ///Delete an instance /// ///Sends a `DELETE` request to /// `/organizations/{organization_name}/projects/{project_name}/instances/ @@ -6040,7 +6332,9 @@ impl Client { } } - ///List disks attached to this instance + ///List an instance's disks + /// + ///Use `GET /v1/instances/{instance}/disks` instead /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/instances/ @@ -6098,7 +6392,9 @@ impl Client { } } - ///List disks attached to this instance as a Stream + ///List an instance's disks as a Stream + /// + ///Use `GET /v1/instances/{instance}/disks` instead /// ///Sends repeated `GET` requests to /// `/organizations/{organization_name}/projects/{project_name}/instances/ @@ -6161,6 +6457,10 @@ impl Client { .boxed() } + ///Attach a disk to an instance + /// + ///Use `POST /v1/instances/{instance}/disks/attach` instead + /// ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/instances/ /// {instance_name}/disks/attach` @@ -6193,6 +6493,10 @@ impl Client { } } + ///Detach a disk from an instance + /// + ///Use `POST /v1/disks/{disk}/detach` instead + /// ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/instances/ /// {instance_name}/disks/detach` @@ -6225,7 +6529,7 @@ impl Client { } } - ///List external IP addresses associated with an instance + ///List external IP addresses /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/instances/ @@ -6258,8 +6562,9 @@ impl Client { } } - ///Migrate an instance to a different propolis-server, possibly on a - /// different sled + ///Migrate an instance + /// + ///Use `POST /v1/instances/{instance}/migrate` instead /// ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/instances/ @@ -6293,7 +6598,7 @@ impl Client { } } - ///List network interfaces attached to this instance + ///List network interfaces /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/instances/ @@ -6351,7 +6656,7 @@ impl Client { } } - ///List network interfaces attached to this instance as a Stream + ///List network interfaces as a Stream /// ///Sends repeated `GET` requests to /// `/organizations/{organization_name}/projects/{project_name}/instances/ @@ -6415,7 +6720,7 @@ impl Client { .boxed() } - ///Create a network interface for an instance + ///Create a network interface /// ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/instances/ @@ -6449,7 +6754,7 @@ impl Client { } } - ///Get an interface attached to an instance + ///Fetch a network interface /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/instances/ @@ -6484,7 +6789,7 @@ impl Client { } } - ///Update information about an instance's network interface + ///Update a network interface /// ///Sends a `PUT` request to /// `/organizations/{organization_name}/projects/{project_name}/instances/ @@ -6520,7 +6825,7 @@ impl Client { } } - ///Detach a network interface from an instance + ///Delete a network interface /// ///Note that the primary interface for an instance cannot be deleted if /// there are any secondary interfaces. A new primary interface must be @@ -6562,6 +6867,8 @@ impl Client { ///Reboot an instance /// + ///Use `POST /v1/instances/{instance}/reboot` instead + /// ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/instances/ /// {instance_name}/reboot` @@ -6593,7 +6900,9 @@ impl Client { } } - ///Get contents of an instance's serial console + ///Fetch an instance's serial console + /// + ///Use `GET /v1/instances/{instance}/serial-console` instead /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/instances/ @@ -6658,8 +6967,53 @@ impl Client { } } + ///Connect to an instance's serial console + /// + ///Use `GET /v1/instances/{instance}/serial-console/stream` instead + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/serial-console/stream` + pub async fn instance_serial_console_stream<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + instance_name: &'a types::Name, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}/instances/{}/serial-console/stream", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), + ); + let request = self + .client + .get(url) + .header(reqwest::header::CONNECTION, "Upgrade") + .header(reqwest::header::UPGRADE, "websocket") + .header(reqwest::header::SEC_WEBSOCKET_VERSION, "13") + .header( + reqwest::header::SEC_WEBSOCKET_KEY, + base64::Engine::encode( + &base64::engine::general_purpose::STANDARD, + rand::random::<[u8; 16]>(), + ), + ) + .build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 101u16 => ResponseValue::upgrade(response).await, + 200..=299 => ResponseValue::upgrade(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + ///Boot an instance /// + ///Use `POST /v1/instances/{instance}/start` instead + /// ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/instances/ /// {instance_name}/start` @@ -6693,6 +7047,8 @@ impl Client { ///Halt an instance /// + ///Use `POST /v1/instances/{instance}/stop` instead + /// ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/instances/ /// {instance_name}/stop` @@ -6724,7 +7080,9 @@ impl Client { } } - ///Fetch the IAM policy for this Project + ///Fetch a project's IAM policy + /// + ///Use `GET /v1/projects/{project}/policy` instead /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/policy` @@ -6758,7 +7116,7 @@ impl Client { } } - ///Update the IAM policy for this Project + ///Update a project's IAM policy /// ///Sends a `PUT` request to /// `/organizations/{organization_name}/projects/{project_name}/policy` @@ -6794,7 +7152,7 @@ impl Client { } } - ///List snapshots in a project + ///List snapshots /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/snapshots` @@ -6848,7 +7206,7 @@ impl Client { } } - ///List snapshots in a project as a Stream + ///List snapshots as a Stream /// ///Sends repeated `GET` requests to /// `/organizations/{organization_name}/projects/{project_name}/snapshots` @@ -6902,7 +7260,9 @@ impl Client { .boxed() } - ///Create a snapshot of a disk + ///Create a snapshot + /// + ///Creates a point-in-time snapshot from a disk. /// ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/snapshots` @@ -6938,7 +7298,7 @@ impl Client { } } - ///Get a snapshot in a project + ///Fetch a snapshot /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/snapshots/ @@ -6971,7 +7331,7 @@ impl Client { } } - ///Delete a snapshot from a project + ///Delete a snapshot /// ///Sends a `DELETE` request to /// `/organizations/{organization_name}/projects/{project_name}/snapshots/ @@ -7004,7 +7364,7 @@ impl Client { } } - ///List VPCs in a project + ///List VPCs /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs` @@ -7058,7 +7418,7 @@ impl Client { } } - ///List VPCs in a project as a Stream + ///List VPCs as a Stream /// ///Sends repeated `GET` requests to /// `/organizations/{organization_name}/projects/{project_name}/vpcs` until @@ -7111,7 +7471,7 @@ impl Client { .boxed() } - ///Create a VPC in a project + ///Create a VPC /// ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs` @@ -7147,7 +7507,7 @@ impl Client { } } - ///Get a VPC in a project + ///Fetch a VPC /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -7214,7 +7574,7 @@ impl Client { } } - ///Delete a vpc from a project + ///Delete a VPC /// ///Sends a `DELETE` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -7247,7 +7607,7 @@ impl Client { } } - ///List firewall rules for a VPC + ///List firewall rules /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -7280,7 +7640,7 @@ impl Client { } } - ///Replace the firewall rules for a VPC + ///Replace firewall rules /// ///Sends a `PUT` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -7314,7 +7674,7 @@ impl Client { } } - ///List VPC Custom and System Routers + ///List routers /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -7372,7 +7732,7 @@ impl Client { } } - ///List VPC Custom and System Routers as a Stream + ///List routers as a Stream /// ///Sends repeated `GET` requests to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -7436,7 +7796,7 @@ impl Client { .boxed() } - ///Create a VPC Router + ///Create a router /// ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -7470,7 +7830,7 @@ impl Client { } } - ///Get a VPC Router + ///Get a router /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -7505,7 +7865,7 @@ impl Client { } } - ///Update a VPC Router + ///Update a router /// ///Sends a `PUT` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -7541,7 +7901,7 @@ impl Client { } } - ///Delete a router from its VPC + ///Delete a router /// ///Sends a `DELETE` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -7576,7 +7936,9 @@ impl Client { } } - ///List a Router's routes + ///List routes + /// + ///List the routes associated with a router in a particular VPC. /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -7637,7 +7999,9 @@ impl Client { } } - ///List a Router's routes as a Stream + ///List routes as a Stream + /// + ///List the routes associated with a router in a particular VPC. /// ///Sends repeated `GET` requests to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -7706,7 +8070,7 @@ impl Client { .boxed() } - ///Create a VPC Router + ///Create a router /// ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -7742,7 +8106,7 @@ impl Client { } } - ///Get a VPC Router route + ///Fetch a route /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -7779,7 +8143,7 @@ impl Client { } } - ///Update a Router route + ///Update a route /// ///Sends a `PUT` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -7817,7 +8181,7 @@ impl Client { } } - ///Delete a route from its router + ///Delete a route /// ///Sends a `DELETE` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -7854,7 +8218,7 @@ impl Client { } } - ///List subnets in a VPC + ///List subnets /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -7912,7 +8276,7 @@ impl Client { } } - ///List subnets in a VPC as a Stream + ///List subnets as a Stream /// ///Sends repeated `GET` requests to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -7976,7 +8340,7 @@ impl Client { .boxed() } - ///Create a subnet in a VPC + ///Create a subnet /// ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -8010,7 +8374,7 @@ impl Client { } } - ///Get subnet in a VPC + ///Fetch a subnet /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -8045,7 +8409,7 @@ impl Client { } } - ///Update a VPC Subnet + ///Update a subnet /// ///Sends a `PUT` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -8081,7 +8445,7 @@ impl Client { } } - ///Delete a subnet from a VPC + ///Delete a subnet /// ///Sends a `DELETE` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -8116,7 +8480,7 @@ impl Client { } } - ///List network interfaces in a VPC subnet + ///List network interfaces /// ///Sends a `GET` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -8177,7 +8541,7 @@ impl Client { } } - ///List network interfaces in a VPC subnet as a Stream + ///List network interfaces as a Stream /// ///Sends repeated `GET` requests to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ @@ -8246,12 +8610,12 @@ impl Client { .boxed() } - ///Fetch the top-level IAM policy + ///Fetch the current silo's IAM policy /// ///Sends a `GET` request to `/policy` pub async fn policy_view<'a>( &'a self, - ) -> Result, Error> { + ) -> Result, Error> { let url = format!("{}/policy", self.baseurl,); let request = self.client.get(url).build()?; let result = self.client.execute(request).await; @@ -8268,13 +8632,13 @@ impl Client { } } - ///Update the top-level IAM policy + ///Update the current silo's IAM policy /// ///Sends a `PUT` request to `/policy` pub async fn policy_update<'a>( &'a self, - body: &'a types::FleetRolePolicy, - ) -> Result, Error> { + body: &'a types::SiloRolePolicy, + ) -> Result, Error> { let url = format!("{}/policy", self.baseurl,); let request = self.client.put(url).json(&body).build()?; let result = self.client.execute(request).await; @@ -8291,7 +8655,7 @@ impl Client { } } - ///List the built-in roles + ///List built-in roles /// ///Sends a `GET` request to `/roles` /// @@ -8329,7 +8693,7 @@ impl Client { } } - ///List the built-in roles as a Stream + ///List built-in roles as a Stream /// ///Sends repeated `GET` requests to `/roles` until there are no more /// results. @@ -8369,7 +8733,7 @@ impl Client { .boxed() } - ///Fetch a specific built-in role + ///Fetch a built-in role /// ///Sends a `GET` request to `/roles/{role_name}` /// @@ -8399,119 +8763,6 @@ impl Client { } } - ///List all sagas (for debugging) - /// - ///Sends a `GET` request to `/sagas` - /// - ///Arguments: - /// - `limit`: Maximum number of items returned by a single call - /// - `page_token`: Token returned by previous call to retrieve the - /// subsequent page - /// - `sort_by` - pub async fn saga_list<'a>( - &'a self, - limit: Option, - page_token: Option<&'a str>, - sort_by: Option, - ) -> Result, Error> { - let url = format!("{}/sagas", self.baseurl,); - let mut query = Vec::with_capacity(3usize); - if let Some(v) = &limit { - query.push(("limit", v.to_string())); - } - - if let Some(v) = &page_token { - query.push(("page_token", v.to_string())); - } - - if let Some(v) = &sort_by { - query.push(("sort_by", v.to_string())); - } - - let request = self.client.get(url).query(&query).build()?; - let result = self.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 200u16 => ResponseValue::from_response(response).await, - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - - ///List all sagas (for debugging) as a Stream - /// - ///Sends repeated `GET` requests to `/sagas` until there are no more - /// results. - /// - ///Arguments: - /// - `limit`: Maximum number of items returned by a single call - /// - `sort_by` - pub fn saga_list_stream<'a>( - &'a self, - limit: Option, - sort_by: Option, - ) -> impl futures::Stream>> + Unpin + '_ { - use futures::StreamExt; - use futures::TryFutureExt; - use futures::TryStreamExt; - self.saga_list(limit, None, sort_by) - .map_ok(move |page| { - let page = page.into_inner(); - let first = futures::stream::iter(page.items.into_iter().map(Ok)); - let rest = futures::stream::try_unfold(page.next_page, move |state| async move { - if state.is_none() { - Ok(None) - } else { - self.saga_list(None, state.as_deref(), None) - .map_ok(|page| { - let page = page.into_inner(); - Some(( - futures::stream::iter(page.items.into_iter().map(Ok)), - page.next_page, - )) - }) - .await - } - }) - .try_flatten(); - first.chain(rest) - }) - .try_flatten_stream() - .boxed() - } - - ///Fetch information about a single saga (for debugging) - /// - ///Sends a `GET` request to `/sagas/{saga_id}` - pub async fn saga_view<'a>( - &'a self, - saga_id: &'a uuid::Uuid, - ) -> Result, Error> { - let url = format!( - "{}/sagas/{}", - self.baseurl, - encode_path(&saga_id.to_string()), - ); - let request = self.client.get(url).build()?; - let result = self.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 200u16 => ResponseValue::from_response(response).await, - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - ///Fetch the user associated with the current session /// ///Sends a `GET` request to `/session/me` @@ -8534,7 +8785,95 @@ impl Client { } } - ///List the current user's SSH public keys + ///Fetch the silo groups the current user belongs to + /// + ///Sends a `GET` request to `/session/me/groups` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + pub async fn session_me_groups<'a>( + &'a self, + limit: Option, + page_token: Option<&'a str>, + sort_by: Option, + ) -> Result, Error> { + let url = format!("{}/session/me/groups", self.baseurl,); + let mut query = Vec::with_capacity(3usize); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + + let request = self.client.get(url).query(&query).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch the silo groups the current user belongs to as a Stream + /// + ///Sends repeated `GET` requests to `/session/me/groups` until there are no + /// more results. + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `sort_by` + pub fn session_me_groups_stream<'a>( + &'a self, + limit: Option, + sort_by: Option, + ) -> impl futures::Stream>> + Unpin + '_ { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.session_me_groups(limit, None, sort_by) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().map(Ok)); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.session_me_groups(None, state.as_deref(), None) + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + page.next_page, + )) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + + ///List SSH public keys + /// + ///Lists SSH public keys for the currently authenticated user. /// ///Sends a `GET` request to `/session/me/sshkeys` /// @@ -8578,7 +8917,9 @@ impl Client { } } - ///List the current user's SSH public keys as a Stream + ///List SSH public keys as a Stream + /// + ///Lists SSH public keys for the currently authenticated user. /// ///Sends repeated `GET` requests to `/session/me/sshkeys` until there are /// no more results. @@ -8620,7 +8961,9 @@ impl Client { .boxed() } - ///Create a new SSH public key for the current user + ///Create an SSH public key + /// + ///Create an SSH public key for the currently authenticated user. /// ///Sends a `POST` request to `/session/me/sshkeys` pub async fn session_sshkey_create<'a>( @@ -8643,7 +8986,10 @@ impl Client { } } - ///Get (by name) an SSH public key belonging to the current user + ///Fetch an SSH public key + /// + ///Fetch an SSH public key associated with the currently authenticated + /// user. /// ///Sends a `GET` request to `/session/me/sshkeys/{ssh_key_name}` pub async fn session_sshkey_view<'a>( @@ -8670,7 +9016,10 @@ impl Client { } } - ///Delete (by name) an SSH public key belonging to the current user + ///Delete an SSH public key + /// + ///Delete an SSH public key associated with the currently authenticated + /// user. /// ///Sends a `DELETE` request to `/session/me/sshkeys/{ssh_key_name}` pub async fn session_sshkey_delete<'a>( @@ -8697,20 +9046,107 @@ impl Client { } } - ///Sends a `GET` request to `/silos` + ///Fetch a system-wide image by id + /// + ///Sends a `GET` request to `/system/by-id/images/{id}` + pub async fn system_image_view_by_id<'a>( + &'a self, + id: &'a uuid::Uuid, + ) -> Result, Error> { + let url = format!( + "{}/system/by-id/images/{}", + self.baseurl, + encode_path(&id.to_string()), + ); + let request = self.client.get(url).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch an IP pool by id + /// + ///Sends a `GET` request to `/system/by-id/ip-pools/{id}` + pub async fn ip_pool_view_by_id<'a>( + &'a self, + id: &'a uuid::Uuid, + ) -> Result, Error> { + let url = format!( + "{}/system/by-id/ip-pools/{}", + self.baseurl, + encode_path(&id.to_string()), + ); + let request = self.client.get(url).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch a silo by id + /// + ///Sends a `GET` request to `/system/by-id/silos/{id}` + pub async fn silo_view_by_id<'a>( + &'a self, + id: &'a uuid::Uuid, + ) -> Result, Error> { + let url = format!( + "{}/system/by-id/silos/{}", + self.baseurl, + encode_path(&id.to_string()), + ); + let request = self.client.get(url).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List system-wide certificates + /// + ///Returns a list of all the system-wide certificates. System-wide + /// certificates are returned sorted by creation date, with the most recent + /// certificates appearing first. + /// + ///Sends a `GET` request to `/system/certificates` /// ///Arguments: /// - `limit`: Maximum number of items returned by a single call /// - `page_token`: Token returned by previous call to retrieve the /// subsequent page /// - `sort_by` - pub async fn silo_list<'a>( + pub async fn certificate_list<'a>( &'a self, limit: Option, page_token: Option<&'a str>, - sort_by: Option, - ) -> Result, Error> { - let url = format!("{}/silos", self.baseurl,); + sort_by: Option, + ) -> Result, Error> { + let url = format!("{}/system/certificates", self.baseurl,); let mut query = Vec::with_capacity(3usize); if let Some(v) = &limit { query.push(("limit", v.to_string())); @@ -8739,7 +9175,1490 @@ impl Client { } } - ///Sends repeated `GET` requests to `/silos` until there are no more + ///List system-wide certificates as a Stream + /// + ///Returns a list of all the system-wide certificates. System-wide + /// certificates are returned sorted by creation date, with the most recent + /// certificates appearing first. + /// + ///Sends repeated `GET` requests to `/system/certificates` until there are + /// no more results. + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `sort_by` + pub fn certificate_list_stream<'a>( + &'a self, + limit: Option, + sort_by: Option, + ) -> impl futures::Stream>> + Unpin + '_ + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.certificate_list(limit, None, sort_by) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().map(Ok)); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.certificate_list(None, state.as_deref(), None) + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + page.next_page, + )) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + + ///Create a new system-wide x.509 certificate + /// + ///This certificate is automatically used by the Oxide Control plane to + /// serve external connections. + /// + ///Sends a `POST` request to `/system/certificates` + pub async fn certificate_create<'a>( + &'a self, + body: &'a types::CertificateCreate, + ) -> Result, Error> { + let url = format!("{}/system/certificates", self.baseurl,); + let request = self.client.post(url).json(&body).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch a certificate + /// + ///Returns the details of a specific certificate + /// + ///Sends a `GET` request to `/system/certificates/{certificate}` + pub async fn certificate_view<'a>( + &'a self, + certificate: &'a types::NameOrId, + ) -> Result, Error> { + let url = format!( + "{}/system/certificates/{}", + self.baseurl, + encode_path(&certificate.to_string()), + ); + let request = self.client.get(url).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Delete a certificate + /// + ///Permanently delete a certificate. This operation cannot be undone. + /// + ///Sends a `DELETE` request to `/system/certificates/{certificate}` + pub async fn certificate_delete<'a>( + &'a self, + certificate: &'a types::NameOrId, + ) -> Result, Error> { + let url = format!( + "{}/system/certificates/{}", + self.baseurl, + encode_path(&certificate.to_string()), + ); + let request = self.client.delete(url).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List physical disks + /// + ///Sends a `GET` request to `/system/hardware/disks` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + pub async fn physical_disk_list<'a>( + &'a self, + limit: Option, + page_token: Option<&'a str>, + sort_by: Option, + ) -> Result, Error> { + let url = format!("{}/system/hardware/disks", self.baseurl,); + let mut query = Vec::with_capacity(3usize); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + + let request = self.client.get(url).query(&query).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List physical disks as a Stream + /// + ///Sends repeated `GET` requests to `/system/hardware/disks` until there + /// are no more results. + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `sort_by` + pub fn physical_disk_list_stream<'a>( + &'a self, + limit: Option, + sort_by: Option, + ) -> impl futures::Stream>> + Unpin + '_ + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.physical_disk_list(limit, None, sort_by) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().map(Ok)); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.physical_disk_list(None, state.as_deref(), None) + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + page.next_page, + )) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + + ///List racks + /// + ///Sends a `GET` request to `/system/hardware/racks` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + pub async fn rack_list<'a>( + &'a self, + limit: Option, + page_token: Option<&'a str>, + sort_by: Option, + ) -> Result, Error> { + let url = format!("{}/system/hardware/racks", self.baseurl,); + let mut query = Vec::with_capacity(3usize); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + + let request = self.client.get(url).query(&query).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List racks as a Stream + /// + ///Sends repeated `GET` requests to `/system/hardware/racks` until there + /// are no more results. + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `sort_by` + pub fn rack_list_stream<'a>( + &'a self, + limit: Option, + sort_by: Option, + ) -> impl futures::Stream>> + Unpin + '_ { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.rack_list(limit, None, sort_by) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().map(Ok)); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.rack_list(None, state.as_deref(), None) + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + page.next_page, + )) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + + ///Fetch a rack + /// + ///Sends a `GET` request to `/system/hardware/racks/{rack_id}` + /// + ///Arguments: + /// - `rack_id`: The rack's unique ID. + pub async fn rack_view<'a>( + &'a self, + rack_id: &'a uuid::Uuid, + ) -> Result, Error> { + let url = format!( + "{}/system/hardware/racks/{}", + self.baseurl, + encode_path(&rack_id.to_string()), + ); + let request = self.client.get(url).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List sleds + /// + ///Sends a `GET` request to `/system/hardware/sleds` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + pub async fn sled_list<'a>( + &'a self, + limit: Option, + page_token: Option<&'a str>, + sort_by: Option, + ) -> Result, Error> { + let url = format!("{}/system/hardware/sleds", self.baseurl,); + let mut query = Vec::with_capacity(3usize); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + + let request = self.client.get(url).query(&query).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List sleds as a Stream + /// + ///Sends repeated `GET` requests to `/system/hardware/sleds` until there + /// are no more results. + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `sort_by` + pub fn sled_list_stream<'a>( + &'a self, + limit: Option, + sort_by: Option, + ) -> impl futures::Stream>> + Unpin + '_ { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.sled_list(limit, None, sort_by) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().map(Ok)); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.sled_list(None, state.as_deref(), None) + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + page.next_page, + )) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + + ///Fetch a sled + /// + ///Sends a `GET` request to `/system/hardware/sleds/{sled_id}` + /// + ///Arguments: + /// - `sled_id`: The sled's unique ID. + pub async fn sled_view<'a>( + &'a self, + sled_id: &'a uuid::Uuid, + ) -> Result, Error> { + let url = format!( + "{}/system/hardware/sleds/{}", + self.baseurl, + encode_path(&sled_id.to_string()), + ); + let request = self.client.get(url).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List physical disks attached to sleds + /// + ///Sends a `GET` request to `/system/hardware/sleds/{sled_id}/disks` + /// + ///Arguments: + /// - `sled_id`: The sled's unique ID. + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + pub async fn sled_physical_disk_list<'a>( + &'a self, + sled_id: &'a uuid::Uuid, + limit: Option, + page_token: Option<&'a str>, + sort_by: Option, + ) -> Result, Error> { + let url = format!( + "{}/system/hardware/sleds/{}/disks", + self.baseurl, + encode_path(&sled_id.to_string()), + ); + let mut query = Vec::with_capacity(3usize); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + + let request = self.client.get(url).query(&query).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List physical disks attached to sleds as a Stream + /// + ///Sends repeated `GET` requests to + /// `/system/hardware/sleds/{sled_id}/disks` until there are no more + /// results. + /// + ///Arguments: + /// - `sled_id`: The sled's unique ID. + /// - `limit`: Maximum number of items returned by a single call + /// - `sort_by` + pub fn sled_physical_disk_list_stream<'a>( + &'a self, + sled_id: &'a uuid::Uuid, + limit: Option, + sort_by: Option, + ) -> impl futures::Stream>> + Unpin + '_ + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.sled_physical_disk_list(sled_id, limit, None, sort_by) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().map(Ok)); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.sled_physical_disk_list(sled_id, None, state.as_deref(), None) + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + page.next_page, + )) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + + ///List system-wide images + /// + ///Returns a list of all the system-wide images. System-wide images are + /// returned sorted by creation date, with the most recent images appearing + /// first. + /// + ///Sends a `GET` request to `/system/images` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + pub async fn system_image_list<'a>( + &'a self, + limit: Option, + page_token: Option<&'a str>, + sort_by: Option, + ) -> Result, Error> { + let url = format!("{}/system/images", self.baseurl,); + let mut query = Vec::with_capacity(3usize); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + + let request = self.client.get(url).query(&query).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List system-wide images as a Stream + /// + ///Returns a list of all the system-wide images. System-wide images are + /// returned sorted by creation date, with the most recent images appearing + /// first. + /// + ///Sends repeated `GET` requests to `/system/images` until there are no + /// more results. + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `sort_by` + pub fn system_image_list_stream<'a>( + &'a self, + limit: Option, + sort_by: Option, + ) -> impl futures::Stream>> + Unpin + '_ + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.system_image_list(limit, None, sort_by) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().map(Ok)); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.system_image_list(None, state.as_deref(), None) + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + page.next_page, + )) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + + ///Create a system-wide image + /// + ///Create a new system-wide image. This image can then be used by any user + /// in any silo as a base for instances. + /// + ///Sends a `POST` request to `/system/images` + pub async fn system_image_create<'a>( + &'a self, + body: &'a types::GlobalImageCreate, + ) -> Result, Error> { + let url = format!("{}/system/images", self.baseurl,); + let request = self.client.post(url).json(&body).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch a system-wide image + /// + ///Returns the details of a specific system-wide image. + /// + ///Sends a `GET` request to `/system/images/{image_name}` + pub async fn system_image_view<'a>( + &'a self, + image_name: &'a types::Name, + ) -> Result, Error> { + let url = format!( + "{}/system/images/{}", + self.baseurl, + encode_path(&image_name.to_string()), + ); + let request = self.client.get(url).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Delete a system-wide image + /// + ///Permanently delete a system-wide image. This operation cannot be undone. + /// Any instances using the system-wide image will continue to run, however + /// new instances can not be created with this image. + /// + ///Sends a `DELETE` request to `/system/images/{image_name}` + pub async fn system_image_delete<'a>( + &'a self, + image_name: &'a types::Name, + ) -> Result, Error> { + let url = format!( + "{}/system/images/{}", + self.baseurl, + encode_path(&image_name.to_string()), + ); + let request = self.client.delete(url).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List IP pools + /// + ///Sends a `GET` request to `/system/ip-pools` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + pub async fn ip_pool_list<'a>( + &'a self, + limit: Option, + page_token: Option<&'a str>, + sort_by: Option, + ) -> Result, Error> { + let url = format!("{}/system/ip-pools", self.baseurl,); + let mut query = Vec::with_capacity(3usize); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + + let request = self.client.get(url).query(&query).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List IP pools as a Stream + /// + ///Sends repeated `GET` requests to `/system/ip-pools` until there are no + /// more results. + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `sort_by` + pub fn ip_pool_list_stream<'a>( + &'a self, + limit: Option, + sort_by: Option, + ) -> impl futures::Stream>> + Unpin + '_ { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.ip_pool_list(limit, None, sort_by) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().map(Ok)); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.ip_pool_list(None, state.as_deref(), None) + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + page.next_page, + )) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + + ///Create an IP pool + /// + ///Sends a `POST` request to `/system/ip-pools` + pub async fn ip_pool_create<'a>( + &'a self, + body: &'a types::IpPoolCreate, + ) -> Result, Error> { + let url = format!("{}/system/ip-pools", self.baseurl,); + let request = self.client.post(url).json(&body).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch an IP pool + /// + ///Sends a `GET` request to `/system/ip-pools/{pool_name}` + pub async fn ip_pool_view<'a>( + &'a self, + pool_name: &'a types::Name, + ) -> Result, Error> { + let url = format!( + "{}/system/ip-pools/{}", + self.baseurl, + encode_path(&pool_name.to_string()), + ); + let request = self.client.get(url).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Update an IP Pool + /// + ///Sends a `PUT` request to `/system/ip-pools/{pool_name}` + pub async fn ip_pool_update<'a>( + &'a self, + pool_name: &'a types::Name, + body: &'a types::IpPoolUpdate, + ) -> Result, Error> { + let url = format!( + "{}/system/ip-pools/{}", + self.baseurl, + encode_path(&pool_name.to_string()), + ); + let request = self.client.put(url).json(&body).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Delete an IP Pool + /// + ///Sends a `DELETE` request to `/system/ip-pools/{pool_name}` + pub async fn ip_pool_delete<'a>( + &'a self, + pool_name: &'a types::Name, + ) -> Result, Error> { + let url = format!( + "{}/system/ip-pools/{}", + self.baseurl, + encode_path(&pool_name.to_string()), + ); + let request = self.client.delete(url).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List ranges for an IP pool + /// + ///Ranges are ordered by their first address. + /// + ///Sends a `GET` request to `/system/ip-pools/{pool_name}/ranges` + /// + ///Arguments: + /// - `pool_name` + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + pub async fn ip_pool_range_list<'a>( + &'a self, + pool_name: &'a types::Name, + limit: Option, + page_token: Option<&'a str>, + ) -> Result, Error> { + let url = format!( + "{}/system/ip-pools/{}/ranges", + self.baseurl, + encode_path(&pool_name.to_string()), + ); + let mut query = Vec::with_capacity(2usize); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + + let request = self.client.get(url).query(&query).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List ranges for an IP pool as a Stream + /// + ///Ranges are ordered by their first address. + /// + ///Sends repeated `GET` requests to `/system/ip-pools/{pool_name}/ranges` + /// until there are no more results. + /// + ///Arguments: + /// - `pool_name` + /// - `limit`: Maximum number of items returned by a single call + pub fn ip_pool_range_list_stream<'a>( + &'a self, + pool_name: &'a types::Name, + limit: Option, + ) -> impl futures::Stream>> + Unpin + '_ + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.ip_pool_range_list(pool_name, limit, None) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().map(Ok)); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.ip_pool_range_list(pool_name, None, state.as_deref()) + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + page.next_page, + )) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + + ///Add a range to an IP pool + /// + ///Sends a `POST` request to `/system/ip-pools/{pool_name}/ranges/add` + pub async fn ip_pool_range_add<'a>( + &'a self, + pool_name: &'a types::Name, + body: &'a types::IpRange, + ) -> Result, Error> { + let url = format!( + "{}/system/ip-pools/{}/ranges/add", + self.baseurl, + encode_path(&pool_name.to_string()), + ); + let request = self.client.post(url).json(&body).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Remove a range from an IP pool + /// + ///Sends a `POST` request to `/system/ip-pools/{pool_name}/ranges/remove` + pub async fn ip_pool_range_remove<'a>( + &'a self, + pool_name: &'a types::Name, + body: &'a types::IpRange, + ) -> Result, Error> { + let url = format!( + "{}/system/ip-pools/{}/ranges/remove", + self.baseurl, + encode_path(&pool_name.to_string()), + ); + let request = self.client.post(url).json(&body).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch the IP pool used for Oxide services + /// + ///Sends a `GET` request to `/system/ip-pools-service` + pub async fn ip_pool_service_view<'a>( + &'a self, + ) -> Result, Error> { + let url = format!("{}/system/ip-pools-service", self.baseurl,); + let request = self.client.get(url).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List ranges for the IP pool used for Oxide services + /// + ///Ranges are ordered by their first address. + /// + ///Sends a `GET` request to `/system/ip-pools-service/ranges` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + pub async fn ip_pool_service_range_list<'a>( + &'a self, + limit: Option, + page_token: Option<&'a str>, + ) -> Result, Error> { + let url = format!("{}/system/ip-pools-service/ranges", self.baseurl,); + let mut query = Vec::with_capacity(2usize); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + + let request = self.client.get(url).query(&query).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List ranges for the IP pool used for Oxide services as a Stream + /// + ///Ranges are ordered by their first address. + /// + ///Sends repeated `GET` requests to `/system/ip-pools-service/ranges` until + /// there are no more results. + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + pub fn ip_pool_service_range_list_stream<'a>( + &'a self, + limit: Option, + ) -> impl futures::Stream>> + Unpin + '_ + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.ip_pool_service_range_list(limit, None) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().map(Ok)); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.ip_pool_service_range_list(None, state.as_deref()) + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + page.next_page, + )) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + + ///Add a range to an IP pool used for Oxide services + /// + ///Sends a `POST` request to `/system/ip-pools-service/ranges/add` + pub async fn ip_pool_service_range_add<'a>( + &'a self, + body: &'a types::IpRange, + ) -> Result, Error> { + let url = format!("{}/system/ip-pools-service/ranges/add", self.baseurl,); + let request = self.client.post(url).json(&body).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Remove a range from an IP pool used for Oxide services + /// + ///Sends a `POST` request to `/system/ip-pools-service/ranges/remove` + pub async fn ip_pool_service_range_remove<'a>( + &'a self, + body: &'a types::IpRange, + ) -> Result, Error> { + let url = format!("{}/system/ip-pools-service/ranges/remove", self.baseurl,); + let request = self.client.post(url).json(&body).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Access metrics data + /// + ///Sends a `GET` request to `/system/metrics/{metric_name}` + /// + ///Arguments: + /// - `metric_name` + /// - `end_time`: An exclusive end time of metrics. + /// - `id`: The UUID of the container being queried + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `start_time`: An inclusive start time of metrics. + pub async fn system_metric<'a>( + &'a self, + metric_name: types::SystemMetricName, + end_time: Option<&'a chrono::DateTime>, + id: &'a uuid::Uuid, + limit: Option, + page_token: Option<&'a str>, + start_time: Option<&'a chrono::DateTime>, + ) -> Result, Error> { + let url = format!( + "{}/system/metrics/{}", + self.baseurl, + encode_path(&metric_name.to_string()), + ); + let mut query = Vec::with_capacity(5usize); + if let Some(v) = &end_time { + query.push(("end_time", v.to_string())); + } + + query.push(("id", id.to_string())); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + + if let Some(v) = &start_time { + query.push(("start_time", v.to_string())); + } + + let request = self.client.get(url).query(&query).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch the top-level IAM policy + /// + ///Sends a `GET` request to `/system/policy` + pub async fn system_policy_view<'a>( + &'a self, + ) -> Result, Error> { + let url = format!("{}/system/policy", self.baseurl,); + let request = self.client.get(url).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Update the top-level IAM policy + /// + ///Sends a `PUT` request to `/system/policy` + pub async fn system_policy_update<'a>( + &'a self, + body: &'a types::FleetRolePolicy, + ) -> Result, Error> { + let url = format!("{}/system/policy", self.baseurl,); + let request = self.client.put(url).json(&body).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List sagas + /// + ///Sends a `GET` request to `/system/sagas` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + pub async fn saga_list<'a>( + &'a self, + limit: Option, + page_token: Option<&'a str>, + sort_by: Option, + ) -> Result, Error> { + let url = format!("{}/system/sagas", self.baseurl,); + let mut query = Vec::with_capacity(3usize); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + + let request = self.client.get(url).query(&query).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List sagas as a Stream + /// + ///Sends repeated `GET` requests to `/system/sagas` until there are no more + /// results. + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `sort_by` + pub fn saga_list_stream<'a>( + &'a self, + limit: Option, + sort_by: Option, + ) -> impl futures::Stream>> + Unpin + '_ { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.saga_list(limit, None, sort_by) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().map(Ok)); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.saga_list(None, state.as_deref(), None) + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + page.next_page, + )) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + + ///Fetch a saga + /// + ///Sends a `GET` request to `/system/sagas/{saga_id}` + pub async fn saga_view<'a>( + &'a self, + saga_id: &'a uuid::Uuid, + ) -> Result, Error> { + let url = format!( + "{}/system/sagas/{}", + self.baseurl, + encode_path(&saga_id.to_string()), + ); + let request = self.client.get(url).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List silos + /// + ///Lists silos that are discoverable based on the current permissions. + /// + ///Sends a `GET` request to `/system/silos` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + pub async fn silo_list<'a>( + &'a self, + limit: Option, + page_token: Option<&'a str>, + sort_by: Option, + ) -> Result, Error> { + let url = format!("{}/system/silos", self.baseurl,); + let mut query = Vec::with_capacity(3usize); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + + let request = self.client.get(url).query(&query).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List silos as a Stream + /// + ///Lists silos that are discoverable based on the current permissions. + /// + ///Sends repeated `GET` requests to `/system/silos` until there are no more /// results. /// ///Arguments: @@ -8779,14 +10698,14 @@ impl Client { .boxed() } - ///Create a new silo + ///Create a silo /// - ///Sends a `POST` request to `/silos` + ///Sends a `POST` request to `/system/silos` pub async fn silo_create<'a>( &'a self, body: &'a types::SiloCreate, ) -> Result, Error> { - let url = format!("{}/silos", self.baseurl,); + let url = format!("{}/system/silos", self.baseurl,); let request = self.client.post(url).json(&body).build()?; let result = self.client.execute(request).await; let response = result?; @@ -8802,9 +10721,11 @@ impl Client { } } - ///Fetch a specific silo + ///Fetch a silo /// - ///Sends a `GET` request to `/silos/{silo_name}` + ///Fetch a silo by name. + /// + ///Sends a `GET` request to `/system/silos/{silo_name}` /// ///Arguments: /// - `silo_name`: The silo's unique name. @@ -8813,7 +10734,7 @@ impl Client { silo_name: &'a types::Name, ) -> Result, Error> { let url = format!( - "{}/silos/{}", + "{}/system/silos/{}", self.baseurl, encode_path(&silo_name.to_string()), ); @@ -8832,9 +10753,11 @@ impl Client { } } - ///Delete a specific silo + ///Delete a silo /// - ///Sends a `DELETE` request to `/silos/{silo_name}` + ///Delete a silo by name. + /// + ///Sends a `DELETE` request to `/system/silos/{silo_name}` /// ///Arguments: /// - `silo_name`: The silo's unique name. @@ -8843,7 +10766,7 @@ impl Client { silo_name: &'a types::Name, ) -> Result, Error> { let url = format!( - "{}/silos/{}", + "{}/system/silos/{}", self.baseurl, encode_path(&silo_name.to_string()), ); @@ -8862,9 +10785,9 @@ impl Client { } } - ///List Silo identity providers + ///List a silo's IDPs /// - ///Sends a `GET` request to `/silos/{silo_name}/identity-providers` + ///Sends a `GET` request to `/system/silos/{silo_name}/identity-providers` /// ///Arguments: /// - `silo_name`: The silo's unique name. @@ -8880,7 +10803,7 @@ impl Client { sort_by: Option, ) -> Result, Error> { let url = format!( - "{}/silos/{}/identity-providers", + "{}/system/silos/{}/identity-providers", self.baseurl, encode_path(&silo_name.to_string()), ); @@ -8912,10 +10835,11 @@ impl Client { } } - ///List Silo identity providers as a Stream + ///List a silo's IDPs as a Stream /// - ///Sends repeated `GET` requests to `/silos/{silo_name}/identity-providers` - /// until there are no more results. + ///Sends repeated `GET` requests to + /// `/system/silos/{silo_name}/identity-providers` until there are no more + /// results. /// ///Arguments: /// - `silo_name`: The silo's unique name. @@ -8957,82 +10881,25 @@ impl Client { .boxed() } - ///Fetch the IAM policy for this Silo + ///Create a user /// - ///Sends a `GET` request to `/silos/{silo_name}/policy` + ///Users can only be created in Silos with `provision_type` == `Fixed`. + /// Otherwise, Silo users are just-in-time (JIT) provisioned when a user + /// first logs in using an external Identity Provider. /// - ///Arguments: - /// - `silo_name`: The silo's unique name. - pub async fn silo_policy_view<'a>( - &'a self, - silo_name: &'a types::Name, - ) -> Result, Error> { - let url = format!( - "{}/silos/{}/policy", - self.baseurl, - encode_path(&silo_name.to_string()), - ); - let request = self.client.get(url).build()?; - let result = self.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 200u16 => ResponseValue::from_response(response).await, - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - - ///Update the IAM policy for this Silo - /// - ///Sends a `PUT` request to `/silos/{silo_name}/policy` + ///Sends a `POST` request to + /// `/system/silos/{silo_name}/identity-providers/local/users` /// ///Arguments: /// - `silo_name`: The silo's unique name. /// - `body` - pub async fn silo_policy_update<'a>( + pub async fn local_idp_user_create<'a>( &'a self, silo_name: &'a types::Name, - body: &'a types::SiloRolePolicy, - ) -> Result, Error> { + body: &'a types::UserCreate, + ) -> Result, Error> { let url = format!( - "{}/silos/{}/policy", - self.baseurl, - encode_path(&silo_name.to_string()), - ); - let request = self.client.put(url).json(&body).build()?; - let result = self.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 200u16 => ResponseValue::from_response(response).await, - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - - ///Create a new SAML identity provider for a silo - /// - ///Sends a `POST` request to `/silos/{silo_name}/saml-identity-providers` - /// - ///Arguments: - /// - `silo_name`: The silo's unique name. - /// - `body` - pub async fn silo_identity_provider_create<'a>( - &'a self, - silo_name: &'a types::Name, - body: &'a types::SamlIdentityProviderCreate, - ) -> Result, Error> { - let url = format!( - "{}/silos/{}/saml-identity-providers", + "{}/system/silos/{}/identity-providers/local/users", self.baseurl, encode_path(&silo_name.to_string()), ); @@ -9051,21 +10918,128 @@ impl Client { } } - ///GET a silo's SAML identity provider + ///Delete a user + /// + ///Sends a `DELETE` request to + /// `/system/silos/{silo_name}/identity-providers/local/users/{user_id}` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + /// - `user_id`: The user's internal id + pub async fn local_idp_user_delete<'a>( + &'a self, + silo_name: &'a types::Name, + user_id: &'a uuid::Uuid, + ) -> Result, Error> { + let url = format!( + "{}/system/silos/{}/identity-providers/local/users/{}", + self.baseurl, + encode_path(&silo_name.to_string()), + encode_path(&user_id.to_string()), + ); + let request = self.client.delete(url).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Set or invalidate a user's password + /// + ///Passwords can only be updated for users in Silos with identity mode + /// `LocalOnly`. + /// + ///Sends a `POST` request to + /// `/system/silos/{silo_name}/identity-providers/local/users/{user_id}/ + /// set-password` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + /// - `user_id`: The user's internal id + /// - `body` + pub async fn local_idp_user_set_password<'a>( + &'a self, + silo_name: &'a types::Name, + user_id: &'a uuid::Uuid, + body: &'a types::UserPassword, + ) -> Result, Error> { + let url = format!( + "{}/system/silos/{}/identity-providers/local/users/{}/set-password", + self.baseurl, + encode_path(&silo_name.to_string()), + encode_path(&user_id.to_string()), + ); + let request = self.client.post(url).json(&body).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Create a SAML IDP + /// + ///Sends a `POST` request to + /// `/system/silos/{silo_name}/identity-providers/saml` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + /// - `body` + pub async fn saml_identity_provider_create<'a>( + &'a self, + silo_name: &'a types::Name, + body: &'a types::SamlIdentityProviderCreate, + ) -> Result, Error> { + let url = format!( + "{}/system/silos/{}/identity-providers/saml", + self.baseurl, + encode_path(&silo_name.to_string()), + ); + let request = self.client.post(url).json(&body).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch a SAML IDP /// ///Sends a `GET` request to - /// `/silos/{silo_name}/saml-identity-providers/{provider_name}` + /// `/system/silos/{silo_name}/identity-providers/saml/{provider_name}` /// ///Arguments: /// - `silo_name`: The silo's unique name. /// - `provider_name`: The SAML identity provider's name - pub async fn silo_identity_provider_view<'a>( + pub async fn saml_identity_provider_view<'a>( &'a self, silo_name: &'a types::Name, provider_name: &'a types::Name, ) -> Result, Error> { let url = format!( - "{}/silos/{}/saml-identity-providers/{}", + "{}/system/silos/{}/identity-providers/saml/{}", self.baseurl, encode_path(&silo_name.to_string()), encode_path(&provider_name.to_string()), @@ -9085,7 +11059,196 @@ impl Client { } } - ///List the built-in system users + ///Fetch a silo's IAM policy + /// + ///Sends a `GET` request to `/system/silos/{silo_name}/policy` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + pub async fn silo_policy_view<'a>( + &'a self, + silo_name: &'a types::Name, + ) -> Result, Error> { + let url = format!( + "{}/system/silos/{}/policy", + self.baseurl, + encode_path(&silo_name.to_string()), + ); + let request = self.client.get(url).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Update a silo's IAM policy + /// + ///Sends a `PUT` request to `/system/silos/{silo_name}/policy` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + /// - `body` + pub async fn silo_policy_update<'a>( + &'a self, + silo_name: &'a types::Name, + body: &'a types::SiloRolePolicy, + ) -> Result, Error> { + let url = format!( + "{}/system/silos/{}/policy", + self.baseurl, + encode_path(&silo_name.to_string()), + ); + let request = self.client.put(url).json(&body).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List users in a silo + /// + ///Sends a `GET` request to `/system/silos/{silo_name}/users/all` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + pub async fn silo_users_list<'a>( + &'a self, + silo_name: &'a types::Name, + limit: Option, + page_token: Option<&'a str>, + sort_by: Option, + ) -> Result, Error> { + let url = format!( + "{}/system/silos/{}/users/all", + self.baseurl, + encode_path(&silo_name.to_string()), + ); + let mut query = Vec::with_capacity(3usize); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + + let request = self.client.get(url).query(&query).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List users in a silo as a Stream + /// + ///Sends repeated `GET` requests to `/system/silos/{silo_name}/users/all` + /// until there are no more results. + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + /// - `limit`: Maximum number of items returned by a single call + /// - `sort_by` + pub fn silo_users_list_stream<'a>( + &'a self, + silo_name: &'a types::Name, + limit: Option, + sort_by: Option, + ) -> impl futures::Stream>> + Unpin + '_ { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.silo_users_list(silo_name, limit, None, sort_by) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().map(Ok)); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.silo_users_list(silo_name, None, state.as_deref(), None) + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + page.next_page, + )) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + + ///Fetch a user + /// + ///Sends a `GET` request to `/system/silos/{silo_name}/users/id/{user_id}` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + /// - `user_id`: The user's internal id + pub async fn silo_user_view<'a>( + &'a self, + silo_name: &'a types::Name, + user_id: &'a uuid::Uuid, + ) -> Result, Error> { + let url = format!( + "{}/system/silos/{}/users/id/{}", + self.baseurl, + encode_path(&silo_name.to_string()), + encode_path(&user_id.to_string()), + ); + let request = self.client.get(url).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List built-in users /// ///Sends a `GET` request to `/system/user` /// @@ -9129,7 +11292,7 @@ impl Client { } } - ///List the built-in system users as a Stream + ///List built-in users as a Stream /// ///Sends repeated `GET` requests to `/system/user` until there are no more /// results. @@ -9172,7 +11335,7 @@ impl Client { .boxed() } - ///Fetch a specific built-in system user + ///Fetch a built-in user /// ///Sends a `GET` request to `/system/user/{user_name}` /// @@ -9202,7 +11365,7 @@ impl Client { } } - ///List all timeseries schema + ///List timeseries schema /// ///Sends a `GET` request to `/timeseries/schema` /// @@ -9240,7 +11403,7 @@ impl Client { } } - ///List all timeseries schema as a Stream + ///List timeseries schema as a Stream /// ///Sends repeated `GET` requests to `/timeseries/schema` until there are no /// more results. @@ -9281,26 +11444,6 @@ impl Client { .boxed() } - ///Refresh update metadata - /// - ///Sends a `POST` request to `/updates/refresh` - pub async fn updates_refresh<'a>(&'a self) -> Result, Error> { - let url = format!("{}/updates/refresh", self.baseurl,); - let request = self.client.post(url).build()?; - let result = self.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 204u16 => Ok(ResponseValue::empty(response)), - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - ///List users /// ///Sends a `GET` request to `/users` @@ -9386,6 +11529,1858 @@ impl Client { .try_flatten_stream() .boxed() } + + ///List disks + /// + ///Sends a `GET` request to `/v1/disks` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `organization` + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `project` + /// - `sort_by` + pub async fn disk_list_v1<'a>( + &'a self, + limit: Option, + organization: Option<&'a types::NameOrId>, + page_token: Option<&'a str>, + project: Option<&'a types::NameOrId>, + sort_by: Option, + ) -> Result, Error> { + let url = format!("{}/v1/disks", self.baseurl,); + let mut query = Vec::with_capacity(5usize); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + + if let Some(v) = &project { + query.push(("project", v.to_string())); + } + + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + + let request = self.client.get(url).query(&query).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List disks as a Stream + /// + ///Sends repeated `GET` requests to `/v1/disks` until there are no more + /// results. + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `organization` + /// - `project` + /// - `sort_by` + pub fn disk_list_v1_stream<'a>( + &'a self, + limit: Option, + organization: Option<&'a types::NameOrId>, + project: Option<&'a types::NameOrId>, + sort_by: Option, + ) -> impl futures::Stream>> + Unpin + '_ { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.disk_list_v1(limit, organization, None, project, sort_by) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().map(Ok)); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.disk_list_v1(None, None, state.as_deref(), None, None) + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + page.next_page, + )) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + + ///Create a disk + /// + ///Sends a `POST` request to `/v1/disks` + pub async fn disk_create_v1<'a>( + &'a self, + organization: Option<&'a types::NameOrId>, + project: &'a types::NameOrId, + body: &'a types::DiskCreate, + ) -> Result, Error> { + let url = format!("{}/v1/disks", self.baseurl,); + let mut query = Vec::with_capacity(2usize); + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + + query.push(("project", project.to_string())); + let request = self.client.post(url).json(&body).query(&query).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch a disk + /// + ///Sends a `GET` request to `/v1/disks/{disk}` + pub async fn disk_view_v1<'a>( + &'a self, + disk: &'a types::NameOrId, + organization: Option<&'a types::NameOrId>, + project: Option<&'a types::NameOrId>, + ) -> Result, Error> { + let url = format!( + "{}/v1/disks/{}", + self.baseurl, + encode_path(&disk.to_string()), + ); + let mut query = Vec::with_capacity(2usize); + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + + if let Some(v) = &project { + query.push(("project", v.to_string())); + } + + let request = self.client.get(url).query(&query).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Delete a disk + /// + ///Sends a `DELETE` request to `/v1/disks/{disk}` + pub async fn disk_delete_v1<'a>( + &'a self, + disk: &'a types::NameOrId, + organization: Option<&'a types::NameOrId>, + project: Option<&'a types::NameOrId>, + ) -> Result, Error> { + let url = format!( + "{}/v1/disks/{}", + self.baseurl, + encode_path(&disk.to_string()), + ); + let mut query = Vec::with_capacity(2usize); + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + + if let Some(v) = &project { + query.push(("project", v.to_string())); + } + + let request = self.client.delete(url).query(&query).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List instances + /// + ///Sends a `GET` request to `/v1/instances` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `organization` + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `project` + /// - `sort_by` + pub async fn instance_list_v1<'a>( + &'a self, + limit: Option, + organization: Option<&'a types::NameOrId>, + page_token: Option<&'a str>, + project: Option<&'a types::NameOrId>, + sort_by: Option, + ) -> Result, Error> { + let url = format!("{}/v1/instances", self.baseurl,); + let mut query = Vec::with_capacity(5usize); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + + if let Some(v) = &project { + query.push(("project", v.to_string())); + } + + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + + let request = self.client.get(url).query(&query).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List instances as a Stream + /// + ///Sends repeated `GET` requests to `/v1/instances` until there are no more + /// results. + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `organization` + /// - `project` + /// - `sort_by` + pub fn instance_list_v1_stream<'a>( + &'a self, + limit: Option, + organization: Option<&'a types::NameOrId>, + project: Option<&'a types::NameOrId>, + sort_by: Option, + ) -> impl futures::Stream>> + Unpin + '_ + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.instance_list_v1(limit, organization, None, project, sort_by) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().map(Ok)); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.instance_list_v1(None, None, state.as_deref(), None, None) + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + page.next_page, + )) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + + ///Create an instance + /// + ///Sends a `POST` request to `/v1/instances` + pub async fn instance_create_v1<'a>( + &'a self, + organization: Option<&'a types::NameOrId>, + project: &'a types::NameOrId, + body: &'a types::InstanceCreate, + ) -> Result, Error> { + let url = format!("{}/v1/instances", self.baseurl,); + let mut query = Vec::with_capacity(2usize); + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + + query.push(("project", project.to_string())); + let request = self.client.post(url).json(&body).query(&query).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch an instance + /// + ///Sends a `GET` request to `/v1/instances/{instance}` + pub async fn instance_view_v1<'a>( + &'a self, + instance: &'a types::NameOrId, + organization: Option<&'a types::NameOrId>, + project: Option<&'a types::NameOrId>, + ) -> Result, Error> { + let url = format!( + "{}/v1/instances/{}", + self.baseurl, + encode_path(&instance.to_string()), + ); + let mut query = Vec::with_capacity(2usize); + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + + if let Some(v) = &project { + query.push(("project", v.to_string())); + } + + let request = self.client.get(url).query(&query).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Delete an instance + /// + ///Sends a `DELETE` request to `/v1/instances/{instance}` + pub async fn instance_delete_v1<'a>( + &'a self, + instance: &'a types::NameOrId, + organization: Option<&'a types::NameOrId>, + project: Option<&'a types::NameOrId>, + ) -> Result, Error> { + let url = format!( + "{}/v1/instances/{}", + self.baseurl, + encode_path(&instance.to_string()), + ); + let mut query = Vec::with_capacity(2usize); + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + + if let Some(v) = &project { + query.push(("project", v.to_string())); + } + + let request = self.client.delete(url).query(&query).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List an instance's disks + /// + ///Sends a `GET` request to `/v1/instances/{instance}/disks` + /// + ///Arguments: + /// - `instance` + /// - `limit`: Maximum number of items returned by a single call + /// - `organization` + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `project` + /// - `sort_by` + pub async fn instance_disk_list_v1<'a>( + &'a self, + instance: &'a types::NameOrId, + limit: Option, + organization: Option<&'a types::NameOrId>, + page_token: Option<&'a str>, + project: Option<&'a types::NameOrId>, + sort_by: Option, + ) -> Result, Error> { + let url = format!( + "{}/v1/instances/{}/disks", + self.baseurl, + encode_path(&instance.to_string()), + ); + let mut query = Vec::with_capacity(5usize); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + + if let Some(v) = &project { + query.push(("project", v.to_string())); + } + + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + + let request = self.client.get(url).query(&query).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List an instance's disks as a Stream + /// + ///Sends repeated `GET` requests to `/v1/instances/{instance}/disks` until + /// there are no more results. + /// + ///Arguments: + /// - `instance` + /// - `limit`: Maximum number of items returned by a single call + /// - `organization` + /// - `project` + /// - `sort_by` + pub fn instance_disk_list_v1_stream<'a>( + &'a self, + instance: &'a types::NameOrId, + limit: Option, + organization: Option<&'a types::NameOrId>, + project: Option<&'a types::NameOrId>, + sort_by: Option, + ) -> impl futures::Stream>> + Unpin + '_ { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.instance_disk_list_v1(instance, limit, organization, None, project, sort_by) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().map(Ok)); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.instance_disk_list_v1( + instance, + None, + None, + state.as_deref(), + None, + None, + ) + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + page.next_page, + )) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + + ///Attach a disk to an instance + /// + ///Sends a `POST` request to `/v1/instances/{instance}/disks/attach` + pub async fn instance_disk_attach_v1<'a>( + &'a self, + instance: &'a types::NameOrId, + organization: Option<&'a types::NameOrId>, + project: Option<&'a types::NameOrId>, + body: &'a types::DiskPath, + ) -> Result, Error> { + let url = format!( + "{}/v1/instances/{}/disks/attach", + self.baseurl, + encode_path(&instance.to_string()), + ); + let mut query = Vec::with_capacity(2usize); + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + + if let Some(v) = &project { + query.push(("project", v.to_string())); + } + + let request = self.client.post(url).json(&body).query(&query).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 202u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Detach a disk from an instance + /// + ///Sends a `POST` request to `/v1/instances/{instance}/disks/detach` + pub async fn instance_disk_detach_v1<'a>( + &'a self, + instance: &'a types::NameOrId, + organization: Option<&'a types::NameOrId>, + project: Option<&'a types::NameOrId>, + body: &'a types::DiskPath, + ) -> Result, Error> { + let url = format!( + "{}/v1/instances/{}/disks/detach", + self.baseurl, + encode_path(&instance.to_string()), + ); + let mut query = Vec::with_capacity(2usize); + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + + if let Some(v) = &project { + query.push(("project", v.to_string())); + } + + let request = self.client.post(url).json(&body).query(&query).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 202u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Migrate an instance + /// + ///Sends a `POST` request to `/v1/instances/{instance}/migrate` + pub async fn instance_migrate_v1<'a>( + &'a self, + instance: &'a types::NameOrId, + organization: Option<&'a types::NameOrId>, + project: Option<&'a types::NameOrId>, + body: &'a types::InstanceMigrate, + ) -> Result, Error> { + let url = format!( + "{}/v1/instances/{}/migrate", + self.baseurl, + encode_path(&instance.to_string()), + ); + let mut query = Vec::with_capacity(2usize); + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + + if let Some(v) = &project { + query.push(("project", v.to_string())); + } + + let request = self.client.post(url).json(&body).query(&query).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Reboot an instance + /// + ///Sends a `POST` request to `/v1/instances/{instance}/reboot` + pub async fn instance_reboot_v1<'a>( + &'a self, + instance: &'a types::NameOrId, + organization: Option<&'a types::NameOrId>, + project: Option<&'a types::NameOrId>, + ) -> Result, Error> { + let url = format!( + "{}/v1/instances/{}/reboot", + self.baseurl, + encode_path(&instance.to_string()), + ); + let mut query = Vec::with_capacity(2usize); + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + + if let Some(v) = &project { + query.push(("project", v.to_string())); + } + + let request = self.client.post(url).query(&query).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 202u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch an instance's serial console + /// + ///Sends a `GET` request to `/v1/instances/{instance}/serial-console` + /// + ///Arguments: + /// - `instance` + /// - `from_start`: Character index in the serial buffer from which to read, + /// counting the bytes output since instance start. If this is not + /// provided, `most_recent` must be provided, and if this *is* provided, + /// `most_recent` must *not* be provided. + /// - `max_bytes`: Maximum number of bytes of buffered serial console + /// contents to return. If the requested range runs to the end of the + /// available buffer, the data returned will be shorter than `max_bytes`. + /// - `most_recent`: Character index in the serial buffer from which to + /// read, counting *backward* from the most recently buffered data + /// retrieved from the instance. (See note on `from_start` about mutual + /// exclusivity) + /// - `organization` + /// - `project` + pub async fn instance_serial_console_v1<'a>( + &'a self, + instance: &'a types::NameOrId, + from_start: Option, + max_bytes: Option, + most_recent: Option, + organization: Option<&'a types::NameOrId>, + project: Option<&'a types::NameOrId>, + ) -> Result, Error> { + let url = format!( + "{}/v1/instances/{}/serial-console", + self.baseurl, + encode_path(&instance.to_string()), + ); + let mut query = Vec::with_capacity(5usize); + if let Some(v) = &from_start { + query.push(("from_start", v.to_string())); + } + + if let Some(v) = &max_bytes { + query.push(("max_bytes", v.to_string())); + } + + if let Some(v) = &most_recent { + query.push(("most_recent", v.to_string())); + } + + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + + if let Some(v) = &project { + query.push(("project", v.to_string())); + } + + let request = self.client.get(url).query(&query).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Stream an instance's serial console + /// + ///Sends a `GET` request to + /// `/v1/instances/{instance}/serial-console/stream` + pub async fn instance_serial_console_stream_v1<'a>( + &'a self, + instance: &'a types::NameOrId, + organization: Option<&'a types::NameOrId>, + project: Option<&'a types::NameOrId>, + ) -> Result, Error> { + let url = format!( + "{}/v1/instances/{}/serial-console/stream", + self.baseurl, + encode_path(&instance.to_string()), + ); + let mut query = Vec::with_capacity(2usize); + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + + if let Some(v) = &project { + query.push(("project", v.to_string())); + } + + let request = self + .client + .get(url) + .query(&query) + .header(reqwest::header::CONNECTION, "Upgrade") + .header(reqwest::header::UPGRADE, "websocket") + .header(reqwest::header::SEC_WEBSOCKET_VERSION, "13") + .header( + reqwest::header::SEC_WEBSOCKET_KEY, + base64::Engine::encode( + &base64::engine::general_purpose::STANDARD, + rand::random::<[u8; 16]>(), + ), + ) + .build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 101u16 => ResponseValue::upgrade(response).await, + 200..=299 => ResponseValue::upgrade(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Boot an instance + /// + ///Sends a `POST` request to `/v1/instances/{instance}/start` + pub async fn instance_start_v1<'a>( + &'a self, + instance: &'a types::NameOrId, + organization: Option<&'a types::NameOrId>, + project: Option<&'a types::NameOrId>, + ) -> Result, Error> { + let url = format!( + "{}/v1/instances/{}/start", + self.baseurl, + encode_path(&instance.to_string()), + ); + let mut query = Vec::with_capacity(2usize); + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + + if let Some(v) = &project { + query.push(("project", v.to_string())); + } + + let request = self.client.post(url).query(&query).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 202u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Stop an instance + /// + ///Sends a `POST` request to `/v1/instances/{instance}/stop` + pub async fn instance_stop_v1<'a>( + &'a self, + instance: &'a types::NameOrId, + organization: Option<&'a types::NameOrId>, + project: Option<&'a types::NameOrId>, + ) -> Result, Error> { + let url = format!( + "{}/v1/instances/{}/stop", + self.baseurl, + encode_path(&instance.to_string()), + ); + let mut query = Vec::with_capacity(2usize); + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + + if let Some(v) = &project { + query.push(("project", v.to_string())); + } + + let request = self.client.post(url).query(&query).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 202u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List organizations + /// + ///Sends a `GET` request to `/v1/organizations` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + pub async fn organization_list_v1<'a>( + &'a self, + limit: Option, + page_token: Option<&'a str>, + sort_by: Option, + ) -> Result, Error> { + let url = format!("{}/v1/organizations", self.baseurl,); + let mut query = Vec::with_capacity(3usize); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + + let request = self.client.get(url).query(&query).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List organizations as a Stream + /// + ///Sends repeated `GET` requests to `/v1/organizations` until there are no + /// more results. + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `sort_by` + pub fn organization_list_v1_stream<'a>( + &'a self, + limit: Option, + sort_by: Option, + ) -> impl futures::Stream>> + Unpin + '_ + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.organization_list_v1(limit, None, sort_by) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().map(Ok)); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.organization_list_v1(None, state.as_deref(), None) + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + page.next_page, + )) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + + ///Create an organization + /// + ///Sends a `POST` request to `/v1/organizations` + pub async fn organization_create_v1<'a>( + &'a self, + body: &'a types::OrganizationCreate, + ) -> Result, Error> { + let url = format!("{}/v1/organizations", self.baseurl,); + let request = self.client.post(url).json(&body).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch an organization + /// + ///Sends a `GET` request to `/v1/organizations/{organization}` + pub async fn organization_view_v1<'a>( + &'a self, + organization: &'a types::NameOrId, + ) -> Result, Error> { + let url = format!( + "{}/v1/organizations/{}", + self.baseurl, + encode_path(&organization.to_string()), + ); + let request = self.client.get(url).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Update an organization + /// + ///Sends a `PUT` request to `/v1/organizations/{organization}` + pub async fn organization_update_v1<'a>( + &'a self, + organization: &'a types::NameOrId, + body: &'a types::OrganizationUpdate, + ) -> Result, Error> { + let url = format!( + "{}/v1/organizations/{}", + self.baseurl, + encode_path(&organization.to_string()), + ); + let request = self.client.put(url).json(&body).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Delete an organization + /// + ///Sends a `DELETE` request to `/v1/organizations/{organization}` + pub async fn organization_delete_v1<'a>( + &'a self, + organization: &'a types::NameOrId, + ) -> Result, Error> { + let url = format!( + "{}/v1/organizations/{}", + self.baseurl, + encode_path(&organization.to_string()), + ); + let request = self.client.delete(url).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch an organization's IAM policy + /// + ///Sends a `GET` request to `/v1/organizations/{organization}/policy` + pub async fn organization_policy_view_v1<'a>( + &'a self, + organization: &'a types::NameOrId, + ) -> Result, Error> { + let url = format!( + "{}/v1/organizations/{}/policy", + self.baseurl, + encode_path(&organization.to_string()), + ); + let request = self.client.get(url).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Update an organization's IAM policy + /// + ///Sends a `PUT` request to `/v1/organizations/{organization}/policy` + pub async fn organization_policy_update_v1<'a>( + &'a self, + organization: &'a types::NameOrId, + body: &'a types::OrganizationRolePolicy, + ) -> Result, Error> { + let url = format!( + "{}/v1/organizations/{}/policy", + self.baseurl, + encode_path(&organization.to_string()), + ); + let request = self.client.put(url).json(&body).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List projects + /// + ///Sends a `GET` request to `/v1/projects` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `organization` + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + pub async fn project_list_v1<'a>( + &'a self, + limit: Option, + organization: Option<&'a types::NameOrId>, + page_token: Option<&'a str>, + sort_by: Option, + ) -> Result, Error> { + let url = format!("{}/v1/projects", self.baseurl,); + let mut query = Vec::with_capacity(4usize); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + + let request = self.client.get(url).query(&query).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List projects as a Stream + /// + ///Sends repeated `GET` requests to `/v1/projects` until there are no more + /// results. + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `organization` + /// - `sort_by` + pub fn project_list_v1_stream<'a>( + &'a self, + limit: Option, + organization: Option<&'a types::NameOrId>, + sort_by: Option, + ) -> impl futures::Stream>> + Unpin + '_ { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.project_list_v1(limit, organization, None, sort_by) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().map(Ok)); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.project_list_v1(None, None, state.as_deref(), None) + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + page.next_page, + )) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + + ///Create a project + /// + ///Sends a `POST` request to `/v1/projects` + pub async fn project_create_v1<'a>( + &'a self, + organization: &'a types::NameOrId, + body: &'a types::ProjectCreate, + ) -> Result, Error> { + let url = format!("{}/v1/projects", self.baseurl,); + let mut query = Vec::with_capacity(1usize); + query.push(("organization", organization.to_string())); + let request = self.client.post(url).json(&body).query(&query).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch a project + /// + ///Sends a `GET` request to `/v1/projects/{project}` + pub async fn project_view_v1<'a>( + &'a self, + project: &'a types::NameOrId, + organization: Option<&'a types::NameOrId>, + ) -> Result, Error> { + let url = format!( + "{}/v1/projects/{}", + self.baseurl, + encode_path(&project.to_string()), + ); + let mut query = Vec::with_capacity(1usize); + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + + let request = self.client.get(url).query(&query).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Update a project + /// + ///Sends a `PUT` request to `/v1/projects/{project}` + pub async fn project_update_v1<'a>( + &'a self, + project: &'a types::NameOrId, + organization: Option<&'a types::NameOrId>, + body: &'a types::ProjectUpdate, + ) -> Result, Error> { + let url = format!( + "{}/v1/projects/{}", + self.baseurl, + encode_path(&project.to_string()), + ); + let mut query = Vec::with_capacity(1usize); + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + + let request = self.client.put(url).json(&body).query(&query).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Delete a project + /// + ///Sends a `DELETE` request to `/v1/projects/{project}` + pub async fn project_delete_v1<'a>( + &'a self, + project: &'a types::NameOrId, + organization: Option<&'a types::NameOrId>, + ) -> Result, Error> { + let url = format!( + "{}/v1/projects/{}", + self.baseurl, + encode_path(&project.to_string()), + ); + let mut query = Vec::with_capacity(1usize); + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + + let request = self.client.delete(url).query(&query).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch a project's IAM policy + /// + ///Sends a `GET` request to `/v1/projects/{project}/policy` + pub async fn project_policy_view_v1<'a>( + &'a self, + project: &'a types::NameOrId, + organization: Option<&'a types::NameOrId>, + ) -> Result, Error> { + let url = format!( + "{}/v1/projects/{}/policy", + self.baseurl, + encode_path(&project.to_string()), + ); + let mut query = Vec::with_capacity(1usize); + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + + let request = self.client.get(url).query(&query).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Update a project's IAM policy + /// + ///Sends a `PUT` request to `/v1/projects/{project}/policy` + pub async fn project_policy_update_v1<'a>( + &'a self, + project: &'a types::NameOrId, + organization: Option<&'a types::NameOrId>, + body: &'a types::ProjectRolePolicy, + ) -> Result, Error> { + let url = format!( + "{}/v1/projects/{}/policy", + self.baseurl, + encode_path(&project.to_string()), + ); + let mut query = Vec::with_capacity(1usize); + if let Some(v) = &organization { + query.push(("organization", v.to_string())); + } + + let request = self.client.put(url).json(&body).query(&query).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///View version and update status of component tree + /// + ///Sends a `GET` request to `/v1/system/update/components` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + pub async fn system_component_version_list<'a>( + &'a self, + limit: Option, + page_token: Option<&'a str>, + sort_by: Option, + ) -> Result, Error> { + let url = format!("{}/v1/system/update/components", self.baseurl,); + let mut query = Vec::with_capacity(3usize); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + + let request = self.client.get(url).query(&query).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///View version and update status of component tree as a Stream + /// + ///Sends repeated `GET` requests to `/v1/system/update/components` until + /// there are no more results. + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `sort_by` + pub fn system_component_version_list_stream<'a>( + &'a self, + limit: Option, + sort_by: Option, + ) -> impl futures::Stream>> + Unpin + '_ + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.system_component_version_list(limit, None, sort_by) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().map(Ok)); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.system_component_version_list(None, state.as_deref(), None) + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + page.next_page, + )) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + + ///List all update deployments + /// + ///Sends a `GET` request to `/v1/system/update/deployments` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + pub async fn update_deployments_list<'a>( + &'a self, + limit: Option, + page_token: Option<&'a str>, + sort_by: Option, + ) -> Result, Error> { + let url = format!("{}/v1/system/update/deployments", self.baseurl,); + let mut query = Vec::with_capacity(3usize); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + + let request = self.client.get(url).query(&query).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List all update deployments as a Stream + /// + ///Sends repeated `GET` requests to `/v1/system/update/deployments` until + /// there are no more results. + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `sort_by` + pub fn update_deployments_list_stream<'a>( + &'a self, + limit: Option, + sort_by: Option, + ) -> impl futures::Stream>> + Unpin + '_ + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.update_deployments_list(limit, None, sort_by) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().map(Ok)); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.update_deployments_list(None, state.as_deref(), None) + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + page.next_page, + )) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + + ///Fetch a system update deployment + /// + ///Sends a `GET` request to `/v1/system/update/deployments/{id}` + pub async fn update_deployment_view<'a>( + &'a self, + id: &'a uuid::Uuid, + ) -> Result, Error> { + let url = format!( + "{}/v1/system/update/deployments/{}", + self.baseurl, + encode_path(&id.to_string()), + ); + let request = self.client.get(url).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Refresh update data + /// + ///Sends a `POST` request to `/v1/system/update/refresh` + pub async fn system_update_refresh<'a>( + &'a self, + ) -> Result, Error> { + let url = format!("{}/v1/system/update/refresh", self.baseurl,); + let request = self.client.post(url).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Start system update + /// + ///Sends a `POST` request to `/v1/system/update/start` + pub async fn system_update_start<'a>( + &'a self, + body: &'a types::SystemUpdateStart, + ) -> Result, Error> { + let url = format!("{}/v1/system/update/start", self.baseurl,); + let request = self.client.post(url).json(&body).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 202u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Stop system update + /// + ///If there is no update in progress, do nothing. + /// + ///Sends a `POST` request to `/v1/system/update/stop` + pub async fn system_update_stop<'a>( + &'a self, + ) -> Result, Error> { + let url = format!("{}/v1/system/update/stop", self.baseurl,); + let request = self.client.post(url).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List all updates + /// + ///Sends a `GET` request to `/v1/system/update/updates` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + pub async fn system_update_list<'a>( + &'a self, + limit: Option, + page_token: Option<&'a str>, + sort_by: Option, + ) -> Result, Error> { + let url = format!("{}/v1/system/update/updates", self.baseurl,); + let mut query = Vec::with_capacity(3usize); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + + let request = self.client.get(url).query(&query).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List all updates as a Stream + /// + ///Sends repeated `GET` requests to `/v1/system/update/updates` until there + /// are no more results. + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `sort_by` + pub fn system_update_list_stream<'a>( + &'a self, + limit: Option, + sort_by: Option, + ) -> impl futures::Stream>> + Unpin + '_ + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.system_update_list(limit, None, sort_by) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().map(Ok)); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.system_update_list(None, state.as_deref(), None) + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + page.next_page, + )) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + + ///View system update + /// + ///Sends a `GET` request to `/v1/system/update/updates/{version}` + pub async fn system_update_view<'a>( + &'a self, + version: &'a types::SemverVersion, + ) -> Result, Error> { + let url = format!( + "{}/v1/system/update/updates/{}", + self.baseurl, + encode_path(&version.to_string()), + ); + let request = self.client.get(url).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///View system update component tree + /// + ///Sends a `GET` request to + /// `/v1/system/update/updates/{version}/components` + pub async fn system_update_components_list<'a>( + &'a self, + version: &'a types::SemverVersion, + ) -> Result, Error> { + let url = format!( + "{}/v1/system/update/updates/{}/components", + self.baseurl, + encode_path(&version.to_string()), + ); + let request = self.client.get(url).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///View system version and update status + /// + ///Sends a `GET` request to `/v1/system/update/version` + pub async fn system_version<'a>( + &'a self, + ) -> Result, Error> { + let url = format!("{}/v1/system/update/version", self.baseurl,); + let request = self.client.get(url).build()?; + let result = self.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } } pub mod prelude { diff --git a/progenitor-impl/tests/test_output.rs b/progenitor-impl/tests/test_output.rs index eb80b41..9b686df 100644 --- a/progenitor-impl/tests/test_output.rs +++ b/progenitor-impl/tests/test_output.rs @@ -6,7 +6,8 @@ use std::{ }; use progenitor_impl::{ - GenerationSettings, Generator, InterfaceStyle, TagStyle, TypePatch, + GenerationSettings, Generator, InterfaceStyle, TagStyle, TypeImpl, + TypePatch, }; use openapiv3::OpenAPI; @@ -19,7 +20,7 @@ where match serde_json::from_reader(f) { Ok(json_value) => json_value, _ => { - f = File::open(p.clone()).unwrap(); + f = File::open(p).unwrap(); serde_yaml::from_reader(f).unwrap() } } @@ -55,7 +56,7 @@ fn verify_apis(openapi_file: &str) { ..Default::default() }, "usize", - ["Display"].into_iter(), + [TypeImpl::Display].into_iter(), ), ); let output = generator.generate_text_normalize_comments(&spec).unwrap(); diff --git a/progenitor-macro/src/lib.rs b/progenitor-macro/src/lib.rs index 732c57e..5231d81 100644 --- a/progenitor-macro/src/lib.rs +++ b/progenitor-macro/src/lib.rs @@ -217,21 +217,13 @@ fn do_generate_api(item: TokenStream) -> Result { }); replace.into_iter().for_each(|(type_name, type_and_impls)| { let type_name = type_name.to_token_stream(); - let type_and_impls = type_and_impls.into_inner(); - let replace_name = type_and_impls.type_name.to_token_stream(); - let impls = type_and_impls - .impls - .into_iter() - .map(|x| x.to_token_stream()); + let (replace_name, impls) = + type_and_impls.into_inner().into_name_and_impls(); settings.with_replacement(type_name, replace_name, impls); }); convert.into_iter().for_each(|(schema, type_and_impls)| { - let type_and_impls = type_and_impls.into_inner(); - let type_name = type_and_impls.type_name.to_token_stream(); - let impls = type_and_impls - .impls - .into_iter() - .map(|x| x.to_token_stream()); + let (type_name, impls) = + type_and_impls.into_inner().into_name_and_impls(); settings.with_conversion(schema, type_name, impls); }); (spec.into_inner(), settings) diff --git a/progenitor-macro/src/token_utils.rs b/progenitor-macro/src/token_utils.rs index 827dc97..671dd2e 100644 --- a/progenitor-macro/src/token_utils.rs +++ b/progenitor-macro/src/token_utils.rs @@ -1,5 +1,7 @@ // Copyright 2023 Oxide Computer Company +use std::collections::HashSet; + use quote::ToTokens; use syn::{ parse::Parse, @@ -8,6 +10,8 @@ use syn::{ Ident, Path, Token, TraitBoundModifier, }; +use progenitor_impl::TypeImpl; + #[derive(Debug)] pub struct TypeAndImpls { pub type_name: Path, @@ -15,6 +19,41 @@ pub struct TypeAndImpls { pub impls: Punctuated, } +impl TypeAndImpls { + pub(crate) fn into_name_and_impls( + self, + ) -> (String, impl Iterator) { + // If there are no traits specified, these are assumed to be + // implemented. A user would use the `?FromStr` syntax to remove one of + // these defaults; + const DEFAULT_IMPLS: [TypeImpl; 2] = + [TypeImpl::FromStr, TypeImpl::Display]; + + let name = self.type_name.to_token_stream().to_string(); + let mut impls = DEFAULT_IMPLS.into_iter().collect::>(); + self.impls.into_iter().for_each( + |ImplTrait { + modifier, + impl_name, + .. + }| { + // TODO should this be an error rather than silently ignored? + if let Some(impl_name) = impl_name { + match modifier { + syn::TraitBoundModifier::None => { + impls.insert(impl_name) + } + syn::TraitBoundModifier::Maybe(_) => { + impls.remove(&impl_name) + } + }; + } + }, + ); + (name, impls.into_iter()) + } +} + impl Parse for TypeAndImpls { fn parse(input: syn::parse::ParseStream) -> syn::Result { let type_name: Path = input.parse()?; @@ -52,16 +91,19 @@ impl ToTokens for TypeAndImpls { #[derive(Debug)] pub struct ImplTrait { pub modifier: TraitBoundModifier, - pub impl_name: Ident, + pub impl_ident: Ident, + pub impl_name: Option, } impl Parse for ImplTrait { fn parse(input: syn::parse::ParseStream) -> syn::Result { let modifier: TraitBoundModifier = input.parse()?; - let impl_name: Ident = input.parse()?; + let impl_ident: Ident = input.parse()?; + let impl_name = impl_ident.to_string().parse().ok(); Ok(Self { modifier, + impl_ident, impl_name, }) } @@ -70,7 +112,7 @@ impl Parse for ImplTrait { impl ToTokens for ImplTrait { fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) { self.modifier.to_tokens(tokens); - self.impl_name.to_tokens(tokens); + self.impl_ident.to_tokens(tokens); } } diff --git a/sample_openapi/nexus.json b/sample_openapi/nexus.json index 2770ecd..29689c7 100644 --- a/sample_openapi/nexus.json +++ b/sample_openapi/nexus.json @@ -15,7 +15,8 @@ "tags": [ "disks" ], - "summary": "Get a disk by id", + "summary": "Fetch a disk by id", + "description": "Use `GET /v1/disks/{disk}` instead", "operationId": "disk_view_by_id", "parameters": [ { @@ -25,8 +26,7 @@ "schema": { "type": "string", "format": "uuid" - }, - "style": "simple" + } } ], "responses": { @@ -46,46 +46,8 @@ "5XX": { "$ref": "#/components/responses/Error" } - } - } - }, - "/by-id/global-images/{id}": { - "get": { - "tags": [ - "images:global" - ], - "summary": "Get a global image by id.", - "operationId": "image_global_view_by_id", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "schema": { - "type": "string", - "format": "uuid" - }, - "style": "simple" - } - ], - "responses": { - "200": { - "description": "successful operation", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/GlobalImage" - } - } - } - }, - "4XX": { - "$ref": "#/components/responses/Error" - }, - "5XX": { - "$ref": "#/components/responses/Error" - } - } + }, + "deprecated": true } }, "/by-id/images/{id}": { @@ -103,8 +65,7 @@ "schema": { "type": "string", "format": "uuid" - }, - "style": "simple" + } } ], "responses": { @@ -132,7 +93,7 @@ "tags": [ "instances" ], - "summary": "Get an instance by id.", + "summary": "Fetch an instance by id", "operationId": "instance_view_by_id", "parameters": [ { @@ -142,8 +103,7 @@ "schema": { "type": "string", "format": "uuid" - }, - "style": "simple" + } } ], "responses": { @@ -171,7 +131,7 @@ "tags": [ "instances" ], - "summary": "Get an instance's network interface by id.", + "summary": "Fetch a network interface by id", "operationId": "instance_network_interface_view_by_id", "parameters": [ { @@ -181,8 +141,7 @@ "schema": { "type": "string", "format": "uuid" - }, - "style": "simple" + } } ], "responses": { @@ -210,7 +169,8 @@ "tags": [ "organizations" ], - "summary": "Get an organization by id", + "summary": "Fetch an organization by id", + "description": "Use `GET /v1/organizations/{organization}` instead", "operationId": "organization_view_by_id", "parameters": [ { @@ -220,8 +180,7 @@ "schema": { "type": "string", "format": "uuid" - }, - "style": "simple" + } } ], "responses": { @@ -241,7 +200,8 @@ "5XX": { "$ref": "#/components/responses/Error" } - } + }, + "deprecated": true } }, "/by-id/projects/{id}": { @@ -249,7 +209,8 @@ "tags": [ "projects" ], - "summary": "Get a project by id", + "summary": "Fetch a project by id", + "description": "Use `GET /v1/projects/{project}` instead", "operationId": "project_view_by_id", "parameters": [ { @@ -259,8 +220,7 @@ "schema": { "type": "string", "format": "uuid" - }, - "style": "simple" + } } ], "responses": { @@ -280,7 +240,8 @@ "5XX": { "$ref": "#/components/responses/Error" } - } + }, + "deprecated": true } }, "/by-id/snapshots/{id}": { @@ -288,7 +249,7 @@ "tags": [ "snapshots" ], - "summary": "Get a snapshot by id.", + "summary": "Fetch a snapshot by id", "operationId": "snapshot_view_by_id", "parameters": [ { @@ -298,8 +259,7 @@ "schema": { "type": "string", "format": "uuid" - }, - "style": "simple" + } } ], "responses": { @@ -327,7 +287,7 @@ "tags": [ "vpcs" ], - "summary": "Get a vpc router route by id", + "summary": "Fetch a route by id", "operationId": "vpc_router_route_view_by_id", "parameters": [ { @@ -337,8 +297,7 @@ "schema": { "type": "string", "format": "uuid" - }, - "style": "simple" + } } ], "responses": { @@ -366,7 +325,7 @@ "tags": [ "vpcs" ], - "summary": "Get a VPC Router by id", + "summary": "Get a router by id", "operationId": "vpc_router_view_by_id", "parameters": [ { @@ -376,8 +335,7 @@ "schema": { "type": "string", "format": "uuid" - }, - "style": "simple" + } } ], "responses": { @@ -405,7 +363,7 @@ "tags": [ "vpcs" ], - "summary": "Get a VPC subnet by id.", + "summary": "Fetch a subnet by id", "operationId": "vpc_subnet_view_by_id", "parameters": [ { @@ -415,8 +373,7 @@ "schema": { "type": "string", "format": "uuid" - }, - "style": "simple" + } } ], "responses": { @@ -444,7 +401,7 @@ "tags": [ "vpcs" ], - "summary": "Get a VPC by id.", + "summary": "Fetch a VPC", "operationId": "vpc_view_by_id", "parameters": [ { @@ -454,8 +411,7 @@ "schema": { "type": "string", "format": "uuid" - }, - "style": "simple" + } } ], "responses": { @@ -569,13 +525,13 @@ } } }, - "/hardware/racks": { + "/groups": { "get": { "tags": [ - "hardware" + "silos" ], - "summary": "List racks in the system.", - "operationId": "rack_list", + "summary": "List groups", + "operationId": "group_list", "parameters": [ { "in": "query", @@ -586,8 +542,7 @@ "type": "integer", "format": "uint32", "minimum": 1 - }, - "style": "form" + } }, { "in": "query", @@ -596,16 +551,14 @@ "schema": { "nullable": true, "type": "string" - }, - "style": "form" + } }, { "in": "query", "name": "sort_by", "schema": { "$ref": "#/components/schemas/IdSortMode" - }, - "style": "form" + } } ], "responses": { @@ -614,7 +567,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/RackResultsPage" + "$ref": "#/components/schemas/GroupResultsPage" } } } @@ -629,653 +582,17 @@ "x-dropshot-pagination": true } }, - "/hardware/racks/{rack_id}": { - "get": { - "tags": [ - "hardware" - ], - "summary": "Fetch information about a particular rack.", - "operationId": "rack_view", - "parameters": [ - { - "in": "path", - "name": "rack_id", - "description": "The rack's unique ID.", - "required": true, - "schema": { - "type": "string", - "format": "uuid" - }, - "style": "simple" - } - ], - "responses": { - "200": { - "description": "successful operation", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Rack" - } - } - } - }, - "4XX": { - "$ref": "#/components/responses/Error" - }, - "5XX": { - "$ref": "#/components/responses/Error" - } - } - } - }, - "/hardware/sleds": { - "get": { - "tags": [ - "hardware" - ], - "summary": "List sleds in the system.", - "operationId": "sled_list", - "parameters": [ - { - "in": "query", - "name": "limit", - "description": "Maximum number of items returned by a single call", - "schema": { - "nullable": true, - "type": "integer", - "format": "uint32", - "minimum": 1 - }, - "style": "form" - }, - { - "in": "query", - "name": "page_token", - "description": "Token returned by previous call to retrieve the subsequent page", - "schema": { - "nullable": true, - "type": "string" - }, - "style": "form" - }, - { - "in": "query", - "name": "sort_by", - "schema": { - "$ref": "#/components/schemas/IdSortMode" - }, - "style": "form" - } - ], - "responses": { - "200": { - "description": "successful operation", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/SledResultsPage" - } - } - } - }, - "4XX": { - "$ref": "#/components/responses/Error" - }, - "5XX": { - "$ref": "#/components/responses/Error" - } - }, - "x-dropshot-pagination": true - } - }, - "/hardware/sleds/{sled_id}": { - "get": { - "tags": [ - "hardware" - ], - "summary": "Fetch information about a sled in the system.", - "operationId": "sled_view", - "parameters": [ - { - "in": "path", - "name": "sled_id", - "description": "The sled's unique ID.", - "required": true, - "schema": { - "type": "string", - "format": "uuid" - }, - "style": "simple" - } - ], - "responses": { - "200": { - "description": "successful operation", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Sled" - } - } - } - }, - "4XX": { - "$ref": "#/components/responses/Error" - }, - "5XX": { - "$ref": "#/components/responses/Error" - } - } - } - }, - "/images": { - "get": { - "tags": [ - "images:global" - ], - "summary": "List global images.", - "description": "Returns a list of all the global images. Global images are returned sorted by creation date, with the most recent images appearing first.", - "operationId": "image_global_list", - "parameters": [ - { - "in": "query", - "name": "limit", - "description": "Maximum number of items returned by a single call", - "schema": { - "nullable": true, - "type": "integer", - "format": "uint32", - "minimum": 1 - }, - "style": "form" - }, - { - "in": "query", - "name": "page_token", - "description": "Token returned by previous call to retrieve the subsequent page", - "schema": { - "nullable": true, - "type": "string" - }, - "style": "form" - }, - { - "in": "query", - "name": "sort_by", - "schema": { - "$ref": "#/components/schemas/NameSortMode" - }, - "style": "form" - } - ], - "responses": { - "200": { - "description": "successful operation", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/GlobalImageResultsPage" - } - } - } - }, - "4XX": { - "$ref": "#/components/responses/Error" - }, - "5XX": { - "$ref": "#/components/responses/Error" - } - }, - "x-dropshot-pagination": true - }, + "/login": { "post": { "tags": [ - "images:global" + "hidden" ], - "summary": "Create a global image.", - "description": "Create a new global image. This image can then be used by any user as a base for instances.", - "operationId": "image_global_create", + "operationId": "login_spoof", "requestBody": { "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/GlobalImageCreate" - } - } - }, - "required": true - }, - "responses": { - "201": { - "description": "successful creation", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/GlobalImage" - } - } - } - }, - "4XX": { - "$ref": "#/components/responses/Error" - }, - "5XX": { - "$ref": "#/components/responses/Error" - } - } - } - }, - "/images/{image_name}": { - "get": { - "tags": [ - "images:global" - ], - "summary": "Get a global image.", - "description": "Returns the details of a specific global image.", - "operationId": "image_global_view", - "parameters": [ - { - "in": "path", - "name": "image_name", - "required": true, - "schema": { - "$ref": "#/components/schemas/Name" - }, - "style": "simple" - } - ], - "responses": { - "200": { - "description": "successful operation", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/GlobalImage" - } - } - } - }, - "4XX": { - "$ref": "#/components/responses/Error" - }, - "5XX": { - "$ref": "#/components/responses/Error" - } - } - }, - "delete": { - "tags": [ - "images:global" - ], - "summary": "Delete a global image.", - "description": "Permanently delete a global image. This operation cannot be undone. Any instances using the global image will continue to run, however new instances can not be created with this image.", - "operationId": "image_global_delete", - "parameters": [ - { - "in": "path", - "name": "image_name", - "required": true, - "schema": { - "$ref": "#/components/schemas/Name" - }, - "style": "simple" - } - ], - "responses": { - "204": { - "description": "successful deletion" - }, - "4XX": { - "$ref": "#/components/responses/Error" - }, - "5XX": { - "$ref": "#/components/responses/Error" - } - } - } - }, - "/ip-pools": { - "get": { - "tags": [ - "ip-pools" - ], - "summary": "List IP Pools.", - "operationId": "ip_pool_list", - "parameters": [ - { - "in": "query", - "name": "limit", - "description": "Maximum number of items returned by a single call", - "schema": { - "nullable": true, - "type": "integer", - "format": "uint32", - "minimum": 1 - }, - "style": "form" - }, - { - "in": "query", - "name": "page_token", - "description": "Token returned by previous call to retrieve the subsequent page", - "schema": { - "nullable": true, - "type": "string" - }, - "style": "form" - }, - { - "in": "query", - "name": "sort_by", - "schema": { - "$ref": "#/components/schemas/NameOrIdSortMode" - }, - "style": "form" - } - ], - "responses": { - "200": { - "description": "successful operation", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/IpPoolResultsPage" - } - } - } - }, - "4XX": { - "$ref": "#/components/responses/Error" - }, - "5XX": { - "$ref": "#/components/responses/Error" - } - }, - "x-dropshot-pagination": true - }, - "post": { - "tags": [ - "ip-pools" - ], - "summary": "Create a new IP Pool.", - "operationId": "ip_pool_create", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/IpPoolCreate" - } - } - }, - "required": true - }, - "responses": { - "201": { - "description": "successful creation", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/IpPool" - } - } - } - }, - "4XX": { - "$ref": "#/components/responses/Error" - }, - "5XX": { - "$ref": "#/components/responses/Error" - } - } - } - }, - "/ip-pools/{pool_name}": { - "get": { - "tags": [ - "ip-pools" - ], - "summary": "Fetch a single IP Pool.", - "operationId": "ip_pool_view", - "parameters": [ - { - "in": "path", - "name": "pool_name", - "required": true, - "schema": { - "$ref": "#/components/schemas/Name" - }, - "style": "simple" - } - ], - "responses": { - "200": { - "description": "successful operation", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/IpPool" - } - } - } - }, - "4XX": { - "$ref": "#/components/responses/Error" - }, - "5XX": { - "$ref": "#/components/responses/Error" - } - } - }, - "put": { - "tags": [ - "ip-pools" - ], - "summary": "Update an IP Pool.", - "operationId": "ip_pool_update", - "parameters": [ - { - "in": "path", - "name": "pool_name", - "required": true, - "schema": { - "$ref": "#/components/schemas/Name" - }, - "style": "simple" - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/IpPoolUpdate" - } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "successful operation", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/IpPool" - } - } - } - }, - "4XX": { - "$ref": "#/components/responses/Error" - }, - "5XX": { - "$ref": "#/components/responses/Error" - } - } - }, - "delete": { - "tags": [ - "ip-pools" - ], - "summary": "Delete an IP Pool.", - "operationId": "ip_pool_delete", - "parameters": [ - { - "in": "path", - "name": "pool_name", - "required": true, - "schema": { - "$ref": "#/components/schemas/Name" - }, - "style": "simple" - } - ], - "responses": { - "204": { - "description": "successful deletion" - }, - "4XX": { - "$ref": "#/components/responses/Error" - }, - "5XX": { - "$ref": "#/components/responses/Error" - } - } - } - }, - "/ip-pools/{pool_name}/ranges": { - "get": { - "tags": [ - "ip-pools" - ], - "summary": "List the ranges of IP addresses within an existing IP Pool.", - "description": "Note that ranges are listed sorted by their first address.", - "operationId": "ip_pool_range_list", - "parameters": [ - { - "in": "path", - "name": "pool_name", - "required": true, - "schema": { - "$ref": "#/components/schemas/Name" - }, - "style": "simple" - }, - { - "in": "query", - "name": "limit", - "description": "Maximum number of items returned by a single call", - "schema": { - "nullable": true, - "type": "integer", - "format": "uint32", - "minimum": 1 - }, - "style": "form" - }, - { - "in": "query", - "name": "page_token", - "description": "Token returned by previous call to retrieve the subsequent page", - "schema": { - "nullable": true, - "type": "string" - }, - "style": "form" - } - ], - "responses": { - "200": { - "description": "successful operation", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/IpPoolRangeResultsPage" - } - } - } - }, - "4XX": { - "$ref": "#/components/responses/Error" - }, - "5XX": { - "$ref": "#/components/responses/Error" - } - }, - "x-dropshot-pagination": true - } - }, - "/ip-pools/{pool_name}/ranges/add": { - "post": { - "tags": [ - "ip-pools" - ], - "summary": "Add a new range to an existing IP Pool.", - "operationId": "ip_pool_range_add", - "parameters": [ - { - "in": "path", - "name": "pool_name", - "required": true, - "schema": { - "$ref": "#/components/schemas/Name" - }, - "style": "simple" - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/IpRange" - } - } - }, - "required": true - }, - "responses": { - "201": { - "description": "successful creation", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/IpPoolRange" - } - } - } - }, - "4XX": { - "$ref": "#/components/responses/Error" - }, - "5XX": { - "$ref": "#/components/responses/Error" - } - } - } - }, - "/ip-pools/{pool_name}/ranges/remove": { - "post": { - "tags": [ - "ip-pools" - ], - "summary": "Remove a range from an existing IP Pool.", - "operationId": "ip_pool_range_remove", - "parameters": [ - { - "in": "path", - "name": "pool_name", - "required": true, - "schema": { - "$ref": "#/components/schemas/Name" - }, - "style": "simple" - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/IpRange" + "$ref": "#/components/schemas/SpoofLoginBody" } } }, @@ -1294,42 +611,64 @@ } } }, - "/login": { + "/login/{silo_name}/local": { "post": { "tags": [ - "hidden" + "login" + ], + "summary": "Authenticate a user (i.e., log in) via username and password", + "operationId": "login_local", + "parameters": [ + { + "in": "path", + "name": "silo_name", + "required": true, + "schema": { + "$ref": "#/components/schemas/Name" + } + } ], - "operationId": "spoof_login", "requestBody": { "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/SpoofLoginBody" + "$ref": "#/components/schemas/UsernamePasswordCredentials" } } }, "required": true }, "responses": { - "default": { - "description": "", - "content": { - "*/*": { - "schema": {} + "303": { + "description": "redirect (see other)", + "headers": { + "location": { + "description": "HTTP \"Location\" header", + "style": "simple", + "required": true, + "schema": { + "type": "string" + } } } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" } } } }, - "/login/{silo_name}/{provider_name}": { + "/login/{silo_name}/saml/{provider_name}": { "get": { "tags": [ "login" ], - "summary": "Ask the user to login to their identity provider", + "summary": "Prompt user login", "description": "Either display a page asking a user for their credentials, or redirect them to their identity provider.", - "operationId": "login", + "operationId": "login_saml_begin", "parameters": [ { "in": "path", @@ -1337,8 +676,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -1346,18 +684,28 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "responses": { - "default": { - "description": "", - "content": { - "*/*": { - "schema": {} + "302": { + "description": "redirect (found)", + "headers": { + "location": { + "description": "HTTP \"Location\" header", + "style": "simple", + "required": true, + "schema": { + "type": "string" + } } } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" } } }, @@ -1365,9 +713,8 @@ "tags": [ "login" ], - "summary": "Consume some sort of credentials, and authenticate a user.", - "description": "Either receive a username and password, or some sort of identity provider data (like a SAMLResponse). Use these to set the user's session cookie.", - "operationId": "consume_credentials", + "summary": "Authenticate a user (i.e., log in) via SAML", + "operationId": "login_saml", "parameters": [ { "in": "path", @@ -1375,8 +722,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -1384,8 +730,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "requestBody": { @@ -1400,13 +745,24 @@ "required": true }, "responses": { - "default": { - "description": "", - "content": { - "*/*": { - "schema": {} + "303": { + "description": "redirect (see other)", + "headers": { + "location": { + "description": "HTTP \"Location\" header", + "style": "simple", + "required": true, + "schema": { + "type": "string" + } } } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" } } } @@ -1418,13 +774,14 @@ ], "operationId": "logout", "responses": { - "default": { - "description": "", - "content": { - "*/*": { - "schema": {} - } - } + "204": { + "description": "resource updated" + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" } } } @@ -1434,7 +791,8 @@ "tags": [ "organizations" ], - "summary": "List all organizations.", + "summary": "List organizations", + "description": "Use `GET /v1/organizations` instead", "operationId": "organization_list", "parameters": [ { @@ -1446,8 +804,7 @@ "type": "integer", "format": "uint32", "minimum": 1 - }, - "style": "form" + } }, { "in": "query", @@ -1456,16 +813,14 @@ "schema": { "nullable": true, "type": "string" - }, - "style": "form" + } }, { "in": "query", "name": "sort_by", "schema": { "$ref": "#/components/schemas/NameOrIdSortMode" - }, - "style": "form" + } } ], "responses": { @@ -1486,13 +841,15 @@ "$ref": "#/components/responses/Error" } }, + "deprecated": true, "x-dropshot-pagination": true }, "post": { "tags": [ "organizations" ], - "summary": "Create a new organization.", + "summary": "Create an organization", + "description": "Use `POST /v1/organizations` instead", "operationId": "organization_create", "requestBody": { "content": { @@ -1521,7 +878,8 @@ "5XX": { "$ref": "#/components/responses/Error" } - } + }, + "deprecated": true } }, "/organizations/{organization_name}": { @@ -1529,7 +887,8 @@ "tags": [ "organizations" ], - "summary": "Fetch a specific organization", + "summary": "Fetch an organization", + "description": "Use `GET /v1/organizations/{organization}` instead", "operationId": "organization_view", "parameters": [ { @@ -1539,8 +898,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "responses": { @@ -1560,13 +918,15 @@ "5XX": { "$ref": "#/components/responses/Error" } - } + }, + "deprecated": true }, "put": { "tags": [ "organizations" ], - "summary": "Update a specific organization.", + "summary": "Update an organization", + "description": "Use `PUT /v1/organizations/{organization}` instead", "operationId": "organization_update", "parameters": [ { @@ -1576,8 +936,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "requestBody": { @@ -1607,13 +966,15 @@ "5XX": { "$ref": "#/components/responses/Error" } - } + }, + "deprecated": true }, "delete": { "tags": [ "organizations" ], - "summary": "Delete a specific organization.", + "summary": "Delete an organization", + "description": "Use `DELETE /v1/organizations/{organization}` instead", "operationId": "organization_delete", "parameters": [ { @@ -1623,8 +984,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "responses": { @@ -1637,7 +997,8 @@ "5XX": { "$ref": "#/components/responses/Error" } - } + }, + "deprecated": true } }, "/organizations/{organization_name}/policy": { @@ -1645,7 +1006,8 @@ "tags": [ "organizations" ], - "summary": "Fetch the IAM policy for this Organization", + "summary": "Fetch an organization's IAM policy", + "description": "Use `GET /v1/organizations/{organization}/policy` instead", "operationId": "organization_policy_view", "parameters": [ { @@ -1655,8 +1017,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "responses": { @@ -1676,13 +1037,15 @@ "5XX": { "$ref": "#/components/responses/Error" } - } + }, + "deprecated": true }, "put": { "tags": [ "organizations" ], - "summary": "Update the IAM policy for this Organization", + "summary": "Update an organization's IAM policy", + "description": "Use `PUT /v1/organizations/{organization}/policy` instead", "operationId": "organization_policy_update", "parameters": [ { @@ -1692,8 +1055,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "requestBody": { @@ -1723,7 +1085,8 @@ "5XX": { "$ref": "#/components/responses/Error" } - } + }, + "deprecated": true } }, "/organizations/{organization_name}/projects": { @@ -1731,7 +1094,8 @@ "tags": [ "projects" ], - "summary": "List all projects.", + "summary": "List projects", + "description": "Use `GET /v1/projects` instead", "operationId": "project_list", "parameters": [ { @@ -1743,8 +1107,7 @@ "type": "integer", "format": "uint32", "minimum": 1 - }, - "style": "form" + } }, { "in": "query", @@ -1753,16 +1116,14 @@ "schema": { "nullable": true, "type": "string" - }, - "style": "form" + } }, { "in": "query", "name": "sort_by", "schema": { "$ref": "#/components/schemas/NameOrIdSortMode" - }, - "style": "form" + } }, { "in": "path", @@ -1771,8 +1132,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "responses": { @@ -1793,13 +1153,15 @@ "$ref": "#/components/responses/Error" } }, + "deprecated": true, "x-dropshot-pagination": true }, "post": { "tags": [ "projects" ], - "summary": "Create a new project.", + "summary": "Create a project", + "description": "Use `POST /v1/projects` instead", "operationId": "project_create", "parameters": [ { @@ -1809,8 +1171,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "requestBody": { @@ -1840,7 +1201,8 @@ "5XX": { "$ref": "#/components/responses/Error" } - } + }, + "deprecated": true } }, "/organizations/{organization_name}/projects/{project_name}": { @@ -1848,7 +1210,8 @@ "tags": [ "projects" ], - "summary": "Fetch a specific project", + "summary": "Fetch a project", + "description": "Use `GET /v1/projects/{project}` instead", "operationId": "project_view", "parameters": [ { @@ -1858,8 +1221,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -1868,8 +1230,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "responses": { @@ -1889,13 +1250,15 @@ "5XX": { "$ref": "#/components/responses/Error" } - } + }, + "deprecated": true }, "put": { "tags": [ "projects" ], - "summary": "Update a specific project.", + "summary": "Update a project", + "description": "Use `PUT /v1/projects/{project}` instead", "operationId": "project_update", "parameters": [ { @@ -1905,8 +1268,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -1915,8 +1277,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "requestBody": { @@ -1946,13 +1307,15 @@ "5XX": { "$ref": "#/components/responses/Error" } - } + }, + "deprecated": true }, "delete": { "tags": [ "projects" ], - "summary": "Delete a specific project.", + "summary": "Delete a project", + "description": "Use `DELETE /v1/projects/{project}` instead", "operationId": "project_delete", "parameters": [ { @@ -1962,8 +1325,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -1972,8 +1334,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "responses": { @@ -1986,7 +1347,8 @@ "5XX": { "$ref": "#/components/responses/Error" } - } + }, + "deprecated": true } }, "/organizations/{organization_name}/projects/{project_name}/disks": { @@ -1994,7 +1356,8 @@ "tags": [ "disks" ], - "summary": "List disks in a project.", + "summary": "List disks", + "description": "Use `GET /v1/disks` instead", "operationId": "disk_list", "parameters": [ { @@ -2006,8 +1369,7 @@ "type": "integer", "format": "uint32", "minimum": 1 - }, - "style": "form" + } }, { "in": "query", @@ -2016,16 +1378,14 @@ "schema": { "nullable": true, "type": "string" - }, - "style": "form" + } }, { "in": "query", "name": "sort_by", "schema": { "$ref": "#/components/schemas/NameSortMode" - }, - "style": "form" + } }, { "in": "path", @@ -2034,8 +1394,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -2044,8 +1403,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "responses": { @@ -2066,13 +1424,14 @@ "$ref": "#/components/responses/Error" } }, + "deprecated": true, "x-dropshot-pagination": true }, "post": { "tags": [ "disks" ], - "summary": "Create a disk in a project.", + "summary": "Use `POST /v1/disks` instead", "operationId": "disk_create", "parameters": [ { @@ -2082,8 +1441,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -2092,8 +1450,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "requestBody": { @@ -2123,7 +1480,8 @@ "5XX": { "$ref": "#/components/responses/Error" } - } + }, + "deprecated": true } }, "/organizations/{organization_name}/projects/{project_name}/disks/{disk_name}": { @@ -2131,7 +1489,8 @@ "tags": [ "disks" ], - "summary": "Get a single disk in a project.", + "summary": "Fetch a disk", + "description": "Use `GET /v1/disks/{disk}` instead", "operationId": "disk_view", "parameters": [ { @@ -2140,8 +1499,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -2149,8 +1507,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -2158,8 +1515,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "responses": { @@ -2179,13 +1535,14 @@ "5XX": { "$ref": "#/components/responses/Error" } - } + }, + "deprecated": true }, "delete": { "tags": [ "disks" ], - "summary": "Delete a disk from a project.", + "summary": "Use `DELETE /v1/disks/{disk}` instead", "operationId": "disk_delete", "parameters": [ { @@ -2194,8 +1551,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -2203,8 +1559,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -2212,8 +1567,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "responses": { @@ -2226,7 +1580,8 @@ "5XX": { "$ref": "#/components/responses/Error" } - } + }, + "deprecated": true } }, "/organizations/{organization_name}/projects/{project_name}/disks/{disk_name}/metrics/{metric_name}": { @@ -2234,7 +1589,7 @@ "tags": [ "disks" ], - "summary": "Fetch metrics for a disk.", + "summary": "Fetch disk metrics", "operationId": "disk_metrics_list", "parameters": [ { @@ -2243,8 +1598,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -2252,8 +1606,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/DiskMetricName" - }, - "style": "simple" + } }, { "in": "path", @@ -2261,8 +1614,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -2270,8 +1622,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "query", @@ -2280,8 +1631,7 @@ "schema": { "type": "string", "format": "date-time" - }, - "style": "form" + } }, { "in": "query", @@ -2292,8 +1642,7 @@ "type": "integer", "format": "uint32", "minimum": 1 - }, - "style": "form" + } }, { "in": "query", @@ -2302,8 +1651,7 @@ "schema": { "nullable": true, "type": "string" - }, - "style": "form" + } }, { "in": "query", @@ -2312,8 +1660,7 @@ "schema": { "type": "string", "format": "date-time" - }, - "style": "form" + } } ], "responses": { @@ -2355,8 +1702,7 @@ "type": "integer", "format": "uint32", "minimum": 1 - }, - "style": "form" + } }, { "in": "query", @@ -2365,16 +1711,14 @@ "schema": { "nullable": true, "type": "string" - }, - "style": "form" + } }, { "in": "query", "name": "sort_by", "schema": { "$ref": "#/components/schemas/NameSortMode" - }, - "style": "form" + } }, { "in": "path", @@ -2383,8 +1727,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -2393,8 +1736,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "responses": { @@ -2432,8 +1774,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -2442,8 +1783,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "requestBody": { @@ -2481,8 +1821,8 @@ "tags": [ "images" ], - "summary": "Get an image", - "description": "Get the details of a specific image in a project.", + "summary": "Fetch an image", + "description": "Fetch the details for a specific image in a project.", "operationId": "image_view", "parameters": [ { @@ -2491,8 +1831,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -2500,8 +1839,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -2509,8 +1847,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "responses": { @@ -2546,8 +1883,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -2555,8 +1891,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -2564,8 +1899,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "responses": { @@ -2586,7 +1920,7 @@ "tags": [ "instances" ], - "summary": "List instances in a project.", + "summary": "List instances", "operationId": "instance_list", "parameters": [ { @@ -2598,8 +1932,7 @@ "type": "integer", "format": "uint32", "minimum": 1 - }, - "style": "form" + } }, { "in": "query", @@ -2608,16 +1941,14 @@ "schema": { "nullable": true, "type": "string" - }, - "style": "form" + } }, { "in": "query", "name": "sort_by", "schema": { "$ref": "#/components/schemas/NameSortMode" - }, - "style": "form" + } }, { "in": "path", @@ -2626,8 +1957,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -2636,8 +1966,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "responses": { @@ -2664,7 +1993,8 @@ "tags": [ "instances" ], - "summary": "Create an instance in a project.", + "summary": "Create an instance", + "description": "Use `POST /v1/instances` instead", "operationId": "instance_create", "parameters": [ { @@ -2674,8 +2004,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -2684,8 +2013,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "requestBody": { @@ -2715,7 +2043,8 @@ "5XX": { "$ref": "#/components/responses/Error" } - } + }, + "deprecated": true } }, "/organizations/{organization_name}/projects/{project_name}/instances/{instance_name}": { @@ -2723,7 +2052,8 @@ "tags": [ "instances" ], - "summary": "Get an instance in a project.", + "summary": "Fetch an instance", + "description": "Use `GET /v1/instances/{instance}` instead", "operationId": "instance_view", "parameters": [ { @@ -2732,8 +2062,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -2741,8 +2070,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -2750,8 +2078,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "responses": { @@ -2771,13 +2098,14 @@ "5XX": { "$ref": "#/components/responses/Error" } - } + }, + "deprecated": true }, "delete": { "tags": [ "instances" ], - "summary": "Delete an instance from a project.", + "summary": "Delete an instance", "operationId": "instance_delete", "parameters": [ { @@ -2786,8 +2114,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -2795,8 +2122,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -2804,8 +2130,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "responses": { @@ -2818,7 +2143,8 @@ "5XX": { "$ref": "#/components/responses/Error" } - } + }, + "deprecated": true } }, "/organizations/{organization_name}/projects/{project_name}/instances/{instance_name}/disks": { @@ -2826,7 +2152,8 @@ "tags": [ "instances" ], - "summary": "List disks attached to this instance.", + "summary": "List an instance's disks", + "description": "Use `GET /v1/instances/{instance}/disks` instead", "operationId": "instance_disk_list", "parameters": [ { @@ -2838,8 +2165,7 @@ "type": "integer", "format": "uint32", "minimum": 1 - }, - "style": "form" + } }, { "in": "query", @@ -2848,16 +2174,14 @@ "schema": { "nullable": true, "type": "string" - }, - "style": "form" + } }, { "in": "query", "name": "sort_by", "schema": { "$ref": "#/components/schemas/NameSortMode" - }, - "style": "form" + } }, { "in": "path", @@ -2865,8 +2189,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -2874,8 +2197,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -2883,8 +2205,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "responses": { @@ -2905,6 +2226,7 @@ "$ref": "#/components/responses/Error" } }, + "deprecated": true, "x-dropshot-pagination": true } }, @@ -2913,6 +2235,8 @@ "tags": [ "instances" ], + "summary": "Attach a disk to an instance", + "description": "Use `POST /v1/instances/{instance}/disks/attach` instead", "operationId": "instance_disk_attach", "parameters": [ { @@ -2921,8 +2245,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -2930,8 +2253,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -2939,8 +2261,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "requestBody": { @@ -2970,7 +2291,8 @@ "5XX": { "$ref": "#/components/responses/Error" } - } + }, + "deprecated": true } }, "/organizations/{organization_name}/projects/{project_name}/instances/{instance_name}/disks/detach": { @@ -2978,6 +2300,8 @@ "tags": [ "instances" ], + "summary": "Detach a disk from an instance", + "description": "Use `POST /v1/disks/{disk}/detach` instead", "operationId": "instance_disk_detach", "parameters": [ { @@ -2986,8 +2310,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -2995,8 +2318,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -3004,8 +2326,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "requestBody": { @@ -3035,7 +2356,8 @@ "5XX": { "$ref": "#/components/responses/Error" } - } + }, + "deprecated": true } }, "/organizations/{organization_name}/projects/{project_name}/instances/{instance_name}/external-ips": { @@ -3043,7 +2365,7 @@ "tags": [ "instances" ], - "summary": "List external IP addresses associated with an instance", + "summary": "List external IP addresses", "operationId": "instance_external_ip_list", "parameters": [ { @@ -3052,8 +2374,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -3061,8 +2382,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -3070,8 +2390,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "responses": { @@ -3099,7 +2418,8 @@ "tags": [ "instances" ], - "summary": "Migrate an instance to a different propolis-server, possibly on a different sled.", + "summary": "Migrate an instance", + "description": "Use `POST /v1/instances/{instance}/migrate` instead", "operationId": "instance_migrate", "parameters": [ { @@ -3108,8 +2428,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -3117,8 +2436,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -3126,8 +2444,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "requestBody": { @@ -3157,7 +2474,8 @@ "5XX": { "$ref": "#/components/responses/Error" } - } + }, + "deprecated": true } }, "/organizations/{organization_name}/projects/{project_name}/instances/{instance_name}/network-interfaces": { @@ -3165,7 +2483,7 @@ "tags": [ "instances" ], - "summary": "List network interfaces attached to this instance.", + "summary": "List network interfaces", "operationId": "instance_network_interface_list", "parameters": [ { @@ -3177,8 +2495,7 @@ "type": "integer", "format": "uint32", "minimum": 1 - }, - "style": "form" + } }, { "in": "query", @@ -3187,16 +2504,14 @@ "schema": { "nullable": true, "type": "string" - }, - "style": "form" + } }, { "in": "query", "name": "sort_by", "schema": { "$ref": "#/components/schemas/NameSortMode" - }, - "style": "form" + } }, { "in": "path", @@ -3204,8 +2519,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -3213,8 +2527,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -3222,8 +2535,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "responses": { @@ -3250,7 +2562,7 @@ "tags": [ "instances" ], - "summary": "Create a network interface for an instance.", + "summary": "Create a network interface", "operationId": "instance_network_interface_create", "parameters": [ { @@ -3259,8 +2571,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -3268,8 +2579,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -3277,8 +2587,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "requestBody": { @@ -3316,7 +2625,7 @@ "tags": [ "instances" ], - "summary": "Get an interface attached to an instance.", + "summary": "Fetch a network interface", "operationId": "instance_network_interface_view", "parameters": [ { @@ -3325,8 +2634,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -3334,8 +2642,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -3343,8 +2650,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -3352,8 +2658,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "responses": { @@ -3379,7 +2684,7 @@ "tags": [ "instances" ], - "summary": "Update information about an instance's network interface", + "summary": "Update a network interface", "operationId": "instance_network_interface_update", "parameters": [ { @@ -3388,8 +2693,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -3397,8 +2701,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -3406,8 +2709,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -3415,8 +2717,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "requestBody": { @@ -3452,7 +2753,7 @@ "tags": [ "instances" ], - "summary": "Detach a network interface from an instance.", + "summary": "Delete a network interface", "description": "Note that the primary interface for an instance cannot be deleted if there are any secondary interfaces. A new primary interface must be designated first. The primary interface can be deleted if there are no secondary interfaces.", "operationId": "instance_network_interface_delete", "parameters": [ @@ -3462,8 +2763,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -3471,8 +2771,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -3480,8 +2779,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -3489,8 +2787,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "responses": { @@ -3511,7 +2808,8 @@ "tags": [ "instances" ], - "summary": "Reboot an instance.", + "summary": "Reboot an instance", + "description": "Use `POST /v1/instances/{instance}/reboot` instead", "operationId": "instance_reboot", "parameters": [ { @@ -3520,8 +2818,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -3529,8 +2826,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -3538,8 +2834,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "responses": { @@ -3559,7 +2854,8 @@ "5XX": { "$ref": "#/components/responses/Error" } - } + }, + "deprecated": true } }, "/organizations/{organization_name}/projects/{project_name}/instances/{instance_name}/serial-console": { @@ -3567,7 +2863,8 @@ "tags": [ "instances" ], - "summary": "Get contents of an instance's serial console.", + "summary": "Fetch an instance's serial console", + "description": "Use `GET /v1/instances/{instance}/serial-console` instead", "operationId": "instance_serial_console", "parameters": [ { @@ -3576,8 +2873,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -3585,8 +2881,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -3594,8 +2889,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "query", @@ -3606,8 +2900,7 @@ "type": "integer", "format": "uint64", "minimum": 0 - }, - "style": "form" + } }, { "in": "query", @@ -3618,8 +2911,7 @@ "type": "integer", "format": "uint64", "minimum": 0 - }, - "style": "form" + } }, { "in": "query", @@ -3630,8 +2922,7 @@ "type": "integer", "format": "uint64", "minimum": 0 - }, - "style": "form" + } } ], "responses": { @@ -3651,7 +2942,56 @@ "5XX": { "$ref": "#/components/responses/Error" } - } + }, + "deprecated": true + } + }, + "/organizations/{organization_name}/projects/{project_name}/instances/{instance_name}/serial-console/stream": { + "get": { + "tags": [ + "instances" + ], + "summary": "Connect to an instance's serial console", + "description": "Use `GET /v1/instances/{instance}/serial-console/stream` instead", + "operationId": "instance_serial_console_stream", + "parameters": [ + { + "in": "path", + "name": "instance_name", + "required": true, + "schema": { + "$ref": "#/components/schemas/Name" + } + }, + { + "in": "path", + "name": "organization_name", + "required": true, + "schema": { + "$ref": "#/components/schemas/Name" + } + }, + { + "in": "path", + "name": "project_name", + "required": true, + "schema": { + "$ref": "#/components/schemas/Name" + } + } + ], + "responses": { + "default": { + "description": "", + "content": { + "*/*": { + "schema": {} + } + } + } + }, + "deprecated": true, + "x-dropshot-websocket": {} } }, "/organizations/{organization_name}/projects/{project_name}/instances/{instance_name}/start": { @@ -3659,7 +2999,8 @@ "tags": [ "instances" ], - "summary": "Boot an instance.", + "summary": "Boot an instance", + "description": "Use `POST /v1/instances/{instance}/start` instead", "operationId": "instance_start", "parameters": [ { @@ -3668,8 +3009,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -3677,8 +3017,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -3686,8 +3025,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "responses": { @@ -3707,7 +3045,8 @@ "5XX": { "$ref": "#/components/responses/Error" } - } + }, + "deprecated": true } }, "/organizations/{organization_name}/projects/{project_name}/instances/{instance_name}/stop": { @@ -3715,7 +3054,8 @@ "tags": [ "instances" ], - "summary": "Halt an instance.", + "summary": "Halt an instance", + "description": "Use `POST /v1/instances/{instance}/stop` instead", "operationId": "instance_stop", "parameters": [ { @@ -3724,8 +3064,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -3733,8 +3072,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -3742,8 +3080,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "responses": { @@ -3763,7 +3100,8 @@ "5XX": { "$ref": "#/components/responses/Error" } - } + }, + "deprecated": true } }, "/organizations/{organization_name}/projects/{project_name}/policy": { @@ -3771,7 +3109,8 @@ "tags": [ "projects" ], - "summary": "Fetch the IAM policy for this Project", + "summary": "Fetch a project's IAM policy", + "description": "Use `GET /v1/projects/{project}/policy` instead", "operationId": "project_policy_view", "parameters": [ { @@ -3781,8 +3120,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -3791,8 +3129,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "responses": { @@ -3812,13 +3149,14 @@ "5XX": { "$ref": "#/components/responses/Error" } - } + }, + "deprecated": true }, "put": { "tags": [ "projects" ], - "summary": "Update the IAM policy for this Project", + "summary": "Update a project's IAM policy", "operationId": "project_policy_update", "parameters": [ { @@ -3828,8 +3166,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -3838,8 +3175,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "requestBody": { @@ -3877,7 +3213,7 @@ "tags": [ "snapshots" ], - "summary": "List snapshots in a project.", + "summary": "List snapshots", "operationId": "snapshot_list", "parameters": [ { @@ -3889,8 +3225,7 @@ "type": "integer", "format": "uint32", "minimum": 1 - }, - "style": "form" + } }, { "in": "query", @@ -3899,16 +3234,14 @@ "schema": { "nullable": true, "type": "string" - }, - "style": "form" + } }, { "in": "query", "name": "sort_by", "schema": { "$ref": "#/components/schemas/NameSortMode" - }, - "style": "form" + } }, { "in": "path", @@ -3917,8 +3250,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -3927,8 +3259,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "responses": { @@ -3955,7 +3286,8 @@ "tags": [ "snapshots" ], - "summary": "Create a snapshot of a disk.", + "summary": "Create a snapshot", + "description": "Creates a point-in-time snapshot from a disk.", "operationId": "snapshot_create", "parameters": [ { @@ -3965,8 +3297,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -3975,8 +3306,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "requestBody": { @@ -4014,7 +3344,7 @@ "tags": [ "snapshots" ], - "summary": "Get a snapshot in a project.", + "summary": "Fetch a snapshot", "operationId": "snapshot_view", "parameters": [ { @@ -4023,8 +3353,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -4032,8 +3361,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -4041,8 +3369,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "responses": { @@ -4068,7 +3395,7 @@ "tags": [ "snapshots" ], - "summary": "Delete a snapshot from a project.", + "summary": "Delete a snapshot", "operationId": "snapshot_delete", "parameters": [ { @@ -4077,8 +3404,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -4086,8 +3412,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -4095,8 +3420,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "responses": { @@ -4117,7 +3441,7 @@ "tags": [ "vpcs" ], - "summary": "List VPCs in a project.", + "summary": "List VPCs", "operationId": "vpc_list", "parameters": [ { @@ -4129,8 +3453,7 @@ "type": "integer", "format": "uint32", "minimum": 1 - }, - "style": "form" + } }, { "in": "query", @@ -4139,16 +3462,14 @@ "schema": { "nullable": true, "type": "string" - }, - "style": "form" + } }, { "in": "query", "name": "sort_by", "schema": { "$ref": "#/components/schemas/NameSortMode" - }, - "style": "form" + } }, { "in": "path", @@ -4157,8 +3478,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -4167,8 +3487,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "responses": { @@ -4195,7 +3514,7 @@ "tags": [ "vpcs" ], - "summary": "Create a VPC in a project.", + "summary": "Create a VPC", "operationId": "vpc_create", "parameters": [ { @@ -4205,8 +3524,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -4215,8 +3533,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "requestBody": { @@ -4254,7 +3571,7 @@ "tags": [ "vpcs" ], - "summary": "Get a VPC in a project.", + "summary": "Fetch a VPC", "operationId": "vpc_view", "parameters": [ { @@ -4263,8 +3580,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -4272,8 +3588,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -4281,8 +3596,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "responses": { @@ -4308,7 +3622,7 @@ "tags": [ "vpcs" ], - "summary": "Update a VPC.", + "summary": "Update a VPC", "operationId": "vpc_update", "parameters": [ { @@ -4317,8 +3631,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -4326,8 +3639,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -4335,8 +3647,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "requestBody": { @@ -4372,7 +3683,7 @@ "tags": [ "vpcs" ], - "summary": "Delete a vpc from a project.", + "summary": "Delete a VPC", "operationId": "vpc_delete", "parameters": [ { @@ -4381,8 +3692,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -4390,8 +3700,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -4399,8 +3708,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "responses": { @@ -4421,7 +3729,7 @@ "tags": [ "vpcs" ], - "summary": "List firewall rules for a VPC.", + "summary": "List firewall rules", "operationId": "vpc_firewall_rules_view", "parameters": [ { @@ -4430,8 +3738,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -4439,8 +3746,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -4448,8 +3754,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "responses": { @@ -4475,7 +3780,7 @@ "tags": [ "vpcs" ], - "summary": "Replace the firewall rules for a VPC", + "summary": "Replace firewall rules", "operationId": "vpc_firewall_rules_update", "parameters": [ { @@ -4484,8 +3789,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -4493,8 +3797,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -4502,8 +3805,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "requestBody": { @@ -4541,7 +3843,7 @@ "tags": [ "vpcs" ], - "summary": "List VPC Custom and System Routers", + "summary": "List routers", "operationId": "vpc_router_list", "parameters": [ { @@ -4553,8 +3855,7 @@ "type": "integer", "format": "uint32", "minimum": 1 - }, - "style": "form" + } }, { "in": "query", @@ -4563,16 +3864,14 @@ "schema": { "nullable": true, "type": "string" - }, - "style": "form" + } }, { "in": "query", "name": "sort_by", "schema": { "$ref": "#/components/schemas/NameSortMode" - }, - "style": "form" + } }, { "in": "path", @@ -4580,8 +3879,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -4589,8 +3887,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -4598,8 +3895,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "responses": { @@ -4626,7 +3922,7 @@ "tags": [ "vpcs" ], - "summary": "Create a VPC Router", + "summary": "Create a router", "operationId": "vpc_router_create", "parameters": [ { @@ -4635,8 +3931,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -4644,8 +3939,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -4653,8 +3947,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "requestBody": { @@ -4692,7 +3985,7 @@ "tags": [ "vpcs" ], - "summary": "Get a VPC Router", + "summary": "Get a router", "operationId": "vpc_router_view", "parameters": [ { @@ -4701,8 +3994,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -4710,8 +4002,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -4719,8 +4010,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -4728,8 +4018,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "responses": { @@ -4755,7 +4044,7 @@ "tags": [ "vpcs" ], - "summary": "Update a VPC Router", + "summary": "Update a router", "operationId": "vpc_router_update", "parameters": [ { @@ -4764,8 +4053,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -4773,8 +4061,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -4782,8 +4069,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -4791,8 +4077,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "requestBody": { @@ -4828,7 +4113,7 @@ "tags": [ "vpcs" ], - "summary": "Delete a router from its VPC", + "summary": "Delete a router", "operationId": "vpc_router_delete", "parameters": [ { @@ -4837,8 +4122,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -4846,8 +4130,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -4855,8 +4138,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -4864,8 +4146,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "responses": { @@ -4886,7 +4167,8 @@ "tags": [ "vpcs" ], - "summary": "List a Router's routes", + "summary": "List routes", + "description": "List the routes associated with a router in a particular VPC.", "operationId": "vpc_router_route_list", "parameters": [ { @@ -4898,8 +4180,7 @@ "type": "integer", "format": "uint32", "minimum": 1 - }, - "style": "form" + } }, { "in": "query", @@ -4908,16 +4189,14 @@ "schema": { "nullable": true, "type": "string" - }, - "style": "form" + } }, { "in": "query", "name": "sort_by", "schema": { "$ref": "#/components/schemas/NameSortMode" - }, - "style": "form" + } }, { "in": "path", @@ -4925,8 +4204,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -4934,8 +4212,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -4943,8 +4220,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -4952,8 +4228,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "responses": { @@ -4980,7 +4255,7 @@ "tags": [ "vpcs" ], - "summary": "Create a VPC Router", + "summary": "Create a router", "operationId": "vpc_router_route_create", "parameters": [ { @@ -4989,8 +4264,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -4998,8 +4272,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -5007,8 +4280,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -5016,8 +4288,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "requestBody": { @@ -5055,7 +4326,7 @@ "tags": [ "vpcs" ], - "summary": "Get a VPC Router route", + "summary": "Fetch a route", "operationId": "vpc_router_route_view", "parameters": [ { @@ -5064,8 +4335,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -5073,8 +4343,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -5082,8 +4351,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -5091,8 +4359,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -5100,8 +4367,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "responses": { @@ -5127,7 +4393,7 @@ "tags": [ "vpcs" ], - "summary": "Update a Router route", + "summary": "Update a route", "operationId": "vpc_router_route_update", "parameters": [ { @@ -5136,8 +4402,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -5145,8 +4410,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -5154,8 +4418,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -5163,8 +4426,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -5172,8 +4434,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "requestBody": { @@ -5209,7 +4470,7 @@ "tags": [ "vpcs" ], - "summary": "Delete a route from its router", + "summary": "Delete a route", "operationId": "vpc_router_route_delete", "parameters": [ { @@ -5218,8 +4479,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -5227,8 +4487,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -5236,8 +4495,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -5245,8 +4503,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -5254,8 +4511,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "responses": { @@ -5276,7 +4532,7 @@ "tags": [ "vpcs" ], - "summary": "List subnets in a VPC.", + "summary": "List subnets", "operationId": "vpc_subnet_list", "parameters": [ { @@ -5288,8 +4544,7 @@ "type": "integer", "format": "uint32", "minimum": 1 - }, - "style": "form" + } }, { "in": "query", @@ -5298,16 +4553,14 @@ "schema": { "nullable": true, "type": "string" - }, - "style": "form" + } }, { "in": "query", "name": "sort_by", "schema": { "$ref": "#/components/schemas/NameSortMode" - }, - "style": "form" + } }, { "in": "path", @@ -5315,8 +4568,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -5324,8 +4576,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -5333,8 +4584,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "responses": { @@ -5361,7 +4611,7 @@ "tags": [ "vpcs" ], - "summary": "Create a subnet in a VPC.", + "summary": "Create a subnet", "operationId": "vpc_subnet_create", "parameters": [ { @@ -5370,8 +4620,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -5379,8 +4628,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -5388,8 +4636,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "requestBody": { @@ -5427,7 +4674,7 @@ "tags": [ "vpcs" ], - "summary": "Get subnet in a VPC.", + "summary": "Fetch a subnet", "operationId": "vpc_subnet_view", "parameters": [ { @@ -5436,8 +4683,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -5445,8 +4691,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -5454,8 +4699,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -5463,8 +4707,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "responses": { @@ -5490,7 +4733,7 @@ "tags": [ "vpcs" ], - "summary": "Update a VPC Subnet.", + "summary": "Update a subnet", "operationId": "vpc_subnet_update", "parameters": [ { @@ -5499,8 +4742,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -5508,8 +4750,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -5517,8 +4758,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -5526,8 +4766,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "requestBody": { @@ -5563,7 +4802,7 @@ "tags": [ "vpcs" ], - "summary": "Delete a subnet from a VPC.", + "summary": "Delete a subnet", "operationId": "vpc_subnet_delete", "parameters": [ { @@ -5572,8 +4811,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -5581,8 +4819,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -5590,8 +4827,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -5599,8 +4835,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "responses": { @@ -5621,7 +4856,7 @@ "tags": [ "vpcs" ], - "summary": "List network interfaces in a VPC subnet.", + "summary": "List network interfaces", "operationId": "vpc_subnet_list_network_interfaces", "parameters": [ { @@ -5633,8 +4868,7 @@ "type": "integer", "format": "uint32", "minimum": 1 - }, - "style": "form" + } }, { "in": "query", @@ -5643,16 +4877,14 @@ "schema": { "nullable": true, "type": "string" - }, - "style": "form" + } }, { "in": "query", "name": "sort_by", "schema": { "$ref": "#/components/schemas/NameSortMode" - }, - "style": "form" + } }, { "in": "path", @@ -5660,8 +4892,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -5669,8 +4900,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -5678,8 +4908,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -5687,8 +4916,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "responses": { @@ -5715,9 +4943,9 @@ "/policy": { "get": { "tags": [ - "policy" + "silos" ], - "summary": "Fetch the top-level IAM policy", + "summary": "Fetch the current silo's IAM policy", "operationId": "policy_view", "responses": { "200": { @@ -5725,7 +4953,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/FleetRolePolicy" + "$ref": "#/components/schemas/SiloRolePolicy" } } } @@ -5740,15 +4968,15 @@ }, "put": { "tags": [ - "policy" + "silos" ], - "summary": "Update the top-level IAM policy", + "summary": "Update the current silo's IAM policy", "operationId": "policy_update", "requestBody": { "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/FleetRolePolicy" + "$ref": "#/components/schemas/SiloRolePolicy" } } }, @@ -5760,7 +4988,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/FleetRolePolicy" + "$ref": "#/components/schemas/SiloRolePolicy" } } } @@ -5779,7 +5007,7 @@ "tags": [ "roles" ], - "summary": "List the built-in roles", + "summary": "List built-in roles", "operationId": "role_list", "parameters": [ { @@ -5791,8 +5019,7 @@ "type": "integer", "format": "uint32", "minimum": 1 - }, - "style": "form" + } }, { "in": "query", @@ -5801,8 +5028,7 @@ "schema": { "nullable": true, "type": "string" - }, - "style": "form" + } } ], "responses": { @@ -5831,7 +5057,7 @@ "tags": [ "roles" ], - "summary": "Fetch a specific built-in role", + "summary": "Fetch a built-in role", "operationId": "role_view", "parameters": [ { @@ -5841,8 +5067,7 @@ "required": true, "schema": { "type": "string" - }, - "style": "simple" + } } ], "responses": { @@ -5865,105 +5090,6 @@ } } }, - "/sagas": { - "get": { - "tags": [ - "sagas" - ], - "summary": "List all sagas (for debugging)", - "operationId": "saga_list", - "parameters": [ - { - "in": "query", - "name": "limit", - "description": "Maximum number of items returned by a single call", - "schema": { - "nullable": true, - "type": "integer", - "format": "uint32", - "minimum": 1 - }, - "style": "form" - }, - { - "in": "query", - "name": "page_token", - "description": "Token returned by previous call to retrieve the subsequent page", - "schema": { - "nullable": true, - "type": "string" - }, - "style": "form" - }, - { - "in": "query", - "name": "sort_by", - "schema": { - "$ref": "#/components/schemas/IdSortMode" - }, - "style": "form" - } - ], - "responses": { - "200": { - "description": "successful operation", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/SagaResultsPage" - } - } - } - }, - "4XX": { - "$ref": "#/components/responses/Error" - }, - "5XX": { - "$ref": "#/components/responses/Error" - } - }, - "x-dropshot-pagination": true - } - }, - "/sagas/{saga_id}": { - "get": { - "tags": [ - "sagas" - ], - "summary": "Fetch information about a single saga (for debugging)", - "operationId": "saga_view", - "parameters": [ - { - "in": "path", - "name": "saga_id", - "required": true, - "schema": { - "type": "string", - "format": "uuid" - }, - "style": "simple" - } - ], - "responses": { - "200": { - "description": "successful operation", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Saga" - } - } - } - }, - "4XX": { - "$ref": "#/components/responses/Error" - }, - "5XX": { - "$ref": "#/components/responses/Error" - } - } - } - }, "/session/me": { "get": { "tags": [ @@ -5991,12 +5117,70 @@ } } }, + "/session/me/groups": { + "get": { + "tags": [ + "hidden" + ], + "summary": "Fetch the silo groups the current user belongs to", + "operationId": "session_me_groups", + "parameters": [ + { + "in": "query", + "name": "limit", + "description": "Maximum number of items returned by a single call", + "schema": { + "nullable": true, + "type": "integer", + "format": "uint32", + "minimum": 1 + } + }, + { + "in": "query", + "name": "page_token", + "description": "Token returned by previous call to retrieve the subsequent page", + "schema": { + "nullable": true, + "type": "string" + } + }, + { + "in": "query", + "name": "sort_by", + "schema": { + "$ref": "#/components/schemas/IdSortMode" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GroupResultsPage" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + }, + "x-dropshot-pagination": true + } + }, "/session/me/sshkeys": { "get": { "tags": [ "session" ], - "summary": "List the current user's SSH public keys", + "summary": "List SSH public keys", + "description": "Lists SSH public keys for the currently authenticated user.", "operationId": "session_sshkey_list", "parameters": [ { @@ -6008,8 +5192,7 @@ "type": "integer", "format": "uint32", "minimum": 1 - }, - "style": "form" + } }, { "in": "query", @@ -6018,16 +5201,14 @@ "schema": { "nullable": true, "type": "string" - }, - "style": "form" + } }, { "in": "query", "name": "sort_by", "schema": { "$ref": "#/components/schemas/NameSortMode" - }, - "style": "form" + } } ], "responses": { @@ -6054,7 +5235,8 @@ "tags": [ "session" ], - "summary": "Create a new SSH public key for the current user", + "summary": "Create an SSH public key", + "description": "Create an SSH public key for the currently authenticated user.", "operationId": "session_sshkey_create", "requestBody": { "content": { @@ -6091,7 +5273,8 @@ "tags": [ "session" ], - "summary": "Get (by name) an SSH public key belonging to the current user", + "summary": "Fetch an SSH public key", + "description": "Fetch an SSH public key associated with the currently authenticated user.", "operationId": "session_sshkey_view", "parameters": [ { @@ -6100,8 +5283,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "responses": { @@ -6127,7 +5309,8 @@ "tags": [ "session" ], - "summary": "Delete (by name) an SSH public key belonging to the current user", + "summary": "Delete an SSH public key", + "description": "Delete an SSH public key associated with the currently authenticated user.", "operationId": "session_sshkey_delete", "parameters": [ { @@ -6136,8 +5319,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "responses": { @@ -6153,11 +5335,1501 @@ } } }, - "/silos": { + "/system/by-id/images/{id}": { "get": { "tags": [ - "silos" + "system" ], + "summary": "Fetch a system-wide image by id", + "operationId": "system_image_view_by_id", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "schema": { + "type": "string", + "format": "uuid" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GlobalImage" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/system/by-id/ip-pools/{id}": { + "get": { + "tags": [ + "system" + ], + "summary": "Fetch an IP pool by id", + "operationId": "ip_pool_view_by_id", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "schema": { + "type": "string", + "format": "uuid" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/IpPool" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/system/by-id/silos/{id}": { + "get": { + "tags": [ + "system" + ], + "summary": "Fetch a silo by id", + "operationId": "silo_view_by_id", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "schema": { + "type": "string", + "format": "uuid" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Silo" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/system/certificates": { + "get": { + "tags": [ + "system" + ], + "summary": "List system-wide certificates", + "description": "Returns a list of all the system-wide certificates. System-wide certificates are returned sorted by creation date, with the most recent certificates appearing first.", + "operationId": "certificate_list", + "parameters": [ + { + "in": "query", + "name": "limit", + "description": "Maximum number of items returned by a single call", + "schema": { + "nullable": true, + "type": "integer", + "format": "uint32", + "minimum": 1 + } + }, + { + "in": "query", + "name": "page_token", + "description": "Token returned by previous call to retrieve the subsequent page", + "schema": { + "nullable": true, + "type": "string" + } + }, + { + "in": "query", + "name": "sort_by", + "schema": { + "$ref": "#/components/schemas/NameSortMode" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CertificateResultsPage" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + }, + "x-dropshot-pagination": true + }, + "post": { + "tags": [ + "system" + ], + "summary": "Create a new system-wide x.509 certificate.", + "description": "This certificate is automatically used by the Oxide Control plane to serve external connections.", + "operationId": "certificate_create", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CertificateCreate" + } + } + }, + "required": true + }, + "responses": { + "201": { + "description": "successful creation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Certificate" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/system/certificates/{certificate}": { + "get": { + "tags": [ + "system" + ], + "summary": "Fetch a certificate", + "description": "Returns the details of a specific certificate", + "operationId": "certificate_view", + "parameters": [ + { + "in": "path", + "name": "certificate", + "required": true, + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Certificate" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + }, + "delete": { + "tags": [ + "system" + ], + "summary": "Delete a certificate", + "description": "Permanently delete a certificate. This operation cannot be undone.", + "operationId": "certificate_delete", + "parameters": [ + { + "in": "path", + "name": "certificate", + "required": true, + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + } + ], + "responses": { + "204": { + "description": "successful deletion" + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/system/hardware/disks": { + "get": { + "tags": [ + "system" + ], + "summary": "List physical disks", + "operationId": "physical_disk_list", + "parameters": [ + { + "in": "query", + "name": "limit", + "description": "Maximum number of items returned by a single call", + "schema": { + "nullable": true, + "type": "integer", + "format": "uint32", + "minimum": 1 + } + }, + { + "in": "query", + "name": "page_token", + "description": "Token returned by previous call to retrieve the subsequent page", + "schema": { + "nullable": true, + "type": "string" + } + }, + { + "in": "query", + "name": "sort_by", + "schema": { + "$ref": "#/components/schemas/IdSortMode" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PhysicalDiskResultsPage" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + }, + "x-dropshot-pagination": true + } + }, + "/system/hardware/racks": { + "get": { + "tags": [ + "system" + ], + "summary": "List racks", + "operationId": "rack_list", + "parameters": [ + { + "in": "query", + "name": "limit", + "description": "Maximum number of items returned by a single call", + "schema": { + "nullable": true, + "type": "integer", + "format": "uint32", + "minimum": 1 + } + }, + { + "in": "query", + "name": "page_token", + "description": "Token returned by previous call to retrieve the subsequent page", + "schema": { + "nullable": true, + "type": "string" + } + }, + { + "in": "query", + "name": "sort_by", + "schema": { + "$ref": "#/components/schemas/IdSortMode" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/RackResultsPage" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + }, + "x-dropshot-pagination": true + } + }, + "/system/hardware/racks/{rack_id}": { + "get": { + "tags": [ + "system" + ], + "summary": "Fetch a rack", + "operationId": "rack_view", + "parameters": [ + { + "in": "path", + "name": "rack_id", + "description": "The rack's unique ID.", + "required": true, + "schema": { + "type": "string", + "format": "uuid" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Rack" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/system/hardware/sleds": { + "get": { + "tags": [ + "system" + ], + "summary": "List sleds", + "operationId": "sled_list", + "parameters": [ + { + "in": "query", + "name": "limit", + "description": "Maximum number of items returned by a single call", + "schema": { + "nullable": true, + "type": "integer", + "format": "uint32", + "minimum": 1 + } + }, + { + "in": "query", + "name": "page_token", + "description": "Token returned by previous call to retrieve the subsequent page", + "schema": { + "nullable": true, + "type": "string" + } + }, + { + "in": "query", + "name": "sort_by", + "schema": { + "$ref": "#/components/schemas/IdSortMode" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SledResultsPage" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + }, + "x-dropshot-pagination": true + } + }, + "/system/hardware/sleds/{sled_id}": { + "get": { + "tags": [ + "system" + ], + "summary": "Fetch a sled", + "operationId": "sled_view", + "parameters": [ + { + "in": "path", + "name": "sled_id", + "description": "The sled's unique ID.", + "required": true, + "schema": { + "type": "string", + "format": "uuid" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Sled" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/system/hardware/sleds/{sled_id}/disks": { + "get": { + "tags": [ + "system" + ], + "summary": "List physical disks attached to sleds", + "operationId": "sled_physical_disk_list", + "parameters": [ + { + "in": "path", + "name": "sled_id", + "description": "The sled's unique ID.", + "required": true, + "schema": { + "type": "string", + "format": "uuid" + } + }, + { + "in": "query", + "name": "limit", + "description": "Maximum number of items returned by a single call", + "schema": { + "nullable": true, + "type": "integer", + "format": "uint32", + "minimum": 1 + } + }, + { + "in": "query", + "name": "page_token", + "description": "Token returned by previous call to retrieve the subsequent page", + "schema": { + "nullable": true, + "type": "string" + } + }, + { + "in": "query", + "name": "sort_by", + "schema": { + "$ref": "#/components/schemas/IdSortMode" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PhysicalDiskResultsPage" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + }, + "x-dropshot-pagination": true + } + }, + "/system/images": { + "get": { + "tags": [ + "system" + ], + "summary": "List system-wide images", + "description": "Returns a list of all the system-wide images. System-wide images are returned sorted by creation date, with the most recent images appearing first.", + "operationId": "system_image_list", + "parameters": [ + { + "in": "query", + "name": "limit", + "description": "Maximum number of items returned by a single call", + "schema": { + "nullable": true, + "type": "integer", + "format": "uint32", + "minimum": 1 + } + }, + { + "in": "query", + "name": "page_token", + "description": "Token returned by previous call to retrieve the subsequent page", + "schema": { + "nullable": true, + "type": "string" + } + }, + { + "in": "query", + "name": "sort_by", + "schema": { + "$ref": "#/components/schemas/NameSortMode" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GlobalImageResultsPage" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + }, + "x-dropshot-pagination": true + }, + "post": { + "tags": [ + "system" + ], + "summary": "Create a system-wide image", + "description": "Create a new system-wide image. This image can then be used by any user in any silo as a base for instances.", + "operationId": "system_image_create", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GlobalImageCreate" + } + } + }, + "required": true + }, + "responses": { + "201": { + "description": "successful creation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GlobalImage" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/system/images/{image_name}": { + "get": { + "tags": [ + "system" + ], + "summary": "Fetch a system-wide image", + "description": "Returns the details of a specific system-wide image.", + "operationId": "system_image_view", + "parameters": [ + { + "in": "path", + "name": "image_name", + "required": true, + "schema": { + "$ref": "#/components/schemas/Name" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GlobalImage" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + }, + "delete": { + "tags": [ + "system" + ], + "summary": "Delete a system-wide image", + "description": "Permanently delete a system-wide image. This operation cannot be undone. Any instances using the system-wide image will continue to run, however new instances can not be created with this image.", + "operationId": "system_image_delete", + "parameters": [ + { + "in": "path", + "name": "image_name", + "required": true, + "schema": { + "$ref": "#/components/schemas/Name" + } + } + ], + "responses": { + "204": { + "description": "successful deletion" + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/system/ip-pools": { + "get": { + "tags": [ + "system" + ], + "summary": "List IP pools", + "operationId": "ip_pool_list", + "parameters": [ + { + "in": "query", + "name": "limit", + "description": "Maximum number of items returned by a single call", + "schema": { + "nullable": true, + "type": "integer", + "format": "uint32", + "minimum": 1 + } + }, + { + "in": "query", + "name": "page_token", + "description": "Token returned by previous call to retrieve the subsequent page", + "schema": { + "nullable": true, + "type": "string" + } + }, + { + "in": "query", + "name": "sort_by", + "schema": { + "$ref": "#/components/schemas/NameOrIdSortMode" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/IpPoolResultsPage" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + }, + "x-dropshot-pagination": true + }, + "post": { + "tags": [ + "system" + ], + "summary": "Create an IP pool", + "operationId": "ip_pool_create", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/IpPoolCreate" + } + } + }, + "required": true + }, + "responses": { + "201": { + "description": "successful creation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/IpPool" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/system/ip-pools/{pool_name}": { + "get": { + "tags": [ + "system" + ], + "summary": "Fetch an IP pool", + "operationId": "ip_pool_view", + "parameters": [ + { + "in": "path", + "name": "pool_name", + "required": true, + "schema": { + "$ref": "#/components/schemas/Name" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/IpPool" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + }, + "put": { + "tags": [ + "system" + ], + "summary": "Update an IP Pool", + "operationId": "ip_pool_update", + "parameters": [ + { + "in": "path", + "name": "pool_name", + "required": true, + "schema": { + "$ref": "#/components/schemas/Name" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/IpPoolUpdate" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/IpPool" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + }, + "delete": { + "tags": [ + "system" + ], + "summary": "Delete an IP Pool", + "operationId": "ip_pool_delete", + "parameters": [ + { + "in": "path", + "name": "pool_name", + "required": true, + "schema": { + "$ref": "#/components/schemas/Name" + } + } + ], + "responses": { + "204": { + "description": "successful deletion" + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/system/ip-pools/{pool_name}/ranges": { + "get": { + "tags": [ + "system" + ], + "summary": "List ranges for an IP pool", + "description": "Ranges are ordered by their first address.", + "operationId": "ip_pool_range_list", + "parameters": [ + { + "in": "path", + "name": "pool_name", + "required": true, + "schema": { + "$ref": "#/components/schemas/Name" + } + }, + { + "in": "query", + "name": "limit", + "description": "Maximum number of items returned by a single call", + "schema": { + "nullable": true, + "type": "integer", + "format": "uint32", + "minimum": 1 + } + }, + { + "in": "query", + "name": "page_token", + "description": "Token returned by previous call to retrieve the subsequent page", + "schema": { + "nullable": true, + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/IpPoolRangeResultsPage" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + }, + "x-dropshot-pagination": true + } + }, + "/system/ip-pools/{pool_name}/ranges/add": { + "post": { + "tags": [ + "system" + ], + "summary": "Add a range to an IP pool", + "operationId": "ip_pool_range_add", + "parameters": [ + { + "in": "path", + "name": "pool_name", + "required": true, + "schema": { + "$ref": "#/components/schemas/Name" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/IpRange" + } + } + }, + "required": true + }, + "responses": { + "201": { + "description": "successful creation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/IpPoolRange" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/system/ip-pools/{pool_name}/ranges/remove": { + "post": { + "tags": [ + "system" + ], + "summary": "Remove a range from an IP pool", + "operationId": "ip_pool_range_remove", + "parameters": [ + { + "in": "path", + "name": "pool_name", + "required": true, + "schema": { + "$ref": "#/components/schemas/Name" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/IpRange" + } + } + }, + "required": true + }, + "responses": { + "204": { + "description": "resource updated" + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/system/ip-pools-service": { + "get": { + "tags": [ + "system" + ], + "summary": "Fetch the IP pool used for Oxide services.", + "operationId": "ip_pool_service_view", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/IpPool" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/system/ip-pools-service/ranges": { + "get": { + "tags": [ + "system" + ], + "summary": "List ranges for the IP pool used for Oxide services.", + "description": "Ranges are ordered by their first address.", + "operationId": "ip_pool_service_range_list", + "parameters": [ + { + "in": "query", + "name": "limit", + "description": "Maximum number of items returned by a single call", + "schema": { + "nullable": true, + "type": "integer", + "format": "uint32", + "minimum": 1 + } + }, + { + "in": "query", + "name": "page_token", + "description": "Token returned by previous call to retrieve the subsequent page", + "schema": { + "nullable": true, + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/IpPoolRangeResultsPage" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + }, + "x-dropshot-pagination": true + } + }, + "/system/ip-pools-service/ranges/add": { + "post": { + "tags": [ + "system" + ], + "summary": "Add a range to an IP pool used for Oxide services.", + "operationId": "ip_pool_service_range_add", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/IpRange" + } + } + }, + "required": true + }, + "responses": { + "201": { + "description": "successful creation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/IpPoolRange" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/system/ip-pools-service/ranges/remove": { + "post": { + "tags": [ + "system" + ], + "summary": "Remove a range from an IP pool used for Oxide services.", + "operationId": "ip_pool_service_range_remove", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/IpRange" + } + } + }, + "required": true + }, + "responses": { + "204": { + "description": "resource updated" + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/system/metrics/{metric_name}": { + "get": { + "tags": [ + "system" + ], + "summary": "Access metrics data", + "operationId": "system_metric", + "parameters": [ + { + "in": "path", + "name": "metric_name", + "required": true, + "schema": { + "$ref": "#/components/schemas/SystemMetricName" + } + }, + { + "in": "query", + "name": "end_time", + "description": "An exclusive end time of metrics.", + "schema": { + "type": "string", + "format": "date-time" + } + }, + { + "in": "query", + "name": "id", + "description": "The UUID of the container being queried", + "required": true, + "schema": { + "type": "string", + "format": "uuid" + } + }, + { + "in": "query", + "name": "limit", + "description": "Maximum number of items returned by a single call", + "schema": { + "nullable": true, + "type": "integer", + "format": "uint32", + "minimum": 1 + } + }, + { + "in": "query", + "name": "page_token", + "description": "Token returned by previous call to retrieve the subsequent page", + "schema": { + "nullable": true, + "type": "string" + } + }, + { + "in": "query", + "name": "start_time", + "description": "An inclusive start time of metrics.", + "schema": { + "type": "string", + "format": "date-time" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/MeasurementResultsPage" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + }, + "x-dropshot-pagination": true + } + }, + "/system/policy": { + "get": { + "tags": [ + "policy" + ], + "summary": "Fetch the top-level IAM policy", + "operationId": "system_policy_view", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/FleetRolePolicy" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + }, + "put": { + "tags": [ + "policy" + ], + "summary": "Update the top-level IAM policy", + "operationId": "system_policy_update", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/FleetRolePolicy" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/FleetRolePolicy" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/system/sagas": { + "get": { + "tags": [ + "system" + ], + "summary": "List sagas", + "operationId": "saga_list", + "parameters": [ + { + "in": "query", + "name": "limit", + "description": "Maximum number of items returned by a single call", + "schema": { + "nullable": true, + "type": "integer", + "format": "uint32", + "minimum": 1 + } + }, + { + "in": "query", + "name": "page_token", + "description": "Token returned by previous call to retrieve the subsequent page", + "schema": { + "nullable": true, + "type": "string" + } + }, + { + "in": "query", + "name": "sort_by", + "schema": { + "$ref": "#/components/schemas/IdSortMode" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SagaResultsPage" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + }, + "x-dropshot-pagination": true + } + }, + "/system/sagas/{saga_id}": { + "get": { + "tags": [ + "system" + ], + "summary": "Fetch a saga", + "operationId": "saga_view", + "parameters": [ + { + "in": "path", + "name": "saga_id", + "required": true, + "schema": { + "type": "string", + "format": "uuid" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Saga" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/system/silos": { + "get": { + "tags": [ + "system" + ], + "summary": "List silos", + "description": "Lists silos that are discoverable based on the current permissions.", "operationId": "silo_list", "parameters": [ { @@ -6169,8 +6841,7 @@ "type": "integer", "format": "uint32", "minimum": 1 - }, - "style": "form" + } }, { "in": "query", @@ -6179,16 +6850,14 @@ "schema": { "nullable": true, "type": "string" - }, - "style": "form" + } }, { "in": "query", "name": "sort_by", "schema": { "$ref": "#/components/schemas/NameOrIdSortMode" - }, - "style": "form" + } } ], "responses": { @@ -6213,9 +6882,9 @@ }, "post": { "tags": [ - "silos" + "system" ], - "summary": "Create a new silo.", + "summary": "Create a silo", "operationId": "silo_create", "requestBody": { "content": { @@ -6247,12 +6916,13 @@ } } }, - "/silos/{silo_name}": { + "/system/silos/{silo_name}": { "get": { "tags": [ - "silos" + "system" ], - "summary": "Fetch a specific silo", + "summary": "Fetch a silo", + "description": "Fetch a silo by name.", "operationId": "silo_view", "parameters": [ { @@ -6262,8 +6932,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "responses": { @@ -6287,9 +6956,10 @@ }, "delete": { "tags": [ - "silos" + "system" ], - "summary": "Delete a specific silo.", + "summary": "Delete a silo", + "description": "Delete a silo by name.", "operationId": "silo_delete", "parameters": [ { @@ -6299,8 +6969,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "responses": { @@ -6316,12 +6985,12 @@ } } }, - "/silos/{silo_name}/identity-providers": { + "/system/silos/{silo_name}/identity-providers": { "get": { "tags": [ - "silos" + "system" ], - "summary": "List Silo identity providers", + "summary": "List a silo's IDPs", "operationId": "silo_identity_provider_list", "parameters": [ { @@ -6331,8 +7000,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "query", @@ -6343,8 +7011,7 @@ "type": "integer", "format": "uint32", "minimum": 1 - }, - "style": "form" + } }, { "in": "query", @@ -6353,16 +7020,14 @@ "schema": { "nullable": true, "type": "string" - }, - "style": "form" + } }, { "in": "query", "name": "sort_by", "schema": { "$ref": "#/components/schemas/NameSortMode" - }, - "style": "form" + } } ], "responses": { @@ -6386,13 +7051,14 @@ "x-dropshot-pagination": true } }, - "/silos/{silo_name}/policy": { - "get": { + "/system/silos/{silo_name}/identity-providers/local/users": { + "post": { "tags": [ - "silos" + "system" ], - "summary": "Fetch the IAM policy for this Silo", - "operationId": "silo_policy_view", + "summary": "Create a user", + "description": "Users can only be created in Silos with `provision_type` == `Fixed`. Otherwise, Silo users are just-in-time (JIT) provisioned when a user first logs in using an external Identity Provider.", + "operationId": "local_idp_user_create", "parameters": [ { "in": "path", @@ -6401,64 +7067,26 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" - } - ], - "responses": { - "200": { - "description": "successful operation", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/SiloRolePolicy" - } - } } - }, - "4XX": { - "$ref": "#/components/responses/Error" - }, - "5XX": { - "$ref": "#/components/responses/Error" - } - } - }, - "put": { - "tags": [ - "silos" - ], - "summary": "Update the IAM policy for this Silo", - "operationId": "silo_policy_update", - "parameters": [ - { - "in": "path", - "name": "silo_name", - "description": "The silo's unique name.", - "required": true, - "schema": { - "$ref": "#/components/schemas/Name" - }, - "style": "simple" } ], "requestBody": { "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/SiloRolePolicy" + "$ref": "#/components/schemas/UserCreate" } } }, "required": true }, "responses": { - "200": { - "description": "successful operation", + "201": { + "description": "successful creation", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/SiloRolePolicy" + "$ref": "#/components/schemas/User" } } } @@ -6472,13 +7100,13 @@ } } }, - "/silos/{silo_name}/saml-identity-providers": { - "post": { + "/system/silos/{silo_name}/identity-providers/local/users/{user_id}": { + "delete": { "tags": [ - "silos" + "system" ], - "summary": "Create a new SAML identity provider for a silo.", - "operationId": "silo_identity_provider_create", + "summary": "Delete a user", + "operationId": "local_idp_user_delete", "parameters": [ { "in": "path", @@ -6487,8 +7115,100 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } + }, + { + "in": "path", + "name": "user_id", + "description": "The user's internal id", + "required": true, + "schema": { + "type": "string", + "format": "uuid" + } + } + ], + "responses": { + "204": { + "description": "successful deletion" + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/system/silos/{silo_name}/identity-providers/local/users/{user_id}/set-password": { + "post": { + "tags": [ + "system" + ], + "summary": "Set or invalidate a user's password", + "description": "Passwords can only be updated for users in Silos with identity mode `LocalOnly`.", + "operationId": "local_idp_user_set_password", + "parameters": [ + { + "in": "path", + "name": "silo_name", + "description": "The silo's unique name.", + "required": true, + "schema": { + "$ref": "#/components/schemas/Name" + } + }, + { + "in": "path", + "name": "user_id", + "description": "The user's internal id", + "required": true, + "schema": { + "type": "string", + "format": "uuid" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UserPassword" + } + } + }, + "required": true + }, + "responses": { + "204": { + "description": "resource updated" + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/system/silos/{silo_name}/identity-providers/saml": { + "post": { + "tags": [ + "system" + ], + "summary": "Create a SAML IDP", + "operationId": "saml_identity_provider_create", + "parameters": [ + { + "in": "path", + "name": "silo_name", + "description": "The silo's unique name.", + "required": true, + "schema": { + "$ref": "#/components/schemas/Name" + } } ], "requestBody": { @@ -6521,13 +7241,13 @@ } } }, - "/silos/{silo_name}/saml-identity-providers/{provider_name}": { + "/system/silos/{silo_name}/identity-providers/saml/{provider_name}": { "get": { "tags": [ - "silos" + "system" ], - "summary": "GET a silo's SAML identity provider", - "operationId": "silo_identity_provider_view", + "summary": "Fetch a SAML IDP", + "operationId": "saml_identity_provider_view", "parameters": [ { "in": "path", @@ -6536,8 +7256,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } }, { "in": "path", @@ -6546,8 +7265,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "responses": { @@ -6570,12 +7288,210 @@ } } }, + "/system/silos/{silo_name}/policy": { + "get": { + "tags": [ + "system" + ], + "summary": "Fetch a silo's IAM policy", + "operationId": "silo_policy_view", + "parameters": [ + { + "in": "path", + "name": "silo_name", + "description": "The silo's unique name.", + "required": true, + "schema": { + "$ref": "#/components/schemas/Name" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SiloRolePolicy" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + }, + "put": { + "tags": [ + "system" + ], + "summary": "Update a silo's IAM policy", + "operationId": "silo_policy_update", + "parameters": [ + { + "in": "path", + "name": "silo_name", + "description": "The silo's unique name.", + "required": true, + "schema": { + "$ref": "#/components/schemas/Name" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SiloRolePolicy" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SiloRolePolicy" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/system/silos/{silo_name}/users/all": { + "get": { + "tags": [ + "system" + ], + "summary": "List users in a silo", + "operationId": "silo_users_list", + "parameters": [ + { + "in": "path", + "name": "silo_name", + "description": "The silo's unique name.", + "required": true, + "schema": { + "$ref": "#/components/schemas/Name" + } + }, + { + "in": "query", + "name": "limit", + "description": "Maximum number of items returned by a single call", + "schema": { + "nullable": true, + "type": "integer", + "format": "uint32", + "minimum": 1 + } + }, + { + "in": "query", + "name": "page_token", + "description": "Token returned by previous call to retrieve the subsequent page", + "schema": { + "nullable": true, + "type": "string" + } + }, + { + "in": "query", + "name": "sort_by", + "schema": { + "$ref": "#/components/schemas/IdSortMode" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UserResultsPage" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + }, + "x-dropshot-pagination": true + } + }, + "/system/silos/{silo_name}/users/id/{user_id}": { + "get": { + "tags": [ + "system" + ], + "summary": "Fetch a user", + "operationId": "silo_user_view", + "parameters": [ + { + "in": "path", + "name": "silo_name", + "description": "The silo's unique name.", + "required": true, + "schema": { + "$ref": "#/components/schemas/Name" + } + }, + { + "in": "path", + "name": "user_id", + "description": "The user's internal id", + "required": true, + "schema": { + "type": "string", + "format": "uuid" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/User" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, "/system/user": { "get": { "tags": [ "system" ], - "summary": "List the built-in system users", + "summary": "List built-in users", "operationId": "system_user_list", "parameters": [ { @@ -6587,8 +7503,7 @@ "type": "integer", "format": "uint32", "minimum": 1 - }, - "style": "form" + } }, { "in": "query", @@ -6597,16 +7512,14 @@ "schema": { "nullable": true, "type": "string" - }, - "style": "form" + } }, { "in": "query", "name": "sort_by", "schema": { "$ref": "#/components/schemas/NameSortMode" - }, - "style": "form" + } } ], "responses": { @@ -6635,7 +7548,7 @@ "tags": [ "system" ], - "summary": "Fetch a specific built-in system user", + "summary": "Fetch a built-in user", "operationId": "system_user_view", "parameters": [ { @@ -6645,8 +7558,7 @@ "required": true, "schema": { "$ref": "#/components/schemas/Name" - }, - "style": "simple" + } } ], "responses": { @@ -6674,7 +7586,7 @@ "tags": [ "metrics" ], - "summary": "List all timeseries schema", + "summary": "List timeseries schema", "operationId": "timeseries_schema_get", "parameters": [ { @@ -6686,8 +7598,7 @@ "type": "integer", "format": "uint32", "minimum": 1 - }, - "style": "form" + } }, { "in": "query", @@ -6696,8 +7607,7 @@ "schema": { "nullable": true, "type": "string" - }, - "style": "form" + } } ], "responses": { @@ -6721,26 +7631,6 @@ "x-dropshot-pagination": true } }, - "/updates/refresh": { - "post": { - "tags": [ - "updates" - ], - "summary": "Refresh update metadata", - "operationId": "updates_refresh", - "responses": { - "204": { - "description": "resource updated" - }, - "4XX": { - "$ref": "#/components/responses/Error" - }, - "5XX": { - "$ref": "#/components/responses/Error" - } - } - } - }, "/users": { "get": { "tags": [ @@ -6758,8 +7648,7 @@ "type": "integer", "format": "uint32", "minimum": 1 - }, - "style": "form" + } }, { "in": "query", @@ -6768,16 +7657,14 @@ "schema": { "nullable": true, "type": "string" - }, - "style": "form" + } }, { "in": "query", "name": "sort_by", "schema": { "$ref": "#/components/schemas/IdSortMode" - }, - "style": "form" + } } ], "responses": { @@ -6800,6 +7687,1989 @@ }, "x-dropshot-pagination": true } + }, + "/v1/disks": { + "get": { + "tags": [ + "disks" + ], + "summary": "List disks", + "operationId": "disk_list_v1", + "parameters": [ + { + "in": "query", + "name": "limit", + "description": "Maximum number of items returned by a single call", + "schema": { + "nullable": true, + "type": "integer", + "format": "uint32", + "minimum": 1 + } + }, + { + "in": "query", + "name": "organization", + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + }, + { + "in": "query", + "name": "page_token", + "description": "Token returned by previous call to retrieve the subsequent page", + "schema": { + "nullable": true, + "type": "string" + } + }, + { + "in": "query", + "name": "project", + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + }, + { + "in": "query", + "name": "sort_by", + "schema": { + "$ref": "#/components/schemas/NameOrIdSortMode" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DiskResultsPage" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + }, + "x-dropshot-pagination": true + }, + "post": { + "tags": [ + "disks" + ], + "summary": "Create a disk", + "operationId": "disk_create_v1", + "parameters": [ + { + "in": "query", + "name": "organization", + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + }, + { + "in": "query", + "name": "project", + "required": true, + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DiskCreate" + } + } + }, + "required": true + }, + "responses": { + "201": { + "description": "successful creation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Disk" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/v1/disks/{disk}": { + "get": { + "tags": [ + "disks" + ], + "summary": "Fetch a disk", + "operationId": "disk_view_v1", + "parameters": [ + { + "in": "path", + "name": "disk", + "required": true, + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + }, + { + "in": "query", + "name": "organization", + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + }, + { + "in": "query", + "name": "project", + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Disk" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + }, + "delete": { + "tags": [ + "disks" + ], + "summary": "Delete a disk", + "operationId": "disk_delete_v1", + "parameters": [ + { + "in": "path", + "name": "disk", + "required": true, + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + }, + { + "in": "query", + "name": "organization", + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + }, + { + "in": "query", + "name": "project", + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + } + ], + "responses": { + "204": { + "description": "successful deletion" + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/v1/instances": { + "get": { + "tags": [ + "instances" + ], + "summary": "List instances", + "operationId": "instance_list_v1", + "parameters": [ + { + "in": "query", + "name": "limit", + "description": "Maximum number of items returned by a single call", + "schema": { + "nullable": true, + "type": "integer", + "format": "uint32", + "minimum": 1 + } + }, + { + "in": "query", + "name": "organization", + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + }, + { + "in": "query", + "name": "page_token", + "description": "Token returned by previous call to retrieve the subsequent page", + "schema": { + "nullable": true, + "type": "string" + } + }, + { + "in": "query", + "name": "project", + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + }, + { + "in": "query", + "name": "sort_by", + "schema": { + "$ref": "#/components/schemas/NameOrIdSortMode" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/InstanceResultsPage" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + }, + "x-dropshot-pagination": true + }, + "post": { + "tags": [ + "instances" + ], + "summary": "Create an instance", + "operationId": "instance_create_v1", + "parameters": [ + { + "in": "query", + "name": "organization", + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + }, + { + "in": "query", + "name": "project", + "required": true, + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/InstanceCreate" + } + } + }, + "required": true + }, + "responses": { + "201": { + "description": "successful creation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Instance" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/v1/instances/{instance}": { + "get": { + "tags": [ + "instances" + ], + "summary": "Fetch an instance", + "operationId": "instance_view_v1", + "parameters": [ + { + "in": "query", + "name": "organization", + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + }, + { + "in": "query", + "name": "project", + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + }, + { + "in": "path", + "name": "instance", + "required": true, + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Instance" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + }, + "delete": { + "tags": [ + "instances" + ], + "summary": "Delete an instance", + "operationId": "instance_delete_v1", + "parameters": [ + { + "in": "query", + "name": "organization", + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + }, + { + "in": "query", + "name": "project", + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + }, + { + "in": "path", + "name": "instance", + "required": true, + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + } + ], + "responses": { + "204": { + "description": "successful deletion" + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/v1/instances/{instance}/disks": { + "get": { + "tags": [ + "instances" + ], + "summary": "List an instance's disks", + "operationId": "instance_disk_list_v1", + "parameters": [ + { + "in": "query", + "name": "limit", + "description": "Maximum number of items returned by a single call", + "schema": { + "nullable": true, + "type": "integer", + "format": "uint32", + "minimum": 1 + } + }, + { + "in": "query", + "name": "organization", + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + }, + { + "in": "query", + "name": "page_token", + "description": "Token returned by previous call to retrieve the subsequent page", + "schema": { + "nullable": true, + "type": "string" + } + }, + { + "in": "query", + "name": "project", + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + }, + { + "in": "query", + "name": "sort_by", + "schema": { + "$ref": "#/components/schemas/NameOrIdSortMode" + } + }, + { + "in": "path", + "name": "instance", + "required": true, + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DiskResultsPage" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + }, + "x-dropshot-pagination": true + } + }, + "/v1/instances/{instance}/disks/attach": { + "post": { + "tags": [ + "instances" + ], + "summary": "Attach a disk to an instance", + "operationId": "instance_disk_attach_v1", + "parameters": [ + { + "in": "path", + "name": "instance", + "required": true, + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + }, + { + "in": "query", + "name": "organization", + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + }, + { + "in": "query", + "name": "project", + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DiskPath" + } + } + }, + "required": true + }, + "responses": { + "202": { + "description": "successfully enqueued operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Disk" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/v1/instances/{instance}/disks/detach": { + "post": { + "tags": [ + "instances" + ], + "summary": "Detach a disk from an instance", + "operationId": "instance_disk_detach_v1", + "parameters": [ + { + "in": "path", + "name": "instance", + "required": true, + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + }, + { + "in": "query", + "name": "organization", + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + }, + { + "in": "query", + "name": "project", + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DiskPath" + } + } + }, + "required": true + }, + "responses": { + "202": { + "description": "successfully enqueued operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Disk" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/v1/instances/{instance}/migrate": { + "post": { + "tags": [ + "instances" + ], + "summary": "Migrate an instance", + "operationId": "instance_migrate_v1", + "parameters": [ + { + "in": "query", + "name": "organization", + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + }, + { + "in": "query", + "name": "project", + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + }, + { + "in": "path", + "name": "instance", + "required": true, + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/InstanceMigrate" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Instance" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/v1/instances/{instance}/reboot": { + "post": { + "tags": [ + "instances" + ], + "summary": "Reboot an instance", + "operationId": "instance_reboot_v1", + "parameters": [ + { + "in": "query", + "name": "organization", + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + }, + { + "in": "query", + "name": "project", + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + }, + { + "in": "path", + "name": "instance", + "required": true, + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + } + ], + "responses": { + "202": { + "description": "successfully enqueued operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Instance" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/v1/instances/{instance}/serial-console": { + "get": { + "tags": [ + "instances" + ], + "summary": "Fetch an instance's serial console", + "operationId": "instance_serial_console_v1", + "parameters": [ + { + "in": "path", + "name": "instance", + "required": true, + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + }, + { + "in": "query", + "name": "from_start", + "description": "Character index in the serial buffer from which to read, counting the bytes output since instance start. If this is not provided, `most_recent` must be provided, and if this *is* provided, `most_recent` must *not* be provided.", + "schema": { + "nullable": true, + "type": "integer", + "format": "uint64", + "minimum": 0 + } + }, + { + "in": "query", + "name": "max_bytes", + "description": "Maximum number of bytes of buffered serial console contents to return. If the requested range runs to the end of the available buffer, the data returned will be shorter than `max_bytes`.", + "schema": { + "nullable": true, + "type": "integer", + "format": "uint64", + "minimum": 0 + } + }, + { + "in": "query", + "name": "most_recent", + "description": "Character index in the serial buffer from which to read, counting *backward* from the most recently buffered data retrieved from the instance. (See note on `from_start` about mutual exclusivity)", + "schema": { + "nullable": true, + "type": "integer", + "format": "uint64", + "minimum": 0 + } + }, + { + "in": "query", + "name": "organization", + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + }, + { + "in": "query", + "name": "project", + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/InstanceSerialConsoleData" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/v1/instances/{instance}/serial-console/stream": { + "get": { + "tags": [ + "instances" + ], + "summary": "Stream an instance's serial console", + "operationId": "instance_serial_console_stream_v1", + "parameters": [ + { + "in": "path", + "name": "instance", + "required": true, + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + }, + { + "in": "query", + "name": "organization", + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + }, + { + "in": "query", + "name": "project", + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + } + ], + "responses": { + "default": { + "description": "", + "content": { + "*/*": { + "schema": {} + } + } + } + }, + "x-dropshot-websocket": {} + } + }, + "/v1/instances/{instance}/start": { + "post": { + "tags": [ + "instances" + ], + "summary": "Boot an instance", + "operationId": "instance_start_v1", + "parameters": [ + { + "in": "query", + "name": "organization", + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + }, + { + "in": "query", + "name": "project", + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + }, + { + "in": "path", + "name": "instance", + "required": true, + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + } + ], + "responses": { + "202": { + "description": "successfully enqueued operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Instance" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/v1/instances/{instance}/stop": { + "post": { + "tags": [ + "instances" + ], + "summary": "Stop an instance", + "operationId": "instance_stop_v1", + "parameters": [ + { + "in": "query", + "name": "organization", + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + }, + { + "in": "query", + "name": "project", + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + }, + { + "in": "path", + "name": "instance", + "required": true, + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + } + ], + "responses": { + "202": { + "description": "successfully enqueued operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Instance" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/v1/organizations": { + "get": { + "tags": [ + "organizations" + ], + "summary": "List organizations", + "operationId": "organization_list_v1", + "parameters": [ + { + "in": "query", + "name": "limit", + "description": "Maximum number of items returned by a single call", + "schema": { + "nullable": true, + "type": "integer", + "format": "uint32", + "minimum": 1 + } + }, + { + "in": "query", + "name": "page_token", + "description": "Token returned by previous call to retrieve the subsequent page", + "schema": { + "nullable": true, + "type": "string" + } + }, + { + "in": "query", + "name": "sort_by", + "schema": { + "$ref": "#/components/schemas/NameOrIdSortMode" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OrganizationResultsPage" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + }, + "x-dropshot-pagination": true + }, + "post": { + "tags": [ + "organizations" + ], + "summary": "Create an organization", + "operationId": "organization_create_v1", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OrganizationCreate" + } + } + }, + "required": true + }, + "responses": { + "201": { + "description": "successful creation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Organization" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/v1/organizations/{organization}": { + "get": { + "tags": [ + "organizations" + ], + "summary": "Fetch an organization", + "operationId": "organization_view_v1", + "parameters": [ + { + "in": "path", + "name": "organization", + "required": true, + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Organization" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + }, + "put": { + "tags": [ + "organizations" + ], + "summary": "Update an organization", + "operationId": "organization_update_v1", + "parameters": [ + { + "in": "path", + "name": "organization", + "required": true, + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OrganizationUpdate" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Organization" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + }, + "delete": { + "tags": [ + "organizations" + ], + "summary": "Delete an organization", + "operationId": "organization_delete_v1", + "parameters": [ + { + "in": "path", + "name": "organization", + "required": true, + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + } + ], + "responses": { + "204": { + "description": "successful deletion" + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/v1/organizations/{organization}/policy": { + "get": { + "tags": [ + "organizations" + ], + "summary": "Fetch an organization's IAM policy", + "operationId": "organization_policy_view_v1", + "parameters": [ + { + "in": "path", + "name": "organization", + "required": true, + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OrganizationRolePolicy" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + }, + "put": { + "tags": [ + "organizations" + ], + "summary": "Update an organization's IAM policy", + "operationId": "organization_policy_update_v1", + "parameters": [ + { + "in": "path", + "name": "organization", + "required": true, + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OrganizationRolePolicy" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OrganizationRolePolicy" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/v1/projects": { + "get": { + "tags": [ + "projects" + ], + "summary": "List projects", + "operationId": "project_list_v1", + "parameters": [ + { + "in": "query", + "name": "limit", + "description": "Maximum number of items returned by a single call", + "schema": { + "nullable": true, + "type": "integer", + "format": "uint32", + "minimum": 1 + } + }, + { + "in": "query", + "name": "organization", + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + }, + { + "in": "query", + "name": "page_token", + "description": "Token returned by previous call to retrieve the subsequent page", + "schema": { + "nullable": true, + "type": "string" + } + }, + { + "in": "query", + "name": "sort_by", + "schema": { + "$ref": "#/components/schemas/NameOrIdSortMode" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProjectResultsPage" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + }, + "x-dropshot-pagination": true + }, + "post": { + "tags": [ + "projects" + ], + "summary": "Create a project", + "operationId": "project_create_v1", + "parameters": [ + { + "in": "query", + "name": "organization", + "required": true, + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProjectCreate" + } + } + }, + "required": true + }, + "responses": { + "201": { + "description": "successful creation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Project" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/v1/projects/{project}": { + "get": { + "tags": [ + "projects" + ], + "summary": "Fetch a project", + "operationId": "project_view_v1", + "parameters": [ + { + "in": "path", + "name": "project", + "required": true, + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + }, + { + "in": "query", + "name": "organization", + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Project" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + }, + "put": { + "tags": [ + "projects" + ], + "summary": "Update a project", + "operationId": "project_update_v1", + "parameters": [ + { + "in": "path", + "name": "project", + "required": true, + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + }, + { + "in": "query", + "name": "organization", + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProjectUpdate" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Project" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + }, + "delete": { + "tags": [ + "projects" + ], + "summary": "Delete a project", + "operationId": "project_delete_v1", + "parameters": [ + { + "in": "path", + "name": "project", + "required": true, + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + }, + { + "in": "query", + "name": "organization", + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + } + ], + "responses": { + "204": { + "description": "successful deletion" + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/v1/projects/{project}/policy": { + "get": { + "tags": [ + "projects" + ], + "summary": "Fetch a project's IAM policy", + "operationId": "project_policy_view_v1", + "parameters": [ + { + "in": "path", + "name": "project", + "required": true, + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + }, + { + "in": "query", + "name": "organization", + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProjectRolePolicy" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + }, + "put": { + "tags": [ + "projects" + ], + "summary": "Update a project's IAM policy", + "operationId": "project_policy_update_v1", + "parameters": [ + { + "in": "path", + "name": "project", + "required": true, + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + }, + { + "in": "query", + "name": "organization", + "schema": { + "$ref": "#/components/schemas/NameOrId" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProjectRolePolicy" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProjectRolePolicy" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/v1/system/update/components": { + "get": { + "tags": [ + "system" + ], + "summary": "View version and update status of component tree", + "operationId": "system_component_version_list", + "parameters": [ + { + "in": "query", + "name": "limit", + "description": "Maximum number of items returned by a single call", + "schema": { + "nullable": true, + "type": "integer", + "format": "uint32", + "minimum": 1 + } + }, + { + "in": "query", + "name": "page_token", + "description": "Token returned by previous call to retrieve the subsequent page", + "schema": { + "nullable": true, + "type": "string" + } + }, + { + "in": "query", + "name": "sort_by", + "schema": { + "$ref": "#/components/schemas/IdSortMode" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UpdateableComponentResultsPage" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + }, + "x-dropshot-pagination": true + } + }, + "/v1/system/update/deployments": { + "get": { + "tags": [ + "system" + ], + "summary": "List all update deployments", + "operationId": "update_deployments_list", + "parameters": [ + { + "in": "query", + "name": "limit", + "description": "Maximum number of items returned by a single call", + "schema": { + "nullable": true, + "type": "integer", + "format": "uint32", + "minimum": 1 + } + }, + { + "in": "query", + "name": "page_token", + "description": "Token returned by previous call to retrieve the subsequent page", + "schema": { + "nullable": true, + "type": "string" + } + }, + { + "in": "query", + "name": "sort_by", + "schema": { + "$ref": "#/components/schemas/IdSortMode" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UpdateDeploymentResultsPage" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + }, + "x-dropshot-pagination": true + } + }, + "/v1/system/update/deployments/{id}": { + "get": { + "tags": [ + "system" + ], + "summary": "Fetch a system update deployment", + "operationId": "update_deployment_view", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "schema": { + "type": "string", + "format": "uuid" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UpdateDeployment" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/v1/system/update/refresh": { + "post": { + "tags": [ + "system" + ], + "summary": "Refresh update data", + "operationId": "system_update_refresh", + "responses": { + "204": { + "description": "resource updated" + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/v1/system/update/start": { + "post": { + "tags": [ + "system" + ], + "summary": "Start system update", + "operationId": "system_update_start", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SystemUpdateStart" + } + } + }, + "required": true + }, + "responses": { + "202": { + "description": "successfully enqueued operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UpdateDeployment" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/v1/system/update/stop": { + "post": { + "tags": [ + "system" + ], + "summary": "Stop system update", + "description": "If there is no update in progress, do nothing.", + "operationId": "system_update_stop", + "responses": { + "204": { + "description": "resource updated" + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/v1/system/update/updates": { + "get": { + "tags": [ + "system" + ], + "summary": "List all updates", + "operationId": "system_update_list", + "parameters": [ + { + "in": "query", + "name": "limit", + "description": "Maximum number of items returned by a single call", + "schema": { + "nullable": true, + "type": "integer", + "format": "uint32", + "minimum": 1 + } + }, + { + "in": "query", + "name": "page_token", + "description": "Token returned by previous call to retrieve the subsequent page", + "schema": { + "nullable": true, + "type": "string" + } + }, + { + "in": "query", + "name": "sort_by", + "schema": { + "$ref": "#/components/schemas/IdSortMode" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SystemUpdateResultsPage" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + }, + "x-dropshot-pagination": true + } + }, + "/v1/system/update/updates/{version}": { + "get": { + "tags": [ + "system" + ], + "summary": "View system update", + "operationId": "system_update_view", + "parameters": [ + { + "in": "path", + "name": "version", + "required": true, + "schema": { + "$ref": "#/components/schemas/SemverVersion" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SystemUpdate" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/v1/system/update/updates/{version}/components": { + "get": { + "tags": [ + "system" + ], + "summary": "View system update component tree", + "operationId": "system_update_components_list", + "parameters": [ + { + "in": "path", + "name": "version", + "required": true, + "schema": { + "$ref": "#/components/schemas/SemverVersion" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ComponentUpdateResultsPage" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/v1/system/update/version": { + "get": { + "tags": [ + "system" + ], + "summary": "View system version and update status", + "operationId": "system_version", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SystemVersion" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } } }, "components": { @@ -6816,6 +9686,27 @@ } }, "schemas": { + "Baseboard": { + "description": "Describes properties that should uniquely identify a Gimlet.", + "type": "object", + "properties": { + "part": { + "type": "string" + }, + "revision": { + "type": "integer", + "format": "int64" + }, + "serial": { + "type": "string" + } + }, + "required": [ + "part", + "revision", + "serial" + ] + }, "BinRangedouble": { "description": "A type storing a range over `T`.\n\nThis type supports ranges similar to the `RangeTo`, `Range` and `RangeFrom` types in the standard library. Those cover `(..end)`, `(start..end)`, and `(start..)` respectively.", "oneOf": [ @@ -7019,6 +9910,171 @@ "format": "uint64", "minimum": 0 }, + "Certificate": { + "description": "Client view of a [`Certificate`]", + "type": "object", + "properties": { + "description": { + "description": "human-readable free-form text about a resource", + "type": "string" + }, + "id": { + "description": "unique, immutable, system-controlled identifier for each resource", + "type": "string", + "format": "uuid" + }, + "name": { + "description": "unique, mutable, user-controlled identifier for each resource", + "allOf": [ + { + "$ref": "#/components/schemas/Name" + } + ] + }, + "service": { + "$ref": "#/components/schemas/ServiceUsingCertificate" + }, + "time_created": { + "description": "timestamp when this resource was created", + "type": "string", + "format": "date-time" + }, + "time_modified": { + "description": "timestamp when this resource was last modified", + "type": "string", + "format": "date-time" + } + }, + "required": [ + "description", + "id", + "name", + "service", + "time_created", + "time_modified" + ] + }, + "CertificateCreate": { + "description": "Create-time parameters for a [`Certificate`](crate::external_api::views::Certificate)", + "type": "object", + "properties": { + "cert": { + "description": "PEM file containing public certificate chain", + "type": "array", + "items": { + "type": "integer", + "format": "uint8", + "minimum": 0 + } + }, + "description": { + "type": "string" + }, + "key": { + "description": "PEM file containing private key", + "type": "array", + "items": { + "type": "integer", + "format": "uint8", + "minimum": 0 + } + }, + "name": { + "$ref": "#/components/schemas/Name" + }, + "service": { + "description": "The service using this certificate", + "allOf": [ + { + "$ref": "#/components/schemas/ServiceUsingCertificate" + } + ] + } + }, + "required": [ + "cert", + "description", + "key", + "name", + "service" + ] + }, + "CertificateResultsPage": { + "description": "A single page of results", + "type": "object", + "properties": { + "items": { + "description": "list of items on this page of results", + "type": "array", + "items": { + "$ref": "#/components/schemas/Certificate" + } + }, + "next_page": { + "nullable": true, + "description": "token used to fetch the next page of results (if any)", + "type": "string" + } + }, + "required": [ + "items" + ] + }, + "ComponentUpdate": { + "description": "Identity-related metadata that's included in \"asset\" public API objects (which generally have no name or description)", + "type": "object", + "properties": { + "component_type": { + "$ref": "#/components/schemas/UpdateableComponentType" + }, + "id": { + "description": "unique, immutable, system-controlled identifier for each resource", + "type": "string", + "format": "uuid" + }, + "time_created": { + "description": "timestamp when this resource was created", + "type": "string", + "format": "date-time" + }, + "time_modified": { + "description": "timestamp when this resource was last modified", + "type": "string", + "format": "date-time" + }, + "version": { + "$ref": "#/components/schemas/SemverVersion" + } + }, + "required": [ + "component_type", + "id", + "time_created", + "time_modified", + "version" + ] + }, + "ComponentUpdateResultsPage": { + "description": "A single page of results", + "type": "object", + "properties": { + "items": { + "description": "list of items on this page of results", + "type": "array", + "items": { + "$ref": "#/components/schemas/ComponentUpdate" + } + }, + "next_page": { + "nullable": true, + "description": "token used to fetch the next page of results (if any)", + "type": "string" + } + }, + "required": [ + "items" + ] + }, "Cumulativedouble": { "description": "A cumulative or counter data type.", "type": "object", @@ -7432,7 +10488,7 @@ ] }, "DiskIdentifier": { - "description": "Parameters for the [`Disk`](omicron_common::api::external::Disk) to be attached or detached to an instance", + "description": "TODO-v1: Delete this Parameters for the [`Disk`](omicron_common::api::external::Disk) to be attached or detached to an instance", "type": "object", "properties": { "name": { @@ -7443,6 +10499,17 @@ "name" ] }, + "DiskPath": { + "type": "object", + "properties": { + "disk": { + "$ref": "#/components/schemas/NameOrId" + } + }, + "required": [ + "disk" + ] + }, "DiskResultsPage": { "description": "A single page of results", "type": "object", @@ -7951,7 +11018,7 @@ ] }, "GlobalImageCreate": { - "description": "Create-time parameters for an [`GlobalImage`](omicron_common::api::external::GlobalImage)", + "description": "Create-time parameters for an [`GlobalImage`](crate::external_api::views::GlobalImage)", "type": "object", "properties": { "block_size": { @@ -8014,6 +11081,51 @@ "items" ] }, + "Group": { + "description": "Client view of a [`Group`]", + "type": "object", + "properties": { + "display_name": { + "description": "Human-readable name that can identify the group", + "type": "string" + }, + "id": { + "type": "string", + "format": "uuid" + }, + "silo_id": { + "description": "Uuid of the silo to which this group belongs", + "type": "string", + "format": "uuid" + } + }, + "required": [ + "display_name", + "id", + "silo_id" + ] + }, + "GroupResultsPage": { + "description": "A single page of results", + "type": "object", + "properties": { + "items": { + "description": "list of items on this page of results", + "type": "array", + "items": { + "$ref": "#/components/schemas/Group" + } + }, + "next_page": { + "nullable": true, + "description": "token used to fetch the next page of results (if any)", + "type": "string" + } + }, + "required": [ + "items" + ] + }, "Histogramdouble": { "description": "A simple type for managing a histogram metric.\n\nA histogram maintains the count of any number of samples, over a set of bins. Bins are specified on construction via their _left_ edges, inclusive. There can't be any \"gaps\" in the bins, and an additional bin may be added to the left, right, or both so that the bins extend to the entire range of the support.\n\nNote that any gaps, unsorted bins, or non-finite values will result in an error.\n\nExample ------- ```rust use oximeter::histogram::{BinRange, Histogram};\n\nlet edges = [0i64, 10, 20]; let mut hist = Histogram::new(&edges).unwrap(); assert_eq!(hist.n_bins(), 4); // One additional bin for the range (20..) assert_eq!(hist.n_samples(), 0); hist.sample(4); hist.sample(100); assert_eq!(hist.n_samples(), 2);\n\nlet data = hist.iter().collect::>(); assert_eq!(data[0].range, BinRange::range(i64::MIN, 0)); // An additional bin for `..0` assert_eq!(data[0].count, 0); // Nothing is in this bin\n\nassert_eq!(data[1].range, BinRange::range(0, 10)); // The range `0..10` assert_eq!(data[1].count, 1); // 4 is sampled into this bin ```\n\nNotes -----\n\nHistograms may be constructed either from their left bin edges, or from a sequence of ranges. In either case, the left-most bin may be converted upon construction. In particular, if the left-most value is not equal to the minimum of the support, a new bin will be added from the minimum to that provided value. If the left-most value _is_ the support's minimum, because the provided bin was unbounded below, such as `(..0)`, then that bin will be converted into one bounded below, `(MIN..0)` in this case.\n\nThe short of this is that, most of the time, it shouldn't matter. If one specifies the extremes of the support as their bins, be aware that the left-most may be converted from a `BinRange::RangeTo` into a `BinRange::Range`. In other words, the first bin of a histogram is _always_ a `Bin::Range` or a `Bin::RangeFrom` after construction. In fact, every bin is one of those variants, the `BinRange::RangeTo` is only provided as a convenience during construction.", "type": "object", @@ -8137,16 +11249,22 @@ ] }, "IdentityProviderType": { - "type": "string", - "enum": [ - "saml" + "oneOf": [ + { + "description": "SAML identity provider", + "type": "string", + "enum": [ + "saml" + ] + } ] }, "IdentityType": { "description": "Describes what kind of identity is described by an id", "type": "string", "enum": [ - "silo_user" + "silo_user", + "silo_group" ] }, "IdpMetadataSource": { @@ -8273,7 +11391,7 @@ ] }, "ImageCreate": { - "description": "Create-time parameters for an [`Image`](omicron_common::api::external::Image)", + "description": "Create-time parameters for an [`Image`](crate::external_api::views::Image)", "type": "object", "properties": { "block_size": { @@ -8514,6 +11632,11 @@ } ] }, + "start": { + "description": "Should this instance be started upon creation; true by default.", + "default": true, + "type": "boolean" + }, "user_data": { "description": "User data for instance initialization systems (such as cloud-init). Must be a Base64-encoded string, as specified in RFC 4648 § 4 (+ and / characters with padding). Maximum 32 KiB unencoded data.", "default": "", @@ -8717,18 +11840,77 @@ }, "InstanceState": { "description": "Running state of an Instance (primarily: booted or stopped)\n\nThis typically reflects whether it's starting, running, stopping, or stopped, but also includes states related to the Instance's lifecycle", - "type": "string", - "enum": [ - "creating", - "starting", - "running", - "stopping", - "stopped", - "rebooting", - "migrating", - "repairing", - "failed", - "destroyed" + "oneOf": [ + { + "description": "The instance is being created.", + "type": "string", + "enum": [ + "creating" + ] + }, + { + "description": "The instance is currently starting up.", + "type": "string", + "enum": [ + "starting" + ] + }, + { + "description": "The instance is currently running.", + "type": "string", + "enum": [ + "running" + ] + }, + { + "description": "The instance has been requested to stop and a transition to \"Stopped\" is imminent.", + "type": "string", + "enum": [ + "stopping" + ] + }, + { + "description": "The instance is currently stopped.", + "type": "string", + "enum": [ + "stopped" + ] + }, + { + "description": "The instance is in the process of rebooting - it will remain in the \"rebooting\" state until the VM is starting once more.", + "type": "string", + "enum": [ + "rebooting" + ] + }, + { + "description": "The instance is in the process of migrating - it will remain in the \"migrating\" state until the migration process is complete and the destination propolis is ready to continue execution.", + "type": "string", + "enum": [ + "migrating" + ] + }, + { + "description": "The instance is attempting to recover from a failure.", + "type": "string", + "enum": [ + "repairing" + ] + }, + { + "description": "The instance has encountered a failure.", + "type": "string", + "enum": [ + "failed" + ] + }, + { + "description": "The instance has been deleted.", + "type": "string", + "enum": [ + "destroyed" + ] + } ] }, "IpKind": { @@ -8780,11 +11962,6 @@ } ] }, - "project_id": { - "nullable": true, - "type": "string", - "format": "uuid" - }, "time_created": { "description": "timestamp when this resource was created", "type": "string", @@ -8805,7 +11982,7 @@ ] }, "IpPoolCreate": { - "description": "Create-time parameters for an IP Pool.\n\nSee [`IpPool`](omicron_nexus::external_api::views::IpPool)", + "description": "Create-time parameters for an IP Pool.\n\nSee [`IpPool`](crate::external_api::views::IpPool)", "type": "object", "properties": { "description": { @@ -8813,12 +11990,6 @@ }, "name": { "$ref": "#/components/schemas/Name" - }, - "organization": { - "$ref": "#/components/schemas/Name" - }, - "project": { - "$ref": "#/components/schemas/Name" } }, "required": [ @@ -8932,7 +12103,7 @@ "title": "An IPv4 subnet", "description": "An IPv4 subnet, including prefix and subnet mask", "type": "string", - "pattern": "^(10\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\/([8-9]|1[0-9]|2[0-9]|3[0-2])|172\\.(1[6-9]|2[0-9]|3[0-1])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\/(1[2-9]|2[0-9]|3[0-2])|192\\.168\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\/(1[6-9]|2[0-9]|3[0-2]))$" + "pattern": "^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/([8-9]|1[0-9]|2[0-9]|3[0-2])$" }, "Ipv4Range": { "description": "A non-decreasing IPv4 address range, inclusive of both ends.\n\nThe first address must be less than or equal to the last address.", @@ -9040,6 +12211,27 @@ "pattern": "^(?![0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$)^[a-z][a-z0-9-]*[a-zA-Z0-9]$", "maxLength": 63 }, + "NameOrId": { + "oneOf": [ + { + "title": "id", + "allOf": [ + { + "type": "string", + "format": "uuid" + } + ] + }, + { + "title": "name", + "allOf": [ + { + "$ref": "#/components/schemas/Name" + } + ] + } + ] + }, "NetworkInterface": { "description": "A `NetworkInterface` represents a virtual network interface device.", "type": "object", @@ -9187,11 +12379,6 @@ "nullable": true, "type": "string" }, - "make_primary": { - "description": "Make a secondary interface the instance's primary interface.\n\nIf applied to a secondary interface, that interface will become the primary on the next reboot of the instance. Note that this may have implications for routing between instances, as the new primary interface will be on a distinct subnet from the previous primary interface.\n\nNote that this can only be used to select a new primary interface for an instance. Requests to change the primary interface into a secondary will return an error.", - "default": false, - "type": "boolean" - }, "name": { "nullable": true, "allOf": [ @@ -9199,9 +12386,18 @@ "$ref": "#/components/schemas/Name" } ] + }, + "primary": { + "description": "Make a secondary interface the instance's primary interface.\n\nIf applied to a secondary interface, that interface will become the primary on the next reboot of the instance. Note that this may have implications for routing between instances, as the new primary interface will be on a distinct subnet from the previous primary interface.\n\nNote that this can only be used to select a new primary interface for an instance. Requests to change the primary interface into a secondary will return an error.", + "default": false, + "type": "boolean" } } }, + "NodeName": { + "description": "Unique name for a saga [`Node`]\n\nEach node requires a string name that's unique within its DAG. The name is used to identify its output. Nodes that depend on a given node (either directly or indirectly) can access the node's output using its name.", + "type": "string" + }, "Organization": { "description": "Client view of an [`Organization`]", "type": "object", @@ -9342,6 +12538,88 @@ } } }, + "Password": { + "title": "A password used to authenticate a user", + "description": "Passwords may be subject to additional constraints.", + "type": "string", + "maxLength": 512 + }, + "PhysicalDisk": { + "description": "Client view of a [`PhysicalDisk`]", + "type": "object", + "properties": { + "disk_type": { + "$ref": "#/components/schemas/PhysicalDiskType" + }, + "id": { + "description": "unique, immutable, system-controlled identifier for each resource", + "type": "string", + "format": "uuid" + }, + "model": { + "type": "string" + }, + "serial": { + "type": "string" + }, + "sled_id": { + "nullable": true, + "description": "The sled to which this disk is attached, if any.", + "type": "string", + "format": "uuid" + }, + "time_created": { + "description": "timestamp when this resource was created", + "type": "string", + "format": "date-time" + }, + "time_modified": { + "description": "timestamp when this resource was last modified", + "type": "string", + "format": "date-time" + }, + "vendor": { + "type": "string" + } + }, + "required": [ + "disk_type", + "id", + "model", + "serial", + "time_created", + "time_modified", + "vendor" + ] + }, + "PhysicalDiskResultsPage": { + "description": "A single page of results", + "type": "object", + "properties": { + "items": { + "description": "list of items on this page of results", + "type": "array", + "items": { + "$ref": "#/components/schemas/PhysicalDisk" + } + }, + "next_page": { + "nullable": true, + "description": "token used to fetch the next page of results (if any)", + "type": "string" + } + }, + "required": [ + "items" + ] + }, + "PhysicalDiskType": { + "type": "string", + "enum": [ + "internal", + "external" + ] + }, "Project": { "description": "Client view of a [`Project`]", "type": "object", @@ -9850,12 +13128,35 @@ }, "RouterRouteKind": { "description": "The classification of a [`RouterRoute`] as defined by the system. The kind determines certain attributes such as if the route is modifiable and describes how or where the route was created.\n\nSee [RFD-21](https://rfd.shared.oxide.computer/rfd/0021#concept-router) for more context", - "type": "string", - "enum": [ - "default", - "vpc_subnet", - "vpc_peering", - "custom" + "oneOf": [ + { + "description": "Determines the default destination of traffic, such as whether it goes to the internet or not.\n\n`Destination: An Internet Gateway` `Modifiable: true`", + "type": "string", + "enum": [ + "default" + ] + }, + { + "description": "Automatically added for each VPC Subnet in the VPC\n\n`Destination: A VPC Subnet` `Modifiable: false`", + "type": "string", + "enum": [ + "vpc_subnet" + ] + }, + { + "description": "Automatically added when VPC peering is established\n\n`Destination: A different VPC` `Modifiable: false`", + "type": "string", + "enum": [ + "vpc_peering" + ] + }, + { + "description": "Created by a user See [`RouteTarget`]\n\n`Destination: User defined` `Modifiable: true`", + "type": "string", + "enum": [ + "custom" + ] + } ] }, "RouterRouteResultsPage": { @@ -10069,7 +13370,7 @@ "$ref": "#/components/schemas/SagaErrorInfo" }, "error_node_name": { - "type": "string" + "$ref": "#/components/schemas/NodeName" }, "state": { "type": "string", @@ -10167,6 +13468,11 @@ "description": { "type": "string" }, + "group_attribute_name": { + "nullable": true, + "description": "If set, SAML attributes with this name will be considered to denote a user's group membership, where the attribute value(s) should be a comma-separated list of group names.", + "type": "string" + }, "idp_entity_id": { "description": "idp's entity id", "type": "string" @@ -10215,6 +13521,22 @@ "technical_contact_email" ] }, + "SemverVersion": { + "type": "string", + "pattern": "^\\d+\\.\\d+\\.\\d+([\\-\\+].+)?$" + }, + "ServiceUsingCertificate": { + "description": "The service intended to use this certificate.", + "oneOf": [ + { + "description": "This certificate is intended for access to the external API.", + "type": "string", + "enum": [ + "external_api" + ] + } + ] + }, "Silo": { "description": "Client view of a ['Silo']", "type": "object", @@ -10232,6 +13554,14 @@ "type": "string", "format": "uuid" }, + "identity_mode": { + "description": "How users and groups are managed in this Silo", + "allOf": [ + { + "$ref": "#/components/schemas/SiloIdentityMode" + } + ] + }, "name": { "description": "unique, mutable, user-controlled identifier for each resource", "allOf": [ @@ -10249,48 +13579,64 @@ "description": "timestamp when this resource was last modified", "type": "string", "format": "date-time" - }, - "user_provision_type": { - "description": "User provision type", - "allOf": [ - { - "$ref": "#/components/schemas/UserProvisionType" - } - ] } }, "required": [ "description", "discoverable", "id", + "identity_mode", "name", "time_created", - "time_modified", - "user_provision_type" + "time_modified" ] }, "SiloCreate": { "description": "Create-time parameters for a [`Silo`](crate::external_api::views::Silo)", "type": "object", "properties": { + "admin_group_name": { + "nullable": true, + "description": "If set, this group will be created during Silo creation and granted the \"Silo Admin\" role. Identity providers can assert that users belong to this group and those users can log in and further initialize the Silo.\n\nNote that if configuring a SAML based identity provider, group_attribute_name must be set for users to be considered part of a group. See [`SamlIdentityProviderCreate`] for more information.", + "type": "string" + }, "description": { "type": "string" }, "discoverable": { "type": "boolean" }, + "identity_mode": { + "$ref": "#/components/schemas/SiloIdentityMode" + }, "name": { "$ref": "#/components/schemas/Name" - }, - "user_provision_type": { - "$ref": "#/components/schemas/UserProvisionType" } }, "required": [ "description", "discoverable", - "name", - "user_provision_type" + "identity_mode", + "name" + ] + }, + "SiloIdentityMode": { + "description": "Describes how identities are managed and users are authenticated in this Silo", + "oneOf": [ + { + "description": "Users are authenticated with SAML using an external authentication provider. The system updates information about users and groups only during successful authentication (i.e,. \"JIT provisioning\" of users and groups).", + "type": "string", + "enum": [ + "saml_jit" + ] + }, + { + "description": "The system is the source of truth about users. There is no linkage to an external authentication provider or identity provider.", + "type": "string", + "enum": [ + "local_only" + ] + } ] }, "SiloResultsPage": { @@ -10360,9 +13706,12 @@ ] }, "Sled": { - "description": "Client view of an [`Sled`]", + "description": "Client view of a [`Sled`]", "type": "object", "properties": { + "baseboard": { + "$ref": "#/components/schemas/Baseboard" + }, "id": { "description": "unique, immutable, system-controlled identifier for each resource", "type": "string", @@ -10383,6 +13732,7 @@ } }, "required": [ + "baseboard", "id", "service_address", "time_created", @@ -10442,6 +13792,9 @@ "size": { "$ref": "#/components/schemas/ByteCount" }, + "state": { + "$ref": "#/components/schemas/SnapshotState" + }, "time_created": { "description": "timestamp when this resource was created", "type": "string", @@ -10460,12 +13813,13 @@ "name", "project_id", "size", + "state", "time_created", "time_modified" ] }, "SnapshotCreate": { - "description": "Create-time parameters for a [`Snapshot`](omicron_common::api::external::Snapshot)", + "description": "Create-time parameters for a [`Snapshot`](crate::external_api::views::Snapshot)", "type": "object", "properties": { "description": { @@ -10510,6 +13864,15 @@ "items" ] }, + "SnapshotState": { + "type": "string", + "enum": [ + "creating", + "ready", + "faulted", + "destroyed" + ] + }, "SpoofLoginBody": { "type": "object", "properties": { @@ -10614,6 +13977,83 @@ "items" ] }, + "SystemUpdate": { + "description": "Identity-related metadata that's included in \"asset\" public API objects (which generally have no name or description)", + "type": "object", + "properties": { + "id": { + "description": "unique, immutable, system-controlled identifier for each resource", + "type": "string", + "format": "uuid" + }, + "time_created": { + "description": "timestamp when this resource was created", + "type": "string", + "format": "date-time" + }, + "time_modified": { + "description": "timestamp when this resource was last modified", + "type": "string", + "format": "date-time" + }, + "version": { + "$ref": "#/components/schemas/SemverVersion" + } + }, + "required": [ + "id", + "time_created", + "time_modified", + "version" + ] + }, + "SystemUpdateResultsPage": { + "description": "A single page of results", + "type": "object", + "properties": { + "items": { + "description": "list of items on this page of results", + "type": "array", + "items": { + "$ref": "#/components/schemas/SystemUpdate" + } + }, + "next_page": { + "nullable": true, + "description": "token used to fetch the next page of results (if any)", + "type": "string" + } + }, + "required": [ + "items" + ] + }, + "SystemUpdateStart": { + "type": "object", + "properties": { + "version": { + "$ref": "#/components/schemas/SemverVersion" + } + }, + "required": [ + "version" + ] + }, + "SystemVersion": { + "type": "object", + "properties": { + "status": { + "$ref": "#/components/schemas/UpdateStatus" + }, + "version_range": { + "$ref": "#/components/schemas/VersionRange" + } + }, + "required": [ + "status", + "version_range" + ] + }, "TimeseriesName": { "title": "The name of a timeseries", "description": "Names are constructed by concatenating the target and metric names with ':'. Target and metric names must be lowercase alphanumeric characters with '_' separating words.", @@ -10669,6 +14109,177 @@ "items" ] }, + "UpdateDeployment": { + "description": "Identity-related metadata that's included in \"asset\" public API objects (which generally have no name or description)", + "type": "object", + "properties": { + "id": { + "description": "unique, immutable, system-controlled identifier for each resource", + "type": "string", + "format": "uuid" + }, + "status": { + "$ref": "#/components/schemas/UpdateStatus" + }, + "time_created": { + "description": "timestamp when this resource was created", + "type": "string", + "format": "date-time" + }, + "time_modified": { + "description": "timestamp when this resource was last modified", + "type": "string", + "format": "date-time" + }, + "version": { + "$ref": "#/components/schemas/SemverVersion" + } + }, + "required": [ + "id", + "status", + "time_created", + "time_modified", + "version" + ] + }, + "UpdateDeploymentResultsPage": { + "description": "A single page of results", + "type": "object", + "properties": { + "items": { + "description": "list of items on this page of results", + "type": "array", + "items": { + "$ref": "#/components/schemas/UpdateDeployment" + } + }, + "next_page": { + "nullable": true, + "description": "token used to fetch the next page of results (if any)", + "type": "string" + } + }, + "required": [ + "items" + ] + }, + "UpdateStatus": { + "oneOf": [ + { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "updating" + ] + } + }, + "required": [ + "status" + ] + }, + { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "steady" + ] + } + }, + "required": [ + "status" + ] + } + ] + }, + "UpdateableComponent": { + "description": "Identity-related metadata that's included in \"asset\" public API objects (which generally have no name or description)", + "type": "object", + "properties": { + "component_type": { + "$ref": "#/components/schemas/UpdateableComponentType" + }, + "device_id": { + "type": "string" + }, + "id": { + "description": "unique, immutable, system-controlled identifier for each resource", + "type": "string", + "format": "uuid" + }, + "status": { + "$ref": "#/components/schemas/UpdateStatus" + }, + "system_version": { + "$ref": "#/components/schemas/SemverVersion" + }, + "time_created": { + "description": "timestamp when this resource was created", + "type": "string", + "format": "date-time" + }, + "time_modified": { + "description": "timestamp when this resource was last modified", + "type": "string", + "format": "date-time" + }, + "version": { + "$ref": "#/components/schemas/SemverVersion" + } + }, + "required": [ + "component_type", + "device_id", + "id", + "status", + "system_version", + "time_created", + "time_modified", + "version" + ] + }, + "UpdateableComponentResultsPage": { + "description": "A single page of results", + "type": "object", + "properties": { + "items": { + "description": "list of items on this page of results", + "type": "array", + "items": { + "$ref": "#/components/schemas/UpdateableComponent" + } + }, + "next_page": { + "nullable": true, + "description": "token used to fetch the next page of results (if any)", + "type": "string" + } + }, + "required": [ + "items" + ] + }, + "UpdateableComponentType": { + "type": "string", + "enum": [ + "bootloader_for_rot", + "bootloader_for_sp", + "bootloader_for_host_proc", + "hubris_for_psc_rot", + "hubris_for_psc_sp", + "hubris_for_sidecar_rot", + "hubris_for_sidecar_sp", + "hubris_for_gimlet_rot", + "hubris_for_gimlet_sp", + "helios_host_phase1", + "helios_host_phase2", + "host_omicron" + ] + }, "User": { "description": "Client view of a [`User`]", "type": "object", @@ -10680,11 +14291,17 @@ "id": { "type": "string", "format": "uuid" + }, + "silo_id": { + "description": "Uuid of the silo to which this user belongs", + "type": "string", + "format": "uuid" } }, "required": [ "display_name", - "id" + "id", + "silo_id" ] }, "UserBuiltin": { @@ -10748,12 +14365,76 @@ "items" ] }, - "UserProvisionType": { - "description": "How users will be provisioned in a silo during authentication.", + "UserCreate": { + "description": "Create-time parameters for a [`User`](crate::external_api::views::User)", + "type": "object", + "properties": { + "external_id": { + "description": "username used to log in", + "allOf": [ + { + "$ref": "#/components/schemas/UserId" + } + ] + }, + "password": { + "description": "password used to log in", + "allOf": [ + { + "$ref": "#/components/schemas/UserPassword" + } + ] + } + }, + "required": [ + "external_id", + "password" + ] + }, + "UserId": { + "title": "A name unique within the parent collection", + "description": "Names must begin with a lower case ASCII letter, be composed exclusively of lowercase ASCII, uppercase ASCII, numbers, and '-', and may not end with a '-'. Names cannot be a UUID though they may contain a UUID.", "type": "string", - "enum": [ - "fixed", - "jit" + "pattern": "^(?![0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$)^[a-z][a-z0-9-]*[a-zA-Z0-9]$", + "maxLength": 63 + }, + "UserPassword": { + "description": "Parameters for setting a user's password", + "oneOf": [ + { + "description": "Sets the user's password to the provided value", + "type": "object", + "properties": { + "details": { + "$ref": "#/components/schemas/Password" + }, + "user_password_value": { + "type": "string", + "enum": [ + "password" + ] + } + }, + "required": [ + "details", + "user_password_value" + ] + }, + { + "description": "Invalidates any current password (disabling password authentication)", + "type": "object", + "properties": { + "user_password_value": { + "type": "string", + "enum": [ + "invalid_password" + ] + } + }, + "required": [ + "user_password_value" + ] + } ] }, "UserResultsPage": { @@ -10777,6 +14458,37 @@ "items" ] }, + "UsernamePasswordCredentials": { + "description": "Credentials for local user login", + "type": "object", + "properties": { + "password": { + "$ref": "#/components/schemas/Password" + }, + "username": { + "$ref": "#/components/schemas/UserId" + } + }, + "required": [ + "password", + "username" + ] + }, + "VersionRange": { + "type": "object", + "properties": { + "high": { + "$ref": "#/components/schemas/SemverVersion" + }, + "low": { + "$ref": "#/components/schemas/SemverVersion" + } + }, + "required": [ + "high", + "low" + ] + }, "Vpc": { "description": "Client view of a [`Vpc`]", "type": "object", @@ -11324,7 +15036,7 @@ ] }, "VpcFirewallRules": { - "description": "Collection of a [`Vpc`]'s firewall rules", + "description": "Collection of a Vpc's firewall rules", "type": "object", "properties": { "rules": { @@ -11636,25 +15348,52 @@ }, "IdSortMode": { "description": "Supported set of sort modes for scanning by id only.\n\nCurrently, we only support scanning in ascending order.", - "type": "string", - "enum": [ - "id_ascending" - ] - }, - "NameSortMode": { - "description": "Supported set of sort modes for scanning by name only\n\nCurrently, we only support scanning in ascending order.", - "type": "string", - "enum": [ - "name_ascending" + "oneOf": [ + { + "description": "sort in increasing order of \"id\"", + "type": "string", + "enum": [ + "id_ascending" + ] + } ] }, "NameOrIdSortMode": { "description": "Supported set of sort modes for scanning by name or id", - "type": "string", - "enum": [ - "name_ascending", - "name_descending", - "id_ascending" + "oneOf": [ + { + "description": "sort in increasing order of \"name\"", + "type": "string", + "enum": [ + "name_ascending" + ] + }, + { + "description": "sort in decreasing order of \"name\"", + "type": "string", + "enum": [ + "name_descending" + ] + }, + { + "description": "sort in increasing order of \"id\"", + "type": "string", + "enum": [ + "id_ascending" + ] + } + ] + }, + "NameSortMode": { + "description": "Supported set of sort modes for scanning by name only\n\nCurrently, we only support scanning in ascending order.", + "oneOf": [ + { + "description": "sort in increasing order of \"name\"", + "type": "string", + "enum": [ + "name_ascending" + ] + } ] }, "DiskMetricName": { @@ -11667,6 +15406,14 @@ "write", "write_bytes" ] + }, + "SystemMetricName": { + "type": "string", + "enum": [ + "virtual_disk_space_provisioned", + "cpus_provisioned", + "ram_provisioned" + ] } } },