Skip to main content

aws_sdk_s3control/operation/
create_multi_region_access_point.rs

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