#![doc = r" This module contains the generated types for the library."] use tabled::Tabled; pub mod base64 { #![doc = " Base64 data that encodes to url safe base64, but can decode from multiple"] #![doc = " base64 implementations to account for various clients and libraries. Compatible"] #![doc = " with serde and JsonSchema."] use serde::de::{Error, Unexpected, Visitor}; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use std::convert::TryFrom; use std::fmt; static ALLOWED_DECODING_FORMATS: &[data_encoding::Encoding] = &[ data_encoding::BASE64, data_encoding::BASE64URL, data_encoding::BASE64URL_NOPAD, data_encoding::BASE64_MIME, data_encoding::BASE64_NOPAD, ]; #[derive(Debug, Clone, PartialEq, Eq)] #[doc = " A container for binary that should be base64 encoded in serialisation. In reverse"] #[doc = " when deserializing, will decode from many different types of base64 possible."] pub struct Base64Data(pub Vec); impl Base64Data { #[doc = " Return is the data is empty."] pub fn is_empty(&self) -> bool { self.0.is_empty() } } impl fmt::Display for Base64Data { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", data_encoding::BASE64URL_NOPAD.encode(&self.0)) } } impl From for Vec { fn from(data: Base64Data) -> Vec { data.0 } } impl From> for Base64Data { fn from(data: Vec) -> Base64Data { Base64Data(data) } } impl AsRef<[u8]> for Base64Data { fn as_ref(&self) -> &[u8] { &self.0 } } impl TryFrom<&str> for Base64Data { type Error = anyhow::Error; fn try_from(v: &str) -> Result { for config in ALLOWED_DECODING_FORMATS { if let Ok(data) = config.decode(v.as_bytes()) { return Ok(Base64Data(data)); } } anyhow::bail!("Could not decode base64 data: {}", v); } } struct Base64DataVisitor; impl<'de> Visitor<'de> for Base64DataVisitor { type Value = Base64Data; fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { write!(formatter, "a base64 encoded string") } fn visit_str(self, v: &str) -> Result where E: Error, { for config in ALLOWED_DECODING_FORMATS { if let Ok(data) = config.decode(v.as_bytes()) { return Ok(Base64Data(data)); } } Err(serde::de::Error::invalid_value(Unexpected::Str(v), &self)) } } impl<'de> Deserialize<'de> for Base64Data { fn deserialize(deserializer: D) -> Result>::Error> where D: Deserializer<'de>, { deserializer.deserialize_str(Base64DataVisitor) } } impl Serialize for Base64Data { fn serialize(&self, serializer: S) -> Result where S: Serializer, { let encoded = data_encoding::BASE64URL_NOPAD.encode(&self.0); serializer.serialize_str(&encoded) } } impl schemars::JsonSchema for Base64Data { fn schema_name() -> String { "Base64Data".to_string() } fn json_schema(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema { let mut obj = gen.root_schema_for::().schema; obj.format = Some("byte".to_string()); schemars::schema::Schema::Object(obj) } fn is_referenceable() -> bool { false } } #[cfg(test)] mod tests { use super::Base64Data; use std::convert::TryFrom; #[test] fn test_base64_try_from() { assert!(Base64Data::try_from("aGVsbG8=").is_ok()); assert!(Base64Data::try_from("abcdefghij").is_err()); } } } pub mod paginate { #![doc = " Utility functions used for pagination."] use anyhow::Result; #[doc = " A trait for types that allow pagination."] pub trait Pagination { #[doc = " The item that is paginated."] type Item: serde::de::DeserializeOwned; #[doc = " Returns true if the response has more pages."] fn has_more_pages(&self) -> bool; #[doc = " Modify a request to get the next page."] fn next_page( &self, req: reqwest::Request, ) -> Result; #[doc = " Get the items from a page."] fn items(&self) -> Vec; } } pub mod phone_number { #![doc = " A library to implement phone numbers for our database and JSON serialization and deserialization."] use schemars::JsonSchema; use std::str::FromStr; #[doc = " A phone number."] #[derive(Debug, Default, Clone, PartialEq, Hash, Eq)] pub struct PhoneNumber(pub Option); impl From for PhoneNumber { fn from(id: phonenumber::PhoneNumber) -> PhoneNumber { PhoneNumber(Some(id)) } } impl AsRef> for PhoneNumber { fn as_ref(&self) -> &Option { &self.0 } } impl std::ops::Deref for PhoneNumber { type Target = Option; fn deref(&self) -> &Self::Target { &self.0 } } impl serde::ser::Serialize for PhoneNumber { fn serialize(&self, serializer: S) -> Result where S: serde::ser::Serializer, { serializer.serialize_str(&self.to_string()) } } impl<'de> serde::de::Deserialize<'de> for PhoneNumber { fn deserialize(deserializer: D) -> Result where D: serde::de::Deserializer<'de>, { let s = String::deserialize(deserializer).unwrap_or_default(); PhoneNumber::from_str(&s).map_err(serde::de::Error::custom) } } impl std::str::FromStr for PhoneNumber { type Err = anyhow::Error; fn from_str(s: &str) -> Result { if s.trim().is_empty() { return Ok(PhoneNumber(None)); } let s = if !s.trim().starts_with('+') { format!("+1{}", s) .replace('-', "") .replace('(', "") .replace(')', "") .replace(' ', "") } else { s.replace('-', "") .replace('(', "") .replace(')', "") .replace(' ', "") }; Ok(PhoneNumber(Some(phonenumber::parse(None, &s).map_err( |e| anyhow::anyhow!("invalid phone number `{}`: {}", s, e), )?))) } } impl std::fmt::Display for PhoneNumber { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { let s = if let Some(phone) = &self.0 { phone .format() .mode(phonenumber::Mode::International) .to_string() } else { String::new() }; write!(f, "{}", s) } } impl JsonSchema for PhoneNumber { fn schema_name() -> String { "PhoneNumber".to_string() } fn json_schema(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema { let mut obj = gen.root_schema_for::().schema; obj.format = Some("phone".to_string()); schemars::schema::Schema::Object(obj) } fn is_referenceable() -> bool { false } } #[cfg(test)] mod test { use super::PhoneNumber; use pretty_assertions::assert_eq; #[test] fn test_parse_phone_number() { let mut phone = "+1-555-555-5555"; let mut phone_parsed: PhoneNumber = serde_json::from_str(&format!(r#""{}""#, phone)).unwrap(); let mut expected = PhoneNumber(Some(phonenumber::parse(None, phone).unwrap())); assert_eq!(phone_parsed, expected); let mut expected_str = "+1 555-555-5555"; assert_eq!(expected_str, serde_json::json!(phone_parsed)); phone = "555-555-5555"; phone_parsed = serde_json::from_str(&format!(r#""{}""#, phone)).unwrap(); assert_eq!(phone_parsed, expected); assert_eq!(expected_str, serde_json::json!(phone_parsed)); phone = "+1 555-555-5555"; phone_parsed = serde_json::from_str(&format!(r#""{}""#, phone)).unwrap(); assert_eq!(phone_parsed, expected); assert_eq!(expected_str, serde_json::json!(phone_parsed)); phone = "5555555555"; phone_parsed = serde_json::from_str(&format!(r#""{}""#, phone)).unwrap(); assert_eq!(phone_parsed, expected); assert_eq!(expected_str, serde_json::json!(phone_parsed)); phone = "(510) 864-1234"; phone_parsed = serde_json::from_str(&format!(r#""{}""#, phone)).unwrap(); expected = PhoneNumber(Some(phonenumber::parse(None, "+15108641234").unwrap())); assert_eq!(phone_parsed, expected); expected_str = "+1 510-864-1234"; assert_eq!(expected_str, serde_json::json!(phone_parsed)); phone = "(510)8641234"; phone_parsed = serde_json::from_str(&format!(r#""{}""#, phone)).unwrap(); assert_eq!(phone_parsed, expected); expected_str = "+1 510-864-1234"; assert_eq!(expected_str, serde_json::json!(phone_parsed)); phone = ""; phone_parsed = serde_json::from_str(&format!(r#""{}""#, phone)).unwrap(); assert_eq!(phone_parsed, PhoneNumber(None)); assert_eq!("", serde_json::json!(phone_parsed)); phone = "+49 30 1234 1234"; phone_parsed = serde_json::from_str(&format!(r#""{}""#, phone)).unwrap(); expected = PhoneNumber(Some(phonenumber::parse(None, phone).unwrap())); assert_eq!(phone_parsed, expected); expected_str = "+49 30 12341234"; assert_eq!(expected_str, serde_json::json!(phone_parsed)); } } } pub mod error { #![doc = " Error methods."] #[doc = " Error produced by generated client methods."] pub enum Error { #[doc = " The request did not conform to API requirements."] InvalidRequest(String), #[doc = " A server error either due to the data, or with the connection."] CommunicationError(reqwest_middleware::Error), #[doc = " A request error, caused when building the request."] RequestError(reqwest::Error), #[doc = " An expected response whose deserialization failed."] SerdeError { #[doc = " The error."] error: format_serde_error::SerdeError, #[doc = " The response status."] status: reqwest::StatusCode, }, #[doc = " An expected error response."] InvalidResponsePayload { #[doc = " The error."] error: reqwest_middleware::Error, #[doc = " The full response."] response: reqwest::Response, }, #[doc = " A response not listed in the API description. This may represent a"] #[doc = " success or failure response; check `status().is_success()`."] UnexpectedResponse(reqwest::Response), } impl Error { #[doc = " Returns the status code, if the error was generated from a response."] pub fn status(&self) -> Option { match self { Error::InvalidRequest(_) => None, Error::RequestError(e) => e.status(), Error::CommunicationError(reqwest_middleware::Error::Reqwest(e)) => e.status(), Error::CommunicationError(reqwest_middleware::Error::Middleware(_)) => None, Error::SerdeError { error: _, status } => Some(*status), Error::InvalidResponsePayload { error: _, response } => Some(response.status()), Error::UnexpectedResponse(r) => Some(r.status()), } } #[doc = " Creates a new error from a response status and a serde error."] pub fn from_serde_error( e: format_serde_error::SerdeError, status: reqwest::StatusCode, ) -> Self { Self::SerdeError { error: e, status } } } impl From for Error { fn from(e: reqwest_middleware::Error) -> Self { Self::CommunicationError(e) } } impl From for Error { fn from(e: reqwest::Error) -> Self { Self::RequestError(e) } } impl std::fmt::Display for Error { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { Error::InvalidRequest(s) => { write!(f, "Invalid Request: {}", s) } Error::CommunicationError(e) => { write!(f, "Communication Error: {}", e) } Error::RequestError(e) => { write!(f, "Request Error: {}", e) } Error::SerdeError { error, status: _ } => { write!(f, "Serde Error: {}", error) } Error::InvalidResponsePayload { error, response: _ } => { write!(f, "Invalid Response Payload: {}", error) } Error::UnexpectedResponse(r) => { write!(f, "Unexpected Response: {:?}", r) } } } } trait ErrorFormat { fn fmt_info(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result; } impl std::fmt::Debug for Error { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self, f) } } impl std::error::Error for Error { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { match self { Error::CommunicationError(e) => Some(e), Error::SerdeError { error, status: _ } => Some(error), Error::InvalidResponsePayload { error, response: _ } => Some(error), _ => None, } } } } #[doc = "The type of an individual datum of a metric."] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Eq, Hash, Debug, Clone, schemars :: JsonSchema, tabled :: Tabled, clap :: ValueEnum, parse_display :: FromStr, parse_display :: Display, )] pub enum DatumType { #[serde(rename = "bool")] #[display("bool")] Bool, #[serde(rename = "i64")] #[display("i64")] I64, #[serde(rename = "f64")] #[display("f64")] F64, #[serde(rename = "string")] #[display("string")] String, #[serde(rename = "bytes")] #[display("bytes")] Bytes, #[serde(rename = "cumulative_i64")] #[display("cumulative_i64")] CumulativeI64, #[serde(rename = "cumulative_f64")] #[display("cumulative_f64")] CumulativeF64, #[serde(rename = "histogram_i64")] #[display("histogram_i64")] HistogramI64, #[serde(rename = "histogram_f64")] #[display("histogram_f64")] HistogramF64, } #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct DerEncodedKeyPair { #[doc = "request signing private key (base64 encoded der file)"] pub private_key: String, #[doc = "request signing public certificate (base64 encoded der file)"] pub public_cert: String, } impl std::fmt::Display for DerEncodedKeyPair { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for DerEncodedKeyPair { const LENGTH: usize = 2; fn fields(&self) -> Vec { vec![self.private_key.clone(), self.public_cert.clone()] } fn headers() -> Vec { vec!["private_key".to_string(), "public_cert".to_string()] } } #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct DeviceAccessTokenRequest { pub client_id: uuid::Uuid, pub device_code: String, pub grant_type: String, } impl std::fmt::Display for DeviceAccessTokenRequest { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for DeviceAccessTokenRequest { const LENGTH: usize = 3; fn fields(&self) -> Vec { vec![ format!("{:?}", self.client_id), self.device_code.clone(), self.grant_type.clone(), ] } fn headers() -> Vec { vec![ "client_id".to_string(), "device_code".to_string(), "grant_type".to_string(), ] } } #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct DeviceAuthRequest { pub client_id: uuid::Uuid, } impl std::fmt::Display for DeviceAuthRequest { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for DeviceAuthRequest { const LENGTH: usize = 1; fn fields(&self) -> Vec { vec![format!("{:?}", self.client_id)] } fn headers() -> Vec { vec!["client_id".to_string()] } } #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct DeviceAuthVerify { pub user_code: String, } impl std::fmt::Display for DeviceAuthVerify { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for DeviceAuthVerify { const LENGTH: usize = 1; fn fields(&self) -> Vec { vec![self.user_code.clone()] } fn headers() -> Vec { vec!["user_code".to_string()] } } #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Eq, Hash, Debug, Clone, schemars :: JsonSchema, tabled :: Tabled, clap :: ValueEnum, parse_display :: FromStr, parse_display :: Display, )] pub enum Type { #[serde(rename = "sha256")] #[display("sha256")] Sha256, } impl std::default::Default for Type { fn default() -> Self { Type::Sha256 } } #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct Digest { #[serde(rename = "type")] pub type_: Type, pub value: String, } impl std::fmt::Display for Digest { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for Digest { const LENGTH: usize = 2; fn fields(&self) -> Vec { vec![format!("{:?}", self.type_), self.value.clone()] } fn headers() -> Vec { vec!["type_".to_string(), "value".to_string()] } } #[doc = "Client view of a [`Disk`]"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct Disk { #[doc = "A count of bytes, typically used either for memory or storage capacity\n\nThe maximum supported byte count is [`i64::MAX`]. This makes it somewhat inconvenient to define constructors: a u32 constructor can be infallible, but an i64 constructor can fail (if the value is negative) and a u64 constructor can fail (if the value is larger than i64::MAX). We provide all of these for consumers' convenience."] pub block_size: u64, #[doc = "human-readable free-form text about a resource"] pub description: String, pub device_path: String, #[doc = "unique, immutable, system-controlled identifier for each resource"] pub id: uuid::Uuid, #[serde(default, skip_serializing_if = "Option::is_none")] pub image_id: Option, #[doc = "unique, mutable, user-controlled identifier for each resource"] pub name: String, pub project_id: uuid::Uuid, #[doc = "A count of bytes, typically used either for memory or storage capacity\n\nThe maximum supported byte count is [`i64::MAX`]. This makes it somewhat inconvenient to define constructors: a u32 constructor can be infallible, but an i64 constructor can fail (if the value is negative) and a u64 constructor can fail (if the value is larger than i64::MAX). We provide all of these for consumers' convenience."] pub size: u64, #[serde(default, skip_serializing_if = "Option::is_none")] pub snapshot_id: Option, #[doc = "State of a Disk (primarily: attached or not)"] pub state: DiskState, #[doc = "timestamp when this resource was created"] pub time_created: chrono::DateTime, #[doc = "timestamp when this resource was last modified"] pub time_modified: chrono::DateTime, } impl std::fmt::Display for Disk { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for Disk { const LENGTH: usize = 12; fn fields(&self) -> Vec { vec![ format!("{:?}", self.block_size), self.description.clone(), self.device_path.clone(), format!("{:?}", self.id), if let Some(image_id) = &self.image_id { format!("{:?}", image_id) } else { String::new() }, self.name.clone(), format!("{:?}", self.project_id), format!("{:?}", self.size), if let Some(snapshot_id) = &self.snapshot_id { format!("{:?}", snapshot_id) } else { String::new() }, format!("{:?}", self.state), format!("{:?}", self.time_created), format!("{:?}", self.time_modified), ] } fn headers() -> Vec { vec![ "block_size".to_string(), "description".to_string(), "device_path".to_string(), "id".to_string(), "image_id".to_string(), "name".to_string(), "project_id".to_string(), "size".to_string(), "snapshot_id".to_string(), "state".to_string(), "time_created".to_string(), "time_modified".to_string(), ] } } #[doc = "Create-time parameters for a [`Disk`](omicron_common::api::external::Disk)"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct DiskCreate { pub description: String, #[doc = "initial source for this disk"] pub disk_source: DiskSource, #[doc = "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."] pub name: String, #[doc = "total size of the Disk in bytes"] pub size: u64, } impl std::fmt::Display for DiskCreate { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for DiskCreate { const LENGTH: usize = 4; fn fields(&self) -> Vec { vec![ self.description.clone(), format!("{:?}", self.disk_source), self.name.clone(), format!("{:?}", self.size), ] } fn headers() -> Vec { vec![ "description".to_string(), "disk_source".to_string(), "name".to_string(), "size".to_string(), ] } } #[doc = "Parameters for the [`Disk`](omicron_common::api::external::Disk) to be attached or detached to an instance"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct DiskIdentifier { #[doc = "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."] pub name: String, } impl std::fmt::Display for DiskIdentifier { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for DiskIdentifier { const LENGTH: usize = 1; fn fields(&self) -> Vec { vec![self.name.clone()] } fn headers() -> Vec { vec!["name".to_string()] } } #[doc = "A single page of results"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct DiskResultsPage { #[doc = "list of items on this page of results"] pub items: Vec, #[doc = "token used to fetch the next page of results (if any)"] #[serde(default, skip_serializing_if = "Option::is_none")] pub next_page: Option, } impl std::fmt::Display for DiskResultsPage { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl crate::types::paginate::Pagination for DiskResultsPage { type Item = Disk; fn has_more_pages(&self) -> bool { self.next_page.is_some() } fn next_page( &self, req: reqwest::Request, ) -> anyhow::Result { let mut req = req.try_clone().ok_or_else(|| { crate::types::error::Error::InvalidRequest(format!( "failed to clone request: {:?}", req )) })?; req.url_mut() .query_pairs_mut() .append_pair("next_page", self.next_page.as_deref().unwrap_or("")); Ok(req) } fn items(&self) -> Vec { self.items.clone() } } impl tabled::Tabled for DiskResultsPage { const LENGTH: usize = 2; fn fields(&self) -> Vec { vec![ format!("{:?}", self.items), if let Some(next_page) = &self.next_page { format!("{:?}", next_page) } else { String::new() }, ] } fn headers() -> Vec { vec!["items".to_string(), "next_page".to_string()] } } #[doc = "Different sources for a disk"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, tabled :: Tabled, )] #[serde(tag = "type")] pub enum DiskSource { #[serde(rename = "blank")] Blank { block_size: i64 }, #[serde(rename = "snapshot")] Snapshot { snapshot_id: uuid::Uuid }, #[serde(rename = "image")] Image { image_id: uuid::Uuid }, #[serde(rename = "global_image")] GlobalImage { image_id: uuid::Uuid }, } #[doc = "State of a Disk (primarily: attached or not)"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, tabled :: Tabled, )] #[serde(tag = "state")] pub enum DiskState { #[serde(rename = "creating")] Creating {}, #[serde(rename = "detached")] Detached {}, #[serde(rename = "attaching")] Attaching { instance: uuid::Uuid }, #[serde(rename = "attached")] Attached { instance: uuid::Uuid }, #[serde(rename = "detaching")] Detaching { instance: uuid::Uuid }, #[serde(rename = "destroyed")] Destroyed {}, #[serde(rename = "faulted")] Faulted {}, } #[doc = "OS image distribution"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct Distribution { #[doc = "The name of the distribution (e.g. \"alpine\" or \"ubuntu\")"] pub name: String, #[doc = "The version of the distribution (e.g. \"3.10\" or \"18.04\")"] pub version: String, } impl std::fmt::Display for Distribution { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for Distribution { const LENGTH: usize = 2; fn fields(&self) -> Vec { vec![self.name.clone(), self.version.clone()] } fn headers() -> Vec { vec!["name".to_string(), "version".to_string()] } } #[doc = "Error information from a response."] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct Error { #[serde(default, skip_serializing_if = "Option::is_none")] pub error_code: Option, pub message: String, pub request_id: String, } impl std::fmt::Display for Error { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for Error { const LENGTH: usize = 3; fn fields(&self) -> Vec { vec![ if let Some(error_code) = &self.error_code { format!("{:?}", error_code) } else { String::new() }, self.message.clone(), self.request_id.clone(), ] } fn headers() -> Vec { vec![ "error_code".to_string(), "message".to_string(), "request_id".to_string(), ] } } #[doc = "The name and type information for a field of a timeseries schema."] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct FieldSchema { pub name: String, #[doc = "The source from which a field is derived, the target or metric."] pub source: FieldSource, #[doc = "The `FieldType` identifies the data type of a target or metric field."] pub ty: FieldType, } impl std::fmt::Display for FieldSchema { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for FieldSchema { const LENGTH: usize = 3; fn fields(&self) -> Vec { vec![ self.name.clone(), format!("{:?}", self.source), format!("{:?}", self.ty), ] } fn headers() -> Vec { vec!["name".to_string(), "source".to_string(), "ty".to_string()] } } #[doc = "The source from which a field is derived, the target or metric."] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Eq, Hash, Debug, Clone, schemars :: JsonSchema, tabled :: Tabled, clap :: ValueEnum, parse_display :: FromStr, parse_display :: Display, )] pub enum FieldSource { #[serde(rename = "target")] #[display("target")] Target, #[serde(rename = "metric")] #[display("metric")] Metric, } #[doc = "The `FieldType` identifies the data type of a target or metric field."] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Eq, Hash, Debug, Clone, schemars :: JsonSchema, tabled :: Tabled, clap :: ValueEnum, parse_display :: FromStr, parse_display :: Display, )] pub enum FieldType { #[serde(rename = "string")] #[display("string")] String, #[serde(rename = "i64")] #[display("i64")] I64, #[serde(rename = "ip_addr")] #[display("ip_addr")] IpAddr, #[serde(rename = "uuid")] #[display("uuid")] Uuid, #[serde(rename = "bool")] #[display("bool")] Bool, } #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Eq, Hash, Debug, Clone, schemars :: JsonSchema, tabled :: Tabled, clap :: ValueEnum, parse_display :: FromStr, parse_display :: Display, )] pub enum FleetRole { #[serde(rename = "admin")] #[display("admin")] Admin, #[serde(rename = "collaborator")] #[display("collaborator")] Collaborator, #[serde(rename = "viewer")] #[display("viewer")] Viewer, } #[doc = "Client view of a [`Policy`], which describes how this resource may be accessed\n\nNote that the Policy only describes access granted explicitly for this resource. The policies of parent resources can also cause a user to have access to this resource."] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct FleetRolePolicy { #[doc = "Roles directly assigned on this resource"] pub role_assignments: Vec, } impl std::fmt::Display for FleetRolePolicy { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for FleetRolePolicy { const LENGTH: usize = 1; fn fields(&self) -> Vec { vec![format!("{:?}", self.role_assignments)] } fn headers() -> Vec { vec!["role_assignments".to_string()] } } #[doc = "Describes the assignment of a particular role on a particular resource to a particular identity (user, group, etc.)\n\nThe resource is not part of this structure. Rather, [`RoleAssignment`]s are put into a [`Policy`] and that Policy is applied to a particular resource."] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct FleetRoleRoleAssignment { pub identity_id: uuid::Uuid, #[doc = "Describes what kind of identity is described by an id"] pub identity_type: IdentityType, pub role_name: FleetRole, } impl std::fmt::Display for FleetRoleRoleAssignment { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for FleetRoleRoleAssignment { const LENGTH: usize = 3; fn fields(&self) -> Vec { vec![ format!("{:?}", self.identity_id), format!("{:?}", self.identity_type), format!("{:?}", self.role_name), ] } fn headers() -> Vec { vec![ "identity_id".to_string(), "identity_type".to_string(), "role_name".to_string(), ] } } #[doc = "Client view of global Images"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct GlobalImage { #[doc = "size of blocks in bytes"] pub block_size: u64, #[doc = "human-readable free-form text about a resource"] pub description: String, #[doc = "Hash of the image contents, if applicable"] #[serde(default, skip_serializing_if = "Option::is_none")] pub digest: Option, #[doc = "Image distribution"] pub distribution: String, #[doc = "unique, immutable, system-controlled identifier for each resource"] pub id: uuid::Uuid, #[doc = "unique, mutable, user-controlled identifier for each resource"] pub name: String, #[doc = "total size in bytes"] pub size: u64, #[doc = "timestamp when this resource was created"] pub time_created: chrono::DateTime, #[doc = "timestamp when this resource was last modified"] pub time_modified: chrono::DateTime, #[doc = "URL source of this image, if any"] #[serde(default, skip_serializing_if = "Option::is_none")] pub url: Option, #[doc = "Image version"] pub version: String, } impl std::fmt::Display for GlobalImage { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for GlobalImage { const LENGTH: usize = 11; fn fields(&self) -> Vec { vec![ format!("{:?}", self.block_size), self.description.clone(), if let Some(digest) = &self.digest { format!("{:?}", digest) } else { String::new() }, self.distribution.clone(), format!("{:?}", self.id), self.name.clone(), format!("{:?}", self.size), format!("{:?}", self.time_created), format!("{:?}", self.time_modified), if let Some(url) = &self.url { format!("{:?}", url) } else { String::new() }, self.version.clone(), ] } fn headers() -> Vec { vec![ "block_size".to_string(), "description".to_string(), "digest".to_string(), "distribution".to_string(), "id".to_string(), "name".to_string(), "size".to_string(), "time_created".to_string(), "time_modified".to_string(), "url".to_string(), "version".to_string(), ] } } #[doc = "Create-time parameters for an [`GlobalImage`](omicron_common::api::external::GlobalImage)"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct GlobalImageCreate { #[doc = "block size in bytes"] pub block_size: i64, pub description: String, #[doc = "OS image distribution"] pub distribution: Distribution, #[doc = "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."] pub name: String, #[doc = "The source of the image's contents."] pub source: ImageSource, } impl std::fmt::Display for GlobalImageCreate { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for GlobalImageCreate { const LENGTH: usize = 5; fn fields(&self) -> Vec { vec![ format!("{:?}", self.block_size), self.description.clone(), format!("{:?}", self.distribution), self.name.clone(), format!("{:?}", self.source), ] } fn headers() -> Vec { vec![ "block_size".to_string(), "description".to_string(), "distribution".to_string(), "name".to_string(), "source".to_string(), ] } } #[doc = "A single page of results"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct GlobalImageResultsPage { #[doc = "list of items on this page of results"] pub items: Vec, #[doc = "token used to fetch the next page of results (if any)"] #[serde(default, skip_serializing_if = "Option::is_none")] pub next_page: Option, } impl std::fmt::Display for GlobalImageResultsPage { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl crate::types::paginate::Pagination for GlobalImageResultsPage { type Item = GlobalImage; fn has_more_pages(&self) -> bool { self.next_page.is_some() } fn next_page( &self, req: reqwest::Request, ) -> anyhow::Result { let mut req = req.try_clone().ok_or_else(|| { crate::types::error::Error::InvalidRequest(format!( "failed to clone request: {:?}", req )) })?; req.url_mut() .query_pairs_mut() .append_pair("next_page", self.next_page.as_deref().unwrap_or("")); Ok(req) } fn items(&self) -> Vec { self.items.clone() } } impl tabled::Tabled for GlobalImageResultsPage { const LENGTH: usize = 2; fn fields(&self) -> Vec { vec![ format!("{:?}", self.items), if let Some(next_page) = &self.next_page { format!("{:?}", next_page) } else { String::new() }, ] } fn headers() -> Vec { vec!["items".to_string(), "next_page".to_string()] } } #[doc = "Client view of an [`IdentityProvider`]"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct IdentityProvider { #[doc = "human-readable free-form text about a resource"] pub description: String, #[doc = "unique, immutable, system-controlled identifier for each resource"] pub id: uuid::Uuid, #[doc = "unique, mutable, user-controlled identifier for each resource"] pub name: String, #[doc = "Identity provider type"] pub provider_type: IdentityProviderType, #[doc = "timestamp when this resource was created"] pub time_created: chrono::DateTime, #[doc = "timestamp when this resource was last modified"] pub time_modified: chrono::DateTime, } impl std::fmt::Display for IdentityProvider { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for IdentityProvider { const LENGTH: usize = 6; fn fields(&self) -> Vec { vec![ self.description.clone(), format!("{:?}", self.id), self.name.clone(), format!("{:?}", self.provider_type), format!("{:?}", self.time_created), format!("{:?}", self.time_modified), ] } fn headers() -> Vec { vec![ "description".to_string(), "id".to_string(), "name".to_string(), "provider_type".to_string(), "time_created".to_string(), "time_modified".to_string(), ] } } #[doc = "A single page of results"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct IdentityProviderResultsPage { #[doc = "list of items on this page of results"] pub items: Vec, #[doc = "token used to fetch the next page of results (if any)"] #[serde(default, skip_serializing_if = "Option::is_none")] pub next_page: Option, } impl std::fmt::Display for IdentityProviderResultsPage { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl crate::types::paginate::Pagination for IdentityProviderResultsPage { type Item = IdentityProvider; fn has_more_pages(&self) -> bool { self.next_page.is_some() } fn next_page( &self, req: reqwest::Request, ) -> anyhow::Result { let mut req = req.try_clone().ok_or_else(|| { crate::types::error::Error::InvalidRequest(format!( "failed to clone request: {:?}", req )) })?; req.url_mut() .query_pairs_mut() .append_pair("next_page", self.next_page.as_deref().unwrap_or("")); Ok(req) } fn items(&self) -> Vec { self.items.clone() } } impl tabled::Tabled for IdentityProviderResultsPage { const LENGTH: usize = 2; fn fields(&self) -> Vec { vec![ format!("{:?}", self.items), if let Some(next_page) = &self.next_page { format!("{:?}", next_page) } else { String::new() }, ] } fn headers() -> Vec { vec!["items".to_string(), "next_page".to_string()] } } #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Eq, Hash, Debug, Clone, schemars :: JsonSchema, tabled :: Tabled, clap :: ValueEnum, parse_display :: FromStr, parse_display :: Display, )] pub enum IdentityProviderType { #[serde(rename = "saml")] #[display("saml")] Saml, } impl std::default::Default for IdentityProviderType { fn default() -> Self { IdentityProviderType::Saml } } #[doc = "Describes what kind of identity is described by an id"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Eq, Hash, Debug, Clone, schemars :: JsonSchema, tabled :: Tabled, clap :: ValueEnum, parse_display :: FromStr, parse_display :: Display, )] pub enum IdentityType { #[serde(rename = "silo_user")] #[display("silo_user")] SiloUser, } impl std::default::Default for IdentityType { fn default() -> Self { IdentityType::SiloUser } } #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, tabled :: Tabled, )] #[serde(tag = "type")] pub enum IdpMetadataSource { #[serde(rename = "url")] Url { url: String }, #[serde(rename = "base64_encoded_xml")] Base64EncodedXml { data: String }, } #[doc = "Client view of project Images"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct Image { #[doc = "size of blocks in bytes"] pub block_size: u64, #[doc = "human-readable free-form text about a resource"] pub description: String, #[doc = "Hash of the image contents, if applicable"] #[serde(default, skip_serializing_if = "Option::is_none")] pub digest: Option, #[doc = "unique, immutable, system-controlled identifier for each resource"] pub id: uuid::Uuid, #[doc = "unique, mutable, user-controlled identifier for each resource"] pub name: String, #[doc = "The project the disk belongs to"] pub project_id: uuid::Uuid, #[doc = "total size in bytes"] pub size: u64, #[doc = "timestamp when this resource was created"] pub time_created: chrono::DateTime, #[doc = "timestamp when this resource was last modified"] pub time_modified: chrono::DateTime, #[doc = "URL source of this image, if any"] #[serde(default, skip_serializing_if = "Option::is_none")] pub url: Option, #[doc = "Version of this, if any"] #[serde(default, skip_serializing_if = "Option::is_none")] pub version: Option, } impl std::fmt::Display for Image { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for Image { const LENGTH: usize = 11; fn fields(&self) -> Vec { vec![ format!("{:?}", self.block_size), self.description.clone(), if let Some(digest) = &self.digest { format!("{:?}", digest) } else { String::new() }, format!("{:?}", self.id), self.name.clone(), format!("{:?}", self.project_id), format!("{:?}", self.size), format!("{:?}", self.time_created), format!("{:?}", self.time_modified), if let Some(url) = &self.url { format!("{:?}", url) } else { String::new() }, if let Some(version) = &self.version { format!("{:?}", version) } else { String::new() }, ] } fn headers() -> Vec { vec![ "block_size".to_string(), "description".to_string(), "digest".to_string(), "id".to_string(), "name".to_string(), "project_id".to_string(), "size".to_string(), "time_created".to_string(), "time_modified".to_string(), "url".to_string(), "version".to_string(), ] } } #[doc = "Create-time parameters for an [`Image`](omicron_common::api::external::Image)"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct ImageCreate { #[doc = "block size in bytes"] pub block_size: i64, pub description: String, #[doc = "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."] pub name: String, #[doc = "The source of the image's contents."] pub source: ImageSource, } impl std::fmt::Display for ImageCreate { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for ImageCreate { const LENGTH: usize = 4; fn fields(&self) -> Vec { vec![ format!("{:?}", self.block_size), self.description.clone(), self.name.clone(), format!("{:?}", self.source), ] } fn headers() -> Vec { vec![ "block_size".to_string(), "description".to_string(), "name".to_string(), "source".to_string(), ] } } #[doc = "A single page of results"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct ImageResultsPage { #[doc = "list of items on this page of results"] pub items: Vec, #[doc = "token used to fetch the next page of results (if any)"] #[serde(default, skip_serializing_if = "Option::is_none")] pub next_page: Option, } impl std::fmt::Display for ImageResultsPage { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl crate::types::paginate::Pagination for ImageResultsPage { type Item = Image; fn has_more_pages(&self) -> bool { self.next_page.is_some() } fn next_page( &self, req: reqwest::Request, ) -> anyhow::Result { let mut req = req.try_clone().ok_or_else(|| { crate::types::error::Error::InvalidRequest(format!( "failed to clone request: {:?}", req )) })?; req.url_mut() .query_pairs_mut() .append_pair("next_page", self.next_page.as_deref().unwrap_or("")); Ok(req) } fn items(&self) -> Vec { self.items.clone() } } impl tabled::Tabled for ImageResultsPage { const LENGTH: usize = 2; fn fields(&self) -> Vec { vec![ format!("{:?}", self.items), if let Some(next_page) = &self.next_page { format!("{:?}", next_page) } else { String::new() }, ] } fn headers() -> Vec { vec!["items".to_string(), "next_page".to_string()] } } #[doc = "The source of the underlying image."] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, tabled :: Tabled, )] #[serde(tag = "type")] pub enum ImageSource { #[serde(rename = "url")] Url { url: String }, #[serde(rename = "snapshot")] Snapshot { id: uuid::Uuid }, #[serde(rename = "you_can_boot_anything_as_long_as_its_alpine")] YouCanBootAnythingAsLongAsItsAlpine {}, } #[doc = "Client view of an [`Instance`]"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct Instance { #[doc = "human-readable free-form text about a resource"] pub description: String, #[doc = "RFC1035-compliant hostname for the Instance."] pub hostname: String, #[doc = "unique, immutable, system-controlled identifier for each resource"] pub id: uuid::Uuid, #[doc = "memory allocated for this Instance"] pub memory: u64, #[doc = "unique, mutable, user-controlled identifier for each resource"] pub name: String, #[doc = "number of CPUs allocated for this Instance"] pub ncpus: u16, #[doc = "id for the project containing this Instance"] pub project_id: uuid::Uuid, #[doc = "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"] pub run_state: InstanceState, #[doc = "timestamp when this resource was created"] pub time_created: chrono::DateTime, #[doc = "timestamp when this resource was last modified"] pub time_modified: chrono::DateTime, pub time_run_state_updated: chrono::DateTime, } impl std::fmt::Display for Instance { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for Instance { const LENGTH: usize = 11; fn fields(&self) -> Vec { vec![ self.description.clone(), self.hostname.clone(), format!("{:?}", self.id), format!("{:?}", self.memory), self.name.clone(), format!("{:?}", self.ncpus), format!("{:?}", self.project_id), format!("{:?}", self.run_state), format!("{:?}", self.time_created), format!("{:?}", self.time_modified), format!("{:?}", self.time_run_state_updated), ] } fn headers() -> Vec { vec![ "description".to_string(), "hostname".to_string(), "id".to_string(), "memory".to_string(), "name".to_string(), "ncpus".to_string(), "project_id".to_string(), "run_state".to_string(), "time_created".to_string(), "time_modified".to_string(), "time_run_state_updated".to_string(), ] } } #[doc = "Create-time parameters for an [`Instance`](omicron_common::api::external::Instance)"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct InstanceCreate { pub description: String, #[doc = "The disks to be created or attached for this instance."] #[serde(default, skip_serializing_if = "Option::is_none")] pub disks: Option>, pub hostname: String, #[doc = "A count of bytes, typically used either for memory or storage capacity\n\nThe maximum supported byte count is [`i64::MAX`]. This makes it somewhat inconvenient to define constructors: a u32 constructor can be infallible, but an i64 constructor can fail (if the value is negative) and a u64 constructor can fail (if the value is larger than i64::MAX). We provide all of these for consumers' convenience."] pub memory: u64, #[doc = "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."] pub name: String, #[doc = "The number of CPUs in an Instance"] pub ncpus: u16, #[doc = "The network interfaces to be created for this instance."] #[serde(default, skip_serializing_if = "Option::is_none")] pub network_interfaces: Option, #[doc = "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."] #[serde(default, skip_serializing_if = "Option::is_none")] pub user_data: Option, } impl std::fmt::Display for InstanceCreate { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for InstanceCreate { const LENGTH: usize = 8; fn fields(&self) -> Vec { vec![ self.description.clone(), if let Some(disks) = &self.disks { format!("{:?}", disks) } else { String::new() }, self.hostname.clone(), format!("{:?}", self.memory), self.name.clone(), format!("{:?}", self.ncpus), if let Some(network_interfaces) = &self.network_interfaces { format!("{:?}", network_interfaces) } else { String::new() }, if let Some(user_data) = &self.user_data { format!("{:?}", user_data) } else { String::new() }, ] } fn headers() -> Vec { vec![ "description".to_string(), "disks".to_string(), "hostname".to_string(), "memory".to_string(), "name".to_string(), "ncpus".to_string(), "network_interfaces".to_string(), "user_data".to_string(), ] } } #[doc = "Describe the instance's disks at creation time"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, tabled :: Tabled, )] #[serde(tag = "type")] pub enum InstanceDiskAttachment { #[serde(rename = "create")] Create { description: String, disk_source: DiskSource, name: String, size: u64, }, #[serde(rename = "attach")] Attach { name: String }, } #[doc = "Migration parameters for an [`Instance`](omicron_common::api::external::Instance)"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct InstanceMigrate { pub dst_sled_id: uuid::Uuid, } impl std::fmt::Display for InstanceMigrate { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for InstanceMigrate { const LENGTH: usize = 1; fn fields(&self) -> Vec { vec![format!("{:?}", self.dst_sled_id)] } fn headers() -> Vec { vec!["dst_sled_id".to_string()] } } #[doc = "Describes an attachment of a `NetworkInterface` to an `Instance`, at the time the instance is created."] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, tabled :: Tabled, )] #[serde(tag = "type")] pub enum InstanceNetworkInterfaceAttachment { #[serde(rename = "create")] Create { params: Vec }, #[serde(rename = "default")] Default {}, #[serde(rename = "none")] None {}, } #[doc = "A single page of results"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct InstanceResultsPage { #[doc = "list of items on this page of results"] pub items: Vec, #[doc = "token used to fetch the next page of results (if any)"] #[serde(default, skip_serializing_if = "Option::is_none")] pub next_page: Option, } impl std::fmt::Display for InstanceResultsPage { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl crate::types::paginate::Pagination for InstanceResultsPage { type Item = Instance; fn has_more_pages(&self) -> bool { self.next_page.is_some() } fn next_page( &self, req: reqwest::Request, ) -> anyhow::Result { let mut req = req.try_clone().ok_or_else(|| { crate::types::error::Error::InvalidRequest(format!( "failed to clone request: {:?}", req )) })?; req.url_mut() .query_pairs_mut() .append_pair("next_page", self.next_page.as_deref().unwrap_or("")); Ok(req) } fn items(&self) -> Vec { self.items.clone() } } impl tabled::Tabled for InstanceResultsPage { const LENGTH: usize = 2; fn fields(&self) -> Vec { vec![ format!("{:?}", self.items), if let Some(next_page) = &self.next_page { format!("{:?}", next_page) } else { String::new() }, ] } fn headers() -> Vec { vec!["items".to_string(), "next_page".to_string()] } } #[doc = "Contents of an Instance's serial console buffer."] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct InstanceSerialConsoleData { #[doc = "The bytes starting from the requested offset up to either the end of the buffer or the request's `max_bytes`. Provided as a u8 array rather than a string, as it may not be UTF-8."] pub data: Vec, #[doc = "The absolute offset since boot (suitable for use as `byte_offset` in a subsequent request) of the last byte returned in `data`."] pub last_byte_offset: u64, } impl std::fmt::Display for InstanceSerialConsoleData { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for InstanceSerialConsoleData { const LENGTH: usize = 2; fn fields(&self) -> Vec { vec![ format!("{:?}", self.data), format!("{:?}", self.last_byte_offset), ] } fn headers() -> Vec { vec!["data".to_string(), "last_byte_offset".to_string()] } } #[doc = "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"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Eq, Hash, Debug, Clone, schemars :: JsonSchema, tabled :: Tabled, clap :: ValueEnum, parse_display :: FromStr, parse_display :: Display, )] pub enum InstanceState { #[serde(rename = "creating")] #[display("creating")] Creating, #[serde(rename = "starting")] #[display("starting")] Starting, #[serde(rename = "running")] #[display("running")] Running, #[serde(rename = "stopping")] #[display("stopping")] Stopping, #[serde(rename = "stopped")] #[display("stopped")] Stopped, #[serde(rename = "rebooting")] #[display("rebooting")] Rebooting, #[serde(rename = "migrating")] #[display("migrating")] Migrating, #[serde(rename = "repairing")] #[display("repairing")] Repairing, #[serde(rename = "failed")] #[display("failed")] Failed, #[serde(rename = "destroyed")] #[display("destroyed")] Destroyed, } #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, tabled :: Tabled, )] pub enum IpNet { V4(String), V6(String), } #[doc = "Identity-related metadata that's included in nearly all public API objects"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct IpPool { #[doc = "human-readable free-form text about a resource"] pub description: String, #[doc = "unique, immutable, system-controlled identifier for each resource"] pub id: uuid::Uuid, #[doc = "unique, mutable, user-controlled identifier for each resource"] pub name: String, #[doc = "timestamp when this resource was created"] pub time_created: chrono::DateTime, #[doc = "timestamp when this resource was last modified"] pub time_modified: chrono::DateTime, } impl std::fmt::Display for IpPool { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for IpPool { const LENGTH: usize = 5; fn fields(&self) -> Vec { vec![ self.description.clone(), format!("{:?}", self.id), self.name.clone(), format!("{:?}", self.time_created), format!("{:?}", self.time_modified), ] } fn headers() -> Vec { vec![ "description".to_string(), "id".to_string(), "name".to_string(), "time_created".to_string(), "time_modified".to_string(), ] } } #[doc = "Create-time parameters for an IP Pool.\n\nSee [`IpPool`](omicron_nexus::external_api::views::IpPool)"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct IpPoolCreate { pub description: String, #[doc = "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."] pub name: String, } impl std::fmt::Display for IpPoolCreate { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for IpPoolCreate { const LENGTH: usize = 2; fn fields(&self) -> Vec { vec![self.description.clone(), self.name.clone()] } fn headers() -> Vec { vec!["description".to_string(), "name".to_string()] } } #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct IpPoolRange { pub id: uuid::Uuid, pub range: IpRange, pub time_created: chrono::DateTime, } impl std::fmt::Display for IpPoolRange { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for IpPoolRange { const LENGTH: usize = 3; fn fields(&self) -> Vec { vec![ format!("{:?}", self.id), format!("{:?}", self.range), format!("{:?}", self.time_created), ] } fn headers() -> Vec { vec![ "id".to_string(), "range".to_string(), "time_created".to_string(), ] } } #[doc = "A single page of results"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct IpPoolRangeResultsPage { #[doc = "list of items on this page of results"] pub items: Vec, #[doc = "token used to fetch the next page of results (if any)"] #[serde(default, skip_serializing_if = "Option::is_none")] pub next_page: Option, } impl std::fmt::Display for IpPoolRangeResultsPage { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl crate::types::paginate::Pagination for IpPoolRangeResultsPage { type Item = IpPoolRange; fn has_more_pages(&self) -> bool { self.next_page.is_some() } fn next_page( &self, req: reqwest::Request, ) -> anyhow::Result { let mut req = req.try_clone().ok_or_else(|| { crate::types::error::Error::InvalidRequest(format!( "failed to clone request: {:?}", req )) })?; req.url_mut() .query_pairs_mut() .append_pair("next_page", self.next_page.as_deref().unwrap_or("")); Ok(req) } fn items(&self) -> Vec { self.items.clone() } } impl tabled::Tabled for IpPoolRangeResultsPage { const LENGTH: usize = 2; fn fields(&self) -> Vec { vec![ format!("{:?}", self.items), if let Some(next_page) = &self.next_page { format!("{:?}", next_page) } else { String::new() }, ] } fn headers() -> Vec { vec!["items".to_string(), "next_page".to_string()] } } #[doc = "A single page of results"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct IpPoolResultsPage { #[doc = "list of items on this page of results"] pub items: Vec, #[doc = "token used to fetch the next page of results (if any)"] #[serde(default, skip_serializing_if = "Option::is_none")] pub next_page: Option, } impl std::fmt::Display for IpPoolResultsPage { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl crate::types::paginate::Pagination for IpPoolResultsPage { type Item = IpPool; fn has_more_pages(&self) -> bool { self.next_page.is_some() } fn next_page( &self, req: reqwest::Request, ) -> anyhow::Result { let mut req = req.try_clone().ok_or_else(|| { crate::types::error::Error::InvalidRequest(format!( "failed to clone request: {:?}", req )) })?; req.url_mut() .query_pairs_mut() .append_pair("next_page", self.next_page.as_deref().unwrap_or("")); Ok(req) } fn items(&self) -> Vec { self.items.clone() } } impl tabled::Tabled for IpPoolResultsPage { const LENGTH: usize = 2; fn fields(&self) -> Vec { vec![ format!("{:?}", self.items), if let Some(next_page) = &self.next_page { format!("{:?}", next_page) } else { String::new() }, ] } fn headers() -> Vec { vec!["items".to_string(), "next_page".to_string()] } } #[doc = "Parameters for updating an IP Pool"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct IpPoolUpdate { #[serde(default, skip_serializing_if = "Option::is_none")] pub description: Option, #[serde(default, skip_serializing_if = "Option::is_none")] pub name: Option, } impl std::fmt::Display for IpPoolUpdate { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for IpPoolUpdate { const LENGTH: usize = 2; fn fields(&self) -> Vec { vec![ if let Some(description) = &self.description { format!("{:?}", description) } else { String::new() }, if let Some(name) = &self.name { format!("{:?}", name) } else { String::new() }, ] } fn headers() -> Vec { vec!["description".to_string(), "name".to_string()] } } #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, tabled :: Tabled, )] pub enum IpRange { V4(Ipv4Range), V6(Ipv6Range), } #[doc = "A non-decreasing IPv4 address range, inclusive of both ends.\n\nThe first address must be less than or equal to the last address."] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct Ipv4Range { pub first: std::net::Ipv4Addr, pub last: std::net::Ipv4Addr, } impl std::fmt::Display for Ipv4Range { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for Ipv4Range { const LENGTH: usize = 2; fn fields(&self) -> Vec { vec![format!("{:?}", self.first), format!("{:?}", self.last)] } fn headers() -> Vec { vec!["first".to_string(), "last".to_string()] } } #[doc = "A non-decreasing IPv6 address range, inclusive of both ends.\n\nThe first address must be less than or equal to the last address."] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct Ipv6Range { pub first: std::net::Ipv6Addr, pub last: std::net::Ipv6Addr, } impl std::fmt::Display for Ipv6Range { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for Ipv6Range { const LENGTH: usize = 2; fn fields(&self) -> Vec { vec![format!("{:?}", self.first), format!("{:?}", self.last)] } fn headers() -> Vec { vec!["first".to_string(), "last".to_string()] } } #[doc = "A `NetworkInterface` represents a virtual network interface device."] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct NetworkInterface { #[doc = "human-readable free-form text about a resource"] pub description: String, #[doc = "unique, immutable, system-controlled identifier for each resource"] pub id: uuid::Uuid, #[doc = "The Instance to which the interface belongs."] pub instance_id: uuid::Uuid, #[doc = "The IP address assigned to this interface."] pub ip: std::net::IpAddr, #[doc = "The MAC address assigned to this interface."] pub mac: String, #[doc = "unique, mutable, user-controlled identifier for each resource"] pub name: String, #[doc = "True if this interface is the primary for the instance to which it's attached."] pub primary: bool, #[doc = "The subnet to which the interface belongs."] pub subnet_id: uuid::Uuid, #[doc = "timestamp when this resource was created"] pub time_created: chrono::DateTime, #[doc = "timestamp when this resource was last modified"] pub time_modified: chrono::DateTime, #[doc = "The VPC to which the interface belongs."] pub vpc_id: uuid::Uuid, } impl std::fmt::Display for NetworkInterface { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for NetworkInterface { const LENGTH: usize = 11; fn fields(&self) -> Vec { vec![ self.description.clone(), format!("{:?}", self.id), format!("{:?}", self.instance_id), format!("{:?}", self.ip), self.mac.clone(), self.name.clone(), format!("{:?}", self.primary), format!("{:?}", self.subnet_id), format!("{:?}", self.time_created), format!("{:?}", self.time_modified), format!("{:?}", self.vpc_id), ] } fn headers() -> Vec { vec![ "description".to_string(), "id".to_string(), "instance_id".to_string(), "ip".to_string(), "mac".to_string(), "name".to_string(), "primary".to_string(), "subnet_id".to_string(), "time_created".to_string(), "time_modified".to_string(), "vpc_id".to_string(), ] } } #[doc = "Create-time parameters for a [`NetworkInterface`](omicron_common::api::external::NetworkInterface)"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct NetworkInterfaceCreate { pub description: String, #[doc = "The IP address for the interface. One will be auto-assigned if not provided."] #[serde(default, skip_serializing_if = "Option::is_none")] pub ip: Option, #[doc = "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."] pub name: String, #[doc = "The VPC Subnet in which to create the interface."] pub subnet_name: String, #[doc = "The VPC in which to create the interface."] pub vpc_name: String, } impl std::fmt::Display for NetworkInterfaceCreate { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for NetworkInterfaceCreate { const LENGTH: usize = 5; fn fields(&self) -> Vec { vec![ self.description.clone(), if let Some(ip) = &self.ip { format!("{:?}", ip) } else { String::new() }, self.name.clone(), self.subnet_name.clone(), self.vpc_name.clone(), ] } fn headers() -> Vec { vec![ "description".to_string(), "ip".to_string(), "name".to_string(), "subnet_name".to_string(), "vpc_name".to_string(), ] } } #[doc = "A single page of results"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct NetworkInterfaceResultsPage { #[doc = "list of items on this page of results"] pub items: Vec, #[doc = "token used to fetch the next page of results (if any)"] #[serde(default, skip_serializing_if = "Option::is_none")] pub next_page: Option, } impl std::fmt::Display for NetworkInterfaceResultsPage { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl crate::types::paginate::Pagination for NetworkInterfaceResultsPage { type Item = NetworkInterface; fn has_more_pages(&self) -> bool { self.next_page.is_some() } fn next_page( &self, req: reqwest::Request, ) -> anyhow::Result { let mut req = req.try_clone().ok_or_else(|| { crate::types::error::Error::InvalidRequest(format!( "failed to clone request: {:?}", req )) })?; req.url_mut() .query_pairs_mut() .append_pair("next_page", self.next_page.as_deref().unwrap_or("")); Ok(req) } fn items(&self) -> Vec { self.items.clone() } } impl tabled::Tabled for NetworkInterfaceResultsPage { const LENGTH: usize = 2; fn fields(&self) -> Vec { vec![ format!("{:?}", self.items), if let Some(next_page) = &self.next_page { format!("{:?}", next_page) } else { String::new() }, ] } fn headers() -> Vec { vec!["items".to_string(), "next_page".to_string()] } } #[doc = "Parameters for updating a [`NetworkInterface`](omicron_common::api::external::NetworkInterface).\n\nNote that modifying IP addresses for an interface is not yet supported, a new interface must be created instead."] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct NetworkInterfaceUpdate { #[serde(default, skip_serializing_if = "Option::is_none")] pub description: Option, #[doc = "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."] #[serde(default, skip_serializing_if = "Option::is_none")] pub make_primary: Option, #[serde(default, skip_serializing_if = "Option::is_none")] pub name: Option, } impl std::fmt::Display for NetworkInterfaceUpdate { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for NetworkInterfaceUpdate { const LENGTH: usize = 3; fn fields(&self) -> Vec { vec![ if let Some(description) = &self.description { format!("{:?}", description) } else { String::new() }, if let Some(make_primary) = &self.make_primary { format!("{:?}", make_primary) } else { String::new() }, if let Some(name) = &self.name { format!("{:?}", name) } else { String::new() }, ] } fn headers() -> Vec { vec![ "description".to_string(), "make_primary".to_string(), "name".to_string(), ] } } #[doc = "Client view of an [`Organization`]"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct Organization { #[doc = "human-readable free-form text about a resource"] pub description: String, #[doc = "unique, immutable, system-controlled identifier for each resource"] pub id: uuid::Uuid, #[doc = "unique, mutable, user-controlled identifier for each resource"] pub name: String, #[doc = "timestamp when this resource was created"] pub time_created: chrono::DateTime, #[doc = "timestamp when this resource was last modified"] pub time_modified: chrono::DateTime, } impl std::fmt::Display for Organization { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for Organization { const LENGTH: usize = 5; fn fields(&self) -> Vec { vec![ self.description.clone(), format!("{:?}", self.id), self.name.clone(), format!("{:?}", self.time_created), format!("{:?}", self.time_modified), ] } fn headers() -> Vec { vec![ "description".to_string(), "id".to_string(), "name".to_string(), "time_created".to_string(), "time_modified".to_string(), ] } } #[doc = "Create-time parameters for an [`Organization`](crate::external_api::views::Organization)"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct OrganizationCreate { pub description: String, #[doc = "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."] pub name: String, } impl std::fmt::Display for OrganizationCreate { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for OrganizationCreate { const LENGTH: usize = 2; fn fields(&self) -> Vec { vec![self.description.clone(), self.name.clone()] } fn headers() -> Vec { vec!["description".to_string(), "name".to_string()] } } #[doc = "A single page of results"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct OrganizationResultsPage { #[doc = "list of items on this page of results"] pub items: Vec, #[doc = "token used to fetch the next page of results (if any)"] #[serde(default, skip_serializing_if = "Option::is_none")] pub next_page: Option, } impl std::fmt::Display for OrganizationResultsPage { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl crate::types::paginate::Pagination for OrganizationResultsPage { type Item = Organization; fn has_more_pages(&self) -> bool { self.next_page.is_some() } fn next_page( &self, req: reqwest::Request, ) -> anyhow::Result { let mut req = req.try_clone().ok_or_else(|| { crate::types::error::Error::InvalidRequest(format!( "failed to clone request: {:?}", req )) })?; req.url_mut() .query_pairs_mut() .append_pair("next_page", self.next_page.as_deref().unwrap_or("")); Ok(req) } fn items(&self) -> Vec { self.items.clone() } } impl tabled::Tabled for OrganizationResultsPage { const LENGTH: usize = 2; fn fields(&self) -> Vec { vec![ format!("{:?}", self.items), if let Some(next_page) = &self.next_page { format!("{:?}", next_page) } else { String::new() }, ] } fn headers() -> Vec { vec!["items".to_string(), "next_page".to_string()] } } #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Eq, Hash, Debug, Clone, schemars :: JsonSchema, tabled :: Tabled, clap :: ValueEnum, parse_display :: FromStr, parse_display :: Display, )] pub enum OrganizationRole { #[serde(rename = "admin")] #[display("admin")] Admin, #[serde(rename = "collaborator")] #[display("collaborator")] Collaborator, #[serde(rename = "viewer")] #[display("viewer")] Viewer, } #[doc = "Client view of a [`Policy`], which describes how this resource may be accessed\n\nNote that the Policy only describes access granted explicitly for this resource. The policies of parent resources can also cause a user to have access to this resource."] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct OrganizationRolePolicy { #[doc = "Roles directly assigned on this resource"] pub role_assignments: Vec, } impl std::fmt::Display for OrganizationRolePolicy { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for OrganizationRolePolicy { const LENGTH: usize = 1; fn fields(&self) -> Vec { vec![format!("{:?}", self.role_assignments)] } fn headers() -> Vec { vec!["role_assignments".to_string()] } } #[doc = "Describes the assignment of a particular role on a particular resource to a particular identity (user, group, etc.)\n\nThe resource is not part of this structure. Rather, [`RoleAssignment`]s are put into a [`Policy`] and that Policy is applied to a particular resource."] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct OrganizationRoleRoleAssignment { pub identity_id: uuid::Uuid, #[doc = "Describes what kind of identity is described by an id"] pub identity_type: IdentityType, pub role_name: OrganizationRole, } impl std::fmt::Display for OrganizationRoleRoleAssignment { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for OrganizationRoleRoleAssignment { const LENGTH: usize = 3; fn fields(&self) -> Vec { vec![ format!("{:?}", self.identity_id), format!("{:?}", self.identity_type), format!("{:?}", self.role_name), ] } fn headers() -> Vec { vec![ "identity_id".to_string(), "identity_type".to_string(), "role_name".to_string(), ] } } #[doc = "Updateable properties of an [`Organization`](crate::external_api::views::Organization)"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct OrganizationUpdate { #[serde(default, skip_serializing_if = "Option::is_none")] pub description: Option, #[serde(default, skip_serializing_if = "Option::is_none")] pub name: Option, } impl std::fmt::Display for OrganizationUpdate { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for OrganizationUpdate { const LENGTH: usize = 2; fn fields(&self) -> Vec { vec![ if let Some(description) = &self.description { format!("{:?}", description) } else { String::new() }, if let Some(name) = &self.name { format!("{:?}", name) } else { String::new() }, ] } fn headers() -> Vec { vec!["description".to_string(), "name".to_string()] } } #[doc = "Client view of a [`Project`]"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct Project { #[doc = "human-readable free-form text about a resource"] pub description: String, #[doc = "unique, immutable, system-controlled identifier for each resource"] pub id: uuid::Uuid, #[doc = "unique, mutable, user-controlled identifier for each resource"] pub name: String, pub organization_id: uuid::Uuid, #[doc = "timestamp when this resource was created"] pub time_created: chrono::DateTime, #[doc = "timestamp when this resource was last modified"] pub time_modified: chrono::DateTime, } impl std::fmt::Display for Project { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for Project { const LENGTH: usize = 6; fn fields(&self) -> Vec { vec![ self.description.clone(), format!("{:?}", self.id), self.name.clone(), format!("{:?}", self.organization_id), format!("{:?}", self.time_created), format!("{:?}", self.time_modified), ] } fn headers() -> Vec { vec![ "description".to_string(), "id".to_string(), "name".to_string(), "organization_id".to_string(), "time_created".to_string(), "time_modified".to_string(), ] } } #[doc = "Create-time parameters for a [`Project`](crate::external_api::views::Project)"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct ProjectCreate { pub description: String, #[doc = "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."] pub name: String, } impl std::fmt::Display for ProjectCreate { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for ProjectCreate { const LENGTH: usize = 2; fn fields(&self) -> Vec { vec![self.description.clone(), self.name.clone()] } fn headers() -> Vec { vec!["description".to_string(), "name".to_string()] } } #[doc = "A single page of results"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct ProjectResultsPage { #[doc = "list of items on this page of results"] pub items: Vec, #[doc = "token used to fetch the next page of results (if any)"] #[serde(default, skip_serializing_if = "Option::is_none")] pub next_page: Option, } impl std::fmt::Display for ProjectResultsPage { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl crate::types::paginate::Pagination for ProjectResultsPage { type Item = Project; fn has_more_pages(&self) -> bool { self.next_page.is_some() } fn next_page( &self, req: reqwest::Request, ) -> anyhow::Result { let mut req = req.try_clone().ok_or_else(|| { crate::types::error::Error::InvalidRequest(format!( "failed to clone request: {:?}", req )) })?; req.url_mut() .query_pairs_mut() .append_pair("next_page", self.next_page.as_deref().unwrap_or("")); Ok(req) } fn items(&self) -> Vec { self.items.clone() } } impl tabled::Tabled for ProjectResultsPage { const LENGTH: usize = 2; fn fields(&self) -> Vec { vec![ format!("{:?}", self.items), if let Some(next_page) = &self.next_page { format!("{:?}", next_page) } else { String::new() }, ] } fn headers() -> Vec { vec!["items".to_string(), "next_page".to_string()] } } #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Eq, Hash, Debug, Clone, schemars :: JsonSchema, tabled :: Tabled, clap :: ValueEnum, parse_display :: FromStr, parse_display :: Display, )] pub enum ProjectRole { #[serde(rename = "admin")] #[display("admin")] Admin, #[serde(rename = "collaborator")] #[display("collaborator")] Collaborator, #[serde(rename = "viewer")] #[display("viewer")] Viewer, } #[doc = "Client view of a [`Policy`], which describes how this resource may be accessed\n\nNote that the Policy only describes access granted explicitly for this resource. The policies of parent resources can also cause a user to have access to this resource."] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct ProjectRolePolicy { #[doc = "Roles directly assigned on this resource"] pub role_assignments: Vec, } impl std::fmt::Display for ProjectRolePolicy { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for ProjectRolePolicy { const LENGTH: usize = 1; fn fields(&self) -> Vec { vec![format!("{:?}", self.role_assignments)] } fn headers() -> Vec { vec!["role_assignments".to_string()] } } #[doc = "Describes the assignment of a particular role on a particular resource to a particular identity (user, group, etc.)\n\nThe resource is not part of this structure. Rather, [`RoleAssignment`]s are put into a [`Policy`] and that Policy is applied to a particular resource."] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct ProjectRoleRoleAssignment { pub identity_id: uuid::Uuid, #[doc = "Describes what kind of identity is described by an id"] pub identity_type: IdentityType, pub role_name: ProjectRole, } impl std::fmt::Display for ProjectRoleRoleAssignment { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for ProjectRoleRoleAssignment { const LENGTH: usize = 3; fn fields(&self) -> Vec { vec![ format!("{:?}", self.identity_id), format!("{:?}", self.identity_type), format!("{:?}", self.role_name), ] } fn headers() -> Vec { vec![ "identity_id".to_string(), "identity_type".to_string(), "role_name".to_string(), ] } } #[doc = "Updateable properties of a [`Project`](crate::external_api::views::Project)"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct ProjectUpdate { #[serde(default, skip_serializing_if = "Option::is_none")] pub description: Option, #[serde(default, skip_serializing_if = "Option::is_none")] pub name: Option, } impl std::fmt::Display for ProjectUpdate { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for ProjectUpdate { const LENGTH: usize = 2; fn fields(&self) -> Vec { vec![ if let Some(description) = &self.description { format!("{:?}", description) } else { String::new() }, if let Some(name) = &self.name { format!("{:?}", name) } else { String::new() }, ] } fn headers() -> Vec { vec!["description".to_string(), "name".to_string()] } } #[doc = "Client view of an [`Rack`]"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct Rack { #[doc = "unique, immutable, system-controlled identifier for each resource"] pub id: uuid::Uuid, #[doc = "timestamp when this resource was created"] pub time_created: chrono::DateTime, #[doc = "timestamp when this resource was last modified"] pub time_modified: chrono::DateTime, } impl std::fmt::Display for Rack { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for Rack { const LENGTH: usize = 3; fn fields(&self) -> Vec { vec![ format!("{:?}", self.id), format!("{:?}", self.time_created), format!("{:?}", self.time_modified), ] } fn headers() -> Vec { vec![ "id".to_string(), "time_created".to_string(), "time_modified".to_string(), ] } } #[doc = "A single page of results"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct RackResultsPage { #[doc = "list of items on this page of results"] pub items: Vec, #[doc = "token used to fetch the next page of results (if any)"] #[serde(default, skip_serializing_if = "Option::is_none")] pub next_page: Option, } impl std::fmt::Display for RackResultsPage { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl crate::types::paginate::Pagination for RackResultsPage { type Item = Rack; fn has_more_pages(&self) -> bool { self.next_page.is_some() } fn next_page( &self, req: reqwest::Request, ) -> anyhow::Result { let mut req = req.try_clone().ok_or_else(|| { crate::types::error::Error::InvalidRequest(format!( "failed to clone request: {:?}", req )) })?; req.url_mut() .query_pairs_mut() .append_pair("next_page", self.next_page.as_deref().unwrap_or("")); Ok(req) } fn items(&self) -> Vec { self.items.clone() } } impl tabled::Tabled for RackResultsPage { const LENGTH: usize = 2; fn fields(&self) -> Vec { vec![ format!("{:?}", self.items), if let Some(next_page) = &self.next_page { format!("{:?}", next_page) } else { String::new() }, ] } fn headers() -> Vec { vec!["items".to_string(), "next_page".to_string()] } } #[doc = "Client view of a [`Role`]"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct Role { pub description: String, #[doc = "Role names consist of two string components separated by dot (\".\")."] pub name: String, } impl std::fmt::Display for Role { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for Role { const LENGTH: usize = 2; fn fields(&self) -> Vec { vec![self.description.clone(), self.name.clone()] } fn headers() -> Vec { vec!["description".to_string(), "name".to_string()] } } #[doc = "A single page of results"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct RoleResultsPage { #[doc = "list of items on this page of results"] pub items: Vec, #[doc = "token used to fetch the next page of results (if any)"] #[serde(default, skip_serializing_if = "Option::is_none")] pub next_page: Option, } impl std::fmt::Display for RoleResultsPage { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl crate::types::paginate::Pagination for RoleResultsPage { type Item = Role; fn has_more_pages(&self) -> bool { self.next_page.is_some() } fn next_page( &self, req: reqwest::Request, ) -> anyhow::Result { let mut req = req.try_clone().ok_or_else(|| { crate::types::error::Error::InvalidRequest(format!( "failed to clone request: {:?}", req )) })?; req.url_mut() .query_pairs_mut() .append_pair("next_page", self.next_page.as_deref().unwrap_or("")); Ok(req) } fn items(&self) -> Vec { self.items.clone() } } impl tabled::Tabled for RoleResultsPage { const LENGTH: usize = 2; fn fields(&self) -> Vec { vec![ format!("{:?}", self.items), if let Some(next_page) = &self.next_page { format!("{:?}", next_page) } else { String::new() }, ] } fn headers() -> Vec { vec!["items".to_string(), "next_page".to_string()] } } #[doc = "A `RouteDestination` is used to match traffic with a routing rule, on the destination of that traffic.\n\nWhen traffic is to be sent to a destination that is within a given `RouteDestination`, the corresponding [`RouterRoute`] applies, and traffic will be forward to the [`RouteTarget`] for that rule."] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, tabled :: Tabled, )] #[serde(tag = "type", content = "value")] pub enum RouteDestination { #[serde(rename = "ip")] Ip(std::net::IpAddr), #[serde(rename = "ip_net")] IpNet(IpNet), #[serde(rename = "vpc")] Vpc(String), #[serde(rename = "subnet")] Subnet(String), } #[doc = "A `RouteTarget` describes the possible locations that traffic matching a route destination can be sent."] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, tabled :: Tabled, )] #[serde(tag = "type", content = "value")] pub enum RouteTarget { #[serde(rename = "ip")] Ip(std::net::IpAddr), #[serde(rename = "vpc")] Vpc(String), #[serde(rename = "subnet")] Subnet(String), #[serde(rename = "instance")] Instance(String), #[serde(rename = "internet_gateway")] InternetGateway(String), } #[doc = "A route defines a rule that governs where traffic should be sent based on its destination."] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct RouterRoute { #[doc = "human-readable free-form text about a resource"] pub description: String, #[doc = "A `RouteDestination` is used to match traffic with a routing rule, on the destination of that traffic.\n\nWhen traffic is to be sent to a destination that is within a given `RouteDestination`, the corresponding [`RouterRoute`] applies, and traffic will be forward to the [`RouteTarget`] for that rule."] pub destination: RouteDestination, #[doc = "unique, immutable, system-controlled identifier for each resource"] pub id: uuid::Uuid, #[doc = "Describes the kind of router. Set at creation. `read-only`"] pub kind: RouterRouteKind, #[doc = "unique, mutable, user-controlled identifier for each resource"] pub name: String, #[doc = "A `RouteTarget` describes the possible locations that traffic matching a route destination can be sent."] pub target: RouteTarget, #[doc = "timestamp when this resource was created"] pub time_created: chrono::DateTime, #[doc = "timestamp when this resource was last modified"] pub time_modified: chrono::DateTime, #[doc = "The VPC Router to which the route belongs."] pub vpc_router_id: uuid::Uuid, } impl std::fmt::Display for RouterRoute { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for RouterRoute { const LENGTH: usize = 9; fn fields(&self) -> Vec { vec![ self.description.clone(), format!("{:?}", self.destination), format!("{:?}", self.id), format!("{:?}", self.kind), self.name.clone(), format!("{:?}", self.target), format!("{:?}", self.time_created), format!("{:?}", self.time_modified), format!("{:?}", self.vpc_router_id), ] } fn headers() -> Vec { vec![ "description".to_string(), "destination".to_string(), "id".to_string(), "kind".to_string(), "name".to_string(), "target".to_string(), "time_created".to_string(), "time_modified".to_string(), "vpc_router_id".to_string(), ] } } #[doc = "Create-time parameters for a [`RouterRoute`]"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct RouterRouteCreateParams { pub description: String, #[doc = "A `RouteDestination` is used to match traffic with a routing rule, on the destination of that traffic.\n\nWhen traffic is to be sent to a destination that is within a given `RouteDestination`, the corresponding [`RouterRoute`] applies, and traffic will be forward to the [`RouteTarget`] for that rule."] pub destination: RouteDestination, #[doc = "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."] pub name: String, #[doc = "A `RouteTarget` describes the possible locations that traffic matching a route destination can be sent."] pub target: RouteTarget, } impl std::fmt::Display for RouterRouteCreateParams { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for RouterRouteCreateParams { const LENGTH: usize = 4; fn fields(&self) -> Vec { vec![ self.description.clone(), format!("{:?}", self.destination), self.name.clone(), format!("{:?}", self.target), ] } fn headers() -> Vec { vec![ "description".to_string(), "destination".to_string(), "name".to_string(), "target".to_string(), ] } } #[doc = "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"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Eq, Hash, Debug, Clone, schemars :: JsonSchema, tabled :: Tabled, clap :: ValueEnum, parse_display :: FromStr, parse_display :: Display, )] pub enum RouterRouteKind { #[serde(rename = "default")] #[display("default")] Default, #[serde(rename = "vpc_subnet")] #[display("vpc_subnet")] VpcSubnet, #[serde(rename = "vpc_peering")] #[display("vpc_peering")] VpcPeering, #[serde(rename = "custom")] #[display("custom")] Custom, } #[doc = "A single page of results"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct RouterRouteResultsPage { #[doc = "list of items on this page of results"] pub items: Vec, #[doc = "token used to fetch the next page of results (if any)"] #[serde(default, skip_serializing_if = "Option::is_none")] pub next_page: Option, } impl std::fmt::Display for RouterRouteResultsPage { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl crate::types::paginate::Pagination for RouterRouteResultsPage { type Item = RouterRoute; fn has_more_pages(&self) -> bool { self.next_page.is_some() } fn next_page( &self, req: reqwest::Request, ) -> anyhow::Result { let mut req = req.try_clone().ok_or_else(|| { crate::types::error::Error::InvalidRequest(format!( "failed to clone request: {:?}", req )) })?; req.url_mut() .query_pairs_mut() .append_pair("next_page", self.next_page.as_deref().unwrap_or("")); Ok(req) } fn items(&self) -> Vec { self.items.clone() } } impl tabled::Tabled for RouterRouteResultsPage { const LENGTH: usize = 2; fn fields(&self) -> Vec { vec![ format!("{:?}", self.items), if let Some(next_page) = &self.next_page { format!("{:?}", next_page) } else { String::new() }, ] } fn headers() -> Vec { vec!["items".to_string(), "next_page".to_string()] } } #[doc = "Updateable properties of a [`RouterRoute`]"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct RouterRouteUpdateParams { #[serde(default, skip_serializing_if = "Option::is_none")] pub description: Option, #[doc = "A `RouteDestination` is used to match traffic with a routing rule, on the destination of that traffic.\n\nWhen traffic is to be sent to a destination that is within a given `RouteDestination`, the corresponding [`RouterRoute`] applies, and traffic will be forward to the [`RouteTarget`] for that rule."] pub destination: RouteDestination, #[serde(default, skip_serializing_if = "Option::is_none")] pub name: Option, #[doc = "A `RouteTarget` describes the possible locations that traffic matching a route destination can be sent."] pub target: RouteTarget, } impl std::fmt::Display for RouterRouteUpdateParams { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for RouterRouteUpdateParams { const LENGTH: usize = 4; fn fields(&self) -> Vec { vec![ if let Some(description) = &self.description { format!("{:?}", description) } else { String::new() }, format!("{:?}", self.destination), if let Some(name) = &self.name { format!("{:?}", name) } else { String::new() }, format!("{:?}", self.target), ] } fn headers() -> Vec { vec![ "description".to_string(), "destination".to_string(), "name".to_string(), "target".to_string(), ] } } #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct Saga { pub id: uuid::Uuid, pub state: SagaState, } impl std::fmt::Display for Saga { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for Saga { const LENGTH: usize = 2; fn fields(&self) -> Vec { vec![format!("{:?}", self.id), format!("{:?}", self.state)] } fn headers() -> Vec { vec!["id".to_string(), "state".to_string()] } } #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, tabled :: Tabled, )] #[serde(tag = "error")] pub enum SagaErrorInfo { #[serde(rename = "action_failed")] ActionFailed { source_error: serde_json::Value }, #[serde(rename = "deserialize_failed")] DeserializeFailed { message: String }, #[serde(rename = "injected_error")] InjectedError {}, #[serde(rename = "serialize_failed")] SerializeFailed { message: String }, #[serde(rename = "subsaga_create_failed")] SubsagaCreateFailed { message: String }, } #[doc = "A single page of results"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct SagaResultsPage { #[doc = "list of items on this page of results"] pub items: Vec, #[doc = "token used to fetch the next page of results (if any)"] #[serde(default, skip_serializing_if = "Option::is_none")] pub next_page: Option, } impl std::fmt::Display for SagaResultsPage { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl crate::types::paginate::Pagination for SagaResultsPage { type Item = Saga; fn has_more_pages(&self) -> bool { self.next_page.is_some() } fn next_page( &self, req: reqwest::Request, ) -> anyhow::Result { let mut req = req.try_clone().ok_or_else(|| { crate::types::error::Error::InvalidRequest(format!( "failed to clone request: {:?}", req )) })?; req.url_mut() .query_pairs_mut() .append_pair("next_page", self.next_page.as_deref().unwrap_or("")); Ok(req) } fn items(&self) -> Vec { self.items.clone() } } impl tabled::Tabled for SagaResultsPage { const LENGTH: usize = 2; fn fields(&self) -> Vec { vec![ format!("{:?}", self.items), if let Some(next_page) = &self.next_page { format!("{:?}", next_page) } else { String::new() }, ] } fn headers() -> Vec { vec!["items".to_string(), "next_page".to_string()] } } #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, tabled :: Tabled, )] #[serde(tag = "state")] pub enum SagaState { #[serde(rename = "running")] Running {}, #[serde(rename = "succeeded")] Succeeded {}, #[serde(rename = "failed")] Failed { error_info: SagaErrorInfo, error_node_name: String, }, } #[doc = "Identity-related metadata that's included in nearly all public API objects"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct SamlIdentityProvider { #[doc = "service provider endpoint where the response will be sent"] pub acs_url: String, #[doc = "human-readable free-form text about a resource"] pub description: String, #[doc = "unique, immutable, system-controlled identifier for each resource"] pub id: uuid::Uuid, #[doc = "idp's entity id"] pub idp_entity_id: String, #[doc = "unique, mutable, user-controlled identifier for each resource"] pub name: String, #[doc = "optional request signing public certificate (base64 encoded der file)"] #[serde(default, skip_serializing_if = "Option::is_none")] pub public_cert: Option, #[doc = "service provider endpoint where the idp should send log out requests"] pub slo_url: String, #[doc = "sp's client id"] pub sp_client_id: String, #[doc = "customer's technical contact for saml configuration"] pub technical_contact_email: String, #[doc = "timestamp when this resource was created"] pub time_created: chrono::DateTime, #[doc = "timestamp when this resource was last modified"] pub time_modified: chrono::DateTime, } impl std::fmt::Display for SamlIdentityProvider { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for SamlIdentityProvider { const LENGTH: usize = 11; fn fields(&self) -> Vec { vec![ self.acs_url.clone(), self.description.clone(), format!("{:?}", self.id), self.idp_entity_id.clone(), self.name.clone(), if let Some(public_cert) = &self.public_cert { format!("{:?}", public_cert) } else { String::new() }, self.slo_url.clone(), self.sp_client_id.clone(), self.technical_contact_email.clone(), format!("{:?}", self.time_created), format!("{:?}", self.time_modified), ] } fn headers() -> Vec { vec![ "acs_url".to_string(), "description".to_string(), "id".to_string(), "idp_entity_id".to_string(), "name".to_string(), "public_cert".to_string(), "slo_url".to_string(), "sp_client_id".to_string(), "technical_contact_email".to_string(), "time_created".to_string(), "time_modified".to_string(), ] } } #[doc = "Create-time identity-related parameters"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct SamlIdentityProviderCreate { #[doc = "service provider endpoint where the response will be sent"] pub acs_url: String, pub description: String, #[doc = "idp's entity id"] pub idp_entity_id: String, #[doc = "the source of an identity provider metadata descriptor"] pub idp_metadata_source: IdpMetadataSource, #[doc = "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."] pub name: String, #[doc = "optional request signing key pair"] #[serde(default, skip_serializing_if = "Option::is_none")] pub signing_keypair: Option, #[doc = "service provider endpoint where the idp should send log out requests"] pub slo_url: String, #[doc = "sp's client id"] pub sp_client_id: String, #[doc = "customer's technical contact for saml configuration"] pub technical_contact_email: String, } impl std::fmt::Display for SamlIdentityProviderCreate { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for SamlIdentityProviderCreate { const LENGTH: usize = 9; fn fields(&self) -> Vec { vec![ self.acs_url.clone(), self.description.clone(), self.idp_entity_id.clone(), format!("{:?}", self.idp_metadata_source), self.name.clone(), if let Some(signing_keypair) = &self.signing_keypair { format!("{:?}", signing_keypair) } else { String::new() }, self.slo_url.clone(), self.sp_client_id.clone(), self.technical_contact_email.clone(), ] } fn headers() -> Vec { vec![ "acs_url".to_string(), "description".to_string(), "idp_entity_id".to_string(), "idp_metadata_source".to_string(), "name".to_string(), "signing_keypair".to_string(), "slo_url".to_string(), "sp_client_id".to_string(), "technical_contact_email".to_string(), ] } } #[doc = "Client view of a ['Silo']"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct Silo { #[doc = "human-readable free-form text about a resource"] pub description: String, #[doc = "A silo where discoverable is false can be retrieved only by its id - it will not be part of the \"list all silos\" output."] pub discoverable: bool, #[doc = "unique, immutable, system-controlled identifier for each resource"] pub id: uuid::Uuid, #[doc = "unique, mutable, user-controlled identifier for each resource"] pub name: String, #[doc = "timestamp when this resource was created"] pub time_created: chrono::DateTime, #[doc = "timestamp when this resource was last modified"] pub time_modified: chrono::DateTime, #[doc = "User provision type"] pub user_provision_type: UserProvisionType, } impl std::fmt::Display for Silo { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for Silo { const LENGTH: usize = 7; fn fields(&self) -> Vec { vec![ self.description.clone(), format!("{:?}", self.discoverable), format!("{:?}", self.id), self.name.clone(), format!("{:?}", self.time_created), format!("{:?}", self.time_modified), format!("{:?}", self.user_provision_type), ] } fn headers() -> Vec { vec![ "description".to_string(), "discoverable".to_string(), "id".to_string(), "name".to_string(), "time_created".to_string(), "time_modified".to_string(), "user_provision_type".to_string(), ] } } #[doc = "Create-time parameters for a [`Silo`](crate::external_api::views::Silo)"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct SiloCreate { pub description: String, pub discoverable: bool, #[doc = "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."] pub name: String, #[doc = "How users will be provisioned in a silo during authentication."] pub user_provision_type: UserProvisionType, } impl std::fmt::Display for SiloCreate { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for SiloCreate { const LENGTH: usize = 4; fn fields(&self) -> Vec { vec![ self.description.clone(), format!("{:?}", self.discoverable), self.name.clone(), format!("{:?}", self.user_provision_type), ] } fn headers() -> Vec { vec![ "description".to_string(), "discoverable".to_string(), "name".to_string(), "user_provision_type".to_string(), ] } } #[doc = "A single page of results"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct SiloResultsPage { #[doc = "list of items on this page of results"] pub items: Vec, #[doc = "token used to fetch the next page of results (if any)"] #[serde(default, skip_serializing_if = "Option::is_none")] pub next_page: Option, } impl std::fmt::Display for SiloResultsPage { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl crate::types::paginate::Pagination for SiloResultsPage { type Item = Silo; fn has_more_pages(&self) -> bool { self.next_page.is_some() } fn next_page( &self, req: reqwest::Request, ) -> anyhow::Result { let mut req = req.try_clone().ok_or_else(|| { crate::types::error::Error::InvalidRequest(format!( "failed to clone request: {:?}", req )) })?; req.url_mut() .query_pairs_mut() .append_pair("next_page", self.next_page.as_deref().unwrap_or("")); Ok(req) } fn items(&self) -> Vec { self.items.clone() } } impl tabled::Tabled for SiloResultsPage { const LENGTH: usize = 2; fn fields(&self) -> Vec { vec![ format!("{:?}", self.items), if let Some(next_page) = &self.next_page { format!("{:?}", next_page) } else { String::new() }, ] } fn headers() -> Vec { vec!["items".to_string(), "next_page".to_string()] } } #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Eq, Hash, Debug, Clone, schemars :: JsonSchema, tabled :: Tabled, clap :: ValueEnum, parse_display :: FromStr, parse_display :: Display, )] pub enum SiloRole { #[serde(rename = "admin")] #[display("admin")] Admin, #[serde(rename = "collaborator")] #[display("collaborator")] Collaborator, #[serde(rename = "viewer")] #[display("viewer")] Viewer, } #[doc = "Client view of a [`Policy`], which describes how this resource may be accessed\n\nNote that the Policy only describes access granted explicitly for this resource. The policies of parent resources can also cause a user to have access to this resource."] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct SiloRolePolicy { #[doc = "Roles directly assigned on this resource"] pub role_assignments: Vec, } impl std::fmt::Display for SiloRolePolicy { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for SiloRolePolicy { const LENGTH: usize = 1; fn fields(&self) -> Vec { vec![format!("{:?}", self.role_assignments)] } fn headers() -> Vec { vec!["role_assignments".to_string()] } } #[doc = "Describes the assignment of a particular role on a particular resource to a particular identity (user, group, etc.)\n\nThe resource is not part of this structure. Rather, [`RoleAssignment`]s are put into a [`Policy`] and that Policy is applied to a particular resource."] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct SiloRoleRoleAssignment { pub identity_id: uuid::Uuid, #[doc = "Describes what kind of identity is described by an id"] pub identity_type: IdentityType, pub role_name: SiloRole, } impl std::fmt::Display for SiloRoleRoleAssignment { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for SiloRoleRoleAssignment { const LENGTH: usize = 3; fn fields(&self) -> Vec { vec![ format!("{:?}", self.identity_id), format!("{:?}", self.identity_type), format!("{:?}", self.role_name), ] } fn headers() -> Vec { vec![ "identity_id".to_string(), "identity_type".to_string(), "role_name".to_string(), ] } } #[doc = "Client view of an [`Sled`]"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct Sled { #[doc = "unique, immutable, system-controlled identifier for each resource"] pub id: uuid::Uuid, pub service_address: String, #[doc = "timestamp when this resource was created"] pub time_created: chrono::DateTime, #[doc = "timestamp when this resource was last modified"] pub time_modified: chrono::DateTime, } impl std::fmt::Display for Sled { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for Sled { const LENGTH: usize = 4; fn fields(&self) -> Vec { vec![ format!("{:?}", self.id), self.service_address.clone(), format!("{:?}", self.time_created), format!("{:?}", self.time_modified), ] } fn headers() -> Vec { vec![ "id".to_string(), "service_address".to_string(), "time_created".to_string(), "time_modified".to_string(), ] } } #[doc = "A single page of results"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct SledResultsPage { #[doc = "list of items on this page of results"] pub items: Vec, #[doc = "token used to fetch the next page of results (if any)"] #[serde(default, skip_serializing_if = "Option::is_none")] pub next_page: Option, } impl std::fmt::Display for SledResultsPage { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl crate::types::paginate::Pagination for SledResultsPage { type Item = Sled; fn has_more_pages(&self) -> bool { self.next_page.is_some() } fn next_page( &self, req: reqwest::Request, ) -> anyhow::Result { let mut req = req.try_clone().ok_or_else(|| { crate::types::error::Error::InvalidRequest(format!( "failed to clone request: {:?}", req )) })?; req.url_mut() .query_pairs_mut() .append_pair("next_page", self.next_page.as_deref().unwrap_or("")); Ok(req) } fn items(&self) -> Vec { self.items.clone() } } impl tabled::Tabled for SledResultsPage { const LENGTH: usize = 2; fn fields(&self) -> Vec { vec![ format!("{:?}", self.items), if let Some(next_page) = &self.next_page { format!("{:?}", next_page) } else { String::new() }, ] } fn headers() -> Vec { vec!["items".to_string(), "next_page".to_string()] } } #[doc = "Client view of a Snapshot"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct Snapshot { #[doc = "human-readable free-form text about a resource"] pub description: String, pub disk_id: uuid::Uuid, #[doc = "unique, immutable, system-controlled identifier for each resource"] pub id: uuid::Uuid, #[doc = "unique, mutable, user-controlled identifier for each resource"] pub name: String, pub project_id: uuid::Uuid, #[doc = "A count of bytes, typically used either for memory or storage capacity\n\nThe maximum supported byte count is [`i64::MAX`]. This makes it somewhat inconvenient to define constructors: a u32 constructor can be infallible, but an i64 constructor can fail (if the value is negative) and a u64 constructor can fail (if the value is larger than i64::MAX). We provide all of these for consumers' convenience."] pub size: u64, #[doc = "timestamp when this resource was created"] pub time_created: chrono::DateTime, #[doc = "timestamp when this resource was last modified"] pub time_modified: chrono::DateTime, } impl std::fmt::Display for Snapshot { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for Snapshot { const LENGTH: usize = 8; fn fields(&self) -> Vec { vec![ self.description.clone(), format!("{:?}", self.disk_id), format!("{:?}", self.id), self.name.clone(), format!("{:?}", self.project_id), format!("{:?}", self.size), format!("{:?}", self.time_created), format!("{:?}", self.time_modified), ] } fn headers() -> Vec { vec![ "description".to_string(), "disk_id".to_string(), "id".to_string(), "name".to_string(), "project_id".to_string(), "size".to_string(), "time_created".to_string(), "time_modified".to_string(), ] } } #[doc = "Create-time parameters for a [`Snapshot`](omicron_common::api::external::Snapshot)"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct SnapshotCreate { pub description: String, #[doc = "The name of the disk to be snapshotted"] pub disk: String, #[doc = "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."] pub name: String, } impl std::fmt::Display for SnapshotCreate { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for SnapshotCreate { const LENGTH: usize = 3; fn fields(&self) -> Vec { vec![ self.description.clone(), self.disk.clone(), self.name.clone(), ] } fn headers() -> Vec { vec![ "description".to_string(), "disk".to_string(), "name".to_string(), ] } } #[doc = "A single page of results"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct SnapshotResultsPage { #[doc = "list of items on this page of results"] pub items: Vec, #[doc = "token used to fetch the next page of results (if any)"] #[serde(default, skip_serializing_if = "Option::is_none")] pub next_page: Option, } impl std::fmt::Display for SnapshotResultsPage { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl crate::types::paginate::Pagination for SnapshotResultsPage { type Item = Snapshot; fn has_more_pages(&self) -> bool { self.next_page.is_some() } fn next_page( &self, req: reqwest::Request, ) -> anyhow::Result { let mut req = req.try_clone().ok_or_else(|| { crate::types::error::Error::InvalidRequest(format!( "failed to clone request: {:?}", req )) })?; req.url_mut() .query_pairs_mut() .append_pair("next_page", self.next_page.as_deref().unwrap_or("")); Ok(req) } fn items(&self) -> Vec { self.items.clone() } } impl tabled::Tabled for SnapshotResultsPage { const LENGTH: usize = 2; fn fields(&self) -> Vec { vec![ format!("{:?}", self.items), if let Some(next_page) = &self.next_page { format!("{:?}", next_page) } else { String::new() }, ] } fn headers() -> Vec { vec!["items".to_string(), "next_page".to_string()] } } #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct SpoofLoginBody { pub username: String, } impl std::fmt::Display for SpoofLoginBody { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for SpoofLoginBody { const LENGTH: usize = 1; fn fields(&self) -> Vec { vec![self.username.clone()] } fn headers() -> Vec { vec!["username".to_string()] } } #[doc = "Client view of a [`SshKey`]"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct SshKey { #[doc = "human-readable free-form text about a resource"] pub description: String, #[doc = "unique, immutable, system-controlled identifier for each resource"] pub id: uuid::Uuid, #[doc = "unique, mutable, user-controlled identifier for each resource"] pub name: String, #[doc = "SSH public key, e.g., `\"ssh-ed25519 AAAAC3NzaC...\"`"] pub public_key: String, #[doc = "The user to whom this key belongs"] pub silo_user_id: uuid::Uuid, #[doc = "timestamp when this resource was created"] pub time_created: chrono::DateTime, #[doc = "timestamp when this resource was last modified"] pub time_modified: chrono::DateTime, } impl std::fmt::Display for SshKey { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for SshKey { const LENGTH: usize = 7; fn fields(&self) -> Vec { vec![ self.description.clone(), format!("{:?}", self.id), self.name.clone(), self.public_key.clone(), format!("{:?}", self.silo_user_id), format!("{:?}", self.time_created), format!("{:?}", self.time_modified), ] } fn headers() -> Vec { vec![ "description".to_string(), "id".to_string(), "name".to_string(), "public_key".to_string(), "silo_user_id".to_string(), "time_created".to_string(), "time_modified".to_string(), ] } } #[doc = "Create-time parameters for an [`SshKey`](crate::external_api::views::SshKey)"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct SshKeyCreate { pub description: String, #[doc = "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."] pub name: String, #[doc = "SSH public key, e.g., `\"ssh-ed25519 AAAAC3NzaC...\"`"] pub public_key: String, } impl std::fmt::Display for SshKeyCreate { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for SshKeyCreate { const LENGTH: usize = 3; fn fields(&self) -> Vec { vec![ self.description.clone(), self.name.clone(), self.public_key.clone(), ] } fn headers() -> Vec { vec![ "description".to_string(), "name".to_string(), "public_key".to_string(), ] } } #[doc = "A single page of results"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct SshKeyResultsPage { #[doc = "list of items on this page of results"] pub items: Vec, #[doc = "token used to fetch the next page of results (if any)"] #[serde(default, skip_serializing_if = "Option::is_none")] pub next_page: Option, } impl std::fmt::Display for SshKeyResultsPage { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl crate::types::paginate::Pagination for SshKeyResultsPage { type Item = SshKey; fn has_more_pages(&self) -> bool { self.next_page.is_some() } fn next_page( &self, req: reqwest::Request, ) -> anyhow::Result { let mut req = req.try_clone().ok_or_else(|| { crate::types::error::Error::InvalidRequest(format!( "failed to clone request: {:?}", req )) })?; req.url_mut() .query_pairs_mut() .append_pair("next_page", self.next_page.as_deref().unwrap_or("")); Ok(req) } fn items(&self) -> Vec { self.items.clone() } } impl tabled::Tabled for SshKeyResultsPage { const LENGTH: usize = 2; fn fields(&self) -> Vec { vec![ format!("{:?}", self.items), if let Some(next_page) = &self.next_page { format!("{:?}", next_page) } else { String::new() }, ] } fn headers() -> Vec { vec!["items".to_string(), "next_page".to_string()] } } #[doc = "The schema for a timeseries.\n\nThis includes the name of the timeseries, as well as the datum type of its metric and the schema for each field."] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct TimeseriesSchema { pub created: chrono::DateTime, #[doc = "The type of an individual datum of a metric."] pub datum_type: DatumType, pub field_schema: Vec, #[doc = "Names are constructed by concatenating the target and metric names with ':'. Target and metric names must be lowercase alphanumeric characters with '_' separating words."] pub timeseries_name: String, } impl std::fmt::Display for TimeseriesSchema { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for TimeseriesSchema { const LENGTH: usize = 4; fn fields(&self) -> Vec { vec![ format!("{:?}", self.created), format!("{:?}", self.datum_type), format!("{:?}", self.field_schema), self.timeseries_name.clone(), ] } fn headers() -> Vec { vec![ "created".to_string(), "datum_type".to_string(), "field_schema".to_string(), "timeseries_name".to_string(), ] } } #[doc = "A single page of results"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct TimeseriesSchemaResultsPage { #[doc = "list of items on this page of results"] pub items: Vec, #[doc = "token used to fetch the next page of results (if any)"] #[serde(default, skip_serializing_if = "Option::is_none")] pub next_page: Option, } impl std::fmt::Display for TimeseriesSchemaResultsPage { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl crate::types::paginate::Pagination for TimeseriesSchemaResultsPage { type Item = TimeseriesSchema; fn has_more_pages(&self) -> bool { self.next_page.is_some() } fn next_page( &self, req: reqwest::Request, ) -> anyhow::Result { let mut req = req.try_clone().ok_or_else(|| { crate::types::error::Error::InvalidRequest(format!( "failed to clone request: {:?}", req )) })?; req.url_mut() .query_pairs_mut() .append_pair("next_page", self.next_page.as_deref().unwrap_or("")); Ok(req) } fn items(&self) -> Vec { self.items.clone() } } impl tabled::Tabled for TimeseriesSchemaResultsPage { const LENGTH: usize = 2; fn fields(&self) -> Vec { vec![ format!("{:?}", self.items), if let Some(next_page) = &self.next_page { format!("{:?}", next_page) } else { String::new() }, ] } fn headers() -> Vec { vec!["items".to_string(), "next_page".to_string()] } } #[doc = "Client view of a [`User`]"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct User { #[doc = "Human-readable name that can identify the user"] pub display_name: String, pub id: uuid::Uuid, } impl std::fmt::Display for User { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for User { const LENGTH: usize = 2; fn fields(&self) -> Vec { vec![self.display_name.clone(), format!("{:?}", self.id)] } fn headers() -> Vec { vec!["display_name".to_string(), "id".to_string()] } } #[doc = "Client view of a [`UserBuiltin`]"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct UserBuiltin { #[doc = "human-readable free-form text about a resource"] pub description: String, #[doc = "unique, immutable, system-controlled identifier for each resource"] pub id: uuid::Uuid, #[doc = "unique, mutable, user-controlled identifier for each resource"] pub name: String, #[doc = "timestamp when this resource was created"] pub time_created: chrono::DateTime, #[doc = "timestamp when this resource was last modified"] pub time_modified: chrono::DateTime, } impl std::fmt::Display for UserBuiltin { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for UserBuiltin { const LENGTH: usize = 5; fn fields(&self) -> Vec { vec![ self.description.clone(), format!("{:?}", self.id), self.name.clone(), format!("{:?}", self.time_created), format!("{:?}", self.time_modified), ] } fn headers() -> Vec { vec![ "description".to_string(), "id".to_string(), "name".to_string(), "time_created".to_string(), "time_modified".to_string(), ] } } #[doc = "A single page of results"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct UserBuiltinResultsPage { #[doc = "list of items on this page of results"] pub items: Vec, #[doc = "token used to fetch the next page of results (if any)"] #[serde(default, skip_serializing_if = "Option::is_none")] pub next_page: Option, } impl std::fmt::Display for UserBuiltinResultsPage { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl crate::types::paginate::Pagination for UserBuiltinResultsPage { type Item = UserBuiltin; fn has_more_pages(&self) -> bool { self.next_page.is_some() } fn next_page( &self, req: reqwest::Request, ) -> anyhow::Result { let mut req = req.try_clone().ok_or_else(|| { crate::types::error::Error::InvalidRequest(format!( "failed to clone request: {:?}", req )) })?; req.url_mut() .query_pairs_mut() .append_pair("next_page", self.next_page.as_deref().unwrap_or("")); Ok(req) } fn items(&self) -> Vec { self.items.clone() } } impl tabled::Tabled for UserBuiltinResultsPage { const LENGTH: usize = 2; fn fields(&self) -> Vec { vec![ format!("{:?}", self.items), if let Some(next_page) = &self.next_page { format!("{:?}", next_page) } else { String::new() }, ] } fn headers() -> Vec { vec!["items".to_string(), "next_page".to_string()] } } #[doc = "How users will be provisioned in a silo during authentication."] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Eq, Hash, Debug, Clone, schemars :: JsonSchema, tabled :: Tabled, clap :: ValueEnum, parse_display :: FromStr, parse_display :: Display, )] pub enum UserProvisionType { #[serde(rename = "fixed")] #[display("fixed")] Fixed, #[serde(rename = "jit")] #[display("jit")] Jit, } #[doc = "A single page of results"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct UserResultsPage { #[doc = "list of items on this page of results"] pub items: Vec, #[doc = "token used to fetch the next page of results (if any)"] #[serde(default, skip_serializing_if = "Option::is_none")] pub next_page: Option, } impl std::fmt::Display for UserResultsPage { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl crate::types::paginate::Pagination for UserResultsPage { type Item = User; fn has_more_pages(&self) -> bool { self.next_page.is_some() } fn next_page( &self, req: reqwest::Request, ) -> anyhow::Result { let mut req = req.try_clone().ok_or_else(|| { crate::types::error::Error::InvalidRequest(format!( "failed to clone request: {:?}", req )) })?; req.url_mut() .query_pairs_mut() .append_pair("next_page", self.next_page.as_deref().unwrap_or("")); Ok(req) } fn items(&self) -> Vec { self.items.clone() } } impl tabled::Tabled for UserResultsPage { const LENGTH: usize = 2; fn fields(&self) -> Vec { vec![ format!("{:?}", self.items), if let Some(next_page) = &self.next_page { format!("{:?}", next_page) } else { String::new() }, ] } fn headers() -> Vec { vec!["items".to_string(), "next_page".to_string()] } } #[doc = "Client view of a [`Vpc`]"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct Vpc { #[doc = "human-readable free-form text about a resource"] pub description: String, #[doc = "The name used for the VPC in DNS."] pub dns_name: String, #[doc = "unique, immutable, system-controlled identifier for each resource"] pub id: uuid::Uuid, #[doc = "The unique local IPv6 address range for subnets in this VPC"] #[serde(rename = "ipv6_prefix")] pub ipv_6_prefix: String, #[doc = "unique, mutable, user-controlled identifier for each resource"] pub name: String, #[doc = "id for the project containing this VPC"] pub project_id: uuid::Uuid, #[doc = "id for the system router where subnet default routes are registered"] pub system_router_id: uuid::Uuid, #[doc = "timestamp when this resource was created"] pub time_created: chrono::DateTime, #[doc = "timestamp when this resource was last modified"] pub time_modified: chrono::DateTime, } impl std::fmt::Display for Vpc { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for Vpc { const LENGTH: usize = 9; fn fields(&self) -> Vec { vec![ self.description.clone(), self.dns_name.clone(), format!("{:?}", self.id), self.ipv_6_prefix.clone(), self.name.clone(), format!("{:?}", self.project_id), format!("{:?}", self.system_router_id), format!("{:?}", self.time_created), format!("{:?}", self.time_modified), ] } fn headers() -> Vec { vec![ "description".to_string(), "dns_name".to_string(), "id".to_string(), "ipv_6_prefix".to_string(), "name".to_string(), "project_id".to_string(), "system_router_id".to_string(), "time_created".to_string(), "time_modified".to_string(), ] } } #[doc = "Create-time parameters for a [`Vpc`](crate::external_api::views::Vpc)"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct VpcCreate { pub description: String, #[doc = "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."] pub dns_name: String, #[doc = "The IPv6 prefix for this VPC.\n\nAll IPv6 subnets created from this VPC must be taken from this range, which sould be a Unique Local Address in the range `fd00::/48`. The default VPC Subnet will have the first `/64` range from this prefix."] #[serde( rename = "ipv6_prefix", default, skip_serializing_if = "Option::is_none" )] pub ipv_6_prefix: Option, #[doc = "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."] pub name: String, } impl std::fmt::Display for VpcCreate { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for VpcCreate { const LENGTH: usize = 4; fn fields(&self) -> Vec { vec![ self.description.clone(), self.dns_name.clone(), if let Some(ipv_6_prefix) = &self.ipv_6_prefix { format!("{:?}", ipv_6_prefix) } else { String::new() }, self.name.clone(), ] } fn headers() -> Vec { vec![ "description".to_string(), "dns_name".to_string(), "ipv_6_prefix".to_string(), "name".to_string(), ] } } #[doc = "A single rule in a VPC firewall"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct VpcFirewallRule { #[doc = "whether traffic matching the rule should be allowed or dropped"] pub action: VpcFirewallRuleAction, #[doc = "human-readable free-form text about a resource"] pub description: String, #[doc = "whether this rule is for incoming or outgoing traffic"] pub direction: VpcFirewallRuleDirection, #[doc = "reductions on the scope of the rule"] pub filters: VpcFirewallRuleFilter, #[doc = "unique, immutable, system-controlled identifier for each resource"] pub id: uuid::Uuid, #[doc = "unique, mutable, user-controlled identifier for each resource"] pub name: String, #[doc = "the relative priority of this rule"] pub priority: u16, #[doc = "whether this rule is in effect"] pub status: VpcFirewallRuleStatus, #[doc = "list of sets of instances that the rule applies to"] pub targets: Vec, #[doc = "timestamp when this resource was created"] pub time_created: chrono::DateTime, #[doc = "timestamp when this resource was last modified"] pub time_modified: chrono::DateTime, #[doc = "the VPC to which this rule belongs"] pub vpc_id: uuid::Uuid, } impl std::fmt::Display for VpcFirewallRule { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for VpcFirewallRule { const LENGTH: usize = 12; fn fields(&self) -> Vec { vec![ format!("{:?}", self.action), self.description.clone(), format!("{:?}", self.direction), format!("{:?}", self.filters), format!("{:?}", self.id), self.name.clone(), format!("{:?}", self.priority), format!("{:?}", self.status), format!("{:?}", self.targets), format!("{:?}", self.time_created), format!("{:?}", self.time_modified), format!("{:?}", self.vpc_id), ] } fn headers() -> Vec { vec![ "action".to_string(), "description".to_string(), "direction".to_string(), "filters".to_string(), "id".to_string(), "name".to_string(), "priority".to_string(), "status".to_string(), "targets".to_string(), "time_created".to_string(), "time_modified".to_string(), "vpc_id".to_string(), ] } } #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Eq, Hash, Debug, Clone, schemars :: JsonSchema, tabled :: Tabled, clap :: ValueEnum, parse_display :: FromStr, parse_display :: Display, )] pub enum VpcFirewallRuleAction { #[serde(rename = "allow")] #[display("allow")] Allow, #[serde(rename = "deny")] #[display("deny")] Deny, } #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Eq, Hash, Debug, Clone, schemars :: JsonSchema, tabled :: Tabled, clap :: ValueEnum, parse_display :: FromStr, parse_display :: Display, )] pub enum VpcFirewallRuleDirection { #[serde(rename = "inbound")] #[display("inbound")] Inbound, #[serde(rename = "outbound")] #[display("outbound")] Outbound, } #[doc = "Filter for a firewall rule. A given packet must match every field that is present for the rule to apply to it. A packet matches a field if any entry in that field matches the packet."] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct VpcFirewallRuleFilter { #[doc = "If present, the sources (if incoming) or destinations (if outgoing) this rule applies to."] #[serde(default, skip_serializing_if = "Option::is_none")] pub hosts: Option>, #[doc = "If present, the destination ports this rule applies to."] #[serde(default, skip_serializing_if = "Option::is_none")] pub ports: Option>, #[doc = "If present, the networking protocols this rule applies to."] #[serde(default, skip_serializing_if = "Option::is_none")] pub protocols: Option>, } impl std::fmt::Display for VpcFirewallRuleFilter { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for VpcFirewallRuleFilter { const LENGTH: usize = 3; fn fields(&self) -> Vec { vec![ if let Some(hosts) = &self.hosts { format!("{:?}", hosts) } else { String::new() }, if let Some(ports) = &self.ports { format!("{:?}", ports) } else { String::new() }, if let Some(protocols) = &self.protocols { format!("{:?}", protocols) } else { String::new() }, ] } fn headers() -> Vec { vec![ "hosts".to_string(), "ports".to_string(), "protocols".to_string(), ] } } #[doc = "The `VpcFirewallRuleHostFilter` is used to filter traffic on the basis of its source or destination host."] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, tabled :: Tabled, )] #[serde(tag = "type", content = "value")] pub enum VpcFirewallRuleHostFilter { #[serde(rename = "vpc")] Vpc(String), #[serde(rename = "subnet")] Subnet(String), #[serde(rename = "instance")] Instance(String), #[serde(rename = "ip")] Ip(std::net::IpAddr), #[serde(rename = "ip_net")] IpNet(IpNet), } #[doc = "The protocols that may be specified in a firewall rule's filter"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Eq, Hash, Debug, Clone, schemars :: JsonSchema, tabled :: Tabled, clap :: ValueEnum, parse_display :: FromStr, parse_display :: Display, )] pub enum VpcFirewallRuleProtocol { #[serde(rename = "TCP")] #[display("TCP")] Tcp, #[serde(rename = "UDP")] #[display("UDP")] Udp, #[serde(rename = "ICMP")] #[display("ICMP")] Icmp, } #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Eq, Hash, Debug, Clone, schemars :: JsonSchema, tabled :: Tabled, clap :: ValueEnum, parse_display :: FromStr, parse_display :: Display, )] pub enum VpcFirewallRuleStatus { #[serde(rename = "disabled")] #[display("disabled")] Disabled, #[serde(rename = "enabled")] #[display("enabled")] Enabled, } #[doc = "A `VpcFirewallRuleTarget` is used to specify the set of [`Instance`]s to which a firewall rule applies."] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, tabled :: Tabled, )] #[serde(tag = "type", content = "value")] pub enum VpcFirewallRuleTarget { #[serde(rename = "vpc")] Vpc(String), #[serde(rename = "subnet")] Subnet(String), #[serde(rename = "instance")] Instance(String), #[serde(rename = "ip")] Ip(std::net::IpAddr), #[serde(rename = "ip_net")] IpNet(IpNet), } #[doc = "A single rule in a VPC firewall"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct VpcFirewallRuleUpdate { #[doc = "whether traffic matching the rule should be allowed or dropped"] pub action: VpcFirewallRuleAction, #[doc = "human-readable free-form text about a resource"] pub description: String, #[doc = "whether this rule is for incoming or outgoing traffic"] pub direction: VpcFirewallRuleDirection, #[doc = "reductions on the scope of the rule"] pub filters: VpcFirewallRuleFilter, #[doc = "name of the rule, unique to this VPC"] pub name: String, #[doc = "the relative priority of this rule"] pub priority: u16, #[doc = "whether this rule is in effect"] pub status: VpcFirewallRuleStatus, #[doc = "list of sets of instances that the rule applies to"] pub targets: Vec, } impl std::fmt::Display for VpcFirewallRuleUpdate { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for VpcFirewallRuleUpdate { const LENGTH: usize = 8; fn fields(&self) -> Vec { vec![ format!("{:?}", self.action), self.description.clone(), format!("{:?}", self.direction), format!("{:?}", self.filters), self.name.clone(), format!("{:?}", self.priority), format!("{:?}", self.status), format!("{:?}", self.targets), ] } fn headers() -> Vec { vec![ "action".to_string(), "description".to_string(), "direction".to_string(), "filters".to_string(), "name".to_string(), "priority".to_string(), "status".to_string(), "targets".to_string(), ] } } #[doc = "Updateable properties of a `Vpc`'s firewall Note that VpcFirewallRules are implicitly created along with a Vpc, so there is no explicit creation."] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct VpcFirewallRuleUpdateParams { pub rules: Vec, } impl std::fmt::Display for VpcFirewallRuleUpdateParams { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for VpcFirewallRuleUpdateParams { const LENGTH: usize = 1; fn fields(&self) -> Vec { vec![format!("{:?}", self.rules)] } fn headers() -> Vec { vec!["rules".to_string()] } } #[doc = "Collection of a [`Vpc`]'s firewall rules"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct VpcFirewallRules { pub rules: Vec, } impl std::fmt::Display for VpcFirewallRules { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for VpcFirewallRules { const LENGTH: usize = 1; fn fields(&self) -> Vec { vec![format!("{:?}", self.rules)] } fn headers() -> Vec { vec!["rules".to_string()] } } #[doc = "A single page of results"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct VpcResultsPage { #[doc = "list of items on this page of results"] pub items: Vec, #[doc = "token used to fetch the next page of results (if any)"] #[serde(default, skip_serializing_if = "Option::is_none")] pub next_page: Option, } impl std::fmt::Display for VpcResultsPage { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl crate::types::paginate::Pagination for VpcResultsPage { type Item = Vpc; fn has_more_pages(&self) -> bool { self.next_page.is_some() } fn next_page( &self, req: reqwest::Request, ) -> anyhow::Result { let mut req = req.try_clone().ok_or_else(|| { crate::types::error::Error::InvalidRequest(format!( "failed to clone request: {:?}", req )) })?; req.url_mut() .query_pairs_mut() .append_pair("next_page", self.next_page.as_deref().unwrap_or("")); Ok(req) } fn items(&self) -> Vec { self.items.clone() } } impl tabled::Tabled for VpcResultsPage { const LENGTH: usize = 2; fn fields(&self) -> Vec { vec![ format!("{:?}", self.items), if let Some(next_page) = &self.next_page { format!("{:?}", next_page) } else { String::new() }, ] } fn headers() -> Vec { vec!["items".to_string(), "next_page".to_string()] } } #[doc = "A VPC router defines a series of rules that indicate where traffic should be sent depending on its destination."] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct VpcRouter { #[doc = "human-readable free-form text about a resource"] pub description: String, #[doc = "unique, immutable, system-controlled identifier for each resource"] pub id: uuid::Uuid, pub kind: VpcRouterKind, #[doc = "unique, mutable, user-controlled identifier for each resource"] pub name: String, #[doc = "timestamp when this resource was created"] pub time_created: chrono::DateTime, #[doc = "timestamp when this resource was last modified"] pub time_modified: chrono::DateTime, #[doc = "The VPC to which the router belongs."] pub vpc_id: uuid::Uuid, } impl std::fmt::Display for VpcRouter { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for VpcRouter { const LENGTH: usize = 7; fn fields(&self) -> Vec { vec![ self.description.clone(), format!("{:?}", self.id), format!("{:?}", self.kind), self.name.clone(), format!("{:?}", self.time_created), format!("{:?}", self.time_modified), format!("{:?}", self.vpc_id), ] } fn headers() -> Vec { vec![ "description".to_string(), "id".to_string(), "kind".to_string(), "name".to_string(), "time_created".to_string(), "time_modified".to_string(), "vpc_id".to_string(), ] } } #[doc = "Create-time parameters for a [`VpcRouter`](crate::external_api::views::VpcRouter)"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct VpcRouterCreate { pub description: String, #[doc = "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."] pub name: String, } impl std::fmt::Display for VpcRouterCreate { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for VpcRouterCreate { const LENGTH: usize = 2; fn fields(&self) -> Vec { vec![self.description.clone(), self.name.clone()] } fn headers() -> Vec { vec!["description".to_string(), "name".to_string()] } } #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Eq, Hash, Debug, Clone, schemars :: JsonSchema, tabled :: Tabled, clap :: ValueEnum, parse_display :: FromStr, parse_display :: Display, )] pub enum VpcRouterKind { #[serde(rename = "system")] #[display("system")] System, #[serde(rename = "custom")] #[display("custom")] Custom, } #[doc = "A single page of results"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct VpcRouterResultsPage { #[doc = "list of items on this page of results"] pub items: Vec, #[doc = "token used to fetch the next page of results (if any)"] #[serde(default, skip_serializing_if = "Option::is_none")] pub next_page: Option, } impl std::fmt::Display for VpcRouterResultsPage { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl crate::types::paginate::Pagination for VpcRouterResultsPage { type Item = VpcRouter; fn has_more_pages(&self) -> bool { self.next_page.is_some() } fn next_page( &self, req: reqwest::Request, ) -> anyhow::Result { let mut req = req.try_clone().ok_or_else(|| { crate::types::error::Error::InvalidRequest(format!( "failed to clone request: {:?}", req )) })?; req.url_mut() .query_pairs_mut() .append_pair("next_page", self.next_page.as_deref().unwrap_or("")); Ok(req) } fn items(&self) -> Vec { self.items.clone() } } impl tabled::Tabled for VpcRouterResultsPage { const LENGTH: usize = 2; fn fields(&self) -> Vec { vec![ format!("{:?}", self.items), if let Some(next_page) = &self.next_page { format!("{:?}", next_page) } else { String::new() }, ] } fn headers() -> Vec { vec!["items".to_string(), "next_page".to_string()] } } #[doc = "Updateable properties of a [`VpcRouter`](crate::external_api::views::VpcRouter)"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct VpcRouterUpdate { #[serde(default, skip_serializing_if = "Option::is_none")] pub description: Option, #[serde(default, skip_serializing_if = "Option::is_none")] pub name: Option, } impl std::fmt::Display for VpcRouterUpdate { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for VpcRouterUpdate { const LENGTH: usize = 2; fn fields(&self) -> Vec { vec![ if let Some(description) = &self.description { format!("{:?}", description) } else { String::new() }, if let Some(name) = &self.name { format!("{:?}", name) } else { String::new() }, ] } fn headers() -> Vec { vec!["description".to_string(), "name".to_string()] } } #[doc = "A VPC subnet represents a logical grouping for instances that allows network traffic between them, within a IPv4 subnetwork or optionall an IPv6 subnetwork."] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct VpcSubnet { #[doc = "human-readable free-form text about a resource"] pub description: String, #[doc = "unique, immutable, system-controlled identifier for each resource"] pub id: uuid::Uuid, #[doc = "The IPv4 subnet CIDR block."] #[serde(rename = "ipv4_block")] pub ipv_4_block: String, #[doc = "The IPv6 subnet CIDR block."] #[serde(rename = "ipv6_block")] pub ipv_6_block: String, #[doc = "unique, mutable, user-controlled identifier for each resource"] pub name: String, #[doc = "timestamp when this resource was created"] pub time_created: chrono::DateTime, #[doc = "timestamp when this resource was last modified"] pub time_modified: chrono::DateTime, #[doc = "The VPC to which the subnet belongs."] pub vpc_id: uuid::Uuid, } impl std::fmt::Display for VpcSubnet { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for VpcSubnet { const LENGTH: usize = 8; fn fields(&self) -> Vec { vec![ self.description.clone(), format!("{:?}", self.id), self.ipv_4_block.clone(), self.ipv_6_block.clone(), self.name.clone(), format!("{:?}", self.time_created), format!("{:?}", self.time_modified), format!("{:?}", self.vpc_id), ] } fn headers() -> Vec { vec![ "description".to_string(), "id".to_string(), "ipv_4_block".to_string(), "ipv_6_block".to_string(), "name".to_string(), "time_created".to_string(), "time_modified".to_string(), "vpc_id".to_string(), ] } } #[doc = "Create-time parameters for a [`VpcSubnet`](crate::external_api::views::VpcSubnet)"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct VpcSubnetCreate { pub description: String, #[doc = "The IPv4 address range for this subnet.\n\nIt must be allocated from an RFC 1918 private address range, and must not overlap with any other existing subnet in the VPC."] #[serde(rename = "ipv4_block")] pub ipv_4_block: String, #[doc = "The IPv6 address range for this subnet.\n\nIt must be allocated from the RFC 4193 Unique Local Address range, with the prefix equal to the parent VPC's prefix. A random `/64` block will be assigned if one is not provided. It must not overlap with any existing subnet in the VPC."] #[serde( rename = "ipv6_block", default, skip_serializing_if = "Option::is_none" )] pub ipv_6_block: Option, #[doc = "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."] pub name: String, } impl std::fmt::Display for VpcSubnetCreate { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for VpcSubnetCreate { const LENGTH: usize = 4; fn fields(&self) -> Vec { vec![ self.description.clone(), self.ipv_4_block.clone(), if let Some(ipv_6_block) = &self.ipv_6_block { format!("{:?}", ipv_6_block) } else { String::new() }, self.name.clone(), ] } fn headers() -> Vec { vec![ "description".to_string(), "ipv_4_block".to_string(), "ipv_6_block".to_string(), "name".to_string(), ] } } #[doc = "A single page of results"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct VpcSubnetResultsPage { #[doc = "list of items on this page of results"] pub items: Vec, #[doc = "token used to fetch the next page of results (if any)"] #[serde(default, skip_serializing_if = "Option::is_none")] pub next_page: Option, } impl std::fmt::Display for VpcSubnetResultsPage { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl crate::types::paginate::Pagination for VpcSubnetResultsPage { type Item = VpcSubnet; fn has_more_pages(&self) -> bool { self.next_page.is_some() } fn next_page( &self, req: reqwest::Request, ) -> anyhow::Result { let mut req = req.try_clone().ok_or_else(|| { crate::types::error::Error::InvalidRequest(format!( "failed to clone request: {:?}", req )) })?; req.url_mut() .query_pairs_mut() .append_pair("next_page", self.next_page.as_deref().unwrap_or("")); Ok(req) } fn items(&self) -> Vec { self.items.clone() } } impl tabled::Tabled for VpcSubnetResultsPage { const LENGTH: usize = 2; fn fields(&self) -> Vec { vec![ format!("{:?}", self.items), if let Some(next_page) = &self.next_page { format!("{:?}", next_page) } else { String::new() }, ] } fn headers() -> Vec { vec!["items".to_string(), "next_page".to_string()] } } #[doc = "Updateable properties of a [`VpcSubnet`](crate::external_api::views::VpcSubnet)"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct VpcSubnetUpdate { #[serde(default, skip_serializing_if = "Option::is_none")] pub description: Option, #[serde(default, skip_serializing_if = "Option::is_none")] pub name: Option, } impl std::fmt::Display for VpcSubnetUpdate { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for VpcSubnetUpdate { const LENGTH: usize = 2; fn fields(&self) -> Vec { vec![ if let Some(description) = &self.description { format!("{:?}", description) } else { String::new() }, if let Some(name) = &self.name { format!("{:?}", name) } else { String::new() }, ] } fn headers() -> Vec { vec!["description".to_string(), "name".to_string()] } } #[doc = "Updateable properties of a [`Vpc`](crate::external_api::views::Vpc)"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema, )] pub struct VpcUpdate { #[serde(default, skip_serializing_if = "Option::is_none")] pub description: Option, #[serde(default, skip_serializing_if = "Option::is_none")] pub dns_name: Option, #[serde(default, skip_serializing_if = "Option::is_none")] pub name: Option, } impl std::fmt::Display for VpcUpdate { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "{}", serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)? ) } } impl tabled::Tabled for VpcUpdate { const LENGTH: usize = 3; fn fields(&self) -> Vec { vec![ if let Some(description) = &self.description { format!("{:?}", description) } else { String::new() }, if let Some(dns_name) = &self.dns_name { format!("{:?}", dns_name) } else { String::new() }, if let Some(name) = &self.name { format!("{:?}", name) } else { String::new() }, ] } fn headers() -> Vec { vec![ "description".to_string(), "dns_name".to_string(), "name".to_string(), ] } } #[doc = "Supported set of sort modes for scanning by id only.\n\nCurrently, we only support scanning in ascending order."] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Eq, Hash, Debug, Clone, schemars :: JsonSchema, tabled :: Tabled, clap :: ValueEnum, parse_display :: FromStr, parse_display :: Display, )] pub enum IdSortMode { #[serde(rename = "id_ascending")] #[display("id_ascending")] IdAscending, } impl std::default::Default for IdSortMode { fn default() -> Self { IdSortMode::IdAscending } } #[doc = "Supported set of sort modes for scanning by name only\n\nCurrently, we only support scanning in ascending order."] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Eq, Hash, Debug, Clone, schemars :: JsonSchema, tabled :: Tabled, clap :: ValueEnum, parse_display :: FromStr, parse_display :: Display, )] pub enum NameSortMode { #[serde(rename = "name_ascending")] #[display("name_ascending")] NameAscending, } impl std::default::Default for NameSortMode { fn default() -> Self { NameSortMode::NameAscending } } #[doc = "Supported set of sort modes for scanning by name or id"] #[derive( serde :: Serialize, serde :: Deserialize, PartialEq, Eq, Hash, Debug, Clone, schemars :: JsonSchema, tabled :: Tabled, clap :: ValueEnum, parse_display :: FromStr, parse_display :: Display, )] pub enum NameOrIdSortMode { #[serde(rename = "name_ascending")] #[display("name_ascending")] NameAscending, #[serde(rename = "name_descending")] #[display("name_descending")] NameDescending, #[serde(rename = "id_ascending")] #[display("id_ascending")] IdAscending, }