Skip to main content

aws_sdk_workspaces/operation/
terminate_workspaces.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2/// Orchestration and serialization glue logic for `TerminateWorkspaces`.
3#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
4#[non_exhaustive]
5pub struct TerminateWorkspaces;
6impl TerminateWorkspaces {
7    /// Creates a new `TerminateWorkspaces`
8    pub fn new() -> Self {
9        Self
10    }
11    /// The schema for this operation's input shape.
12    pub const INPUT_SCHEMA: &'static ::aws_smithy_schema::Schema<'static> = crate::operation::terminate_workspaces::TerminateWorkspacesInput::SCHEMA;
13    /// The schema for this operation's output shape.
14    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            // Create a parent span for the entire operation. Includes a random, internal-only,
61            // seven-digit ID for the operation orchestration so that it can be correlated in the logs.
62            .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        // Load body and headers BEFORE BeforeParseResponse so customizations
167        // (e.g., S3's `body_is_error` check that detects errors returned with
168        // HTTP 200) can inspect them. The legacy non-streaming path also
169        // loads `body` before firing this hook.
170        #[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            // `headers` is already in scope from the top of the function; alias it as
201            // `_response_headers` so MutateOutput customizations have a stable name to
202            // read from.
203            let _response_headers = headers;
204            // `mut` is required because `deserialize_members` and the `MutateOutput`
205            // builder setters take `&mut self`. Marked `allow(unused_mut)` because an
206            // empty output has no members and no customizations to run.
207            #[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(&input, TerminateWorkspaces::INPUT_SCHEMA, "/", _cfg)
236            .map_err(::aws_smithy_runtime_api::box_error::BoxError::from)?;
237
238        return ::std::result::Result::Ok(request);
239    }
240}
241#[derive(Debug)]
242struct TerminateWorkspacesEndpointParamsInterceptor;
243
244#[::aws_smithy_runtime_api::client::interceptors::dyn_dispatch_hint]
245impl ::aws_smithy_runtime_api::client::interceptors::Intercept for TerminateWorkspacesEndpointParamsInterceptor {
246    fn name(&self) -> &'static str {
247        "TerminateWorkspacesEndpointParamsInterceptor"
248    }
249
250    fn read_before_execution(
251        &self,
252        context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
253            '_,
254            ::aws_smithy_runtime_api::client::interceptors::context::Input,
255            ::aws_smithy_runtime_api::client::interceptors::context::Output,
256            ::aws_smithy_runtime_api::client::interceptors::context::Error,
257        >,
258        cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
259    ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
260        let _input = context
261            .input()
262            .downcast_ref::<TerminateWorkspacesInput>()
263            .ok_or("failed to downcast to TerminateWorkspacesInput")?;
264
265        let params = crate::config::endpoint::Params::builder()
266            .set_region(cfg.load::<::aws_types::region::Region>().map(|r| r.as_ref().to_owned()))
267            .set_use_dual_stack(cfg.load::<::aws_types::endpoint_config::UseDualStack>().map(|ty| ty.0))
268            .set_use_fips(cfg.load::<::aws_types::endpoint_config::UseFips>().map(|ty| ty.0))
269            .set_endpoint(cfg.load::<::aws_types::endpoint_config::EndpointUrl>().map(|ty| ty.0.clone()))
270            .build()
271            .map_err(|err| {
272                ::aws_smithy_runtime_api::client::interceptors::error::ContextAttachedError::new("endpoint params could not be built", err)
273            })?;
274        cfg.interceptor_state()
275            .store_put(::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams::new(params));
276        ::std::result::Result::Ok(())
277    }
278}
279
280// The get_* functions below are generated from JMESPath expressions in the
281// operationContextParams trait. They target the operation's input shape.
282
283/// Error type for the `TerminateWorkspacesError` operation.
284#[non_exhaustive]
285#[derive(::std::fmt::Debug)]
286pub enum TerminateWorkspacesError {
287    /// An unexpected error occurred (e.g., invalid JSON returned by the service or an unknown error code).
288    #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
289    variable wildcard pattern and check `.code()`:
290     \
291    &nbsp;&nbsp;&nbsp;`err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
292     \
293    See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-TerminateWorkspacesError) for what information is available for the error.")]
294    Unhandled(crate::error::sealed_unhandled::Unhandled),
295}
296impl TerminateWorkspacesError {
297    /// Creates the `TerminateWorkspacesError::Unhandled` variant from any error type.
298    pub fn unhandled(
299        err: impl ::std::convert::Into<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>>,
300    ) -> Self {
301        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
302            source: err.into(),
303            meta: ::std::default::Default::default(),
304        })
305    }
306
307    /// Creates the `TerminateWorkspacesError::Unhandled` variant from an [`ErrorMetadata`](::aws_smithy_types::error::ErrorMetadata).
308    pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self {
309        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
310            source: err.clone().into(),
311            meta: err,
312        })
313    }
314    ///
315    /// Returns error metadata, which includes the error code, message,
316    /// request ID, and potentially additional information.
317    ///
318    pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
319        match self {
320            Self::Unhandled(e) => &e.meta,
321        }
322    }
323}
324impl ::std::error::Error for TerminateWorkspacesError {
325    fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
326        match self {
327            Self::Unhandled(_inner) => ::std::option::Option::Some(&*_inner.source),
328        }
329    }
330}
331impl ::std::fmt::Display for TerminateWorkspacesError {
332    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
333        match self {
334            Self::Unhandled(_inner) => {
335                if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
336                    write!(f, "unhandled error ({code})")
337                } else {
338                    f.write_str("unhandled error")
339                }
340            }
341        }
342    }
343}
344impl ::aws_smithy_types::retry::ProvideErrorKind for TerminateWorkspacesError {
345    fn code(&self) -> ::std::option::Option<&str> {
346        ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self)
347    }
348    fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> {
349        ::std::option::Option::None
350    }
351}
352impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for TerminateWorkspacesError {
353    fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
354        match self {
355            Self::Unhandled(_inner) => &_inner.meta,
356        }
357    }
358}
359impl ::aws_smithy_runtime_api::client::result::CreateUnhandledError for TerminateWorkspacesError {
360    fn create_unhandled_error(
361        source: ::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>,
362        meta: ::std::option::Option<::aws_smithy_types::error::ErrorMetadata>,
363    ) -> Self {
364        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
365            source,
366            meta: meta.unwrap_or_default(),
367        })
368    }
369}
370impl ::aws_types::request_id::RequestId for crate::operation::terminate_workspaces::TerminateWorkspacesError {
371    fn request_id(&self) -> Option<&str> {
372        self.meta().request_id()
373    }
374}
375
376pub use crate::operation::terminate_workspaces::_terminate_workspaces_input::TerminateWorkspacesInput;
377
378pub use crate::operation::terminate_workspaces::_terminate_workspaces_output::TerminateWorkspacesOutput;
379
380mod _terminate_workspaces_input;
381
382mod _terminate_workspaces_output;
383
384/// Builders
385pub mod builders;