aws_sdk_securityir/operation/
list_cases.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2/// Orchestration and serialization glue logic for `ListCases`.
3#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
4#[non_exhaustive]
5pub struct ListCases;
6impl ListCases {
7    /// Creates a new `ListCases`
8    pub fn new() -> Self {
9        Self
10    }
11    pub(crate) async fn orchestrate(
12        runtime_plugins: &::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
13        input: crate::operation::list_cases::ListCasesInput,
14    ) -> ::std::result::Result<
15        crate::operation::list_cases::ListCasesOutput,
16        ::aws_smithy_runtime_api::client::result::SdkError<
17            crate::operation::list_cases::ListCasesError,
18            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
19        >,
20    > {
21        let map_err = |err: ::aws_smithy_runtime_api::client::result::SdkError<
22            ::aws_smithy_runtime_api::client::interceptors::context::Error,
23            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
24        >| {
25            err.map_service_error(|err| {
26                err.downcast::<crate::operation::list_cases::ListCasesError>()
27                    .expect("correct error type")
28            })
29        };
30        let context = Self::orchestrate_with_stop_point(runtime_plugins, input, ::aws_smithy_runtime::client::orchestrator::StopPoint::None)
31            .await
32            .map_err(map_err)?;
33        let output = context.finalize().map_err(map_err)?;
34        ::std::result::Result::Ok(
35            output
36                .downcast::<crate::operation::list_cases::ListCasesOutput>()
37                .expect("correct output type"),
38        )
39    }
40
41    pub(crate) async fn orchestrate_with_stop_point(
42        runtime_plugins: &::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
43        input: crate::operation::list_cases::ListCasesInput,
44        stop_point: ::aws_smithy_runtime::client::orchestrator::StopPoint,
45    ) -> ::std::result::Result<
46        ::aws_smithy_runtime_api::client::interceptors::context::InterceptorContext,
47        ::aws_smithy_runtime_api::client::result::SdkError<
48            ::aws_smithy_runtime_api::client::interceptors::context::Error,
49            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
50        >,
51    > {
52        let input = ::aws_smithy_runtime_api::client::interceptors::context::Input::erase(input);
53        ::aws_smithy_runtime::client::orchestrator::invoke_with_stop_point("securityir", "ListCases", input, runtime_plugins, stop_point).await
54    }
55
56    pub(crate) fn operation_runtime_plugins(
57        client_runtime_plugins: ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
58        client_config: &crate::config::Config,
59        config_override: ::std::option::Option<crate::config::Builder>,
60    ) -> ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins {
61        let mut runtime_plugins = client_runtime_plugins.with_operation_plugin(Self::new());
62        runtime_plugins = runtime_plugins.with_client_plugin(crate::auth_plugin::DefaultAuthOptionsPlugin::new(vec![
63            ::aws_runtime::auth::sigv4::SCHEME_ID,
64        ]));
65        if let ::std::option::Option::Some(config_override) = config_override {
66            for plugin in config_override.runtime_plugins.iter().cloned() {
67                runtime_plugins = runtime_plugins.with_operation_plugin(plugin);
68            }
69            runtime_plugins = runtime_plugins.with_operation_plugin(crate::config::ConfigOverrideRuntimePlugin::new(
70                config_override,
71                client_config.config.clone(),
72                &client_config.runtime_components,
73            ));
74        }
75        runtime_plugins
76    }
77}
78impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin for ListCases {
79    fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
80        let mut cfg = ::aws_smithy_types::config_bag::Layer::new("ListCases");
81
82        cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedRequestSerializer::new(
83            ListCasesRequestSerializer,
84        ));
85        cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer::new(
86            ListCasesResponseDeserializer,
87        ));
88
89        cfg.store_put(::aws_smithy_runtime_api::client::auth::AuthSchemeOptionResolverParams::new(
90            ::aws_smithy_runtime_api::client::auth::static_resolver::StaticAuthSchemeOptionResolverParams::new(),
91        ));
92
93        cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::SensitiveOutput);
94        cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::Metadata::new("ListCases", "securityir"));
95        let mut signing_options = ::aws_runtime::auth::SigningOptions::default();
96        signing_options.double_uri_encode = true;
97        signing_options.content_sha256_header = false;
98        signing_options.normalize_uri_path = true;
99        signing_options.payload_override = None;
100
101        cfg.store_put(::aws_runtime::auth::SigV4OperationSigningConfig {
102            signing_options,
103            ..::std::default::Default::default()
104        });
105
106        ::std::option::Option::Some(cfg.freeze())
107    }
108
109    fn runtime_components(
110        &self,
111        _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
112    ) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
113        #[allow(unused_mut)]
114        let mut rcb = ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder::new("ListCases")
115            .with_interceptor(::aws_smithy_runtime::client::stalled_stream_protection::StalledStreamProtectionInterceptor::default())
116            .with_interceptor(ListCasesEndpointParamsInterceptor)
117            .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::TransientErrorClassifier::<
118                crate::operation::list_cases::ListCasesError,
119            >::new())
120            .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::ModeledAsRetryableClassifier::<
121                crate::operation::list_cases::ListCasesError,
122            >::new())
123            .with_retry_classifier(::aws_runtime::retries::classifiers::AwsErrorCodeClassifier::<
124                crate::operation::list_cases::ListCasesError,
125            >::new());
126
127        ::std::borrow::Cow::Owned(rcb)
128    }
129}
130
131#[derive(Debug)]
132struct ListCasesResponseDeserializer;
133impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for ListCasesResponseDeserializer {
134    fn deserialize_nonstreaming(
135        &self,
136        response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
137    ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
138        let (success, status) = (response.status().is_success(), response.status().as_u16());
139        let headers = response.headers();
140        let body = response.body().bytes().expect("body loaded");
141        #[allow(unused_mut)]
142        let mut force_error = false;
143        ::tracing::debug!(request_id = ?::aws_types::request_id::RequestId::request_id(response));
144        let parse_result = if !success && status != 200 || force_error {
145            crate::protocol_serde::shape_list_cases::de_list_cases_http_error(status, headers, body)
146        } else {
147            crate::protocol_serde::shape_list_cases::de_list_cases_http_response(status, headers, body)
148        };
149        crate::protocol_serde::type_erase_result(parse_result)
150    }
151}
152#[derive(Debug)]
153struct ListCasesRequestSerializer;
154impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for ListCasesRequestSerializer {
155    #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
156    fn serialize_input(
157        &self,
158        input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
159        _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
160    ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
161        let input = input.downcast::<crate::operation::list_cases::ListCasesInput>().expect("correct type");
162        let _header_serialization_settings = _cfg
163            .load::<crate::serialization_settings::HeaderSerializationSettings>()
164            .cloned()
165            .unwrap_or_default();
166        let mut request_builder = {
167            fn uri_base(
168                _input: &crate::operation::list_cases::ListCasesInput,
169                output: &mut ::std::string::String,
170            ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
171                use ::std::fmt::Write as _;
172                ::std::write!(output, "/v1/list-cases").expect("formatting should succeed");
173                ::std::result::Result::Ok(())
174            }
175            #[allow(clippy::unnecessary_wraps)]
176            fn update_http_builder(
177                input: &crate::operation::list_cases::ListCasesInput,
178                builder: ::http::request::Builder,
179            ) -> ::std::result::Result<::http::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
180                let mut uri = ::std::string::String::new();
181                uri_base(input, &mut uri)?;
182                ::std::result::Result::Ok(builder.method("POST").uri(uri))
183            }
184            let mut builder = update_http_builder(&input, ::http::request::Builder::new())?;
185            builder = _header_serialization_settings.set_default_header(builder, ::http::header::CONTENT_TYPE, "application/json");
186            builder
187        };
188        let body = ::aws_smithy_types::body::SdkBody::from(crate::protocol_serde::shape_list_cases::ser_list_cases_input(&input)?);
189        if let Some(content_length) = body.content_length() {
190            let content_length = content_length.to_string();
191            request_builder = _header_serialization_settings.set_default_header(request_builder, ::http::header::CONTENT_LENGTH, &content_length);
192        }
193        ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
194    }
195}
196#[derive(Debug)]
197struct ListCasesEndpointParamsInterceptor;
198
199impl ::aws_smithy_runtime_api::client::interceptors::Intercept for ListCasesEndpointParamsInterceptor {
200    fn name(&self) -> &'static str {
201        "ListCasesEndpointParamsInterceptor"
202    }
203
204    fn read_before_execution(
205        &self,
206        context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
207            '_,
208            ::aws_smithy_runtime_api::client::interceptors::context::Input,
209            ::aws_smithy_runtime_api::client::interceptors::context::Output,
210            ::aws_smithy_runtime_api::client::interceptors::context::Error,
211        >,
212        cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
213    ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
214        let _input = context
215            .input()
216            .downcast_ref::<ListCasesInput>()
217            .ok_or("failed to downcast to ListCasesInput")?;
218
219        let params = crate::config::endpoint::Params::builder()
220            .set_use_fips(cfg.load::<::aws_types::endpoint_config::UseFips>().map(|ty| ty.0))
221            .set_endpoint(cfg.load::<::aws_types::endpoint_config::EndpointUrl>().map(|ty| ty.0.clone()))
222            .set_region(cfg.load::<::aws_types::region::Region>().map(|r| r.as_ref().to_owned()))
223            .build()
224            .map_err(|err| {
225                ::aws_smithy_runtime_api::client::interceptors::error::ContextAttachedError::new("endpoint params could not be built", err)
226            })?;
227        cfg.interceptor_state()
228            .store_put(::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams::new(params));
229        ::std::result::Result::Ok(())
230    }
231}
232
233// The get_* functions below are generated from JMESPath expressions in the
234// operationContextParams trait. They target the operation's input shape.
235
236/// Error type for the `ListCasesError` operation.
237#[non_exhaustive]
238#[derive(::std::fmt::Debug)]
239pub enum ListCasesError {
240    /// <p></p>
241    AccessDeniedException(crate::types::error::AccessDeniedException),
242    /// <p></p>
243    ConflictException(crate::types::error::ConflictException),
244    /// <p></p>
245    InternalServerException(crate::types::error::InternalServerException),
246    /// <p></p>
247    InvalidTokenException(crate::types::error::InvalidTokenException),
248    /// <p></p>
249    ResourceNotFoundException(crate::types::error::ResourceNotFoundException),
250    /// <p></p>
251    SecurityIncidentResponseNotActiveException(crate::types::error::SecurityIncidentResponseNotActiveException),
252    /// <p></p>
253    ServiceQuotaExceededException(crate::types::error::ServiceQuotaExceededException),
254    /// <p></p>
255    ThrottlingException(crate::types::error::ThrottlingException),
256    /// <p></p>
257    ValidationException(crate::types::error::ValidationException),
258    /// An unexpected error occurred (e.g., invalid JSON returned by the service or an unknown error code).
259    #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
260    variable wildcard pattern and check `.code()`:
261     \
262    &nbsp;&nbsp;&nbsp;`err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
263     \
264    See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-ListCasesError) for what information is available for the error.")]
265    Unhandled(crate::error::sealed_unhandled::Unhandled),
266}
267impl ListCasesError {
268    /// Creates the `ListCasesError::Unhandled` variant from any error type.
269    pub fn unhandled(
270        err: impl ::std::convert::Into<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>>,
271    ) -> Self {
272        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
273            source: err.into(),
274            meta: ::std::default::Default::default(),
275        })
276    }
277
278    /// Creates the `ListCasesError::Unhandled` variant from an [`ErrorMetadata`](::aws_smithy_types::error::ErrorMetadata).
279    pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self {
280        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
281            source: err.clone().into(),
282            meta: err,
283        })
284    }
285    ///
286    /// Returns error metadata, which includes the error code, message,
287    /// request ID, and potentially additional information.
288    ///
289    pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
290        match self {
291            Self::AccessDeniedException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
292            Self::ConflictException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
293            Self::InternalServerException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
294            Self::InvalidTokenException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
295            Self::ResourceNotFoundException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
296            Self::SecurityIncidentResponseNotActiveException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
297            Self::ServiceQuotaExceededException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
298            Self::ThrottlingException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
299            Self::ValidationException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
300            Self::Unhandled(e) => &e.meta,
301        }
302    }
303    /// Returns `true` if the error kind is `ListCasesError::AccessDeniedException`.
304    pub fn is_access_denied_exception(&self) -> bool {
305        matches!(self, Self::AccessDeniedException(_))
306    }
307    /// Returns `true` if the error kind is `ListCasesError::ConflictException`.
308    pub fn is_conflict_exception(&self) -> bool {
309        matches!(self, Self::ConflictException(_))
310    }
311    /// Returns `true` if the error kind is `ListCasesError::InternalServerException`.
312    pub fn is_internal_server_exception(&self) -> bool {
313        matches!(self, Self::InternalServerException(_))
314    }
315    /// Returns `true` if the error kind is `ListCasesError::InvalidTokenException`.
316    pub fn is_invalid_token_exception(&self) -> bool {
317        matches!(self, Self::InvalidTokenException(_))
318    }
319    /// Returns `true` if the error kind is `ListCasesError::ResourceNotFoundException`.
320    pub fn is_resource_not_found_exception(&self) -> bool {
321        matches!(self, Self::ResourceNotFoundException(_))
322    }
323    /// Returns `true` if the error kind is `ListCasesError::SecurityIncidentResponseNotActiveException`.
324    pub fn is_security_incident_response_not_active_exception(&self) -> bool {
325        matches!(self, Self::SecurityIncidentResponseNotActiveException(_))
326    }
327    /// Returns `true` if the error kind is `ListCasesError::ServiceQuotaExceededException`.
328    pub fn is_service_quota_exceeded_exception(&self) -> bool {
329        matches!(self, Self::ServiceQuotaExceededException(_))
330    }
331    /// Returns `true` if the error kind is `ListCasesError::ThrottlingException`.
332    pub fn is_throttling_exception(&self) -> bool {
333        matches!(self, Self::ThrottlingException(_))
334    }
335    /// Returns `true` if the error kind is `ListCasesError::ValidationException`.
336    pub fn is_validation_exception(&self) -> bool {
337        matches!(self, Self::ValidationException(_))
338    }
339}
340impl ::std::error::Error for ListCasesError {
341    fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
342        match self {
343            Self::AccessDeniedException(_inner) => ::std::option::Option::Some(_inner),
344            Self::ConflictException(_inner) => ::std::option::Option::Some(_inner),
345            Self::InternalServerException(_inner) => ::std::option::Option::Some(_inner),
346            Self::InvalidTokenException(_inner) => ::std::option::Option::Some(_inner),
347            Self::ResourceNotFoundException(_inner) => ::std::option::Option::Some(_inner),
348            Self::SecurityIncidentResponseNotActiveException(_inner) => ::std::option::Option::Some(_inner),
349            Self::ServiceQuotaExceededException(_inner) => ::std::option::Option::Some(_inner),
350            Self::ThrottlingException(_inner) => ::std::option::Option::Some(_inner),
351            Self::ValidationException(_inner) => ::std::option::Option::Some(_inner),
352            Self::Unhandled(_inner) => ::std::option::Option::Some(&*_inner.source),
353        }
354    }
355}
356impl ::std::fmt::Display for ListCasesError {
357    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
358        match self {
359            Self::AccessDeniedException(_inner) => _inner.fmt(f),
360            Self::ConflictException(_inner) => _inner.fmt(f),
361            Self::InternalServerException(_inner) => _inner.fmt(f),
362            Self::InvalidTokenException(_inner) => _inner.fmt(f),
363            Self::ResourceNotFoundException(_inner) => _inner.fmt(f),
364            Self::SecurityIncidentResponseNotActiveException(_inner) => _inner.fmt(f),
365            Self::ServiceQuotaExceededException(_inner) => _inner.fmt(f),
366            Self::ThrottlingException(_inner) => _inner.fmt(f),
367            Self::ValidationException(_inner) => _inner.fmt(f),
368            Self::Unhandled(_inner) => {
369                if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
370                    write!(f, "unhandled error ({code})")
371                } else {
372                    f.write_str("unhandled error")
373                }
374            }
375        }
376    }
377}
378impl ::aws_smithy_types::retry::ProvideErrorKind for ListCasesError {
379    fn code(&self) -> ::std::option::Option<&str> {
380        ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self)
381    }
382    fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> {
383        match self {
384            Self::InternalServerException(inner) => ::std::option::Option::Some(inner.retryable_error_kind()),
385            Self::InvalidTokenException(inner) => ::std::option::Option::Some(inner.retryable_error_kind()),
386            Self::ThrottlingException(inner) => ::std::option::Option::Some(inner.retryable_error_kind()),
387            _ => ::std::option::Option::None,
388        }
389    }
390}
391impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for ListCasesError {
392    fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
393        match self {
394            Self::AccessDeniedException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
395            Self::ConflictException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
396            Self::InternalServerException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
397            Self::InvalidTokenException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
398            Self::ResourceNotFoundException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
399            Self::SecurityIncidentResponseNotActiveException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
400            Self::ServiceQuotaExceededException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
401            Self::ThrottlingException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
402            Self::ValidationException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
403            Self::Unhandled(_inner) => &_inner.meta,
404        }
405    }
406}
407impl ::aws_smithy_runtime_api::client::result::CreateUnhandledError for ListCasesError {
408    fn create_unhandled_error(
409        source: ::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>,
410        meta: ::std::option::Option<::aws_smithy_types::error::ErrorMetadata>,
411    ) -> Self {
412        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
413            source,
414            meta: meta.unwrap_or_default(),
415        })
416    }
417}
418impl ::aws_types::request_id::RequestId for crate::operation::list_cases::ListCasesError {
419    fn request_id(&self) -> Option<&str> {
420        self.meta().request_id()
421    }
422}
423
424pub use crate::operation::list_cases::_list_cases_output::ListCasesOutput;
425
426pub use crate::operation::list_cases::_list_cases_input::ListCasesInput;
427
428mod _list_cases_input;
429
430mod _list_cases_output;
431
432/// Builders
433pub mod builders;
434
435/// Paginator for this operation
436pub mod paginator;