Skip to main content

aws_sdk_migrationhubrefactorspaces/operation/
get_route.rs

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