aws_sdk_workspaces/operation/
terminate_workspaces.rs1#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
4#[non_exhaustive]
5pub struct TerminateWorkspaces;
6impl TerminateWorkspaces {
7 pub fn new() -> Self {
9 Self
10 }
11 pub const INPUT_SCHEMA: &'static ::aws_smithy_schema::Schema<'static> = crate::operation::terminate_workspaces::TerminateWorkspacesInput::SCHEMA;
13 pub const OUTPUT_SCHEMA: &'static ::aws_smithy_schema::Schema<'static> =
15 crate::operation::terminate_workspaces::TerminateWorkspacesOutput::SCHEMA;
16 pub(crate) async fn orchestrate(
17 runtime_plugins: &::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
18 input: crate::operation::terminate_workspaces::TerminateWorkspacesInput,
19 ) -> ::std::result::Result<
20 crate::operation::terminate_workspaces::TerminateWorkspacesOutput,
21 ::aws_smithy_runtime_api::client::result::SdkError<
22 crate::operation::terminate_workspaces::TerminateWorkspacesError,
23 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
24 >,
25 > {
26 let map_err = |err: ::aws_smithy_runtime_api::client::result::SdkError<
27 ::aws_smithy_runtime_api::client::interceptors::context::Error,
28 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
29 >| {
30 err.map_service_error(|err| {
31 err.downcast::<crate::operation::terminate_workspaces::TerminateWorkspacesError>()
32 .expect("correct error type")
33 })
34 };
35 let context = Self::orchestrate_with_stop_point(runtime_plugins, input, ::aws_smithy_runtime::client::orchestrator::StopPoint::None)
36 .await
37 .map_err(map_err)?;
38 let output = context.finalize().map_err(map_err)?;
39 ::std::result::Result::Ok(
40 output
41 .downcast::<crate::operation::terminate_workspaces::TerminateWorkspacesOutput>()
42 .expect("correct output type"),
43 )
44 }
45
46 pub(crate) async fn orchestrate_with_stop_point(
47 runtime_plugins: &::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
48 input: crate::operation::terminate_workspaces::TerminateWorkspacesInput,
49 stop_point: ::aws_smithy_runtime::client::orchestrator::StopPoint,
50 ) -> ::std::result::Result<
51 ::aws_smithy_runtime_api::client::interceptors::context::InterceptorContext,
52 ::aws_smithy_runtime_api::client::result::SdkError<
53 ::aws_smithy_runtime_api::client::interceptors::context::Error,
54 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
55 >,
56 > {
57 let input = ::aws_smithy_runtime_api::client::interceptors::context::Input::erase(input);
58 use ::tracing::Instrument;
59 ::aws_smithy_runtime::client::orchestrator::invoke_with_stop_point("WorkSpaces", "TerminateWorkspaces", input, runtime_plugins, stop_point)
60 .instrument(::tracing::debug_span!(
63 "WorkSpaces.TerminateWorkspaces",
64 "rpc.service" = "WorkSpaces",
65 "rpc.method" = "TerminateWorkspaces",
66 "sdk_invocation_id" = ::fastrand::u32(1_000_000..10_000_000),
67 "rpc.system" = "aws-api",
68 ))
69 .await
70 }
71
72 pub(crate) fn operation_runtime_plugins(
73 client_runtime_plugins: ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
74 client_config: &crate::config::Config,
75 config_override: ::std::option::Option<crate::config::Builder>,
76 ) -> ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins {
77 let mut runtime_plugins = client_runtime_plugins.with_operation_plugin(Self::new());
78
79 if let ::std::option::Option::Some(config_override) = config_override {
80 for plugin in config_override.runtime_plugins.iter().cloned() {
81 runtime_plugins = runtime_plugins.with_operation_plugin(plugin);
82 }
83 runtime_plugins = runtime_plugins.with_operation_plugin(crate::config::ConfigOverrideRuntimePlugin::new(
84 config_override,
85 client_config.config.clone(),
86 &client_config.runtime_components,
87 ));
88 }
89 runtime_plugins
90 }
91}
92impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin for TerminateWorkspaces {
93 fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
94 let mut cfg = ::aws_smithy_types::config_bag::Layer::new("TerminateWorkspaces");
95
96 cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedRequestSerializer::new(
97 TerminateWorkspacesRequestSerializer,
98 ));
99 cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer::new(
100 TerminateWorkspacesResponseDeserializer,
101 ));
102
103 cfg.store_put(::aws_smithy_runtime_api::client::auth::AuthSchemeOptionResolverParams::new(
104 crate::config::auth::Params::builder()
105 .operation_name("TerminateWorkspaces")
106 .build()
107 .expect("required fields set"),
108 ));
109
110 cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::Metadata::new(
111 "TerminateWorkspaces",
112 "WorkSpaces",
113 ));
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("TerminateWorkspaces")
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 TerminateWorkspacesEndpointParamsInterceptor,
139 ))
140 .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::TransientErrorClassifier::<
141 crate::operation::terminate_workspaces::TerminateWorkspacesError,
142 >::new())
143 .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::ModeledAsRetryableClassifier::<
144 crate::operation::terminate_workspaces::TerminateWorkspacesError,
145 >::new())
146 .with_retry_classifier(::aws_runtime::retries::classifiers::AwsErrorCodeClassifier::<
147 crate::operation::terminate_workspaces::TerminateWorkspacesError,
148 >::new())
149 .with_retry_classifier(::aws_runtime::service_clock_skew::ServiceClockSkewClassifier::<
150 crate::operation::terminate_workspaces::TerminateWorkspacesError,
151 >::new());
152
153 ::std::borrow::Cow::Owned(rcb)
154 }
155}
156
157#[derive(Debug)]
158struct TerminateWorkspacesResponseDeserializer;
159impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for TerminateWorkspacesResponseDeserializer {
160 fn deserialize_nonstreaming_with_config(
161 &self,
162 response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
163 _cfg: &::aws_smithy_types::config_bag::ConfigBag,
164 ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
165 let (success, status) = (response.status().is_success(), response.status().as_u16());
166 #[allow(unused_variables)]
171 let body = response.body().bytes().expect("body loaded");
172 let headers = response.headers();
173 #[allow(unused_mut)]
174 let mut force_error = false;
175 ::tracing::debug!(request_id = ?::aws_types::request_id::RequestId::request_id(response));
176 if !success && status != 200 || force_error {
177 let protocol = _cfg
178 .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
179 .expect("a SharedClientProtocol is required");
180 #[allow(unused_mut)]
181 let mut generic_builder = protocol.parse_error_metadata(response, _cfg).map_err(|e| {
182 ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
183 })?;
184 generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, headers);
185 let generic = generic_builder.build();
186 ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::operation(
187 ::aws_smithy_runtime_api::client::interceptors::context::Error::erase(
188 crate::operation::terminate_workspaces::TerminateWorkspacesError::generic(generic),
189 ),
190 ))
191 } else {
192 let protocol = _cfg
193 .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
194 .expect("a SharedClientProtocol is required");
195 let mut deser = protocol
196 .deserialize_response(response, TerminateWorkspaces::OUTPUT_SCHEMA, _cfg)
197 .map_err(|e| {
198 ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
199 })?;
200 let _response_headers = headers;
204 #[allow(unused_mut)]
208 let mut output = <crate::operation::terminate_workspaces::builders::TerminateWorkspacesOutputBuilder>::default();
209 output.deserialize_members(&mut *deser).map_err(|e| {
210 ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
211 })?;
212 output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
213 let output = output.build();
214 ::std::result::Result::Ok(::aws_smithy_runtime_api::client::interceptors::context::Output::erase(output))
215 }
216 }
217}
218#[derive(Debug)]
219struct TerminateWorkspacesRequestSerializer;
220impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for TerminateWorkspacesRequestSerializer {
221 #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
222 fn serialize_input(
223 &self,
224 input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
225 _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
226 ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
227 let input = input
228 .downcast::<crate::operation::terminate_workspaces::TerminateWorkspacesInput>()
229 .expect("correct type");
230
231 let protocol = _cfg
232 .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
233 .expect("a SharedClientProtocol is required");
234 let mut request = protocol
235 .serialize_request(
236 &input,
237 TerminateWorkspaces::INPUT_SCHEMA,
238 "/service/WorkspacesService/operation/TerminateWorkspaces",
239 _cfg,
240 )
241 .map_err(::aws_smithy_runtime_api::box_error::BoxError::from)?;
242
243 return ::std::result::Result::Ok(request);
244 }
245}
246#[derive(Debug)]
247struct TerminateWorkspacesEndpointParamsInterceptor;
248
249#[::aws_smithy_runtime_api::client::interceptors::dyn_dispatch_hint]
250impl ::aws_smithy_runtime_api::client::interceptors::Intercept for TerminateWorkspacesEndpointParamsInterceptor {
251 fn name(&self) -> &'static str {
252 "TerminateWorkspacesEndpointParamsInterceptor"
253 }
254
255 fn read_before_execution(
256 &self,
257 context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
258 '_,
259 ::aws_smithy_runtime_api::client::interceptors::context::Input,
260 ::aws_smithy_runtime_api::client::interceptors::context::Output,
261 ::aws_smithy_runtime_api::client::interceptors::context::Error,
262 >,
263 cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
264 ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
265 let _input = context
266 .input()
267 .downcast_ref::<TerminateWorkspacesInput>()
268 .ok_or("failed to downcast to TerminateWorkspacesInput")?;
269
270 let params = crate::config::endpoint::Params::builder()
271 .set_region(cfg.load::<::aws_types::region::Region>().map(|r| r.as_ref().to_owned()))
272 .set_use_dual_stack(cfg.load::<::aws_types::endpoint_config::UseDualStack>().map(|ty| ty.0))
273 .set_use_fips(cfg.load::<::aws_types::endpoint_config::UseFips>().map(|ty| ty.0))
274 .set_endpoint(cfg.load::<::aws_types::endpoint_config::EndpointUrl>().map(|ty| ty.0.clone()))
275 .build()
276 .map_err(|err| {
277 ::aws_smithy_runtime_api::client::interceptors::error::ContextAttachedError::new("endpoint params could not be built", err)
278 })?;
279 cfg.interceptor_state()
280 .store_put(::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams::new(params));
281 ::std::result::Result::Ok(())
282 }
283}
284
285#[non_exhaustive]
290#[derive(::std::fmt::Debug)]
291pub enum TerminateWorkspacesError {
292 #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
294 variable wildcard pattern and check `.code()`:
295 \
296 `err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
297 \
298 See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-TerminateWorkspacesError) for what information is available for the error.")]
299 Unhandled(crate::error::sealed_unhandled::Unhandled),
300}
301impl TerminateWorkspacesError {
302 pub fn unhandled(
304 err: impl ::std::convert::Into<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>>,
305 ) -> Self {
306 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
307 source: err.into(),
308 meta: ::std::default::Default::default(),
309 })
310 }
311
312 pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self {
314 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
315 source: err.clone().into(),
316 meta: err,
317 })
318 }
319 pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
324 match self {
325 Self::Unhandled(e) => &e.meta,
326 }
327 }
328}
329impl ::std::error::Error for TerminateWorkspacesError {
330 fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
331 match self {
332 Self::Unhandled(_inner) => ::std::option::Option::Some(&*_inner.source),
333 }
334 }
335}
336impl ::std::fmt::Display for TerminateWorkspacesError {
337 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
338 match self {
339 Self::Unhandled(_inner) => {
340 if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
341 write!(f, "unhandled error ({code})")
342 } else {
343 f.write_str("unhandled error")
344 }
345 }
346 }
347 }
348}
349impl ::aws_smithy_types::retry::ProvideErrorKind for TerminateWorkspacesError {
350 fn code(&self) -> ::std::option::Option<&str> {
351 ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self)
352 }
353 fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> {
354 ::std::option::Option::None
355 }
356}
357impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for TerminateWorkspacesError {
358 fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
359 match self {
360 Self::Unhandled(_inner) => &_inner.meta,
361 }
362 }
363}
364impl ::aws_smithy_runtime_api::client::result::CreateUnhandledError for TerminateWorkspacesError {
365 fn create_unhandled_error(
366 source: ::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>,
367 meta: ::std::option::Option<::aws_smithy_types::error::ErrorMetadata>,
368 ) -> Self {
369 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
370 source,
371 meta: meta.unwrap_or_default(),
372 })
373 }
374}
375impl ::aws_types::request_id::RequestId for crate::operation::terminate_workspaces::TerminateWorkspacesError {
376 fn request_id(&self) -> Option<&str> {
377 self.meta().request_id()
378 }
379}
380
381pub use crate::operation::terminate_workspaces::_terminate_workspaces_input::TerminateWorkspacesInput;
382
383pub use crate::operation::terminate_workspaces::_terminate_workspaces_output::TerminateWorkspacesOutput;
384
385mod _terminate_workspaces_input;
386
387mod _terminate_workspaces_output;
388
389pub mod builders;