aws_sdk_codecatalyst/operation/
get_space.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2/// Orchestration and serialization glue logic for `GetSpace`.
3#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
4#[non_exhaustive]
5pub struct GetSpace;
6impl GetSpace {
7    /// Creates a new `GetSpace`
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_space::GetSpaceInput,
14    ) -> ::std::result::Result<
15        crate::operation::get_space::GetSpaceOutput,
16        ::aws_smithy_runtime_api::client::result::SdkError<
17            crate::operation::get_space::GetSpaceError,
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_space::GetSpaceError>().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_space::GetSpaceOutput>()
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_space::GetSpaceInput,
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("CodeCatalyst", "GetSpace", input, runtime_plugins, stop_point)
51            // Create a parent span for the entire operation. Includes a random, internal-only,
52            // seven-digit ID for the operation orchestration so that it can be correlated in the logs.
53            .instrument(::tracing::debug_span!(
54                "CodeCatalyst.GetSpace",
55                "rpc.service" = "CodeCatalyst",
56                "rpc.method" = "GetSpace",
57                "sdk_invocation_id" = ::fastrand::u32(1_000_000..10_000_000),
58                "rpc.system" = "aws-api",
59            ))
60            .await
61    }
62
63    pub(crate) fn operation_runtime_plugins(
64        client_runtime_plugins: ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
65        client_config: &crate::config::Config,
66        config_override: ::std::option::Option<crate::config::Builder>,
67    ) -> ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins {
68        let mut runtime_plugins = client_runtime_plugins.with_operation_plugin(Self::new());
69
70        if let ::std::option::Option::Some(config_override) = config_override {
71            for plugin in config_override.runtime_plugins.iter().cloned() {
72                runtime_plugins = runtime_plugins.with_operation_plugin(plugin);
73            }
74            runtime_plugins = runtime_plugins.with_operation_plugin(crate::config::ConfigOverrideRuntimePlugin::new(
75                config_override,
76                client_config.config.clone(),
77                &client_config.runtime_components,
78            ));
79        }
80        runtime_plugins
81    }
82}
83impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin for GetSpace {
84    fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
85        let mut cfg = ::aws_smithy_types::config_bag::Layer::new("GetSpace");
86
87        cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedRequestSerializer::new(
88            GetSpaceRequestSerializer,
89        ));
90        cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer::new(
91            GetSpaceResponseDeserializer,
92        ));
93
94        cfg.store_put(::aws_smithy_runtime_api::client::auth::AuthSchemeOptionResolverParams::new(
95            crate::config::auth::Params::builder()
96                .operation_name("GetSpace")
97                .build()
98                .expect("required fields set"),
99        ));
100
101        cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::Metadata::new("GetSpace", "CodeCatalyst"));
102
103        ::std::option::Option::Some(cfg.freeze())
104    }
105
106    fn runtime_components(
107        &self,
108        _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
109    ) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
110        #[allow(unused_mut)]
111        let mut rcb = ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder::new("GetSpace")
112            .with_interceptor(::aws_smithy_runtime::client::stalled_stream_protection::StalledStreamProtectionInterceptor::default())
113            .with_interceptor(GetSpaceEndpointParamsInterceptor)
114            .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::TransientErrorClassifier::<
115                crate::operation::get_space::GetSpaceError,
116            >::new())
117            .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::ModeledAsRetryableClassifier::<
118                crate::operation::get_space::GetSpaceError,
119            >::new())
120            .with_retry_classifier(::aws_runtime::retries::classifiers::AwsErrorCodeClassifier::<
121                crate::operation::get_space::GetSpaceError,
122            >::new());
123
124        ::std::borrow::Cow::Owned(rcb)
125    }
126}
127
128#[derive(Debug)]
129struct GetSpaceResponseDeserializer;
130impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for GetSpaceResponseDeserializer {
131    fn deserialize_nonstreaming(
132        &self,
133        response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
134    ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
135        let (success, status) = (response.status().is_success(), response.status().as_u16());
136        let headers = response.headers();
137        let body = response.body().bytes().expect("body loaded");
138        #[allow(unused_mut)]
139        let mut force_error = false;
140        ::tracing::debug!(request_id = ?::aws_types::request_id::RequestId::request_id(response));
141        let parse_result = if !success && status != 200 || force_error {
142            crate::protocol_serde::shape_get_space::de_get_space_http_error(status, headers, body)
143        } else {
144            crate::protocol_serde::shape_get_space::de_get_space_http_response(status, headers, body)
145        };
146        crate::protocol_serde::type_erase_result(parse_result)
147    }
148}
149#[derive(Debug)]
150struct GetSpaceRequestSerializer;
151impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for GetSpaceRequestSerializer {
152    #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
153    fn serialize_input(
154        &self,
155        input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
156        _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
157    ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
158        let input = input.downcast::<crate::operation::get_space::GetSpaceInput>().expect("correct type");
159        let _header_serialization_settings = _cfg
160            .load::<crate::serialization_settings::HeaderSerializationSettings>()
161            .cloned()
162            .unwrap_or_default();
163        let mut request_builder = {
164            #[allow(clippy::uninlined_format_args)]
165            fn uri_base(
166                _input: &crate::operation::get_space::GetSpaceInput,
167                output: &mut ::std::string::String,
168            ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
169                use ::std::fmt::Write as _;
170                let input_1 = &_input.name;
171                let input_1 = input_1
172                    .as_ref()
173                    .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("name", "cannot be empty or unset"))?;
174                let name = ::aws_smithy_http::label::fmt_string(input_1, ::aws_smithy_http::label::EncodingStrategy::Default);
175                if name.is_empty() {
176                    return ::std::result::Result::Err(::aws_smithy_types::error::operation::BuildError::missing_field(
177                        "name",
178                        "cannot be empty or unset",
179                    ));
180                }
181                ::std::write!(output, "/v1/spaces/{name}", name = name).expect("formatting should succeed");
182                ::std::result::Result::Ok(())
183            }
184            #[allow(clippy::unnecessary_wraps)]
185            fn update_http_builder(
186                input: &crate::operation::get_space::GetSpaceInput,
187                builder: ::http::request::Builder,
188            ) -> ::std::result::Result<::http::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
189                let mut uri = ::std::string::String::new();
190                uri_base(input, &mut uri)?;
191                ::std::result::Result::Ok(builder.method("GET").uri(uri))
192            }
193            let mut builder = update_http_builder(&input, ::http::request::Builder::new())?;
194            builder
195        };
196        let body = ::aws_smithy_types::body::SdkBody::from("");
197
198        ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
199    }
200}
201#[derive(Debug)]
202struct GetSpaceEndpointParamsInterceptor;
203
204impl ::aws_smithy_runtime_api::client::interceptors::Intercept for GetSpaceEndpointParamsInterceptor {
205    fn name(&self) -> &'static str {
206        "GetSpaceEndpointParamsInterceptor"
207    }
208
209    fn read_before_execution(
210        &self,
211        context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
212            '_,
213            ::aws_smithy_runtime_api::client::interceptors::context::Input,
214            ::aws_smithy_runtime_api::client::interceptors::context::Output,
215            ::aws_smithy_runtime_api::client::interceptors::context::Error,
216        >,
217        cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
218    ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
219        let _input = context
220            .input()
221            .downcast_ref::<GetSpaceInput>()
222            .ok_or("failed to downcast to GetSpaceInput")?;
223
224        let params = crate::config::endpoint::Params::builder()
225            .set_use_fips(cfg.load::<::aws_types::endpoint_config::UseFips>().map(|ty| ty.0))
226            .set_region(cfg.load::<::aws_types::region::Region>().map(|r| r.as_ref().to_owned()))
227            .set_endpoint(cfg.load::<::aws_types::endpoint_config::EndpointUrl>().map(|ty| ty.0.clone()))
228            .build()
229            .map_err(|err| {
230                ::aws_smithy_runtime_api::client::interceptors::error::ContextAttachedError::new("endpoint params could not be built", err)
231            })?;
232        cfg.interceptor_state()
233            .store_put(::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams::new(params));
234        ::std::result::Result::Ok(())
235    }
236}
237
238// The get_* functions below are generated from JMESPath expressions in the
239// operationContextParams trait. They target the operation's input shape.
240
241/// Error type for the `GetSpaceError` operation.
242#[non_exhaustive]
243#[derive(::std::fmt::Debug)]
244pub enum GetSpaceError {
245    /// <p>The request was denied because you don't have sufficient access to perform this action. Verify that you are a member of a role that allows this action.</p>
246    AccessDeniedException(crate::types::error::AccessDeniedException),
247    /// <p>The request was denied because the requested operation would cause a conflict with the current state of a service resource associated with the request. Another user might have updated the resource. Reload, make sure you have the latest data, and then try again.</p>
248    ConflictException(crate::types::error::ConflictException),
249    /// <p>The request was denied because the specified resource was not found. Verify that the spelling is correct and that you have access to the resource.</p>
250    ResourceNotFoundException(crate::types::error::ResourceNotFoundException),
251    /// <p>The request was denied because one or more resources has reached its limits for the tier the space belongs to. Either reduce the number of resources, or change the tier if applicable.</p>
252    ServiceQuotaExceededException(crate::types::error::ServiceQuotaExceededException),
253    /// <p>The request was denied due to request throttling.</p>
254    ThrottlingException(crate::types::error::ThrottlingException),
255    /// <p>The request was denied because an input failed to satisfy the constraints specified by the service. Check the spelling and input requirements, and then try again.</p>
256    ValidationException(crate::types::error::ValidationException),
257    /// An unexpected error occurred (e.g., invalid JSON returned by the service or an unknown error code).
258    #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
259    variable wildcard pattern and check `.code()`:
260     \
261    &nbsp;&nbsp;&nbsp;`err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
262     \
263    See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-GetSpaceError) for what information is available for the error.")]
264    Unhandled(crate::error::sealed_unhandled::Unhandled),
265}
266impl GetSpaceError {
267    /// Creates the `GetSpaceError::Unhandled` variant from any error type.
268    pub fn unhandled(
269        err: impl ::std::convert::Into<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>>,
270    ) -> Self {
271        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
272            source: err.into(),
273            meta: ::std::default::Default::default(),
274        })
275    }
276
277    /// Creates the `GetSpaceError::Unhandled` variant from an [`ErrorMetadata`](::aws_smithy_types::error::ErrorMetadata).
278    pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self {
279        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
280            source: err.clone().into(),
281            meta: err,
282        })
283    }
284    ///
285    /// Returns error metadata, which includes the error code, message,
286    /// request ID, and potentially additional information.
287    ///
288    pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
289        match self {
290            Self::AccessDeniedException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
291            Self::ConflictException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
292            Self::ResourceNotFoundException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
293            Self::ServiceQuotaExceededException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
294            Self::ThrottlingException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
295            Self::ValidationException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
296            Self::Unhandled(e) => &e.meta,
297        }
298    }
299    /// Returns `true` if the error kind is `GetSpaceError::AccessDeniedException`.
300    pub fn is_access_denied_exception(&self) -> bool {
301        matches!(self, Self::AccessDeniedException(_))
302    }
303    /// Returns `true` if the error kind is `GetSpaceError::ConflictException`.
304    pub fn is_conflict_exception(&self) -> bool {
305        matches!(self, Self::ConflictException(_))
306    }
307    /// Returns `true` if the error kind is `GetSpaceError::ResourceNotFoundException`.
308    pub fn is_resource_not_found_exception(&self) -> bool {
309        matches!(self, Self::ResourceNotFoundException(_))
310    }
311    /// Returns `true` if the error kind is `GetSpaceError::ServiceQuotaExceededException`.
312    pub fn is_service_quota_exceeded_exception(&self) -> bool {
313        matches!(self, Self::ServiceQuotaExceededException(_))
314    }
315    /// Returns `true` if the error kind is `GetSpaceError::ThrottlingException`.
316    pub fn is_throttling_exception(&self) -> bool {
317        matches!(self, Self::ThrottlingException(_))
318    }
319    /// Returns `true` if the error kind is `GetSpaceError::ValidationException`.
320    pub fn is_validation_exception(&self) -> bool {
321        matches!(self, Self::ValidationException(_))
322    }
323}
324impl ::std::error::Error for GetSpaceError {
325    fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
326        match self {
327            Self::AccessDeniedException(_inner) => ::std::option::Option::Some(_inner),
328            Self::ConflictException(_inner) => ::std::option::Option::Some(_inner),
329            Self::ResourceNotFoundException(_inner) => ::std::option::Option::Some(_inner),
330            Self::ServiceQuotaExceededException(_inner) => ::std::option::Option::Some(_inner),
331            Self::ThrottlingException(_inner) => ::std::option::Option::Some(_inner),
332            Self::ValidationException(_inner) => ::std::option::Option::Some(_inner),
333            Self::Unhandled(_inner) => ::std::option::Option::Some(&*_inner.source),
334        }
335    }
336}
337impl ::std::fmt::Display for GetSpaceError {
338    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
339        match self {
340            Self::AccessDeniedException(_inner) => _inner.fmt(f),
341            Self::ConflictException(_inner) => _inner.fmt(f),
342            Self::ResourceNotFoundException(_inner) => _inner.fmt(f),
343            Self::ServiceQuotaExceededException(_inner) => _inner.fmt(f),
344            Self::ThrottlingException(_inner) => _inner.fmt(f),
345            Self::ValidationException(_inner) => _inner.fmt(f),
346            Self::Unhandled(_inner) => {
347                if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
348                    write!(f, "unhandled error ({code})")
349                } else {
350                    f.write_str("unhandled error")
351                }
352            }
353        }
354    }
355}
356impl ::aws_smithy_types::retry::ProvideErrorKind for GetSpaceError {
357    fn code(&self) -> ::std::option::Option<&str> {
358        ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self)
359    }
360    fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> {
361        match self {
362            Self::ThrottlingException(inner) => ::std::option::Option::Some(inner.retryable_error_kind()),
363            _ => ::std::option::Option::None,
364        }
365    }
366}
367impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for GetSpaceError {
368    fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
369        match self {
370            Self::AccessDeniedException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
371            Self::ConflictException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
372            Self::ResourceNotFoundException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
373            Self::ServiceQuotaExceededException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
374            Self::ThrottlingException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
375            Self::ValidationException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
376            Self::Unhandled(_inner) => &_inner.meta,
377        }
378    }
379}
380impl ::aws_smithy_runtime_api::client::result::CreateUnhandledError for GetSpaceError {
381    fn create_unhandled_error(
382        source: ::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>,
383        meta: ::std::option::Option<::aws_smithy_types::error::ErrorMetadata>,
384    ) -> Self {
385        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
386            source,
387            meta: meta.unwrap_or_default(),
388        })
389    }
390}
391impl ::aws_types::request_id::RequestId for crate::operation::get_space::GetSpaceError {
392    fn request_id(&self) -> Option<&str> {
393        self.meta().request_id()
394    }
395}
396
397pub use crate::operation::get_space::_get_space_output::GetSpaceOutput;
398
399pub use crate::operation::get_space::_get_space_input::GetSpaceInput;
400
401mod _get_space_input;
402
403mod _get_space_output;
404
405/// Builders
406pub mod builders;