Skip to main content

aws_sdk_ec2/operation/
get_vpc_resources_blocking_encryption_enforcement.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2/// Orchestration and serialization glue logic for `GetVpcResourcesBlockingEncryptionEnforcement`.
3#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
4#[non_exhaustive]
5pub struct GetVpcResourcesBlockingEncryptionEnforcement;
6impl GetVpcResourcesBlockingEncryptionEnforcement {
7    /// Creates a new `GetVpcResourcesBlockingEncryptionEnforcement`
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::get_vpc_resources_blocking_encryption_enforcement::GetVpcResourcesBlockingEncryptionEnforcementInput,
14    ) -> ::std::result::Result<
15        crate::operation::get_vpc_resources_blocking_encryption_enforcement::GetVpcResourcesBlockingEncryptionEnforcementOutput,
16        ::aws_smithy_runtime_api::client::result::SdkError<
17            crate::operation::get_vpc_resources_blocking_encryption_enforcement::GetVpcResourcesBlockingEncryptionEnforcementError,
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::get_vpc_resources_blocking_encryption_enforcement::GetVpcResourcesBlockingEncryptionEnforcementError>().expect("correct error type")
27                            })
28        };
29        let context = Self::orchestrate_with_stop_point(runtime_plugins, input, ::aws_smithy_runtime::client::orchestrator::StopPoint::None)
30            .await
31            .map_err(map_err)?;
32        let output = context.finalize().map_err(map_err)?;
33        ::std::result::Result::Ok(
34            output
35                .downcast::<crate::operation::get_vpc_resources_blocking_encryption_enforcement::GetVpcResourcesBlockingEncryptionEnforcementOutput>()
36                .expect("correct output type"),
37        )
38    }
39
40    pub(crate) async fn orchestrate_with_stop_point(
41        runtime_plugins: &::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
42        input: crate::operation::get_vpc_resources_blocking_encryption_enforcement::GetVpcResourcesBlockingEncryptionEnforcementInput,
43        stop_point: ::aws_smithy_runtime::client::orchestrator::StopPoint,
44    ) -> ::std::result::Result<
45        ::aws_smithy_runtime_api::client::interceptors::context::InterceptorContext,
46        ::aws_smithy_runtime_api::client::result::SdkError<
47            ::aws_smithy_runtime_api::client::interceptors::context::Error,
48            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
49        >,
50    > {
51        let input = ::aws_smithy_runtime_api::client::interceptors::context::Input::erase(input);
52        use ::tracing::Instrument;
53        ::aws_smithy_runtime::client::orchestrator::invoke_with_stop_point(
54            "EC2",
55            "GetVpcResourcesBlockingEncryptionEnforcement",
56            input,
57            runtime_plugins,
58            stop_point,
59        )
60        // Create a parent span for the entire operation. Includes a random, internal-only,
61        // seven-digit ID for the operation orchestration so that it can be correlated in the logs.
62        .instrument(::tracing::debug_span!(
63            "EC2.GetVpcResourcesBlockingEncryptionEnforcement",
64            "rpc.service" = "EC2",
65            "rpc.method" = "GetVpcResourcesBlockingEncryptionEnforcement",
66            "sdk_invocation_id" = ::fastrand::u32(1_000_000..10_000_000),
67            "rpc.system" = "aws-api",
68        ))
69        .await
70    }
71
72    pub(crate) fn operation_runtime_plugins(
73        client_runtime_plugins: ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
74        client_config: &crate::config::Config,
75        config_override: ::std::option::Option<crate::config::Builder>,
76    ) -> ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins {
77        let mut runtime_plugins = client_runtime_plugins.with_operation_plugin(Self::new());
78
79        if let ::std::option::Option::Some(config_override) = config_override {
80            for plugin in config_override.runtime_plugins.iter().cloned() {
81                runtime_plugins = runtime_plugins.with_operation_plugin(plugin);
82            }
83            runtime_plugins = runtime_plugins.with_operation_plugin(crate::config::ConfigOverrideRuntimePlugin::new(
84                config_override,
85                client_config.config.clone(),
86                &client_config.runtime_components,
87            ));
88        }
89        runtime_plugins
90    }
91}
92impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin for GetVpcResourcesBlockingEncryptionEnforcement {
93    fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
94        let mut cfg = ::aws_smithy_types::config_bag::Layer::new("GetVpcResourcesBlockingEncryptionEnforcement");
95
96        cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedRequestSerializer::new(
97            GetVpcResourcesBlockingEncryptionEnforcementRequestSerializer,
98        ));
99        cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer::new(
100            GetVpcResourcesBlockingEncryptionEnforcementResponseDeserializer,
101        ));
102
103        cfg.store_put(::aws_smithy_runtime_api::client::auth::AuthSchemeOptionResolverParams::new(
104            crate::config::auth::Params::builder()
105                .operation_name("GetVpcResourcesBlockingEncryptionEnforcement")
106                .build()
107                .expect("required fields set"),
108        ));
109
110        cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::Metadata::new(
111            "GetVpcResourcesBlockingEncryptionEnforcement",
112            "EC2",
113        ));
114        let mut signing_options = ::aws_runtime::auth::SigningOptions::default();
115        signing_options.double_uri_encode = true;
116        signing_options.content_sha256_header = false;
117        signing_options.normalize_uri_path = true;
118        signing_options.payload_override = None;
119
120        cfg.store_put(::aws_runtime::auth::SigV4OperationSigningConfig {
121            signing_options,
122            ..::std::default::Default::default()
123        });
124
125        ::std::option::Option::Some(cfg.freeze())
126    }
127
128    fn runtime_components(
129        &self,
130        _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
131    ) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
132        #[allow(unused_mut)]
133        let mut rcb =
134            ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder::new("GetVpcResourcesBlockingEncryptionEnforcement")
135                .with_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
136                    ::aws_smithy_runtime::client::stalled_stream_protection::StalledStreamProtectionInterceptor::default(),
137                ))
138                .with_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
139                    GetVpcResourcesBlockingEncryptionEnforcementEndpointParamsInterceptor,
140                ))
141                .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::TransientErrorClassifier::<
142                    crate::operation::get_vpc_resources_blocking_encryption_enforcement::GetVpcResourcesBlockingEncryptionEnforcementError,
143                >::new())
144                .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::ModeledAsRetryableClassifier::<
145                    crate::operation::get_vpc_resources_blocking_encryption_enforcement::GetVpcResourcesBlockingEncryptionEnforcementError,
146                >::new())
147                .with_retry_classifier(::aws_runtime::retries::classifiers::AwsErrorCodeClassifier::<
148                    crate::operation::get_vpc_resources_blocking_encryption_enforcement::GetVpcResourcesBlockingEncryptionEnforcementError,
149                >::new());
150
151        ::std::borrow::Cow::Owned(rcb)
152    }
153}
154
155#[derive(Debug)]
156struct GetVpcResourcesBlockingEncryptionEnforcementResponseDeserializer;
157impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for GetVpcResourcesBlockingEncryptionEnforcementResponseDeserializer {
158    fn deserialize_nonstreaming(
159        &self,
160        response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
161    ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
162        let (success, status) = (response.status().is_success(), response.status().as_u16());
163        let headers = response.headers();
164        let body = response.body().bytes().expect("body loaded");
165        #[allow(unused_mut)]
166        let mut force_error = false;
167        ::tracing::debug!(request_id = ?::aws_types::request_id::RequestId::request_id(response));
168        let parse_result = if !success && status != 200 || force_error {
169            crate::protocol_serde::shape_get_vpc_resources_blocking_encryption_enforcement::de_get_vpc_resources_blocking_encryption_enforcement_http_error(status, headers, body)
170        } else {
171            crate::protocol_serde::shape_get_vpc_resources_blocking_encryption_enforcement::de_get_vpc_resources_blocking_encryption_enforcement_http_response(status, headers, body)
172        };
173        crate::protocol_serde::type_erase_result(parse_result)
174    }
175}
176#[derive(Debug)]
177struct GetVpcResourcesBlockingEncryptionEnforcementRequestSerializer;
178impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for GetVpcResourcesBlockingEncryptionEnforcementRequestSerializer {
179    #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
180    fn serialize_input(
181        &self,
182        input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
183        _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
184    ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
185        let input = input
186            .downcast::<crate::operation::get_vpc_resources_blocking_encryption_enforcement::GetVpcResourcesBlockingEncryptionEnforcementInput>()
187            .expect("correct type");
188        let _header_serialization_settings = _cfg
189            .load::<crate::serialization_settings::HeaderSerializationSettings>()
190            .cloned()
191            .unwrap_or_default();
192        let mut request_builder = {
193            #[allow(clippy::uninlined_format_args)]
194            fn uri_base(
195                _input: &crate::operation::get_vpc_resources_blocking_encryption_enforcement::GetVpcResourcesBlockingEncryptionEnforcementInput,
196                output: &mut ::std::string::String,
197            ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
198                use ::std::fmt::Write as _;
199                ::std::write!(output, "/").expect("formatting should succeed");
200                ::std::result::Result::Ok(())
201            }
202            #[allow(clippy::unnecessary_wraps)]
203            fn update_http_builder(
204                input: &crate::operation::get_vpc_resources_blocking_encryption_enforcement::GetVpcResourcesBlockingEncryptionEnforcementInput,
205                builder: ::http_1x::request::Builder,
206            ) -> ::std::result::Result<::http_1x::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
207                let mut uri = ::std::string::String::new();
208                uri_base(input, &mut uri)?;
209                ::std::result::Result::Ok(builder.method("POST").uri(uri))
210            }
211            let mut builder = update_http_builder(&input, ::http_1x::request::Builder::new())?;
212            builder =
213                _header_serialization_settings.set_default_header(builder, ::http_1x::header::CONTENT_TYPE, "application/x-www-form-urlencoded");
214            builder
215        };
216        let body = ::aws_smithy_types::body::SdkBody::from(crate::protocol_serde::shape_get_vpc_resources_blocking_encryption_enforcement_input::ser_get_vpc_resources_blocking_encryption_enforcement_input_input_input(&input)?);
217        if let Some(content_length) = body.content_length() {
218            let content_length = content_length.to_string();
219            request_builder = _header_serialization_settings.set_default_header(request_builder, ::http_1x::header::CONTENT_LENGTH, &content_length);
220        }
221        ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
222    }
223}
224#[derive(Debug)]
225struct GetVpcResourcesBlockingEncryptionEnforcementEndpointParamsInterceptor;
226
227#[::aws_smithy_runtime_api::client::interceptors::dyn_dispatch_hint]
228impl ::aws_smithy_runtime_api::client::interceptors::Intercept for GetVpcResourcesBlockingEncryptionEnforcementEndpointParamsInterceptor {
229    fn name(&self) -> &'static str {
230        "GetVpcResourcesBlockingEncryptionEnforcementEndpointParamsInterceptor"
231    }
232
233    fn read_before_execution(
234        &self,
235        context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
236            '_,
237            ::aws_smithy_runtime_api::client::interceptors::context::Input,
238            ::aws_smithy_runtime_api::client::interceptors::context::Output,
239            ::aws_smithy_runtime_api::client::interceptors::context::Error,
240        >,
241        cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
242    ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
243        let _input = context
244            .input()
245            .downcast_ref::<GetVpcResourcesBlockingEncryptionEnforcementInput>()
246            .ok_or("failed to downcast to GetVpcResourcesBlockingEncryptionEnforcementInput")?;
247
248        let params = crate::config::endpoint::Params::builder()
249            .set_region(cfg.load::<::aws_types::region::Region>().map(|r| r.as_ref().to_owned()))
250            .set_use_dual_stack(cfg.load::<::aws_types::endpoint_config::UseDualStack>().map(|ty| ty.0))
251            .set_use_fips(cfg.load::<::aws_types::endpoint_config::UseFips>().map(|ty| ty.0))
252            .set_endpoint(cfg.load::<::aws_types::endpoint_config::EndpointUrl>().map(|ty| ty.0.clone()))
253            .build()
254            .map_err(|err| {
255                ::aws_smithy_runtime_api::client::interceptors::error::ContextAttachedError::new("endpoint params could not be built", err)
256            })?;
257        cfg.interceptor_state()
258            .store_put(::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams::new(params));
259        ::std::result::Result::Ok(())
260    }
261}
262
263// The get_* functions below are generated from JMESPath expressions in the
264// operationContextParams trait. They target the operation's input shape.
265
266/// Error type for the `GetVpcResourcesBlockingEncryptionEnforcementError` operation.
267#[non_exhaustive]
268#[derive(::std::fmt::Debug)]
269pub enum GetVpcResourcesBlockingEncryptionEnforcementError {
270    /// An unexpected error occurred (e.g., invalid JSON returned by the service or an unknown error code).
271    #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
272    variable wildcard pattern and check `.code()`:
273     \
274    &nbsp;&nbsp;&nbsp;`err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
275     \
276    See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-GetVpcResourcesBlockingEncryptionEnforcementError) for what information is available for the error.")]
277    Unhandled(crate::error::sealed_unhandled::Unhandled),
278}
279impl GetVpcResourcesBlockingEncryptionEnforcementError {
280    /// Creates the `GetVpcResourcesBlockingEncryptionEnforcementError::Unhandled` variant from any error type.
281    pub fn unhandled(
282        err: impl ::std::convert::Into<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>>,
283    ) -> Self {
284        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
285            source: err.into(),
286            meta: ::std::default::Default::default(),
287        })
288    }
289
290    /// Creates the `GetVpcResourcesBlockingEncryptionEnforcementError::Unhandled` variant from an [`ErrorMetadata`](::aws_smithy_types::error::ErrorMetadata).
291    pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self {
292        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
293            source: err.clone().into(),
294            meta: err,
295        })
296    }
297    ///
298    /// Returns error metadata, which includes the error code, message,
299    /// request ID, and potentially additional information.
300    ///
301    pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
302        match self {
303            Self::Unhandled(e) => &e.meta,
304        }
305    }
306}
307impl ::std::error::Error for GetVpcResourcesBlockingEncryptionEnforcementError {
308    fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
309        match self {
310            Self::Unhandled(_inner) => ::std::option::Option::Some(&*_inner.source),
311        }
312    }
313}
314impl ::std::fmt::Display for GetVpcResourcesBlockingEncryptionEnforcementError {
315    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
316        match self {
317            Self::Unhandled(_inner) => {
318                if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
319                    write!(f, "unhandled error ({code})")
320                } else {
321                    f.write_str("unhandled error")
322                }
323            }
324        }
325    }
326}
327impl ::aws_smithy_types::retry::ProvideErrorKind for GetVpcResourcesBlockingEncryptionEnforcementError {
328    fn code(&self) -> ::std::option::Option<&str> {
329        ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self)
330    }
331    fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> {
332        ::std::option::Option::None
333    }
334}
335impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for GetVpcResourcesBlockingEncryptionEnforcementError {
336    fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
337        match self {
338            Self::Unhandled(_inner) => &_inner.meta,
339        }
340    }
341}
342impl ::aws_smithy_runtime_api::client::result::CreateUnhandledError for GetVpcResourcesBlockingEncryptionEnforcementError {
343    fn create_unhandled_error(
344        source: ::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>,
345        meta: ::std::option::Option<::aws_smithy_types::error::ErrorMetadata>,
346    ) -> Self {
347        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
348            source,
349            meta: meta.unwrap_or_default(),
350        })
351    }
352}
353impl ::aws_types::request_id::RequestId
354    for crate::operation::get_vpc_resources_blocking_encryption_enforcement::GetVpcResourcesBlockingEncryptionEnforcementError
355{
356    fn request_id(&self) -> Option<&str> {
357        self.meta().request_id()
358    }
359}
360
361pub use crate::operation::get_vpc_resources_blocking_encryption_enforcement::_get_vpc_resources_blocking_encryption_enforcement_input::GetVpcResourcesBlockingEncryptionEnforcementInput;
362
363pub use crate::operation::get_vpc_resources_blocking_encryption_enforcement::_get_vpc_resources_blocking_encryption_enforcement_output::GetVpcResourcesBlockingEncryptionEnforcementOutput;
364
365mod _get_vpc_resources_blocking_encryption_enforcement_input;
366
367mod _get_vpc_resources_blocking_encryption_enforcement_output;
368
369/// Builders
370pub mod builders;