aws_sdk_codecatalyst/operation/
list_spaces.rs1#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
4#[non_exhaustive]
5pub struct ListSpaces;
6impl ListSpaces {
7 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_spaces::ListSpacesInput,
14 ) -> ::std::result::Result<
15 crate::operation::list_spaces::ListSpacesOutput,
16 ::aws_smithy_runtime_api::client::result::SdkError<
17 crate::operation::list_spaces::ListSpacesError,
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_spaces::ListSpacesError>()
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_spaces::ListSpacesOutput>()
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_spaces::ListSpacesInput,
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("CodeCatalyst", "ListSpaces", input, runtime_plugins, stop_point)
55 .instrument(::tracing::debug_span!(
58 "CodeCatalyst.ListSpaces",
59 "rpc.service" = "CodeCatalyst",
60 "rpc.method" = "ListSpaces",
61 "sdk_invocation_id" = ::fastrand::u32(1_000_000..10_000_000),
62 "rpc.system" = "aws-api",
63 ))
64 .await
65 }
66
67 pub(crate) fn operation_runtime_plugins(
68 client_runtime_plugins: ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
69 client_config: &crate::config::Config,
70 config_override: ::std::option::Option<crate::config::Builder>,
71 ) -> ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins {
72 let mut runtime_plugins = client_runtime_plugins.with_operation_plugin(Self::new());
73
74 if let ::std::option::Option::Some(config_override) = config_override {
75 for plugin in config_override.runtime_plugins.iter().cloned() {
76 runtime_plugins = runtime_plugins.with_operation_plugin(plugin);
77 }
78 runtime_plugins = runtime_plugins.with_operation_plugin(crate::config::ConfigOverrideRuntimePlugin::new(
79 config_override,
80 client_config.config.clone(),
81 &client_config.runtime_components,
82 ));
83 }
84 runtime_plugins
85 }
86}
87impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin for ListSpaces {
88 fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
89 let mut cfg = ::aws_smithy_types::config_bag::Layer::new("ListSpaces");
90
91 cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedRequestSerializer::new(
92 ListSpacesRequestSerializer,
93 ));
94 cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer::new(
95 ListSpacesResponseDeserializer,
96 ));
97
98 cfg.store_put(::aws_smithy_runtime_api::client::auth::AuthSchemeOptionResolverParams::new(
99 crate::config::auth::Params::builder()
100 .operation_name("ListSpaces")
101 .build()
102 .expect("required fields set"),
103 ));
104
105 cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::Metadata::new(
106 "ListSpaces",
107 "CodeCatalyst",
108 ));
109
110 ::std::option::Option::Some(cfg.freeze())
111 }
112
113 fn runtime_components(
114 &self,
115 _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
116 ) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
117 #[allow(unused_mut)]
118 let mut rcb = ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder::new("ListSpaces")
119 .with_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
120 ::aws_smithy_runtime::client::stalled_stream_protection::StalledStreamProtectionInterceptor::default(),
121 ))
122 .with_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
123 ListSpacesEndpointParamsInterceptor,
124 ))
125 .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::TransientErrorClassifier::<
126 crate::operation::list_spaces::ListSpacesError,
127 >::new())
128 .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::ModeledAsRetryableClassifier::<
129 crate::operation::list_spaces::ListSpacesError,
130 >::new())
131 .with_retry_classifier(::aws_runtime::retries::classifiers::AwsErrorCodeClassifier::<
132 crate::operation::list_spaces::ListSpacesError,
133 >::new());
134
135 ::std::borrow::Cow::Owned(rcb)
136 }
137}
138
139#[derive(Debug)]
140struct ListSpacesResponseDeserializer;
141impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for ListSpacesResponseDeserializer {
142 fn deserialize_nonstreaming(
143 &self,
144 response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
145 ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
146 let (success, status) = (response.status().is_success(), response.status().as_u16());
147 let headers = response.headers();
148 let body = response.body().bytes().expect("body loaded");
149 #[allow(unused_mut)]
150 let mut force_error = false;
151 ::tracing::debug!(request_id = ?::aws_types::request_id::RequestId::request_id(response));
152 let parse_result = if !success && status != 200 || force_error {
153 crate::protocol_serde::shape_list_spaces::de_list_spaces_http_error(status, headers, body)
154 } else {
155 crate::protocol_serde::shape_list_spaces::de_list_spaces_http_response(status, headers, body)
156 };
157 crate::protocol_serde::type_erase_result(parse_result)
158 }
159}
160#[derive(Debug)]
161struct ListSpacesRequestSerializer;
162impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for ListSpacesRequestSerializer {
163 #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
164 fn serialize_input(
165 &self,
166 input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
167 _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
168 ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
169 let input = input.downcast::<crate::operation::list_spaces::ListSpacesInput>().expect("correct type");
170 let _header_serialization_settings = _cfg
171 .load::<crate::serialization_settings::HeaderSerializationSettings>()
172 .cloned()
173 .unwrap_or_default();
174 let mut request_builder = {
175 #[allow(clippy::uninlined_format_args)]
176 fn uri_base(
177 _input: &crate::operation::list_spaces::ListSpacesInput,
178 output: &mut ::std::string::String,
179 ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
180 use ::std::fmt::Write as _;
181 ::std::write!(output, "/v1/spaces").expect("formatting should succeed");
182 ::std::result::Result::Ok(())
183 }
184 #[allow(clippy::unnecessary_wraps)]
185 fn update_http_builder(
186 input: &crate::operation::list_spaces::ListSpacesInput,
187 builder: ::http_1x::request::Builder,
188 ) -> ::std::result::Result<::http_1x::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("POST").uri(uri))
192 }
193 let mut builder = update_http_builder(&input, ::http_1x::request::Builder::new())?;
194 builder = _header_serialization_settings.set_default_header(builder, ::http_1x::header::CONTENT_TYPE, "application/json");
195 builder
196 };
197 let body = ::aws_smithy_types::body::SdkBody::from(crate::protocol_serde::shape_list_spaces::ser_list_spaces_input(&input)?);
198 if let Some(content_length) = body.content_length() {
199 let content_length = content_length.to_string();
200 request_builder = _header_serialization_settings.set_default_header(request_builder, ::http_1x::header::CONTENT_LENGTH, &content_length);
201 }
202 ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
203 }
204}
205#[derive(Debug)]
206struct ListSpacesEndpointParamsInterceptor;
207
208#[::aws_smithy_runtime_api::client::interceptors::dyn_dispatch_hint]
209impl ::aws_smithy_runtime_api::client::interceptors::Intercept for ListSpacesEndpointParamsInterceptor {
210 fn name(&self) -> &'static str {
211 "ListSpacesEndpointParamsInterceptor"
212 }
213
214 fn read_before_execution(
215 &self,
216 context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
217 '_,
218 ::aws_smithy_runtime_api::client::interceptors::context::Input,
219 ::aws_smithy_runtime_api::client::interceptors::context::Output,
220 ::aws_smithy_runtime_api::client::interceptors::context::Error,
221 >,
222 cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
223 ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
224 let _input = context
225 .input()
226 .downcast_ref::<ListSpacesInput>()
227 .ok_or("failed to downcast to ListSpacesInput")?;
228
229 let params = crate::config::endpoint::Params::builder()
230 .set_use_fips(cfg.load::<::aws_types::endpoint_config::UseFips>().map(|ty| ty.0))
231 .set_region(cfg.load::<::aws_types::region::Region>().map(|r| r.as_ref().to_owned()))
232 .set_endpoint(cfg.load::<::aws_types::endpoint_config::EndpointUrl>().map(|ty| ty.0.clone()))
233 .build()
234 .map_err(|err| {
235 ::aws_smithy_runtime_api::client::interceptors::error::ContextAttachedError::new("endpoint params could not be built", err)
236 })?;
237 cfg.interceptor_state()
238 .store_put(::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams::new(params));
239 ::std::result::Result::Ok(())
240 }
241}
242
243#[non_exhaustive]
248#[derive(::std::fmt::Debug)]
249pub enum ListSpacesError {
250 AccessDeniedException(crate::types::error::AccessDeniedException),
252 ConflictException(crate::types::error::ConflictException),
254 ResourceNotFoundException(crate::types::error::ResourceNotFoundException),
256 ServiceQuotaExceededException(crate::types::error::ServiceQuotaExceededException),
258 ThrottlingException(crate::types::error::ThrottlingException),
260 ValidationException(crate::types::error::ValidationException),
262 #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
264 variable wildcard pattern and check `.code()`:
265 \
266 `err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
267 \
268 See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-ListSpacesError) for what information is available for the error.")]
269 Unhandled(crate::error::sealed_unhandled::Unhandled),
270}
271impl ListSpacesError {
272 pub fn unhandled(
274 err: impl ::std::convert::Into<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>>,
275 ) -> Self {
276 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
277 source: err.into(),
278 meta: ::std::default::Default::default(),
279 })
280 }
281
282 pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self {
284 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
285 source: err.clone().into(),
286 meta: err,
287 })
288 }
289 pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
294 match self {
295 Self::AccessDeniedException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
296 Self::ConflictException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
297 Self::ResourceNotFoundException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
298 Self::ServiceQuotaExceededException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
299 Self::ThrottlingException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
300 Self::ValidationException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
301 Self::Unhandled(e) => &e.meta,
302 }
303 }
304 pub fn is_access_denied_exception(&self) -> bool {
306 matches!(self, Self::AccessDeniedException(_))
307 }
308 pub fn is_conflict_exception(&self) -> bool {
310 matches!(self, Self::ConflictException(_))
311 }
312 pub fn is_resource_not_found_exception(&self) -> bool {
314 matches!(self, Self::ResourceNotFoundException(_))
315 }
316 pub fn is_service_quota_exceeded_exception(&self) -> bool {
318 matches!(self, Self::ServiceQuotaExceededException(_))
319 }
320 pub fn is_throttling_exception(&self) -> bool {
322 matches!(self, Self::ThrottlingException(_))
323 }
324 pub fn is_validation_exception(&self) -> bool {
326 matches!(self, Self::ValidationException(_))
327 }
328}
329impl ::std::error::Error for ListSpacesError {
330 fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
331 match self {
332 Self::AccessDeniedException(_inner) => ::std::option::Option::Some(_inner),
333 Self::ConflictException(_inner) => ::std::option::Option::Some(_inner),
334 Self::ResourceNotFoundException(_inner) => ::std::option::Option::Some(_inner),
335 Self::ServiceQuotaExceededException(_inner) => ::std::option::Option::Some(_inner),
336 Self::ThrottlingException(_inner) => ::std::option::Option::Some(_inner),
337 Self::ValidationException(_inner) => ::std::option::Option::Some(_inner),
338 Self::Unhandled(_inner) => ::std::option::Option::Some(&*_inner.source),
339 }
340 }
341}
342impl ::std::fmt::Display for ListSpacesError {
343 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
344 match self {
345 Self::AccessDeniedException(_inner) => _inner.fmt(f),
346 Self::ConflictException(_inner) => _inner.fmt(f),
347 Self::ResourceNotFoundException(_inner) => _inner.fmt(f),
348 Self::ServiceQuotaExceededException(_inner) => _inner.fmt(f),
349 Self::ThrottlingException(_inner) => _inner.fmt(f),
350 Self::ValidationException(_inner) => _inner.fmt(f),
351 Self::Unhandled(_inner) => {
352 if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
353 write!(f, "unhandled error ({code})")
354 } else {
355 f.write_str("unhandled error")
356 }
357 }
358 }
359 }
360}
361impl ::aws_smithy_types::retry::ProvideErrorKind for ListSpacesError {
362 fn code(&self) -> ::std::option::Option<&str> {
363 ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self)
364 }
365 fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> {
366 match self {
367 Self::ThrottlingException(inner) => ::std::option::Option::Some(inner.retryable_error_kind()),
368 _ => ::std::option::Option::None,
369 }
370 }
371}
372impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for ListSpacesError {
373 fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
374 match self {
375 Self::AccessDeniedException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
376 Self::ConflictException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
377 Self::ResourceNotFoundException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
378 Self::ServiceQuotaExceededException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
379 Self::ThrottlingException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
380 Self::ValidationException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
381 Self::Unhandled(_inner) => &_inner.meta,
382 }
383 }
384}
385impl ::aws_smithy_runtime_api::client::result::CreateUnhandledError for ListSpacesError {
386 fn create_unhandled_error(
387 source: ::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>,
388 meta: ::std::option::Option<::aws_smithy_types::error::ErrorMetadata>,
389 ) -> Self {
390 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
391 source,
392 meta: meta.unwrap_or_default(),
393 })
394 }
395}
396impl ::aws_types::request_id::RequestId for crate::operation::list_spaces::ListSpacesError {
397 fn request_id(&self) -> Option<&str> {
398 self.meta().request_id()
399 }
400}
401
402pub use crate::operation::list_spaces::_list_spaces_input::ListSpacesInput;
403
404pub use crate::operation::list_spaces::_list_spaces_output::ListSpacesOutput;
405
406mod _list_spaces_input;
407
408mod _list_spaces_output;
409
410pub mod builders;
412
413pub mod paginator;