aws_sdk_dynamodb/operation/
import_table.rs1#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
4#[non_exhaustive]
5pub struct ImportTable;
6impl ImportTable {
7 pub fn new() -> Self {
9 Self
10 }
11 pub const INPUT_SCHEMA: &'static ::aws_smithy_schema::Schema = crate::operation::import_table::ImportTableInput::SCHEMA;
13 pub const OUTPUT_SCHEMA: &'static ::aws_smithy_schema::Schema = crate::operation::import_table::ImportTableOutput::SCHEMA;
15 pub(crate) async fn orchestrate(
16 runtime_plugins: &::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
17 input: crate::operation::import_table::ImportTableInput,
18 ) -> ::std::result::Result<crate::operation::import_table::ImportTableOutput, ::aws_smithy_runtime_api::client::result::SdkError<crate::operation::import_table::ImportTableError, ::aws_smithy_runtime_api::client::orchestrator::HttpResponse>> {
19 let map_err = |err: ::aws_smithy_runtime_api::client::result::SdkError<::aws_smithy_runtime_api::client::interceptors::context::Error, ::aws_smithy_runtime_api::client::orchestrator::HttpResponse>| {
20 err.map_service_error(|err| {
21 err.downcast::<crate::operation::import_table::ImportTableError>().expect("correct error type")
22 })
23 };
24 let context = Self::orchestrate_with_stop_point(runtime_plugins, input, ::aws_smithy_runtime::client::orchestrator::StopPoint::None)
25 .await
26 .map_err(map_err)?;
27 let output = context.finalize().map_err(map_err)?;
28 ::std::result::Result::Ok(output.downcast::<crate::operation::import_table::ImportTableOutput>().expect("correct output type"))
29 }
30
31 pub(crate) async fn orchestrate_with_stop_point(
32 runtime_plugins: &::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
33 input: crate::operation::import_table::ImportTableInput,
34 stop_point: ::aws_smithy_runtime::client::orchestrator::StopPoint,
35 ) -> ::std::result::Result<::aws_smithy_runtime_api::client::interceptors::context::InterceptorContext, ::aws_smithy_runtime_api::client::result::SdkError<::aws_smithy_runtime_api::client::interceptors::context::Error, ::aws_smithy_runtime_api::client::orchestrator::HttpResponse>> {
36 let input = ::aws_smithy_runtime_api::client::interceptors::context::Input::erase(input);
37 use ::tracing::Instrument;
38 ::aws_smithy_runtime::client::orchestrator::invoke_with_stop_point(
39 "DynamoDB",
40 "ImportTable",
41 input,
42 runtime_plugins,
43 stop_point
44 )
45 .instrument(::tracing::debug_span!(
48 "DynamoDB.ImportTable",
49 "rpc.service" = "DynamoDB",
50 "rpc.method" = "ImportTable",
51 "sdk_invocation_id" = ::fastrand::u32(1_000_000..10_000_000),
52 "rpc.system" = "aws-api",
53 ))
54 .await
55 }
56
57 pub(crate) fn operation_runtime_plugins(
58 client_runtime_plugins: ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
59 client_config: &crate::config::Config,
60 config_override: ::std::option::Option<crate::config::Builder>,
61 ) -> ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins {
62 let mut runtime_plugins = client_runtime_plugins.with_operation_plugin(Self::new());
63 runtime_plugins = runtime_plugins
64 .with_operation_plugin(crate::client_idempotency_token::IdempotencyTokenRuntimePlugin::new(|token_provider, input| {
65 let input: &mut crate::operation::import_table::ImportTableInput = input.downcast_mut().expect("correct type");
66 if input.client_token.is_none() {
67 input.client_token = ::std::option::Option::Some(token_provider.make_idempotency_token());
68 }
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(
75 crate::config::ConfigOverrideRuntimePlugin::new(config_override, client_config.config.clone(), &client_config.runtime_components)
76 );
77 }
78 runtime_plugins
79 }
80}
81impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin for ImportTable {
82 fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
83 let mut cfg = ::aws_smithy_types::config_bag::Layer::new("ImportTable");
84
85 cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedRequestSerializer::new(ImportTableRequestSerializer));
86 cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer::new(ImportTableResponseDeserializer));
87
88 cfg.store_put(::aws_smithy_runtime_api::client::auth::AuthSchemeOptionResolverParams::new(
89 crate::config::auth::Params::builder()
90 .operation_name("ImportTable")
91 .build()
92 .expect("required fields set")
93 ));
94
95 cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::Metadata::new(
96 "ImportTable",
97 "DynamoDB",
98 ));
99let mut signing_options = ::aws_runtime::auth::SigningOptions::default();
100 signing_options.double_uri_encode = true;
101 signing_options.content_sha256_header = false;
102 signing_options.normalize_uri_path = true;
103 signing_options.payload_override = None;
104
105 cfg.store_put(::aws_runtime::auth::SigV4OperationSigningConfig {
106 signing_options,
107 ..::std::default::Default::default()
108 });
109
110 ::std::option::Option::Some(cfg.freeze())
111 }
112
113 fn runtime_components(&self, _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
114 #[allow(unused_mut)]
115 let mut rcb = ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder::new("ImportTable")
116 .with_interceptor(::aws_smithy_runtime::client::stalled_stream_protection::StalledStreamProtectionInterceptor::default())
117.with_interceptor(ImportTableEndpointParamsInterceptor)
118 .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::TransientErrorClassifier::<crate::operation::import_table::ImportTableError>::new())
119.with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::ModeledAsRetryableClassifier::<crate::operation::import_table::ImportTableError>::new())
120.with_retry_classifier(::aws_runtime::retries::classifiers::AwsErrorCodeClassifier::<crate::operation::import_table::ImportTableError>::new());
121
122 ::std::borrow::Cow::Owned(rcb)
123 }
124 }
125
126
127#[derive(Debug)]
128 struct ImportTableResponseDeserializer;
129 impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for ImportTableResponseDeserializer {
130
131
132 fn deserialize_nonstreaming_with_config(&self, response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse, _cfg: &::aws_smithy_types::config_bag::ConfigBag) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
133 let (success, status) = (response.status().is_success(), response.status().as_u16());
134 #[allow(unused_mut)]
135 let mut force_error = false;
136 ::tracing::debug!(request_id = ?::aws_types::request_id::RequestId::request_id(response));
137 if !success && status != 200 || force_error {
138 let headers = response.headers();
139 let body = response.body().bytes().expect("body loaded");
140#[allow(unused_mut)]
141 let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(status, headers, body)
142 .map_err(|e| ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e)))?;
143 generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, headers);
144 let generic = generic_builder.build();
145let error_code = match generic.code() {
146 ::std::option::Option::Some(code) => code,
147 ::std::option::Option::None => return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(crate::operation::import_table::ImportTableError::unhandled(generic)))),
148 };
149 let _error_message = generic.message().map(|msg| msg.to_owned());
150 let protocol = _cfg.load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
151 .expect("a SharedClientProtocol is required");
152let err = match error_code {
153"ImportConflictException" => crate::operation::import_table::ImportTableError::ImportConflictException({
154let mut tmp = match protocol.deserialize_response(response, crate::types::error::ImportConflictException::SCHEMA, _cfg)
155 .and_then(|mut deser| crate::types::error::ImportConflictException::deserialize_with_response(&mut *deser, response.headers(), response.status().into(), body))
156 {
157 ::std::result::Result::Ok(val) => val,
158 ::std::result::Result::Err(e) => return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))),
159 };
160 tmp.meta = generic;
161if tmp.message.is_none() {
162 tmp.message = _error_message;
163 }
164tmp
165}),
166"LimitExceededException" => crate::operation::import_table::ImportTableError::LimitExceededException({
167let mut tmp = match protocol.deserialize_response(response, crate::types::error::LimitExceededException::SCHEMA, _cfg)
168 .and_then(|mut deser| crate::types::error::LimitExceededException::deserialize_with_response(&mut *deser, response.headers(), response.status().into(), body))
169 {
170 ::std::result::Result::Ok(val) => val,
171 ::std::result::Result::Err(e) => return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))),
172 };
173 tmp.meta = generic;
174if tmp.message.is_none() {
175 tmp.message = _error_message;
176 }
177tmp
178}),
179"ResourceInUseException" => crate::operation::import_table::ImportTableError::ResourceInUseException({
180let mut tmp = match protocol.deserialize_response(response, crate::types::error::ResourceInUseException::SCHEMA, _cfg)
181 .and_then(|mut deser| crate::types::error::ResourceInUseException::deserialize_with_response(&mut *deser, response.headers(), response.status().into(), body))
182 {
183 ::std::result::Result::Ok(val) => val,
184 ::std::result::Result::Err(e) => return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))),
185 };
186 tmp.meta = generic;
187if tmp.message.is_none() {
188 tmp.message = _error_message;
189 }
190tmp
191}),
192_ => crate::operation::import_table::ImportTableError::generic(generic)
193};
194 ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::operation(::aws_smithy_runtime_api::client::interceptors::context::Error::erase(err)))
195} else {
196 let protocol = _cfg.load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
197 .expect("a SharedClientProtocol is required");
198 let mut deser = protocol.deserialize_response(response, ImportTable::OUTPUT_SCHEMA, _cfg)
199 .map_err(|e| ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e)))?;
200 let body = response.body().bytes().expect("body loaded");
201 let output = crate::operation::import_table::ImportTableOutput::deserialize_with_response(
202 &mut *deser,
203 response.headers(),
204 response.status().into(),
205 body,
206 ).map_err(|e| ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e)))?;
207 ::std::result::Result::Ok(::aws_smithy_runtime_api::client::interceptors::context::Output::erase(output))
208 }
209 }
210 }
211#[derive(Debug)]
212 struct ImportTableRequestSerializer;
213 impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for ImportTableRequestSerializer {
214 #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
215 fn serialize_input(&self, input: ::aws_smithy_runtime_api::client::interceptors::context::Input, _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
216 let input = input.downcast::<crate::operation::import_table::ImportTableInput>().expect("correct type");
217 let protocol = _cfg.load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
218 .expect("a SharedClientProtocol is required");
219 let mut request = protocol.serialize_request(
220 &input, ImportTable::INPUT_SCHEMA, "", _cfg,
221 ).map_err(::aws_smithy_runtime_api::box_error::BoxError::from)?;
222
223 return ::std::result::Result::Ok(request);
224 }
225 }
226#[derive(Debug)]
227 struct ImportTableEndpointParamsInterceptor;
228
229 impl ::aws_smithy_runtime_api::client::interceptors::Intercept for ImportTableEndpointParamsInterceptor {
230 fn name(&self) -> &'static str {
231 "ImportTableEndpointParamsInterceptor"
232 }
233
234 fn read_before_execution(
235 &self,
236 context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<'_, ::aws_smithy_runtime_api::client::interceptors::context::Input, ::aws_smithy_runtime_api::client::interceptors::context::Output, ::aws_smithy_runtime_api::client::interceptors::context::Error>,
237 cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
238 ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
239 let _input = context.input()
240 .downcast_ref::<ImportTableInput>()
241 .ok_or("failed to downcast to ImportTableInput")?;
242
243
244
245 let params = crate::config::endpoint::Params::builder()
246 .set_region(cfg.load::<::aws_types::region::Region>().map(|r|r.as_ref().to_owned()))
247.set_use_dual_stack(cfg.load::<::aws_types::endpoint_config::UseDualStack>().map(|ty| ty.0))
248.set_use_fips(cfg.load::<::aws_types::endpoint_config::UseFips>().map(|ty| ty.0))
249.set_endpoint(cfg.load::<::aws_types::endpoint_config::EndpointUrl>().map(|ty| ty.0.clone()))
250.set_account_id_endpoint_mode(::std::option::Option::Some(cfg.load::<::aws_types::endpoint_config::AccountIdEndpointMode>().cloned().unwrap_or_default().to_string()))
251.set_resource_arn(get_resource_arn(_input).cloned())
252 .build()
253 .map_err(|err| ::aws_smithy_runtime_api::client::interceptors::error::ContextAttachedError::new("endpoint params could not be built", err))?;
254 cfg.interceptor_state().store_put(::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams::new(params));
255 ::std::result::Result::Ok(())
256 }
257 }
258
259 fn get_resource_arn(input: &crate::operation::import_table::ImportTableInput) -> Option<&::std::string::String> {
264 let _fld_1 = input.table_creation_parameters.as_ref()?;
265 let _fld_2 = &_fld_1.table_name;
266 Some(_fld_2)
267}
268
269#[non_exhaustive]
271#[derive(::std::fmt::Debug)]
272pub enum ImportTableError {
273 ImportConflictException(crate::types::error::ImportConflictException),
275 LimitExceededException(crate::types::error::LimitExceededException),
283 ResourceInUseException(crate::types::error::ResourceInUseException),
294 #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
296 variable wildcard pattern and check `.code()`:
297 \
298 `err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
299 \
300 See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-ImportTableError) for what information is available for the error.")]
301 Unhandled(crate::error::sealed_unhandled::Unhandled),
302}
303impl ImportTableError {
304 pub fn unhandled(err: impl ::std::convert::Into<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>>) -> Self {
306 Self::Unhandled(crate::error::sealed_unhandled::Unhandled { source: err.into(), meta: ::std::default::Default::default() })
307 }
308
309 pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self {
311 Self::Unhandled(crate::error::sealed_unhandled::Unhandled { source: err.clone().into(), meta: err })
312 }
313 pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
318 match self {
319 Self::ImportConflictException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
320 Self::LimitExceededException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
321 Self::ResourceInUseException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
322 Self::Unhandled(e) => &e.meta,
323 }
324 }
325 pub fn is_import_conflict_exception(&self) -> bool {
327 matches!(self, Self::ImportConflictException(_))
328 }
329 pub fn is_limit_exceeded_exception(&self) -> bool {
331 matches!(self, Self::LimitExceededException(_))
332 }
333 pub fn is_resource_in_use_exception(&self) -> bool {
335 matches!(self, Self::ResourceInUseException(_))
336 }
337}
338impl ::std::error::Error for ImportTableError {
339 fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
340 match self {
341 Self::ImportConflictException(_inner) =>
342 ::std::option::Option::Some(_inner)
343 ,
344 Self::LimitExceededException(_inner) =>
345 ::std::option::Option::Some(_inner)
346 ,
347 Self::ResourceInUseException(_inner) =>
348 ::std::option::Option::Some(_inner)
349 ,
350 Self::Unhandled(_inner) => {
351 ::std::option::Option::Some(&*_inner.source)
352 }
353 }
354 }
355}
356impl ::std::fmt::Display for ImportTableError {
357 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
358 match self {
359 Self::ImportConflictException(_inner) =>
360 _inner.fmt(f)
361 ,
362 Self::LimitExceededException(_inner) =>
363 _inner.fmt(f)
364 ,
365 Self::ResourceInUseException(_inner) =>
366 _inner.fmt(f)
367 ,
368 Self::Unhandled(_inner) => {
369 if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
370 write!(f, "unhandled error ({code})")
371 } else {
372 f.write_str("unhandled error")
373 }
374 }
375 }
376 }
377}
378impl ::aws_smithy_types::retry::ProvideErrorKind for ImportTableError {
379 fn code(&self) -> ::std::option::Option<&str> {
380 ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self)
381 }
382 fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> {
383 ::std::option::Option::None
384 }
385}
386impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for ImportTableError {
387 fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
388 match self {
389 Self::ImportConflictException(_inner) =>
390 ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner)
391 ,
392 Self::LimitExceededException(_inner) =>
393 ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner)
394 ,
395 Self::ResourceInUseException(_inner) =>
396 ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner)
397 ,
398 Self::Unhandled(_inner) => {
399 &_inner.meta
400 }
401 }
402 }
403}
404impl ::aws_smithy_runtime_api::client::result::CreateUnhandledError for ImportTableError {
405 fn create_unhandled_error(
406 source: ::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>,
407 meta: ::std::option::Option<::aws_smithy_types::error::ErrorMetadata>
408 ) -> Self {
409 Self::Unhandled(crate::error::sealed_unhandled::Unhandled { source, meta: meta.unwrap_or_default() })
410 }
411}
412impl ::aws_types::request_id::RequestId for crate::operation::import_table::ImportTableError {
413 fn request_id(&self) -> Option<&str> {
414 self.meta().request_id()
415 }
416 }
417
418pub use crate::operation::import_table::_import_table_input::ImportTableInput;
419
420pub use crate::operation::import_table::_import_table_output::ImportTableOutput;
421
422mod _import_table_input;
423
424mod _import_table_output;
425
426pub mod builders;
428