aws_sdk_backupstorage/operation/
get_chunk.rs1#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
4#[non_exhaustive]
5pub struct GetChunk;
6impl GetChunk {
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::get_chunk::GetChunkInput,
14 ) -> ::std::result::Result<
15 crate::operation::get_chunk::GetChunkOutput,
16 ::aws_smithy_runtime_api::client::result::SdkError<
17 crate::operation::get_chunk::GetChunkError,
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_chunk::GetChunkError>().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_chunk::GetChunkOutput>()
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_chunk::GetChunkInput,
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 ::aws_smithy_runtime::client::orchestrator::invoke_with_stop_point("backupstorage", "GetChunk", input, runtime_plugins, stop_point).await
50 }
51
52 pub(crate) fn operation_runtime_plugins(
53 client_runtime_plugins: ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
54 client_config: &crate::config::Config,
55 config_override: ::std::option::Option<crate::config::Builder>,
56 ) -> ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins {
57 let mut runtime_plugins = client_runtime_plugins.with_operation_plugin(Self::new());
58 runtime_plugins = runtime_plugins.with_client_plugin(crate::auth_plugin::DefaultAuthOptionsPlugin::new(vec![
59 ::aws_runtime::auth::sigv4::SCHEME_ID,
60 ]));
61 if let ::std::option::Option::Some(config_override) = config_override {
62 for plugin in config_override.runtime_plugins.iter().cloned() {
63 runtime_plugins = runtime_plugins.with_operation_plugin(plugin);
64 }
65 runtime_plugins = runtime_plugins.with_operation_plugin(crate::config::ConfigOverrideRuntimePlugin::new(
66 config_override,
67 client_config.config.clone(),
68 &client_config.runtime_components,
69 ));
70 }
71 runtime_plugins
72 }
73}
74impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin for GetChunk {
75 fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
76 let mut cfg = ::aws_smithy_types::config_bag::Layer::new("GetChunk");
77
78 cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedRequestSerializer::new(
79 GetChunkRequestSerializer,
80 ));
81 cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer::new(
82 GetChunkResponseDeserializer,
83 ));
84
85 cfg.store_put(::aws_smithy_runtime_api::client::auth::AuthSchemeOptionResolverParams::new(
86 ::aws_smithy_runtime_api::client::auth::static_resolver::StaticAuthSchemeOptionResolverParams::new(),
87 ));
88
89 cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::Metadata::new("GetChunk", "backupstorage"));
90 let mut signing_options = ::aws_runtime::auth::SigningOptions::default();
91 signing_options.double_uri_encode = true;
92 signing_options.content_sha256_header = false;
93 signing_options.normalize_uri_path = true;
94 signing_options.payload_override = None;
95
96 cfg.store_put(::aws_runtime::auth::SigV4OperationSigningConfig {
97 signing_options,
98 ..::std::default::Default::default()
99 });
100
101 ::std::option::Option::Some(cfg.freeze())
102 }
103
104 fn runtime_components(
105 &self,
106 _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
107 ) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
108 #[allow(unused_mut)]
109 let mut rcb = ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder::new("GetChunk")
110 .with_interceptor(::aws_smithy_runtime::client::stalled_stream_protection::StalledStreamProtectionInterceptor::default())
111 .with_interceptor(GetChunkEndpointParamsInterceptor)
112 .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::TransientErrorClassifier::<
113 crate::operation::get_chunk::GetChunkError,
114 >::new())
115 .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::ModeledAsRetryableClassifier::<
116 crate::operation::get_chunk::GetChunkError,
117 >::new())
118 .with_retry_classifier(::aws_runtime::retries::classifiers::AwsErrorCodeClassifier::<
119 crate::operation::get_chunk::GetChunkError,
120 >::new());
121
122 ::std::borrow::Cow::Owned(rcb)
123 }
124}
125
126#[derive(Debug)]
127struct GetChunkResponseDeserializer;
128impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for GetChunkResponseDeserializer {
129 fn deserialize_streaming(
130 &self,
131 response: &mut ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
132 ) -> ::std::option::Option<::aws_smithy_runtime_api::client::interceptors::context::OutputOrError> {
133 #[allow(unused_mut)]
134 let mut force_error = false;
135 ::tracing::debug!(request_id = ?::aws_types::request_id::RequestId::request_id(response));
136
137 if (!response.status().is_success() && response.status().as_u16() != 200) || force_error {
139 return ::std::option::Option::None;
140 }
141 ::std::option::Option::Some(crate::protocol_serde::type_erase_result(
142 crate::protocol_serde::shape_get_chunk::de_get_chunk_http_response(response),
143 ))
144 }
145
146 fn deserialize_nonstreaming(
147 &self,
148 response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
149 ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
150 let body = response.body().bytes().expect("body loaded");
152 crate::protocol_serde::type_erase_result(crate::protocol_serde::shape_get_chunk::de_get_chunk_http_error(
153 response.status().as_u16(),
154 response.headers(),
155 body,
156 ))
157 }
158}
159#[derive(Debug)]
160struct GetChunkRequestSerializer;
161impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for GetChunkRequestSerializer {
162 #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
163 fn serialize_input(
164 &self,
165 input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
166 _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
167 ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
168 let input = input.downcast::<crate::operation::get_chunk::GetChunkInput>().expect("correct type");
169 let _header_serialization_settings = _cfg
170 .load::<crate::serialization_settings::HeaderSerializationSettings>()
171 .cloned()
172 .unwrap_or_default();
173 let mut request_builder = {
174 fn uri_base(
175 _input: &crate::operation::get_chunk::GetChunkInput,
176 output: &mut ::std::string::String,
177 ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
178 use ::std::fmt::Write as _;
179 let input_1 = &_input.storage_job_id;
180 let input_1 = input_1
181 .as_ref()
182 .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("storage_job_id", "cannot be empty or unset"))?;
183 let storage_job_id = ::aws_smithy_http::label::fmt_string(input_1, ::aws_smithy_http::label::EncodingStrategy::Default);
184 if storage_job_id.is_empty() {
185 return ::std::result::Result::Err(::aws_smithy_types::error::operation::BuildError::missing_field(
186 "storage_job_id",
187 "cannot be empty or unset",
188 ));
189 }
190 let input_2 = &_input.chunk_token;
191 let input_2 = input_2
192 .as_ref()
193 .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("chunk_token", "cannot be empty or unset"))?;
194 let chunk_token = ::aws_smithy_http::label::fmt_string(input_2, ::aws_smithy_http::label::EncodingStrategy::Default);
195 if chunk_token.is_empty() {
196 return ::std::result::Result::Err(::aws_smithy_types::error::operation::BuildError::missing_field(
197 "chunk_token",
198 "cannot be empty or unset",
199 ));
200 }
201 ::std::write!(
202 output,
203 "/restore-jobs/{StorageJobId}/chunk/{ChunkToken}",
204 StorageJobId = storage_job_id,
205 ChunkToken = chunk_token
206 )
207 .expect("formatting should succeed");
208 ::std::result::Result::Ok(())
209 }
210 #[allow(clippy::unnecessary_wraps)]
211 fn update_http_builder(
212 input: &crate::operation::get_chunk::GetChunkInput,
213 builder: ::http::request::Builder,
214 ) -> ::std::result::Result<::http::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
215 let mut uri = ::std::string::String::new();
216 uri_base(input, &mut uri)?;
217 ::std::result::Result::Ok(builder.method("GET").uri(uri))
218 }
219 let mut builder = update_http_builder(&input, ::http::request::Builder::new())?;
220 builder
221 };
222 let body = ::aws_smithy_types::body::SdkBody::from("");
223
224 ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
225 }
226}
227#[derive(Debug)]
228struct GetChunkEndpointParamsInterceptor;
229
230impl ::aws_smithy_runtime_api::client::interceptors::Intercept for GetChunkEndpointParamsInterceptor {
231 fn name(&self) -> &'static str {
232 "GetChunkEndpointParamsInterceptor"
233 }
234
235 fn read_before_execution(
236 &self,
237 context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
238 '_,
239 ::aws_smithy_runtime_api::client::interceptors::context::Input,
240 ::aws_smithy_runtime_api::client::interceptors::context::Output,
241 ::aws_smithy_runtime_api::client::interceptors::context::Error,
242 >,
243 cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
244 ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
245 let _input = context
246 .input()
247 .downcast_ref::<GetChunkInput>()
248 .ok_or("failed to downcast to GetChunkInput")?;
249
250 let params = crate::config::endpoint::Params::builder()
251 .set_region(cfg.load::<::aws_types::region::Region>().map(|r| r.as_ref().to_owned()))
252 .set_use_dual_stack(cfg.load::<::aws_types::endpoint_config::UseDualStack>().map(|ty| ty.0))
253 .set_use_fips(cfg.load::<::aws_types::endpoint_config::UseFips>().map(|ty| ty.0))
254 .set_endpoint(cfg.load::<::aws_types::endpoint_config::EndpointUrl>().map(|ty| ty.0.clone()))
255 .build()
256 .map_err(|err| {
257 ::aws_smithy_runtime_api::client::interceptors::error::ContextAttachedError::new("endpoint params could not be built", err)
258 })?;
259 cfg.interceptor_state()
260 .store_put(::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams::new(params));
261 ::std::result::Result::Ok(())
262 }
263}
264
265#[non_exhaustive]
267#[derive(::std::fmt::Debug)]
268pub enum GetChunkError {
269 #[allow(missing_docs)] AccessDeniedException(crate::types::error::AccessDeniedException),
271 IllegalArgumentException(crate::types::error::IllegalArgumentException),
273 KmsInvalidKeyUsageException(crate::types::error::KmsInvalidKeyUsageException),
275 ResourceNotFoundException(crate::types::error::ResourceNotFoundException),
277 RetryableException(crate::types::error::RetryableException),
279 ServiceInternalException(crate::types::error::ServiceInternalException),
281 ThrottlingException(crate::types::error::ThrottlingException),
283 #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
285 variable wildcard pattern and check `.code()`:
286 \
287 `err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
288 \
289 See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-GetChunkError) for what information is available for the error.")]
290 Unhandled(crate::error::sealed_unhandled::Unhandled),
291}
292impl GetChunkError {
293 pub fn unhandled(
295 err: impl ::std::convert::Into<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>>,
296 ) -> Self {
297 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
298 source: err.into(),
299 meta: ::std::default::Default::default(),
300 })
301 }
302
303 pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self {
305 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
306 source: err.clone().into(),
307 meta: err,
308 })
309 }
310 pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
315 match self {
316 Self::AccessDeniedException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
317 Self::IllegalArgumentException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
318 Self::KmsInvalidKeyUsageException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
319 Self::ResourceNotFoundException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
320 Self::RetryableException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
321 Self::ServiceInternalException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
322 Self::ThrottlingException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
323 Self::Unhandled(e) => &e.meta,
324 }
325 }
326 pub fn is_access_denied_exception(&self) -> bool {
328 matches!(self, Self::AccessDeniedException(_))
329 }
330 pub fn is_illegal_argument_exception(&self) -> bool {
332 matches!(self, Self::IllegalArgumentException(_))
333 }
334 pub fn is_kms_invalid_key_usage_exception(&self) -> bool {
336 matches!(self, Self::KmsInvalidKeyUsageException(_))
337 }
338 pub fn is_resource_not_found_exception(&self) -> bool {
340 matches!(self, Self::ResourceNotFoundException(_))
341 }
342 pub fn is_retryable_exception(&self) -> bool {
344 matches!(self, Self::RetryableException(_))
345 }
346 pub fn is_service_internal_exception(&self) -> bool {
348 matches!(self, Self::ServiceInternalException(_))
349 }
350 pub fn is_throttling_exception(&self) -> bool {
352 matches!(self, Self::ThrottlingException(_))
353 }
354}
355impl ::std::error::Error for GetChunkError {
356 fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
357 match self {
358 Self::AccessDeniedException(_inner) => ::std::option::Option::Some(_inner),
359 Self::IllegalArgumentException(_inner) => ::std::option::Option::Some(_inner),
360 Self::KmsInvalidKeyUsageException(_inner) => ::std::option::Option::Some(_inner),
361 Self::ResourceNotFoundException(_inner) => ::std::option::Option::Some(_inner),
362 Self::RetryableException(_inner) => ::std::option::Option::Some(_inner),
363 Self::ServiceInternalException(_inner) => ::std::option::Option::Some(_inner),
364 Self::ThrottlingException(_inner) => ::std::option::Option::Some(_inner),
365 Self::Unhandled(_inner) => ::std::option::Option::Some(&*_inner.source),
366 }
367 }
368}
369impl ::std::fmt::Display for GetChunkError {
370 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
371 match self {
372 Self::AccessDeniedException(_inner) => _inner.fmt(f),
373 Self::IllegalArgumentException(_inner) => _inner.fmt(f),
374 Self::KmsInvalidKeyUsageException(_inner) => _inner.fmt(f),
375 Self::ResourceNotFoundException(_inner) => _inner.fmt(f),
376 Self::RetryableException(_inner) => _inner.fmt(f),
377 Self::ServiceInternalException(_inner) => _inner.fmt(f),
378 Self::ThrottlingException(_inner) => _inner.fmt(f),
379 Self::Unhandled(_inner) => {
380 if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
381 write!(f, "unhandled error ({code})")
382 } else {
383 f.write_str("unhandled error")
384 }
385 }
386 }
387 }
388}
389impl ::aws_smithy_types::retry::ProvideErrorKind for GetChunkError {
390 fn code(&self) -> ::std::option::Option<&str> {
391 ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self)
392 }
393 fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> {
394 ::std::option::Option::None
395 }
396}
397impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for GetChunkError {
398 fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
399 match self {
400 Self::AccessDeniedException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
401 Self::IllegalArgumentException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
402 Self::KmsInvalidKeyUsageException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
403 Self::ResourceNotFoundException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
404 Self::RetryableException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
405 Self::ServiceInternalException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
406 Self::ThrottlingException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
407 Self::Unhandled(_inner) => &_inner.meta,
408 }
409 }
410}
411impl ::aws_smithy_runtime_api::client::result::CreateUnhandledError for GetChunkError {
412 fn create_unhandled_error(
413 source: ::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>,
414 meta: ::std::option::Option<::aws_smithy_types::error::ErrorMetadata>,
415 ) -> Self {
416 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
417 source,
418 meta: meta.unwrap_or_default(),
419 })
420 }
421}
422impl ::aws_types::request_id::RequestId for crate::operation::get_chunk::GetChunkError {
423 fn request_id(&self) -> Option<&str> {
424 self.meta().request_id()
425 }
426}
427
428pub use crate::operation::get_chunk::_get_chunk_output::GetChunkOutput;
429
430pub use crate::operation::get_chunk::_get_chunk_input::GetChunkInput;
431
432mod _get_chunk_input;
433
434mod _get_chunk_output;
435
436pub mod builders;