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