1#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
4#[non_exhaustive]
5pub struct CreateFileSystemFromBackup;
6impl CreateFileSystemFromBackup {
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::create_file_system_from_backup::CreateFileSystemFromBackupInput,
14 ) -> ::std::result::Result<
15 crate::operation::create_file_system_from_backup::CreateFileSystemFromBackupOutput,
16 ::aws_smithy_runtime_api::client::result::SdkError<
17 crate::operation::create_file_system_from_backup::CreateFileSystemFromBackupError,
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::create_file_system_from_backup::CreateFileSystemFromBackupError>()
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::create_file_system_from_backup::CreateFileSystemFromBackupOutput>()
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::create_file_system_from_backup::CreateFileSystemFromBackupInput,
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("FSx", "CreateFileSystemFromBackup", input, runtime_plugins, stop_point)
55 .instrument(::tracing::debug_span!(
58 "FSx.CreateFileSystemFromBackup",
59 "rpc.service" = "FSx",
60 "rpc.method" = "CreateFileSystemFromBackup",
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 runtime_plugins = runtime_plugins.with_operation_plugin(crate::client_idempotency_token::IdempotencyTokenRuntimePlugin::new(
74 |token_provider, input| {
75 let input: &mut crate::operation::create_file_system_from_backup::CreateFileSystemFromBackupInput =
76 input.downcast_mut().expect("correct type");
77 if input.client_request_token.is_none() {
78 input.client_request_token = ::std::option::Option::Some(token_provider.make_idempotency_token());
79 }
80 },
81 ));
82 if let ::std::option::Option::Some(config_override) = config_override {
83 for plugin in config_override.runtime_plugins.iter().cloned() {
84 runtime_plugins = runtime_plugins.with_operation_plugin(plugin);
85 }
86 runtime_plugins = runtime_plugins.with_operation_plugin(crate::config::ConfigOverrideRuntimePlugin::new(
87 config_override,
88 client_config.config.clone(),
89 &client_config.runtime_components,
90 ));
91 }
92 runtime_plugins
93 }
94}
95impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin for CreateFileSystemFromBackup {
96 fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
97 let mut cfg = ::aws_smithy_types::config_bag::Layer::new("CreateFileSystemFromBackup");
98
99 cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedRequestSerializer::new(
100 CreateFileSystemFromBackupRequestSerializer,
101 ));
102 cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer::new(
103 CreateFileSystemFromBackupResponseDeserializer,
104 ));
105
106 cfg.store_put(::aws_smithy_runtime_api::client::auth::AuthSchemeOptionResolverParams::new(
107 crate::config::auth::Params::builder()
108 .operation_name("CreateFileSystemFromBackup")
109 .build()
110 .expect("required fields set"),
111 ));
112
113 cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::SensitiveOutput);
114 cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::Metadata::new(
115 "CreateFileSystemFromBackup",
116 "FSx",
117 ));
118 let mut signing_options = ::aws_runtime::auth::SigningOptions::default();
119 signing_options.double_uri_encode = true;
120 signing_options.content_sha256_header = false;
121 signing_options.normalize_uri_path = true;
122 signing_options.payload_override = None;
123
124 cfg.store_put(::aws_runtime::auth::SigV4OperationSigningConfig {
125 signing_options,
126 ..::std::default::Default::default()
127 });
128
129 ::std::option::Option::Some(cfg.freeze())
130 }
131
132 fn runtime_components(
133 &self,
134 _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
135 ) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
136 #[allow(unused_mut)]
137 let mut rcb = ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder::new("CreateFileSystemFromBackup")
138 .with_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
139 ::aws_smithy_runtime::client::stalled_stream_protection::StalledStreamProtectionInterceptor::default(),
140 ))
141 .with_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
142 CreateFileSystemFromBackupEndpointParamsInterceptor,
143 ))
144 .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::TransientErrorClassifier::<
145 crate::operation::create_file_system_from_backup::CreateFileSystemFromBackupError,
146 >::new())
147 .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::ModeledAsRetryableClassifier::<
148 crate::operation::create_file_system_from_backup::CreateFileSystemFromBackupError,
149 >::new())
150 .with_retry_classifier(::aws_runtime::retries::classifiers::AwsErrorCodeClassifier::<
151 crate::operation::create_file_system_from_backup::CreateFileSystemFromBackupError,
152 >::new());
153
154 ::std::borrow::Cow::Owned(rcb)
155 }
156}
157
158#[derive(Debug)]
159struct CreateFileSystemFromBackupResponseDeserializer;
160impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for CreateFileSystemFromBackupResponseDeserializer {
161 fn deserialize_nonstreaming_with_config(
162 &self,
163 response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
164 _cfg: &::aws_smithy_types::config_bag::ConfigBag,
165 ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
166 let (success, status) = (response.status().is_success(), response.status().as_u16());
167 let headers = response.headers();
168 let body = response.body().bytes().expect("body loaded");
169 #[allow(unused_mut)]
170 let mut force_error = false;
171 ::tracing::debug!(request_id = ?::aws_types::request_id::RequestId::request_id(response));
172 let parse_result = if !success && status != 200 || force_error {
173 crate::protocol_serde::shape_create_file_system_from_backup::de_create_file_system_from_backup_http_error(status, headers, body)
174 } else {
175 crate::protocol_serde::shape_create_file_system_from_backup::de_create_file_system_from_backup_http_response(status, headers, body)
176 };
177 crate::protocol_serde::type_erase_result(parse_result)
178 }
179}
180#[derive(Debug)]
181struct CreateFileSystemFromBackupRequestSerializer;
182impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for CreateFileSystemFromBackupRequestSerializer {
183 #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
184 fn serialize_input(
185 &self,
186 input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
187 _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
188 ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
189 let input = input
190 .downcast::<crate::operation::create_file_system_from_backup::CreateFileSystemFromBackupInput>()
191 .expect("correct type");
192 let _header_serialization_settings = _cfg
193 .load::<crate::serialization_settings::HeaderSerializationSettings>()
194 .cloned()
195 .unwrap_or_default();
196 let mut request_builder = {
197 #[allow(clippy::uninlined_format_args)]
198 fn uri_base(
199 _input: &crate::operation::create_file_system_from_backup::CreateFileSystemFromBackupInput,
200 output: &mut ::std::string::String,
201 ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
202 use ::std::fmt::Write as _;
203 ::std::write!(output, "/").expect("formatting should succeed");
204 ::std::result::Result::Ok(())
205 }
206 #[allow(clippy::unnecessary_wraps)]
207 fn update_http_builder(
208 input: &crate::operation::create_file_system_from_backup::CreateFileSystemFromBackupInput,
209 builder: ::http_1x::request::Builder,
210 ) -> ::std::result::Result<::http_1x::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
211 let mut uri = ::std::string::String::new();
212 uri_base(input, &mut uri)?;
213 ::std::result::Result::Ok(builder.method("POST").uri(uri))
214 }
215 let mut builder = update_http_builder(&input, ::http_1x::request::Builder::new())?;
216 builder = _header_serialization_settings.set_default_header(builder, ::http_1x::header::CONTENT_TYPE, "application/x-amz-json-1.1");
217 builder = _header_serialization_settings.set_default_header(
218 builder,
219 ::http_1x::header::HeaderName::from_static("x-amz-target"),
220 "AWSSimbaAPIService_v20180301.CreateFileSystemFromBackup",
221 );
222 builder
223 };
224 let body = ::aws_smithy_types::body::SdkBody::from(
225 crate::protocol_serde::shape_create_file_system_from_backup::ser_create_file_system_from_backup_input(&input)?,
226 );
227 if let Some(content_length) = body.content_length() {
228 let content_length = content_length.to_string();
229 request_builder = _header_serialization_settings.set_default_header(request_builder, ::http_1x::header::CONTENT_LENGTH, &content_length);
230 }
231 ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
232 }
233}
234#[derive(Debug)]
235struct CreateFileSystemFromBackupEndpointParamsInterceptor;
236
237#[::aws_smithy_runtime_api::client::interceptors::dyn_dispatch_hint]
238impl ::aws_smithy_runtime_api::client::interceptors::Intercept for CreateFileSystemFromBackupEndpointParamsInterceptor {
239 fn name(&self) -> &'static str {
240 "CreateFileSystemFromBackupEndpointParamsInterceptor"
241 }
242
243 fn read_before_execution(
244 &self,
245 context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
246 '_,
247 ::aws_smithy_runtime_api::client::interceptors::context::Input,
248 ::aws_smithy_runtime_api::client::interceptors::context::Output,
249 ::aws_smithy_runtime_api::client::interceptors::context::Error,
250 >,
251 cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
252 ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
253 let _input = context
254 .input()
255 .downcast_ref::<CreateFileSystemFromBackupInput>()
256 .ok_or("failed to downcast to CreateFileSystemFromBackupInput")?;
257
258 let params = crate::config::endpoint::Params::builder()
259 .set_region(cfg.load::<::aws_types::region::Region>().map(|r| r.as_ref().to_owned()))
260 .set_use_dual_stack(cfg.load::<::aws_types::endpoint_config::UseDualStack>().map(|ty| ty.0))
261 .set_use_fips(cfg.load::<::aws_types::endpoint_config::UseFips>().map(|ty| ty.0))
262 .set_endpoint(cfg.load::<::aws_types::endpoint_config::EndpointUrl>().map(|ty| ty.0.clone()))
263 .build()
264 .map_err(|err| {
265 ::aws_smithy_runtime_api::client::interceptors::error::ContextAttachedError::new("endpoint params could not be built", err)
266 })?;
267 cfg.interceptor_state()
268 .store_put(::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams::new(params));
269 ::std::result::Result::Ok(())
270 }
271}
272
273#[non_exhaustive]
278#[derive(::std::fmt::Debug)]
279pub enum CreateFileSystemFromBackupError {
280 ActiveDirectoryError(crate::types::error::ActiveDirectoryError),
282 BackupNotFound(crate::types::error::BackupNotFound),
284 BadRequest(crate::types::error::BadRequest),
286 IncompatibleParameterError(crate::types::error::IncompatibleParameterError),
288 InternalServerError(crate::types::error::InternalServerError),
290 InvalidNetworkSettings(crate::types::error::InvalidNetworkSettings),
292 InvalidPerUnitStorageThroughput(crate::types::error::InvalidPerUnitStorageThroughput),
294 MissingFileSystemConfiguration(crate::types::error::MissingFileSystemConfiguration),
296 ServiceLimitExceeded(crate::types::error::ServiceLimitExceeded),
298 #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
300 variable wildcard pattern and check `.code()`:
301 \
302 `err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
303 \
304 See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-CreateFileSystemFromBackupError) for what information is available for the error.")]
305 Unhandled(crate::error::sealed_unhandled::Unhandled),
306}
307impl CreateFileSystemFromBackupError {
308 pub fn unhandled(
310 err: impl ::std::convert::Into<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>>,
311 ) -> Self {
312 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
313 source: err.into(),
314 meta: ::std::default::Default::default(),
315 })
316 }
317
318 pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self {
320 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
321 source: err.clone().into(),
322 meta: err,
323 })
324 }
325 pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
330 match self {
331 Self::ActiveDirectoryError(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
332 Self::BackupNotFound(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
333 Self::BadRequest(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
334 Self::IncompatibleParameterError(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
335 Self::InternalServerError(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
336 Self::InvalidNetworkSettings(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
337 Self::InvalidPerUnitStorageThroughput(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
338 Self::MissingFileSystemConfiguration(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
339 Self::ServiceLimitExceeded(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
340 Self::Unhandled(e) => &e.meta,
341 }
342 }
343 pub fn is_active_directory_error(&self) -> bool {
345 matches!(self, Self::ActiveDirectoryError(_))
346 }
347 pub fn is_backup_not_found(&self) -> bool {
349 matches!(self, Self::BackupNotFound(_))
350 }
351 pub fn is_bad_request(&self) -> bool {
353 matches!(self, Self::BadRequest(_))
354 }
355 pub fn is_incompatible_parameter_error(&self) -> bool {
357 matches!(self, Self::IncompatibleParameterError(_))
358 }
359 pub fn is_internal_server_error(&self) -> bool {
361 matches!(self, Self::InternalServerError(_))
362 }
363 pub fn is_invalid_network_settings(&self) -> bool {
365 matches!(self, Self::InvalidNetworkSettings(_))
366 }
367 pub fn is_invalid_per_unit_storage_throughput(&self) -> bool {
369 matches!(self, Self::InvalidPerUnitStorageThroughput(_))
370 }
371 pub fn is_missing_file_system_configuration(&self) -> bool {
373 matches!(self, Self::MissingFileSystemConfiguration(_))
374 }
375 pub fn is_service_limit_exceeded(&self) -> bool {
377 matches!(self, Self::ServiceLimitExceeded(_))
378 }
379}
380impl ::std::error::Error for CreateFileSystemFromBackupError {
381 fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
382 match self {
383 Self::ActiveDirectoryError(_inner) => ::std::option::Option::Some(_inner),
384 Self::BackupNotFound(_inner) => ::std::option::Option::Some(_inner),
385 Self::BadRequest(_inner) => ::std::option::Option::Some(_inner),
386 Self::IncompatibleParameterError(_inner) => ::std::option::Option::Some(_inner),
387 Self::InternalServerError(_inner) => ::std::option::Option::Some(_inner),
388 Self::InvalidNetworkSettings(_inner) => ::std::option::Option::Some(_inner),
389 Self::InvalidPerUnitStorageThroughput(_inner) => ::std::option::Option::Some(_inner),
390 Self::MissingFileSystemConfiguration(_inner) => ::std::option::Option::Some(_inner),
391 Self::ServiceLimitExceeded(_inner) => ::std::option::Option::Some(_inner),
392 Self::Unhandled(_inner) => ::std::option::Option::Some(&*_inner.source),
393 }
394 }
395}
396impl ::std::fmt::Display for CreateFileSystemFromBackupError {
397 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
398 match self {
399 Self::ActiveDirectoryError(_inner) => _inner.fmt(f),
400 Self::BackupNotFound(_inner) => _inner.fmt(f),
401 Self::BadRequest(_inner) => _inner.fmt(f),
402 Self::IncompatibleParameterError(_inner) => _inner.fmt(f),
403 Self::InternalServerError(_inner) => _inner.fmt(f),
404 Self::InvalidNetworkSettings(_inner) => _inner.fmt(f),
405 Self::InvalidPerUnitStorageThroughput(_inner) => _inner.fmt(f),
406 Self::MissingFileSystemConfiguration(_inner) => _inner.fmt(f),
407 Self::ServiceLimitExceeded(_inner) => _inner.fmt(f),
408 Self::Unhandled(_inner) => {
409 if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
410 write!(f, "unhandled error ({code})")
411 } else {
412 f.write_str("unhandled error")
413 }
414 }
415 }
416 }
417}
418impl ::aws_smithy_types::retry::ProvideErrorKind for CreateFileSystemFromBackupError {
419 fn code(&self) -> ::std::option::Option<&str> {
420 ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self)
421 }
422 fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> {
423 ::std::option::Option::None
424 }
425}
426impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for CreateFileSystemFromBackupError {
427 fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
428 match self {
429 Self::ActiveDirectoryError(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
430 Self::BackupNotFound(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
431 Self::BadRequest(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
432 Self::IncompatibleParameterError(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
433 Self::InternalServerError(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
434 Self::InvalidNetworkSettings(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
435 Self::InvalidPerUnitStorageThroughput(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
436 Self::MissingFileSystemConfiguration(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
437 Self::ServiceLimitExceeded(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
438 Self::Unhandled(_inner) => &_inner.meta,
439 }
440 }
441}
442impl ::aws_smithy_runtime_api::client::result::CreateUnhandledError for CreateFileSystemFromBackupError {
443 fn create_unhandled_error(
444 source: ::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>,
445 meta: ::std::option::Option<::aws_smithy_types::error::ErrorMetadata>,
446 ) -> Self {
447 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
448 source,
449 meta: meta.unwrap_or_default(),
450 })
451 }
452}
453impl ::aws_types::request_id::RequestId for crate::operation::create_file_system_from_backup::CreateFileSystemFromBackupError {
454 fn request_id(&self) -> Option<&str> {
455 self.meta().request_id()
456 }
457}
458
459pub use crate::operation::create_file_system_from_backup::_create_file_system_from_backup_input::CreateFileSystemFromBackupInput;
460
461pub use crate::operation::create_file_system_from_backup::_create_file_system_from_backup_output::CreateFileSystemFromBackupOutput;
462
463mod _create_file_system_from_backup_input;
464
465mod _create_file_system_from_backup_output;
466
467pub mod builders;