diff --git a/cli/src/generated_cli.rs b/cli/src/generated_cli.rs index cfee47a5..781086b3 100644 --- a/cli/src/generated_cli.rs +++ b/cli/src/generated_cli.rs @@ -20,6 +20,15 @@ impl Cli { CliCommand::ProbeCreate => Self::cli_probe_create(), CliCommand::ProbeView => Self::cli_probe_view(), CliCommand::ProbeDelete => Self::cli_probe_delete(), + CliCommand::SupportBundleList => Self::cli_support_bundle_list(), + CliCommand::SupportBundleCreate => Self::cli_support_bundle_create(), + CliCommand::SupportBundleView => Self::cli_support_bundle_view(), + CliCommand::SupportBundleDelete => Self::cli_support_bundle_delete(), + CliCommand::SupportBundleDownload => Self::cli_support_bundle_download(), + CliCommand::SupportBundleHead => Self::cli_support_bundle_head(), + CliCommand::SupportBundleDownloadFile => Self::cli_support_bundle_download_file(), + CliCommand::SupportBundleHeadFile => Self::cli_support_bundle_head_file(), + CliCommand::SupportBundleIndex => Self::cli_support_bundle_index(), CliCommand::LoginSaml => Self::cli_login_saml(), CliCommand::CertificateList => Self::cli_certificate_list(), CliCommand::CertificateCreate => Self::cli_certificate_create(), @@ -490,6 +499,135 @@ impl Cli { .about("Delete instrumentation probe") } + pub fn cli_support_bundle_list() -> ::clap::Command { + ::clap::Command::new("") + .arg( + ::clap::Arg::new("limit") + .long("limit") + .value_parser(::clap::value_parser!(std::num::NonZeroU32)) + .required(false) + .help("Maximum number of items returned by a single call"), + ) + .arg( + ::clap::Arg::new("sort-by") + .long("sort-by") + .value_parser(::clap::builder::TypedValueParser::map( + ::clap::builder::PossibleValuesParser::new([ + types::IdSortMode::IdAscending.to_string(), + ]), + |s| types::IdSortMode::try_from(s).unwrap(), + )) + .required(false), + ) + .about("List all support bundles") + } + + pub fn cli_support_bundle_create() -> ::clap::Command { + ::clap::Command::new("").about("Create a new support bundle") + } + + pub fn cli_support_bundle_view() -> ::clap::Command { + ::clap::Command::new("") + .arg( + ::clap::Arg::new("support-bundle") + .long("support-bundle") + .value_parser(::clap::value_parser!(uuid::Uuid)) + .required(true) + .help("ID of the support bundle"), + ) + .about("View a support bundle") + } + + pub fn cli_support_bundle_delete() -> ::clap::Command { + ::clap::Command::new("") + .arg( + ::clap::Arg::new("support-bundle") + .long("support-bundle") + .value_parser(::clap::value_parser!(uuid::Uuid)) + .required(true) + .help("ID of the support bundle"), + ) + .about("Delete an existing support bundle") + .long_about( + "May also be used to cancel a support bundle which is currently being collected, \ + or to remove metadata for a support bundle that has failed.", + ) + } + + pub fn cli_support_bundle_download() -> ::clap::Command { + ::clap::Command::new("") + .arg( + ::clap::Arg::new("support-bundle") + .long("support-bundle") + .value_parser(::clap::value_parser!(uuid::Uuid)) + .required(true) + .help("ID of the support bundle"), + ) + .about("Download the contents of a support bundle") + } + + pub fn cli_support_bundle_head() -> ::clap::Command { + ::clap::Command::new("") + .arg( + ::clap::Arg::new("support-bundle") + .long("support-bundle") + .value_parser(::clap::value_parser!(uuid::Uuid)) + .required(true) + .help("ID of the support bundle"), + ) + .about("Download the metadata of a support bundle") + } + + pub fn cli_support_bundle_download_file() -> ::clap::Command { + ::clap::Command::new("") + .arg( + ::clap::Arg::new("file") + .long("file") + .value_parser(::clap::value_parser!(::std::string::String)) + .required(true) + .help("The file within the bundle to download"), + ) + .arg( + ::clap::Arg::new("support-bundle") + .long("support-bundle") + .value_parser(::clap::value_parser!(uuid::Uuid)) + .required(true) + .help("ID of the support bundle"), + ) + .about("Download a file within a support bundle") + } + + pub fn cli_support_bundle_head_file() -> ::clap::Command { + ::clap::Command::new("") + .arg( + ::clap::Arg::new("file") + .long("file") + .value_parser(::clap::value_parser!(::std::string::String)) + .required(true) + .help("The file within the bundle to download"), + ) + .arg( + ::clap::Arg::new("support-bundle") + .long("support-bundle") + .value_parser(::clap::value_parser!(uuid::Uuid)) + .required(true) + .help("ID of the support bundle"), + ) + .about("Download the metadata of a file within the support bundle") + } + + pub fn cli_support_bundle_index() -> ::clap::Command { + ::clap::Command::new("") + .arg( + ::clap::Arg::new("support-bundle") + .long("support-bundle") + .value_parser(::clap::value_parser!(uuid::Uuid)) + .required(true) + .help("ID of the support bundle"), + ) + .about("Download the index of a support bundle") + } + pub fn cli_login_saml() -> ::clap::Command { ::clap::Command::new("") .arg( @@ -6634,6 +6772,21 @@ impl Cli { CliCommand::ProbeCreate => self.execute_probe_create(matches).await, CliCommand::ProbeView => self.execute_probe_view(matches).await, CliCommand::ProbeDelete => self.execute_probe_delete(matches).await, + CliCommand::SupportBundleList => self.execute_support_bundle_list(matches).await, + CliCommand::SupportBundleCreate => self.execute_support_bundle_create(matches).await, + CliCommand::SupportBundleView => self.execute_support_bundle_view(matches).await, + CliCommand::SupportBundleDelete => self.execute_support_bundle_delete(matches).await, + CliCommand::SupportBundleDownload => { + self.execute_support_bundle_download(matches).await + } + CliCommand::SupportBundleHead => self.execute_support_bundle_head(matches).await, + CliCommand::SupportBundleDownloadFile => { + self.execute_support_bundle_download_file(matches).await + } + CliCommand::SupportBundleHeadFile => { + self.execute_support_bundle_head_file(matches).await + } + CliCommand::SupportBundleIndex => self.execute_support_bundle_index(matches).await, CliCommand::LoginSaml => self.execute_login_saml(matches).await, CliCommand::CertificateList => self.execute_certificate_list(matches).await, CliCommand::CertificateCreate => self.execute_certificate_create(matches).await, @@ -7214,6 +7367,233 @@ impl Cli { } } + pub async fn execute_support_bundle_list( + &self, + matches: &::clap::ArgMatches, + ) -> anyhow::Result<()> { + let mut request = self.client.support_bundle_list(); + if let Some(value) = matches.get_one::("limit") { + request = request.limit(value.clone()); + } + + if let Some(value) = matches.get_one::("sort-by") { + request = request.sort_by(value.clone()); + } + + self.config + .execute_support_bundle_list(matches, &mut request)?; + self.config + .list_start::(); + let mut stream = futures::StreamExt::take( + request.stream(), + matches + .get_one::("limit") + .map_or(usize::MAX, |x| x.get() as usize), + ); + loop { + match futures::TryStreamExt::try_next(&mut stream).await { + Err(r) => { + self.config.list_end_error(&r); + return Err(anyhow::Error::new(r)); + } + Ok(None) => { + self.config + .list_end_success::(); + return Ok(()); + } + Ok(Some(value)) => { + self.config.list_item(&value); + } + } + } + } + + pub async fn execute_support_bundle_create( + &self, + matches: &::clap::ArgMatches, + ) -> anyhow::Result<()> { + let mut request = self.client.support_bundle_create(); + self.config + .execute_support_bundle_create(matches, &mut request)?; + let result = request.send().await; + match result { + Ok(r) => { + self.config.success_item(&r); + Ok(()) + } + Err(r) => { + self.config.error(&r); + Err(anyhow::Error::new(r)) + } + } + } + + pub async fn execute_support_bundle_view( + &self, + matches: &::clap::ArgMatches, + ) -> anyhow::Result<()> { + let mut request = self.client.support_bundle_view(); + if let Some(value) = matches.get_one::("support-bundle") { + request = request.support_bundle(value.clone()); + } + + self.config + .execute_support_bundle_view(matches, &mut request)?; + let result = request.send().await; + match result { + Ok(r) => { + self.config.success_item(&r); + Ok(()) + } + Err(r) => { + self.config.error(&r); + Err(anyhow::Error::new(r)) + } + } + } + + pub async fn execute_support_bundle_delete( + &self, + matches: &::clap::ArgMatches, + ) -> anyhow::Result<()> { + let mut request = self.client.support_bundle_delete(); + if let Some(value) = matches.get_one::("support-bundle") { + request = request.support_bundle(value.clone()); + } + + self.config + .execute_support_bundle_delete(matches, &mut request)?; + let result = request.send().await; + match result { + Ok(r) => { + self.config.success_no_item(&r); + Ok(()) + } + Err(r) => { + self.config.error(&r); + Err(anyhow::Error::new(r)) + } + } + } + + pub async fn execute_support_bundle_download( + &self, + matches: &::clap::ArgMatches, + ) -> anyhow::Result<()> { + let mut request = self.client.support_bundle_download(); + if let Some(value) = matches.get_one::("support-bundle") { + request = request.support_bundle(value.clone()); + } + + self.config + .execute_support_bundle_download(matches, &mut request)?; + let result = request.send().await; + match result { + Ok(r) => { + todo!() + } + Err(r) => { + todo!() + } + } + } + + pub async fn execute_support_bundle_head( + &self, + matches: &::clap::ArgMatches, + ) -> anyhow::Result<()> { + let mut request = self.client.support_bundle_head(); + if let Some(value) = matches.get_one::("support-bundle") { + request = request.support_bundle(value.clone()); + } + + self.config + .execute_support_bundle_head(matches, &mut request)?; + let result = request.send().await; + match result { + Ok(r) => { + todo!() + } + Err(r) => { + todo!() + } + } + } + + pub async fn execute_support_bundle_download_file( + &self, + matches: &::clap::ArgMatches, + ) -> anyhow::Result<()> { + let mut request = self.client.support_bundle_download_file(); + if let Some(value) = matches.get_one::<::std::string::String>("file") { + request = request.file(value.clone()); + } + + if let Some(value) = matches.get_one::("support-bundle") { + request = request.support_bundle(value.clone()); + } + + self.config + .execute_support_bundle_download_file(matches, &mut request)?; + let result = request.send().await; + match result { + Ok(r) => { + todo!() + } + Err(r) => { + todo!() + } + } + } + + pub async fn execute_support_bundle_head_file( + &self, + matches: &::clap::ArgMatches, + ) -> anyhow::Result<()> { + let mut request = self.client.support_bundle_head_file(); + if let Some(value) = matches.get_one::<::std::string::String>("file") { + request = request.file(value.clone()); + } + + if let Some(value) = matches.get_one::("support-bundle") { + request = request.support_bundle(value.clone()); + } + + self.config + .execute_support_bundle_head_file(matches, &mut request)?; + let result = request.send().await; + match result { + Ok(r) => { + todo!() + } + Err(r) => { + todo!() + } + } + } + + pub async fn execute_support_bundle_index( + &self, + matches: &::clap::ArgMatches, + ) -> anyhow::Result<()> { + let mut request = self.client.support_bundle_index(); + if let Some(value) = matches.get_one::("support-bundle") { + request = request.support_bundle(value.clone()); + } + + self.config + .execute_support_bundle_index(matches, &mut request)?; + let result = request.send().await; + match result { + Ok(r) => { + todo!() + } + Err(r) => { + todo!() + } + } + } + pub async fn execute_login_saml(&self, matches: &::clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.login_saml(); if let Some(value) = matches.get_one::("provider-name") { @@ -14200,6 +14580,78 @@ pub trait CliConfig { Ok(()) } + fn execute_support_bundle_list( + &self, + matches: &::clap::ArgMatches, + request: &mut builder::SupportBundleList, + ) -> anyhow::Result<()> { + Ok(()) + } + + fn execute_support_bundle_create( + &self, + matches: &::clap::ArgMatches, + request: &mut builder::SupportBundleCreate, + ) -> anyhow::Result<()> { + Ok(()) + } + + fn execute_support_bundle_view( + &self, + matches: &::clap::ArgMatches, + request: &mut builder::SupportBundleView, + ) -> anyhow::Result<()> { + Ok(()) + } + + fn execute_support_bundle_delete( + &self, + matches: &::clap::ArgMatches, + request: &mut builder::SupportBundleDelete, + ) -> anyhow::Result<()> { + Ok(()) + } + + fn execute_support_bundle_download( + &self, + matches: &::clap::ArgMatches, + request: &mut builder::SupportBundleDownload, + ) -> anyhow::Result<()> { + Ok(()) + } + + fn execute_support_bundle_head( + &self, + matches: &::clap::ArgMatches, + request: &mut builder::SupportBundleHead, + ) -> anyhow::Result<()> { + Ok(()) + } + + fn execute_support_bundle_download_file( + &self, + matches: &::clap::ArgMatches, + request: &mut builder::SupportBundleDownloadFile, + ) -> anyhow::Result<()> { + Ok(()) + } + + fn execute_support_bundle_head_file( + &self, + matches: &::clap::ArgMatches, + request: &mut builder::SupportBundleHeadFile, + ) -> anyhow::Result<()> { + Ok(()) + } + + fn execute_support_bundle_index( + &self, + matches: &::clap::ArgMatches, + request: &mut builder::SupportBundleIndex, + ) -> anyhow::Result<()> { + Ok(()) + } + fn execute_login_saml( &self, matches: &::clap::ArgMatches, @@ -15826,6 +16278,15 @@ pub enum CliCommand { ProbeCreate, ProbeView, ProbeDelete, + SupportBundleList, + SupportBundleCreate, + SupportBundleView, + SupportBundleDelete, + SupportBundleDownload, + SupportBundleHead, + SupportBundleDownloadFile, + SupportBundleHeadFile, + SupportBundleIndex, LoginSaml, CertificateList, CertificateCreate, @@ -16040,6 +16501,15 @@ impl CliCommand { CliCommand::ProbeCreate, CliCommand::ProbeView, CliCommand::ProbeDelete, + CliCommand::SupportBundleList, + CliCommand::SupportBundleCreate, + CliCommand::SupportBundleView, + CliCommand::SupportBundleDelete, + CliCommand::SupportBundleDownload, + CliCommand::SupportBundleHead, + CliCommand::SupportBundleDownloadFile, + CliCommand::SupportBundleHeadFile, + CliCommand::SupportBundleIndex, CliCommand::LoginSaml, CliCommand::CertificateList, CliCommand::CertificateCreate, diff --git a/oxide.json b/oxide.json index c0b6a96f..bc043059 100644 --- a/oxide.json +++ b/oxide.json @@ -301,6 +301,329 @@ } } }, + "/experimental/v1/system/support-bundles": { + "get": { + "tags": [ + "hidden" + ], + "summary": "List all support bundles", + "operationId": "support_bundle_list", + "parameters": [ + { + "in": "query", + "name": "limit", + "description": "Maximum number of items returned by a single call", + "schema": { + "nullable": true, + "type": "integer", + "format": "uint32", + "minimum": 1 + } + }, + { + "in": "query", + "name": "page_token", + "description": "Token returned by previous call to retrieve the subsequent page", + "schema": { + "nullable": true, + "type": "string" + } + }, + { + "in": "query", + "name": "sort_by", + "schema": { + "$ref": "#/components/schemas/IdSortMode" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SupportBundleInfoResultsPage" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + }, + "x-dropshot-pagination": { + "required": [] + } + }, + "post": { + "tags": [ + "hidden" + ], + "summary": "Create a new support bundle", + "operationId": "support_bundle_create", + "responses": { + "201": { + "description": "successful creation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SupportBundleInfo" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/experimental/v1/system/support-bundles/{support_bundle}": { + "get": { + "tags": [ + "hidden" + ], + "summary": "View a support bundle", + "operationId": "support_bundle_view", + "parameters": [ + { + "in": "path", + "name": "support_bundle", + "description": "ID of the support bundle", + "required": true, + "schema": { + "type": "string", + "format": "uuid" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SupportBundleInfo" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + }, + "delete": { + "tags": [ + "hidden" + ], + "summary": "Delete an existing support bundle", + "description": "May also be used to cancel a support bundle which is currently being collected, or to remove metadata for a support bundle that has failed.", + "operationId": "support_bundle_delete", + "parameters": [ + { + "in": "path", + "name": "support_bundle", + "description": "ID of the support bundle", + "required": true, + "schema": { + "type": "string", + "format": "uuid" + } + } + ], + "responses": { + "204": { + "description": "successful deletion" + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/experimental/v1/system/support-bundles/{support_bundle}/download": { + "get": { + "tags": [ + "hidden" + ], + "summary": "Download the contents of a support bundle", + "operationId": "support_bundle_download", + "parameters": [ + { + "in": "path", + "name": "support_bundle", + "description": "ID of the support bundle", + "required": true, + "schema": { + "type": "string", + "format": "uuid" + } + } + ], + "responses": { + "default": { + "description": "", + "content": { + "*/*": { + "schema": {} + } + } + } + } + }, + "head": { + "tags": [ + "hidden" + ], + "summary": "Download the metadata of a support bundle", + "operationId": "support_bundle_head", + "parameters": [ + { + "in": "path", + "name": "support_bundle", + "description": "ID of the support bundle", + "required": true, + "schema": { + "type": "string", + "format": "uuid" + } + } + ], + "responses": { + "default": { + "description": "", + "content": { + "*/*": { + "schema": {} + } + } + } + } + } + }, + "/experimental/v1/system/support-bundles/{support_bundle}/download/{file}": { + "get": { + "tags": [ + "hidden" + ], + "summary": "Download a file within a support bundle", + "operationId": "support_bundle_download_file", + "parameters": [ + { + "in": "path", + "name": "file", + "description": "The file within the bundle to download", + "required": true, + "schema": { + "type": "string" + } + }, + { + "in": "path", + "name": "support_bundle", + "description": "ID of the support bundle", + "required": true, + "schema": { + "type": "string", + "format": "uuid" + } + } + ], + "responses": { + "default": { + "description": "", + "content": { + "*/*": { + "schema": {} + } + } + } + } + }, + "head": { + "tags": [ + "hidden" + ], + "summary": "Download the metadata of a file within the support bundle", + "operationId": "support_bundle_head_file", + "parameters": [ + { + "in": "path", + "name": "file", + "description": "The file within the bundle to download", + "required": true, + "schema": { + "type": "string" + } + }, + { + "in": "path", + "name": "support_bundle", + "description": "ID of the support bundle", + "required": true, + "schema": { + "type": "string", + "format": "uuid" + } + } + ], + "responses": { + "default": { + "description": "", + "content": { + "*/*": { + "schema": {} + } + } + } + } + } + }, + "/experimental/v1/system/support-bundles/{support_bundle}/index": { + "get": { + "tags": [ + "hidden" + ], + "summary": "Download the index of a support bundle", + "operationId": "support_bundle_index", + "parameters": [ + { + "in": "path", + "name": "support_bundle", + "description": "ID of the support bundle", + "required": true, + "schema": { + "type": "string", + "format": "uuid" + } + } + ], + "responses": { + "default": { + "description": "", + "content": { + "*/*": { + "schema": {} + } + } + } + } + } + }, "/login/{silo_name}/saml/{provider_name}": { "post": { "tags": [ @@ -20059,6 +20382,87 @@ "items" ] }, + "SupportBundleInfo": { + "type": "object", + "properties": { + "id": { + "$ref": "#/components/schemas/TypedUuidForSupportBundleKind" + }, + "reason_for_creation": { + "type": "string" + }, + "reason_for_failure": { + "nullable": true, + "type": "string" + }, + "state": { + "$ref": "#/components/schemas/SupportBundleState" + }, + "time_created": { + "type": "string", + "format": "date-time" + } + }, + "required": [ + "id", + "reason_for_creation", + "state", + "time_created" + ] + }, + "SupportBundleInfoResultsPage": { + "description": "A single page of results", + "type": "object", + "properties": { + "items": { + "description": "list of items on this page of results", + "type": "array", + "items": { + "$ref": "#/components/schemas/SupportBundleInfo" + } + }, + "next_page": { + "nullable": true, + "description": "token used to fetch the next page of results (if any)", + "type": "string" + } + }, + "required": [ + "items" + ] + }, + "SupportBundleState": { + "oneOf": [ + { + "description": "Support Bundle still actively being collected.\n\nThis is the initial state for a Support Bundle, and it will automatically transition to either \"Failing\" or \"Active\".\n\nIf a user no longer wants to access a Support Bundle, they can request cancellation, which will transition to the \"Destroying\" state.", + "type": "string", + "enum": [ + "collecting" + ] + }, + { + "description": "Support Bundle is being destroyed.\n\nOnce backing storage has been freed, this bundle is destroyed.", + "type": "string", + "enum": [ + "destroying" + ] + }, + { + "description": "Support Bundle was not created successfully, or was created and has lost backing storage.\n\nThe record of the bundle still exists for readability, but the only valid operation on these bundles is to destroy them.", + "type": "string", + "enum": [ + "failed" + ] + }, + { + "description": "Support Bundle has been processed, and is ready for usage.", + "type": "string", + "enum": [ + "active" + ] + } + ] + }, "Switch": { "description": "An operator's view of a Switch.", "type": "object", @@ -21073,6 +21477,10 @@ } } }, + "TypedUuidForSupportBundleKind": { + "type": "string", + "format": "uuid" + }, "UninitializedSled": { "description": "A sled that has not been added to an initialized rack yet", "type": "object", @@ -22509,6 +22917,18 @@ } ] }, + "IdSortMode": { + "description": "Supported set of sort modes for scanning by id only.\n\nCurrently, we only support scanning in ascending order.", + "oneOf": [ + { + "description": "sort in increasing order of \"id\"", + "type": "string", + "enum": [ + "id_ascending" + ] + } + ] + }, "DiskMetricName": { "type": "string", "enum": [ @@ -22528,18 +22948,6 @@ "descending" ] }, - "IdSortMode": { - "description": "Supported set of sort modes for scanning by id only.\n\nCurrently, we only support scanning in ascending order.", - "oneOf": [ - { - "description": "sort in increasing order of \"id\"", - "type": "string", - "enum": [ - "id_ascending" - ] - } - ] - }, "SystemMetricName": { "type": "string", "enum": [ diff --git a/sdk-httpmock/src/generated_httpmock.rs b/sdk-httpmock/src/generated_httpmock.rs index 73c304a2..57c46f4f 100644 --- a/sdk-httpmock/src/generated_httpmock.rs +++ b/sdk-httpmock/src/generated_httpmock.rs @@ -445,6 +445,523 @@ pub mod operations { } } + pub struct SupportBundleListWhen(::httpmock::When); + impl SupportBundleListWhen { + pub fn new(inner: ::httpmock::When) -> Self { + Self(inner.method(::httpmock::Method::GET).path_matches( + regex::Regex::new("^/experimental/v1/system/support-bundles$").unwrap(), + )) + } + + pub fn into_inner(self) -> ::httpmock::When { + self.0 + } + + pub fn limit(self, value: T) -> Self + where + T: Into>, + { + if let Some(value) = value.into() { + Self(self.0.query_param("limit", value.to_string())) + } else { + Self(self.0.matches(|req| { + req.query_params + .as_ref() + .and_then(|qs| qs.iter().find(|(key, _)| key == "limit")) + .is_none() + })) + } + } + + pub fn page_token<'a, T>(self, value: T) -> Self + where + T: Into>, + { + if let Some(value) = value.into() { + Self(self.0.query_param("page_token", value.to_string())) + } else { + Self(self.0.matches(|req| { + req.query_params + .as_ref() + .and_then(|qs| qs.iter().find(|(key, _)| key == "page_token")) + .is_none() + })) + } + } + + pub fn sort_by(self, value: T) -> Self + where + T: Into>, + { + if let Some(value) = value.into() { + Self(self.0.query_param("sort_by", value.to_string())) + } else { + Self(self.0.matches(|req| { + req.query_params + .as_ref() + .and_then(|qs| qs.iter().find(|(key, _)| key == "sort_by")) + .is_none() + })) + } + } + } + + pub struct SupportBundleListThen(::httpmock::Then); + impl SupportBundleListThen { + pub fn new(inner: ::httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> ::httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::SupportBundleInfoResultsPage) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct SupportBundleCreateWhen(::httpmock::When); + impl SupportBundleCreateWhen { + pub fn new(inner: ::httpmock::When) -> Self { + Self(inner.method(::httpmock::Method::POST).path_matches( + regex::Regex::new("^/experimental/v1/system/support-bundles$").unwrap(), + )) + } + + pub fn into_inner(self) -> ::httpmock::When { + self.0 + } + } + + pub struct SupportBundleCreateThen(::httpmock::Then); + impl SupportBundleCreateThen { + pub fn new(inner: ::httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> ::httpmock::Then { + self.0 + } + + pub fn created(self, value: &types::SupportBundleInfo) -> Self { + Self( + self.0 + .status(201u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct SupportBundleViewWhen(::httpmock::When); + impl SupportBundleViewWhen { + pub fn new(inner: ::httpmock::When) -> Self { + Self(inner.method(::httpmock::Method::GET).path_matches( + regex::Regex::new("^/experimental/v1/system/support-bundles/[^/]*$").unwrap(), + )) + } + + pub fn into_inner(self) -> ::httpmock::When { + self.0 + } + + pub fn support_bundle(self, value: &uuid::Uuid) -> Self { + let re = regex::Regex::new(&format!( + "^/experimental/v1/system/support-bundles/{}$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct SupportBundleViewThen(::httpmock::Then); + impl SupportBundleViewThen { + pub fn new(inner: ::httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> ::httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::SupportBundleInfo) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct SupportBundleDeleteWhen(::httpmock::When); + impl SupportBundleDeleteWhen { + pub fn new(inner: ::httpmock::When) -> Self { + Self(inner.method(::httpmock::Method::DELETE).path_matches( + regex::Regex::new("^/experimental/v1/system/support-bundles/[^/]*$").unwrap(), + )) + } + + pub fn into_inner(self) -> ::httpmock::When { + self.0 + } + + pub fn support_bundle(self, value: &uuid::Uuid) -> Self { + let re = regex::Regex::new(&format!( + "^/experimental/v1/system/support-bundles/{}$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct SupportBundleDeleteThen(::httpmock::Then); + impl SupportBundleDeleteThen { + pub fn new(inner: ::httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> ::httpmock::Then { + self.0 + } + + pub fn no_content(self) -> Self { + Self(self.0.status(204u16)) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct SupportBundleDownloadWhen(::httpmock::When); + impl SupportBundleDownloadWhen { + pub fn new(inner: ::httpmock::When) -> Self { + Self( + inner.method(::httpmock::Method::GET).path_matches( + regex::Regex::new("^/experimental/v1/system/support-bundles/[^/]*/download$") + .unwrap(), + ), + ) + } + + pub fn into_inner(self) -> ::httpmock::When { + self.0 + } + + pub fn support_bundle(self, value: &uuid::Uuid) -> Self { + let re = regex::Regex::new(&format!( + "^/experimental/v1/system/support-bundles/{}/download$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct SupportBundleDownloadThen(::httpmock::Then); + impl SupportBundleDownloadThen { + pub fn new(inner: ::httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> ::httpmock::Then { + self.0 + } + + pub fn default_response(self, status: u16, value: serde_json::Value) -> Self { + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body(value), + ) + } + } + + pub struct SupportBundleHeadWhen(::httpmock::When); + impl SupportBundleHeadWhen { + pub fn new(inner: ::httpmock::When) -> Self { + Self( + inner.method(::httpmock::Method::HEAD).path_matches( + regex::Regex::new("^/experimental/v1/system/support-bundles/[^/]*/download$") + .unwrap(), + ), + ) + } + + pub fn into_inner(self) -> ::httpmock::When { + self.0 + } + + pub fn support_bundle(self, value: &uuid::Uuid) -> Self { + let re = regex::Regex::new(&format!( + "^/experimental/v1/system/support-bundles/{}/download$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct SupportBundleHeadThen(::httpmock::Then); + impl SupportBundleHeadThen { + pub fn new(inner: ::httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> ::httpmock::Then { + self.0 + } + + pub fn default_response(self, status: u16, value: serde_json::Value) -> Self { + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body(value), + ) + } + } + + pub struct SupportBundleDownloadFileWhen(::httpmock::When); + impl SupportBundleDownloadFileWhen { + pub fn new(inner: ::httpmock::When) -> Self { + Self( + inner.method(::httpmock::Method::GET).path_matches( + regex::Regex::new( + "^/experimental/v1/system/support-bundles/[^/]*/download/[^/]*$", + ) + .unwrap(), + ), + ) + } + + pub fn into_inner(self) -> ::httpmock::When { + self.0 + } + + pub fn support_bundle(self, value: &uuid::Uuid) -> Self { + let re = regex::Regex::new(&format!( + "^/experimental/v1/system/support-bundles/{}/download/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn file(self, value: &str) -> Self { + let re = regex::Regex::new(&format!( + "^/experimental/v1/system/support-bundles/.*/download/{}$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct SupportBundleDownloadFileThen(::httpmock::Then); + impl SupportBundleDownloadFileThen { + pub fn new(inner: ::httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> ::httpmock::Then { + self.0 + } + + pub fn default_response(self, status: u16, value: serde_json::Value) -> Self { + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body(value), + ) + } + } + + pub struct SupportBundleHeadFileWhen(::httpmock::When); + impl SupportBundleHeadFileWhen { + pub fn new(inner: ::httpmock::When) -> Self { + Self( + inner.method(::httpmock::Method::HEAD).path_matches( + regex::Regex::new( + "^/experimental/v1/system/support-bundles/[^/]*/download/[^/]*$", + ) + .unwrap(), + ), + ) + } + + pub fn into_inner(self) -> ::httpmock::When { + self.0 + } + + pub fn support_bundle(self, value: &uuid::Uuid) -> Self { + let re = regex::Regex::new(&format!( + "^/experimental/v1/system/support-bundles/{}/download/.*$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + + pub fn file(self, value: &str) -> Self { + let re = regex::Regex::new(&format!( + "^/experimental/v1/system/support-bundles/.*/download/{}$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct SupportBundleHeadFileThen(::httpmock::Then); + impl SupportBundleHeadFileThen { + pub fn new(inner: ::httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> ::httpmock::Then { + self.0 + } + + pub fn default_response(self, status: u16, value: serde_json::Value) -> Self { + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body(value), + ) + } + } + + pub struct SupportBundleIndexWhen(::httpmock::When); + impl SupportBundleIndexWhen { + pub fn new(inner: ::httpmock::When) -> Self { + Self(inner.method(::httpmock::Method::GET).path_matches( + regex::Regex::new("^/experimental/v1/system/support-bundles/[^/]*/index$").unwrap(), + )) + } + + pub fn into_inner(self) -> ::httpmock::When { + self.0 + } + + pub fn support_bundle(self, value: &uuid::Uuid) -> Self { + let re = regex::Regex::new(&format!( + "^/experimental/v1/system/support-bundles/{}/index$", + value.to_string() + )) + .unwrap(); + Self(self.0.path_matches(re)) + } + } + + pub struct SupportBundleIndexThen(::httpmock::Then); + impl SupportBundleIndexThen { + pub fn new(inner: ::httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> ::httpmock::Then { + self.0 + } + + pub fn default_response(self, status: u16, value: serde_json::Value) -> Self { + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body(value), + ) + } + } + pub struct LoginSamlWhen(::httpmock::When); impl LoginSamlWhen { pub fn new(inner: ::httpmock::When) -> Self { @@ -17053,6 +17570,36 @@ pub trait MockServerExt { fn probe_delete(&self, config_fn: F) -> ::httpmock::Mock where F: FnOnce(operations::ProbeDeleteWhen, operations::ProbeDeleteThen); + fn support_bundle_list(&self, config_fn: F) -> ::httpmock::Mock + where + F: FnOnce(operations::SupportBundleListWhen, operations::SupportBundleListThen); + fn support_bundle_create(&self, config_fn: F) -> ::httpmock::Mock + where + F: FnOnce(operations::SupportBundleCreateWhen, operations::SupportBundleCreateThen); + fn support_bundle_view(&self, config_fn: F) -> ::httpmock::Mock + where + F: FnOnce(operations::SupportBundleViewWhen, operations::SupportBundleViewThen); + fn support_bundle_delete(&self, config_fn: F) -> ::httpmock::Mock + where + F: FnOnce(operations::SupportBundleDeleteWhen, operations::SupportBundleDeleteThen); + fn support_bundle_download(&self, config_fn: F) -> ::httpmock::Mock + where + F: FnOnce(operations::SupportBundleDownloadWhen, operations::SupportBundleDownloadThen); + fn support_bundle_head(&self, config_fn: F) -> ::httpmock::Mock + where + F: FnOnce(operations::SupportBundleHeadWhen, operations::SupportBundleHeadThen); + fn support_bundle_download_file(&self, config_fn: F) -> ::httpmock::Mock + where + F: FnOnce( + operations::SupportBundleDownloadFileWhen, + operations::SupportBundleDownloadFileThen, + ); + fn support_bundle_head_file(&self, config_fn: F) -> ::httpmock::Mock + where + F: FnOnce(operations::SupportBundleHeadFileWhen, operations::SupportBundleHeadFileThen); + fn support_bundle_index(&self, config_fn: F) -> ::httpmock::Mock + where + F: FnOnce(operations::SupportBundleIndexWhen, operations::SupportBundleIndexThen); fn login_saml(&self, config_fn: F) -> ::httpmock::Mock where F: FnOnce(operations::LoginSamlWhen, operations::LoginSamlThen); @@ -17884,6 +18431,117 @@ impl MockServerExt for ::httpmock::MockServer { }) } + fn support_bundle_list(&self, config_fn: F) -> ::httpmock::Mock + where + F: FnOnce(operations::SupportBundleListWhen, operations::SupportBundleListThen), + { + self.mock(|when, then| { + config_fn( + operations::SupportBundleListWhen::new(when), + operations::SupportBundleListThen::new(then), + ) + }) + } + + fn support_bundle_create(&self, config_fn: F) -> ::httpmock::Mock + where + F: FnOnce(operations::SupportBundleCreateWhen, operations::SupportBundleCreateThen), + { + self.mock(|when, then| { + config_fn( + operations::SupportBundleCreateWhen::new(when), + operations::SupportBundleCreateThen::new(then), + ) + }) + } + + fn support_bundle_view(&self, config_fn: F) -> ::httpmock::Mock + where + F: FnOnce(operations::SupportBundleViewWhen, operations::SupportBundleViewThen), + { + self.mock(|when, then| { + config_fn( + operations::SupportBundleViewWhen::new(when), + operations::SupportBundleViewThen::new(then), + ) + }) + } + + fn support_bundle_delete(&self, config_fn: F) -> ::httpmock::Mock + where + F: FnOnce(operations::SupportBundleDeleteWhen, operations::SupportBundleDeleteThen), + { + self.mock(|when, then| { + config_fn( + operations::SupportBundleDeleteWhen::new(when), + operations::SupportBundleDeleteThen::new(then), + ) + }) + } + + fn support_bundle_download(&self, config_fn: F) -> ::httpmock::Mock + where + F: FnOnce(operations::SupportBundleDownloadWhen, operations::SupportBundleDownloadThen), + { + self.mock(|when, then| { + config_fn( + operations::SupportBundleDownloadWhen::new(when), + operations::SupportBundleDownloadThen::new(then), + ) + }) + } + + fn support_bundle_head(&self, config_fn: F) -> ::httpmock::Mock + where + F: FnOnce(operations::SupportBundleHeadWhen, operations::SupportBundleHeadThen), + { + self.mock(|when, then| { + config_fn( + operations::SupportBundleHeadWhen::new(when), + operations::SupportBundleHeadThen::new(then), + ) + }) + } + + fn support_bundle_download_file(&self, config_fn: F) -> ::httpmock::Mock + where + F: FnOnce( + operations::SupportBundleDownloadFileWhen, + operations::SupportBundleDownloadFileThen, + ), + { + self.mock(|when, then| { + config_fn( + operations::SupportBundleDownloadFileWhen::new(when), + operations::SupportBundleDownloadFileThen::new(then), + ) + }) + } + + fn support_bundle_head_file(&self, config_fn: F) -> ::httpmock::Mock + where + F: FnOnce(operations::SupportBundleHeadFileWhen, operations::SupportBundleHeadFileThen), + { + self.mock(|when, then| { + config_fn( + operations::SupportBundleHeadFileWhen::new(when), + operations::SupportBundleHeadFileThen::new(then), + ) + }) + } + + fn support_bundle_index(&self, config_fn: F) -> ::httpmock::Mock + where + F: FnOnce(operations::SupportBundleIndexWhen, operations::SupportBundleIndexThen), + { + self.mock(|when, then| { + config_fn( + operations::SupportBundleIndexWhen::new(when), + operations::SupportBundleIndexThen::new(then), + ) + }) + } + fn login_saml(&self, config_fn: F) -> ::httpmock::Mock where F: FnOnce(operations::LoginSamlWhen, operations::LoginSamlThen), diff --git a/sdk/src/generated_sdk.rs b/sdk/src/generated_sdk.rs index 2363be38..1b27acac 100644 --- a/sdk/src/generated_sdk.rs +++ b/sdk/src/generated_sdk.rs @@ -22822,6 +22822,265 @@ pub mod types { } } + /// SupportBundleInfo + /// + ///
JSON schema + /// + /// ```json + /// { + /// "type": "object", + /// "required": [ + /// "id", + /// "reason_for_creation", + /// "state", + /// "time_created" + /// ], + /// "properties": { + /// "id": { + /// "$ref": "#/components/schemas/TypedUuidForSupportBundleKind" + /// }, + /// "reason_for_creation": { + /// "type": "string" + /// }, + /// "reason_for_failure": { + /// "type": [ + /// "string", + /// "null" + /// ] + /// }, + /// "state": { + /// "$ref": "#/components/schemas/SupportBundleState" + /// }, + /// "time_created": { + /// "type": "string", + /// "format": "date-time" + /// } + /// } + /// } + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct SupportBundleInfo { + pub id: TypedUuidForSupportBundleKind, + pub reason_for_creation: ::std::string::String, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub reason_for_failure: ::std::option::Option<::std::string::String>, + pub state: SupportBundleState, + pub time_created: chrono::DateTime, + } + + impl ::std::convert::From<&SupportBundleInfo> for SupportBundleInfo { + fn from(value: &SupportBundleInfo) -> Self { + value.clone() + } + } + + impl SupportBundleInfo { + pub fn builder() -> builder::SupportBundleInfo { + Default::default() + } + } + + /// A single page of results + /// + ///
JSON schema + /// + /// ```json + /// { + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/SupportBundleInfo" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + /// } + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct SupportBundleInfoResultsPage { + /// list of items on this page of results + pub items: ::std::vec::Vec, + /// token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&SupportBundleInfoResultsPage> for SupportBundleInfoResultsPage { + fn from(value: &SupportBundleInfoResultsPage) -> Self { + value.clone() + } + } + + impl SupportBundleInfoResultsPage { + pub fn builder() -> builder::SupportBundleInfoResultsPage { + Default::default() + } + } + + /// SupportBundleState + /// + ///
JSON schema + /// + /// ```json + /// { + /// "oneOf": [ + /// { + /// "description": "Support Bundle still actively being + /// collected.\n\nThis is the initial state for a Support Bundle, and it + /// will automatically transition to either \"Failing\" or \"Active\".\n\nIf + /// a user no longer wants to access a Support Bundle, they can request + /// cancellation, which will transition to the \"Destroying\" state.", + /// "type": "string", + /// "enum": [ + /// "collecting" + /// ] + /// }, + /// { + /// "description": "Support Bundle is being destroyed.\n\nOnce backing + /// storage has been freed, this bundle is destroyed.", + /// "type": "string", + /// "enum": [ + /// "destroying" + /// ] + /// }, + /// { + /// "description": "Support Bundle was not created successfully, or was + /// created and has lost backing storage.\n\nThe record of the bundle still + /// exists for readability, but the only valid operation on these bundles is + /// to destroy them.", + /// "type": "string", + /// "enum": [ + /// "failed" + /// ] + /// }, + /// { + /// "description": "Support Bundle has been processed, and is ready for + /// usage.", + /// "type": "string", + /// "enum": [ + /// "active" + /// ] + /// } + /// ] + /// } + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + schemars :: JsonSchema, + )] + pub enum SupportBundleState { + /// Support Bundle still actively being collected. + /// + /// This is the initial state for a Support Bundle, and it will + /// automatically transition to either "Failing" or "Active". + /// + /// If a user no longer wants to access a Support Bundle, they can + /// request cancellation, which will transition to the "Destroying" + /// state. + #[serde(rename = "collecting")] + Collecting, + /// Support Bundle is being destroyed. + /// + /// Once backing storage has been freed, this bundle is destroyed. + #[serde(rename = "destroying")] + Destroying, + /// Support Bundle was not created successfully, or was created and has + /// lost backing storage. + /// + /// The record of the bundle still exists for readability, but the only + /// valid operation on these bundles is to destroy them. + #[serde(rename = "failed")] + Failed, + /// Support Bundle has been processed, and is ready for usage. + #[serde(rename = "active")] + Active, + } + + impl ::std::convert::From<&Self> for SupportBundleState { + fn from(value: &SupportBundleState) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for SupportBundleState { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Collecting => write!(f, "collecting"), + Self::Destroying => write!(f, "destroying"), + Self::Failed => write!(f, "failed"), + Self::Active => write!(f, "active"), + } + } + } + + impl ::std::str::FromStr for SupportBundleState { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "collecting" => Ok(Self::Collecting), + "destroying" => Ok(Self::Destroying), + "failed" => Ok(Self::Failed), + "active" => Ok(Self::Active), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for SupportBundleState { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for SupportBundleState { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for SupportBundleState { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + /// An operator's view of a Switch. /// ///
JSON schema @@ -25448,6 +25707,81 @@ pub mod types { } } + /// TypedUuidForSupportBundleKind + /// + ///
JSON schema + /// + /// ```json + /// { + /// "type": "string", + /// "format": "uuid" + /// } + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + #[serde(transparent)] + pub struct TypedUuidForSupportBundleKind(pub uuid::Uuid); + impl ::std::ops::Deref for TypedUuidForSupportBundleKind { + type Target = uuid::Uuid; + fn deref(&self) -> &uuid::Uuid { + &self.0 + } + } + + impl ::std::convert::From for uuid::Uuid { + fn from(value: TypedUuidForSupportBundleKind) -> Self { + value.0 + } + } + + impl ::std::convert::From<&TypedUuidForSupportBundleKind> for TypedUuidForSupportBundleKind { + fn from(value: &TypedUuidForSupportBundleKind) -> Self { + value.clone() + } + } + + impl ::std::convert::From for TypedUuidForSupportBundleKind { + fn from(value: uuid::Uuid) -> Self { + Self(value) + } + } + + impl ::std::str::FromStr for TypedUuidForSupportBundleKind { + type Err = ::Err; + fn from_str(value: &str) -> ::std::result::Result { + Ok(Self(value.parse()?)) + } + } + + impl ::std::convert::TryFrom<&str> for TypedUuidForSupportBundleKind { + type Error = ::Err; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&String> for TypedUuidForSupportBundleKind { + type Error = ::Err; + fn try_from(value: &String) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom for TypedUuidForSupportBundleKind { + type Error = ::Err; + fn try_from(value: String) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::fmt::Display for TypedUuidForSupportBundleKind { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + self.0.fmt(f) + } + } + /// A sled that has not been added to an initialized rack yet /// ///
JSON schema @@ -45799,6 +46133,185 @@ pub mod types { } } + #[derive(Clone, Debug)] + pub struct SupportBundleInfo { + id: ::std::result::Result, + reason_for_creation: + ::std::result::Result<::std::string::String, ::std::string::String>, + reason_for_failure: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + state: ::std::result::Result, + time_created: + ::std::result::Result, ::std::string::String>, + } + + impl ::std::default::Default for SupportBundleInfo { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + reason_for_creation: Err( + "no value supplied for reason_for_creation".to_string() + ), + reason_for_failure: Ok(Default::default()), + state: Err("no value supplied for state".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + } + } + } + + impl SupportBundleInfo { + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn reason_for_creation(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.reason_for_creation = value.try_into().map_err(|e| { + format!( + "error converting supplied value for reason_for_creation: {}", + e + ) + }); + self + } + pub fn reason_for_failure(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.reason_for_failure = value.try_into().map_err(|e| { + format!( + "error converting supplied value for reason_for_failure: {}", + e + ) + }); + self + } + pub fn state(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.state = value + .try_into() + .map_err(|e| format!("error converting supplied value for state: {}", e)); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: ::std::convert::TryInto>, + T::Error: ::std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + } + + impl ::std::convert::TryFrom for super::SupportBundleInfo { + type Error = super::error::ConversionError; + fn try_from( + value: SupportBundleInfo, + ) -> ::std::result::Result { + Ok(Self { + id: value.id?, + reason_for_creation: value.reason_for_creation?, + reason_for_failure: value.reason_for_failure?, + state: value.state?, + time_created: value.time_created?, + }) + } + } + + impl ::std::convert::From for SupportBundleInfo { + fn from(value: super::SupportBundleInfo) -> Self { + Self { + id: Ok(value.id), + reason_for_creation: Ok(value.reason_for_creation), + reason_for_failure: Ok(value.reason_for_failure), + state: Ok(value.state), + time_created: Ok(value.time_created), + } + } + } + + #[derive(Clone, Debug)] + pub struct SupportBundleInfoResultsPage { + items: ::std::result::Result< + ::std::vec::Vec, + ::std::string::String, + >, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for SupportBundleInfoResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl SupportBundleInfoResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::SupportBundleInfoResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: SupportBundleInfoResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for SupportBundleInfoResultsPage { + fn from(value: super::SupportBundleInfoResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + #[derive(Clone, Debug)] pub struct Switch { baseboard: ::std::result::Result, @@ -51126,6 +51639,141 @@ pub trait ClientHiddenExt { /// .await; /// ``` fn probe_delete(&self) -> builder::ProbeDelete; + /// List all support bundles + /// + /// Sends a `GET` request to `/experimental/v1/system/support-bundles` + /// + /// Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + /// ```ignore + /// let response = client.support_bundle_list() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn support_bundle_list(&self) -> builder::SupportBundleList; + /// Create a new support bundle + /// + /// Sends a `POST` request to `/experimental/v1/system/support-bundles` + /// + /// ```ignore + /// let response = client.support_bundle_create() + /// .send() + /// .await; + /// ``` + fn support_bundle_create(&self) -> builder::SupportBundleCreate; + /// View a support bundle + /// + /// Sends a `GET` request to + /// `/experimental/v1/system/support-bundles/{support_bundle}` + /// + /// Arguments: + /// - `support_bundle`: ID of the support bundle + /// ```ignore + /// let response = client.support_bundle_view() + /// .support_bundle(support_bundle) + /// .send() + /// .await; + /// ``` + fn support_bundle_view(&self) -> builder::SupportBundleView; + /// Delete an existing support bundle + /// + /// May also be used to cancel a support bundle which is currently being + /// collected, or to remove metadata for a support bundle that has failed. + /// + /// Sends a `DELETE` request to + /// `/experimental/v1/system/support-bundles/{support_bundle}` + /// + /// Arguments: + /// - `support_bundle`: ID of the support bundle + /// ```ignore + /// let response = client.support_bundle_delete() + /// .support_bundle(support_bundle) + /// .send() + /// .await; + /// ``` + fn support_bundle_delete(&self) -> builder::SupportBundleDelete; + /// Download the contents of a support bundle + /// + /// Sends a `GET` request to + /// `/experimental/v1/system/support-bundles/{support_bundle}/download` + /// + /// Arguments: + /// - `support_bundle`: ID of the support bundle + /// ```ignore + /// let response = client.support_bundle_download() + /// .support_bundle(support_bundle) + /// .send() + /// .await; + /// ``` + fn support_bundle_download(&self) -> builder::SupportBundleDownload; + /// Download the metadata of a support bundle + /// + /// Sends a `HEAD` request to + /// `/experimental/v1/system/support-bundles/{support_bundle}/download` + /// + /// Arguments: + /// - `support_bundle`: ID of the support bundle + /// ```ignore + /// let response = client.support_bundle_head() + /// .support_bundle(support_bundle) + /// .send() + /// .await; + /// ``` + fn support_bundle_head(&self) -> builder::SupportBundleHead; + /// Download a file within a support bundle + /// + /// Sends a `GET` request to + /// `/experimental/v1/system/support-bundles/{support_bundle}/download/ + /// {file}` + /// + /// Arguments: + /// - `support_bundle`: ID of the support bundle + /// - `file`: The file within the bundle to download + /// ```ignore + /// let response = client.support_bundle_download_file() + /// .support_bundle(support_bundle) + /// .file(file) + /// .send() + /// .await; + /// ``` + fn support_bundle_download_file(&self) -> builder::SupportBundleDownloadFile; + /// Download the metadata of a file within the support bundle + /// + /// Sends a `HEAD` request to + /// `/experimental/v1/system/support-bundles/{support_bundle}/download/ + /// {file}` + /// + /// Arguments: + /// - `support_bundle`: ID of the support bundle + /// - `file`: The file within the bundle to download + /// ```ignore + /// let response = client.support_bundle_head_file() + /// .support_bundle(support_bundle) + /// .file(file) + /// .send() + /// .await; + /// ``` + fn support_bundle_head_file(&self) -> builder::SupportBundleHeadFile; + /// Download the index of a support bundle + /// + /// Sends a `GET` request to + /// `/experimental/v1/system/support-bundles/{support_bundle}/index` + /// + /// Arguments: + /// - `support_bundle`: ID of the support bundle + /// ```ignore + /// let response = client.support_bundle_index() + /// .support_bundle(support_bundle) + /// .send() + /// .await; + /// ``` + fn support_bundle_index(&self) -> builder::SupportBundleIndex; /// Log user out of web console by deleting session on client and server /// /// Sends a `POST` request to `/v1/logout` @@ -51186,6 +51834,42 @@ impl ClientHiddenExt for Client { builder::ProbeDelete::new(self) } + fn support_bundle_list(&self) -> builder::SupportBundleList { + builder::SupportBundleList::new(self) + } + + fn support_bundle_create(&self) -> builder::SupportBundleCreate { + builder::SupportBundleCreate::new(self) + } + + fn support_bundle_view(&self) -> builder::SupportBundleView { + builder::SupportBundleView::new(self) + } + + fn support_bundle_delete(&self) -> builder::SupportBundleDelete { + builder::SupportBundleDelete::new(self) + } + + fn support_bundle_download(&self) -> builder::SupportBundleDownload { + builder::SupportBundleDownload::new(self) + } + + fn support_bundle_head(&self) -> builder::SupportBundleHead { + builder::SupportBundleHead::new(self) + } + + fn support_bundle_download_file(&self) -> builder::SupportBundleDownloadFile { + builder::SupportBundleDownloadFile::new(self) + } + + fn support_bundle_head_file(&self) -> builder::SupportBundleHeadFile { + builder::SupportBundleHeadFile::new(self) + } + + fn support_bundle_index(&self) -> builder::SupportBundleIndex { + builder::SupportBundleIndex::new(self) + } + fn logout(&self) -> builder::Logout { builder::Logout::new(self) } @@ -55749,6 +56433,610 @@ pub mod builder { } } + /// Builder for [`ClientHiddenExt::support_bundle_list`] + /// + /// [`ClientHiddenExt::support_bundle_list`]: super::ClientHiddenExt::support_bundle_list + #[derive(Debug, Clone)] + pub struct SupportBundleList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> SupportBundleList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `IdSortMode` for sort_by failed".to_string()); + self + } + + /// Sends a `GET` request to `/experimental/v1/system/support-bundles` + pub async fn send( + self, + ) -> Result, Error> + { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/experimental/v1/system/support-bundles", client.baseurl,); + #[allow(unused_mut)] + let mut request = client + .client + .get(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .query(&progenitor_client::QueryParam::new("limit", &limit)) + .query(&progenitor_client::QueryParam::new( + "page_token", + &page_token, + )) + .query(&progenitor_client::QueryParam::new("sort_by", &sort_by)) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + /// Streams `GET` requests to `/experimental/v1/system/support-bundles` + pub fn stream( + self, + ) -> impl futures::Stream>> + + Unpin + + 'a { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + /// Builder for [`ClientHiddenExt::support_bundle_create`] + /// + /// [`ClientHiddenExt::support_bundle_create`]: super::ClientHiddenExt::support_bundle_create + #[derive(Debug, Clone)] + pub struct SupportBundleCreate<'a> { + client: &'a super::Client, + } + + impl<'a> SupportBundleCreate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client: client } + } + + /// Sends a `POST` request to `/experimental/v1/system/support-bundles` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client } = self; + let url = format!("{}/experimental/v1/system/support-bundles", client.baseurl,); + #[allow(unused_mut)] + let mut request = client + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + /// Builder for [`ClientHiddenExt::support_bundle_view`] + /// + /// [`ClientHiddenExt::support_bundle_view`]: super::ClientHiddenExt::support_bundle_view + #[derive(Debug, Clone)] + pub struct SupportBundleView<'a> { + client: &'a super::Client, + support_bundle: Result, + } + + impl<'a> SupportBundleView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + support_bundle: Err("support_bundle was not initialized".to_string()), + } + } + + pub fn support_bundle(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.support_bundle = value + .try_into() + .map_err(|_| "conversion to `uuid :: Uuid` for support_bundle failed".to_string()); + self + } + + /// Sends a `GET` request to + /// `/experimental/v1/system/support-bundles/{support_bundle}` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + support_bundle, + } = self; + let support_bundle = support_bundle.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/experimental/v1/system/support-bundles/{}", + client.baseurl, + encode_path(&support_bundle.to_string()), + ); + #[allow(unused_mut)] + let mut request = client + .client + .get(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + /// Builder for [`ClientHiddenExt::support_bundle_delete`] + /// + /// [`ClientHiddenExt::support_bundle_delete`]: super::ClientHiddenExt::support_bundle_delete + #[derive(Debug, Clone)] + pub struct SupportBundleDelete<'a> { + client: &'a super::Client, + support_bundle: Result, + } + + impl<'a> SupportBundleDelete<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + support_bundle: Err("support_bundle was not initialized".to_string()), + } + } + + pub fn support_bundle(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.support_bundle = value + .try_into() + .map_err(|_| "conversion to `uuid :: Uuid` for support_bundle failed".to_string()); + self + } + + /// Sends a `DELETE` request to + /// `/experimental/v1/system/support-bundles/{support_bundle}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + support_bundle, + } = self; + let support_bundle = support_bundle.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/experimental/v1/system/support-bundles/{}", + client.baseurl, + encode_path(&support_bundle.to_string()), + ); + #[allow(unused_mut)] + let mut request = client + .client + .delete(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + /// Builder for [`ClientHiddenExt::support_bundle_download`] + /// + /// [`ClientHiddenExt::support_bundle_download`]: super::ClientHiddenExt::support_bundle_download + #[derive(Debug, Clone)] + pub struct SupportBundleDownload<'a> { + client: &'a super::Client, + support_bundle: Result, + } + + impl<'a> SupportBundleDownload<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + support_bundle: Err("support_bundle was not initialized".to_string()), + } + } + + pub fn support_bundle(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.support_bundle = value + .try_into() + .map_err(|_| "conversion to `uuid :: Uuid` for support_bundle failed".to_string()); + self + } + + /// Sends a `GET` request to + /// `/experimental/v1/system/support-bundles/{support_bundle}/download` + pub async fn send(self) -> Result, Error> { + let Self { + client, + support_bundle, + } = self; + let support_bundle = support_bundle.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/experimental/v1/system/support-bundles/{}/download", + client.baseurl, + encode_path(&support_bundle.to_string()), + ); + #[allow(unused_mut)] + let mut request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200..=299 => Ok(ResponseValue::stream(response)), + _ => Err(Error::ErrorResponse(ResponseValue::stream(response))), + } + } + } + + /// Builder for [`ClientHiddenExt::support_bundle_head`] + /// + /// [`ClientHiddenExt::support_bundle_head`]: super::ClientHiddenExt::support_bundle_head + #[derive(Debug, Clone)] + pub struct SupportBundleHead<'a> { + client: &'a super::Client, + support_bundle: Result, + } + + impl<'a> SupportBundleHead<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + support_bundle: Err("support_bundle was not initialized".to_string()), + } + } + + pub fn support_bundle(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.support_bundle = value + .try_into() + .map_err(|_| "conversion to `uuid :: Uuid` for support_bundle failed".to_string()); + self + } + + /// Sends a `HEAD` request to + /// `/experimental/v1/system/support-bundles/{support_bundle}/download` + pub async fn send(self) -> Result, Error> { + let Self { + client, + support_bundle, + } = self; + let support_bundle = support_bundle.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/experimental/v1/system/support-bundles/{}/download", + client.baseurl, + encode_path(&support_bundle.to_string()), + ); + #[allow(unused_mut)] + let mut request = client.client.head(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200..=299 => Ok(ResponseValue::stream(response)), + _ => Err(Error::ErrorResponse(ResponseValue::stream(response))), + } + } + } + + /// Builder for [`ClientHiddenExt::support_bundle_download_file`] + /// + /// [`ClientHiddenExt::support_bundle_download_file`]: super::ClientHiddenExt::support_bundle_download_file + #[derive(Debug, Clone)] + pub struct SupportBundleDownloadFile<'a> { + client: &'a super::Client, + support_bundle: Result, + file: Result<::std::string::String, String>, + } + + impl<'a> SupportBundleDownloadFile<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + support_bundle: Err("support_bundle was not initialized".to_string()), + file: Err("file was not initialized".to_string()), + } + } + + pub fn support_bundle(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.support_bundle = value + .try_into() + .map_err(|_| "conversion to `uuid :: Uuid` for support_bundle failed".to_string()); + self + } + + pub fn file(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.file = value.try_into().map_err(|_| { + "conversion to `:: std :: string :: String` for file failed".to_string() + }); + self + } + + /// Sends a `GET` request to + /// `/experimental/v1/system/support-bundles/{support_bundle}/download/ + /// {file}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + support_bundle, + file, + } = self; + let support_bundle = support_bundle.map_err(Error::InvalidRequest)?; + let file = file.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/experimental/v1/system/support-bundles/{}/download/{}", + client.baseurl, + encode_path(&support_bundle.to_string()), + encode_path(&file.to_string()), + ); + #[allow(unused_mut)] + let mut request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200..=299 => Ok(ResponseValue::stream(response)), + _ => Err(Error::ErrorResponse(ResponseValue::stream(response))), + } + } + } + + /// Builder for [`ClientHiddenExt::support_bundle_head_file`] + /// + /// [`ClientHiddenExt::support_bundle_head_file`]: super::ClientHiddenExt::support_bundle_head_file + #[derive(Debug, Clone)] + pub struct SupportBundleHeadFile<'a> { + client: &'a super::Client, + support_bundle: Result, + file: Result<::std::string::String, String>, + } + + impl<'a> SupportBundleHeadFile<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + support_bundle: Err("support_bundle was not initialized".to_string()), + file: Err("file was not initialized".to_string()), + } + } + + pub fn support_bundle(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.support_bundle = value + .try_into() + .map_err(|_| "conversion to `uuid :: Uuid` for support_bundle failed".to_string()); + self + } + + pub fn file(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.file = value.try_into().map_err(|_| { + "conversion to `:: std :: string :: String` for file failed".to_string() + }); + self + } + + /// Sends a `HEAD` request to + /// `/experimental/v1/system/support-bundles/{support_bundle}/download/ + /// {file}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + support_bundle, + file, + } = self; + let support_bundle = support_bundle.map_err(Error::InvalidRequest)?; + let file = file.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/experimental/v1/system/support-bundles/{}/download/{}", + client.baseurl, + encode_path(&support_bundle.to_string()), + encode_path(&file.to_string()), + ); + #[allow(unused_mut)] + let mut request = client.client.head(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200..=299 => Ok(ResponseValue::stream(response)), + _ => Err(Error::ErrorResponse(ResponseValue::stream(response))), + } + } + } + + /// Builder for [`ClientHiddenExt::support_bundle_index`] + /// + /// [`ClientHiddenExt::support_bundle_index`]: super::ClientHiddenExt::support_bundle_index + #[derive(Debug, Clone)] + pub struct SupportBundleIndex<'a> { + client: &'a super::Client, + support_bundle: Result, + } + + impl<'a> SupportBundleIndex<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + support_bundle: Err("support_bundle was not initialized".to_string()), + } + } + + pub fn support_bundle(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.support_bundle = value + .try_into() + .map_err(|_| "conversion to `uuid :: Uuid` for support_bundle failed".to_string()); + self + } + + /// Sends a `GET` request to + /// `/experimental/v1/system/support-bundles/{support_bundle}/index` + pub async fn send(self) -> Result, Error> { + let Self { + client, + support_bundle, + } = self; + let support_bundle = support_bundle.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/experimental/v1/system/support-bundles/{}/index", + client.baseurl, + encode_path(&support_bundle.to_string()), + ); + #[allow(unused_mut)] + let mut request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200..=299 => Ok(ResponseValue::stream(response)), + _ => Err(Error::ErrorResponse(ResponseValue::stream(response))), + } + } + } + /// Builder for [`ClientLoginExt::login_saml`] /// /// [`ClientLoginExt::login_saml`]: super::ClientLoginExt::login_saml