aws_sdk_datazone/operation/
get_rule.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2/// Orchestration and serialization glue logic for `GetRule`.
3#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
4#[non_exhaustive]
5pub struct GetRule;
6impl GetRule {
7    /// Creates a new `GetRule`
8    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::get_rule::GetRuleInput,
14    ) -> ::std::result::Result<
15        crate::operation::get_rule::GetRuleOutput,
16        ::aws_smithy_runtime_api::client::result::SdkError<
17            crate::operation::get_rule::GetRuleError,
18            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
19        >,
20    > {
21        let map_err =
22            |err: ::aws_smithy_runtime_api::client::result::SdkError<
23                ::aws_smithy_runtime_api::client::interceptors::context::Error,
24                ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
25            >| { err.map_service_error(|err| err.downcast::<crate::operation::get_rule::GetRuleError>().expect("correct error type")) };
26        let context = Self::orchestrate_with_stop_point(runtime_plugins, input, ::aws_smithy_runtime::client::orchestrator::StopPoint::None)
27            .await
28            .map_err(map_err)?;
29        let output = context.finalize().map_err(map_err)?;
30        ::std::result::Result::Ok(
31            output
32                .downcast::<crate::operation::get_rule::GetRuleOutput>()
33                .expect("correct output type"),
34        )
35    }
36
37    pub(crate) async fn orchestrate_with_stop_point(
38        runtime_plugins: &::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
39        input: crate::operation::get_rule::GetRuleInput,
40        stop_point: ::aws_smithy_runtime::client::orchestrator::StopPoint,
41    ) -> ::std::result::Result<
42        ::aws_smithy_runtime_api::client::interceptors::context::InterceptorContext,
43        ::aws_smithy_runtime_api::client::result::SdkError<
44            ::aws_smithy_runtime_api::client::interceptors::context::Error,
45            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
46        >,
47    > {
48        let input = ::aws_smithy_runtime_api::client::interceptors::context::Input::erase(input);
49        use ::tracing::Instrument;
50        ::aws_smithy_runtime::client::orchestrator::invoke_with_stop_point("DataZone", "GetRule", input, runtime_plugins, stop_point)
51            // Create a parent span for the entire operation. Includes a random, internal-only,
52            // seven-digit ID for the operation orchestration so that it can be correlated in the logs.
53            .instrument(::tracing::debug_span!(
54                "DataZone.GetRule",
55                "rpc.service" = "DataZone",
56                "rpc.method" = "GetRule",
57                "sdk_invocation_id" = ::fastrand::u32(1_000_000..10_000_000),
58                "rpc.system" = "aws-api",
59            ))
60            .await
61    }
62
63    pub(crate) fn operation_runtime_plugins(
64        client_runtime_plugins: ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
65        client_config: &crate::config::Config,
66        config_override: ::std::option::Option<crate::config::Builder>,
67    ) -> ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins {
68        let mut runtime_plugins = client_runtime_plugins.with_operation_plugin(Self::new());
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(crate::config::ConfigOverrideRuntimePlugin::new(
75                config_override,
76                client_config.config.clone(),
77                &client_config.runtime_components,
78            ));
79        }
80        runtime_plugins
81    }
82}
83impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin for GetRule {
84    fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
85        let mut cfg = ::aws_smithy_types::config_bag::Layer::new("GetRule");
86
87        cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedRequestSerializer::new(
88            GetRuleRequestSerializer,
89        ));
90        cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer::new(
91            GetRuleResponseDeserializer,
92        ));
93
94        cfg.store_put(::aws_smithy_runtime_api::client::auth::AuthSchemeOptionResolverParams::new(
95            crate::config::auth::Params::builder()
96                .operation_name("GetRule")
97                .build()
98                .expect("required fields set"),
99        ));
100
101        cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::SensitiveOutput);
102        cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::Metadata::new("GetRule", "DataZone"));
103        let mut signing_options = ::aws_runtime::auth::SigningOptions::default();
104        signing_options.double_uri_encode = true;
105        signing_options.content_sha256_header = false;
106        signing_options.normalize_uri_path = true;
107        signing_options.payload_override = None;
108
109        cfg.store_put(::aws_runtime::auth::SigV4OperationSigningConfig {
110            signing_options,
111            ..::std::default::Default::default()
112        });
113
114        ::std::option::Option::Some(cfg.freeze())
115    }
116
117    fn runtime_components(
118        &self,
119        _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
120    ) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
121        #[allow(unused_mut)]
122        let mut rcb = ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder::new("GetRule")
123            .with_interceptor(::aws_smithy_runtime::client::stalled_stream_protection::StalledStreamProtectionInterceptor::default())
124            .with_interceptor(GetRuleEndpointParamsInterceptor)
125            .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::TransientErrorClassifier::<
126                crate::operation::get_rule::GetRuleError,
127            >::new())
128            .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::ModeledAsRetryableClassifier::<
129                crate::operation::get_rule::GetRuleError,
130            >::new())
131            .with_retry_classifier(::aws_runtime::retries::classifiers::AwsErrorCodeClassifier::<
132                crate::operation::get_rule::GetRuleError,
133            >::new());
134
135        ::std::borrow::Cow::Owned(rcb)
136    }
137}
138
139#[derive(Debug)]
140struct GetRuleResponseDeserializer;
141impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for GetRuleResponseDeserializer {
142    fn deserialize_nonstreaming(
143        &self,
144        response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
145    ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
146        let (success, status) = (response.status().is_success(), response.status().as_u16());
147        let headers = response.headers();
148        let body = response.body().bytes().expect("body loaded");
149        #[allow(unused_mut)]
150        let mut force_error = false;
151        ::tracing::debug!(request_id = ?::aws_types::request_id::RequestId::request_id(response));
152        let parse_result = if !success && status != 200 || force_error {
153            crate::protocol_serde::shape_get_rule::de_get_rule_http_error(status, headers, body)
154        } else {
155            crate::protocol_serde::shape_get_rule::de_get_rule_http_response(status, headers, body)
156        };
157        crate::protocol_serde::type_erase_result(parse_result)
158    }
159}
160#[derive(Debug)]
161struct GetRuleRequestSerializer;
162impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for GetRuleRequestSerializer {
163    #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
164    fn serialize_input(
165        &self,
166        input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
167        _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
168    ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
169        let input = input.downcast::<crate::operation::get_rule::GetRuleInput>().expect("correct type");
170        let _header_serialization_settings = _cfg
171            .load::<crate::serialization_settings::HeaderSerializationSettings>()
172            .cloned()
173            .unwrap_or_default();
174        let mut request_builder = {
175            fn uri_base(
176                _input: &crate::operation::get_rule::GetRuleInput,
177                output: &mut ::std::string::String,
178            ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
179                use ::std::fmt::Write as _;
180                let input_1 = &_input.domain_identifier;
181                let input_1 = input_1.as_ref().ok_or_else(|| {
182                    ::aws_smithy_types::error::operation::BuildError::missing_field("domain_identifier", "cannot be empty or unset")
183                })?;
184                let domain_identifier = ::aws_smithy_http::label::fmt_string(input_1, ::aws_smithy_http::label::EncodingStrategy::Default);
185                if domain_identifier.is_empty() {
186                    return ::std::result::Result::Err(::aws_smithy_types::error::operation::BuildError::missing_field(
187                        "domain_identifier",
188                        "cannot be empty or unset",
189                    ));
190                }
191                let input_2 = &_input.identifier;
192                let input_2 = input_2
193                    .as_ref()
194                    .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("identifier", "cannot be empty or unset"))?;
195                let identifier = ::aws_smithy_http::label::fmt_string(input_2, ::aws_smithy_http::label::EncodingStrategy::Default);
196                if identifier.is_empty() {
197                    return ::std::result::Result::Err(::aws_smithy_types::error::operation::BuildError::missing_field(
198                        "identifier",
199                        "cannot be empty or unset",
200                    ));
201                }
202                ::std::write!(
203                    output,
204                    "/v2/domains/{domainIdentifier}/rules/{identifier}",
205                    domainIdentifier = domain_identifier,
206                    identifier = identifier
207                )
208                .expect("formatting should succeed");
209                ::std::result::Result::Ok(())
210            }
211            fn uri_query(
212                _input: &crate::operation::get_rule::GetRuleInput,
213                mut output: &mut ::std::string::String,
214            ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
215                let mut query = ::aws_smithy_http::query::Writer::new(output);
216                if let ::std::option::Option::Some(inner_3) = &_input.revision {
217                    {
218                        query.push_kv("revision", &::aws_smithy_http::query::fmt_string(inner_3));
219                    }
220                }
221                ::std::result::Result::Ok(())
222            }
223            #[allow(clippy::unnecessary_wraps)]
224            fn update_http_builder(
225                input: &crate::operation::get_rule::GetRuleInput,
226                builder: ::http::request::Builder,
227            ) -> ::std::result::Result<::http::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
228                let mut uri = ::std::string::String::new();
229                uri_base(input, &mut uri)?;
230                uri_query(input, &mut uri)?;
231                ::std::result::Result::Ok(builder.method("GET").uri(uri))
232            }
233            let mut builder = update_http_builder(&input, ::http::request::Builder::new())?;
234            builder
235        };
236        let body = ::aws_smithy_types::body::SdkBody::from("");
237
238        ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
239    }
240}
241#[derive(Debug)]
242struct GetRuleEndpointParamsInterceptor;
243
244impl ::aws_smithy_runtime_api::client::interceptors::Intercept for GetRuleEndpointParamsInterceptor {
245    fn name(&self) -> &'static str {
246        "GetRuleEndpointParamsInterceptor"
247    }
248
249    fn read_before_execution(
250        &self,
251        context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
252            '_,
253            ::aws_smithy_runtime_api::client::interceptors::context::Input,
254            ::aws_smithy_runtime_api::client::interceptors::context::Output,
255            ::aws_smithy_runtime_api::client::interceptors::context::Error,
256        >,
257        cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
258    ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
259        let _input = context
260            .input()
261            .downcast_ref::<GetRuleInput>()
262            .ok_or("failed to downcast to GetRuleInput")?;
263
264        let params = crate::config::endpoint::Params::builder()
265            .set_region(cfg.load::<::aws_types::region::Region>().map(|r| r.as_ref().to_owned()))
266            .set_use_fips(cfg.load::<::aws_types::endpoint_config::UseFips>().map(|ty| ty.0))
267            .set_endpoint(cfg.load::<::aws_types::endpoint_config::EndpointUrl>().map(|ty| ty.0.clone()))
268            .build()
269            .map_err(|err| {
270                ::aws_smithy_runtime_api::client::interceptors::error::ContextAttachedError::new("endpoint params could not be built", err)
271            })?;
272        cfg.interceptor_state()
273            .store_put(::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams::new(params));
274        ::std::result::Result::Ok(())
275    }
276}
277
278// The get_* functions below are generated from JMESPath expressions in the
279// operationContextParams trait. They target the operation's input shape.
280
281/// Error type for the `GetRuleError` operation.
282#[non_exhaustive]
283#[derive(::std::fmt::Debug)]
284pub enum GetRuleError {
285    /// <p>You do not have sufficient access to perform this action.</p>
286    AccessDeniedException(crate::types::error::AccessDeniedException),
287    /// <p>The request has failed because of an unknown error, exception or failure.</p>
288    InternalServerException(crate::types::error::InternalServerException),
289    /// <p>The specified resource cannot be found.</p>
290    ResourceNotFoundException(crate::types::error::ResourceNotFoundException),
291    /// <p>The request was denied due to request throttling.</p>
292    ThrottlingException(crate::types::error::ThrottlingException),
293    /// <p>The input fails to satisfy the constraints specified by the Amazon Web Services service.</p>
294    ValidationException(crate::types::error::ValidationException),
295    /// <p>You do not have permission to perform this action.</p>
296    UnauthorizedException(crate::types::error::UnauthorizedException),
297    /// An unexpected error occurred (e.g., invalid JSON returned by the service or an unknown error code).
298    #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
299    variable wildcard pattern and check `.code()`:
300     \
301    &nbsp;&nbsp;&nbsp;`err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
302     \
303    See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-GetRuleError) for what information is available for the error.")]
304    Unhandled(crate::error::sealed_unhandled::Unhandled),
305}
306impl GetRuleError {
307    /// Creates the `GetRuleError::Unhandled` variant from any error type.
308    pub fn unhandled(
309        err: impl ::std::convert::Into<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>>,
310    ) -> Self {
311        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
312            source: err.into(),
313            meta: ::std::default::Default::default(),
314        })
315    }
316
317    /// Creates the `GetRuleError::Unhandled` variant from an [`ErrorMetadata`](::aws_smithy_types::error::ErrorMetadata).
318    pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self {
319        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
320            source: err.clone().into(),
321            meta: err,
322        })
323    }
324    ///
325    /// Returns error metadata, which includes the error code, message,
326    /// request ID, and potentially additional information.
327    ///
328    pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
329        match self {
330            Self::AccessDeniedException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
331            Self::InternalServerException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
332            Self::ResourceNotFoundException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
333            Self::ThrottlingException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
334            Self::ValidationException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
335            Self::UnauthorizedException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
336            Self::Unhandled(e) => &e.meta,
337        }
338    }
339    /// Returns `true` if the error kind is `GetRuleError::AccessDeniedException`.
340    pub fn is_access_denied_exception(&self) -> bool {
341        matches!(self, Self::AccessDeniedException(_))
342    }
343    /// Returns `true` if the error kind is `GetRuleError::InternalServerException`.
344    pub fn is_internal_server_exception(&self) -> bool {
345        matches!(self, Self::InternalServerException(_))
346    }
347    /// Returns `true` if the error kind is `GetRuleError::ResourceNotFoundException`.
348    pub fn is_resource_not_found_exception(&self) -> bool {
349        matches!(self, Self::ResourceNotFoundException(_))
350    }
351    /// Returns `true` if the error kind is `GetRuleError::ThrottlingException`.
352    pub fn is_throttling_exception(&self) -> bool {
353        matches!(self, Self::ThrottlingException(_))
354    }
355    /// Returns `true` if the error kind is `GetRuleError::ValidationException`.
356    pub fn is_validation_exception(&self) -> bool {
357        matches!(self, Self::ValidationException(_))
358    }
359    /// Returns `true` if the error kind is `GetRuleError::UnauthorizedException`.
360    pub fn is_unauthorized_exception(&self) -> bool {
361        matches!(self, Self::UnauthorizedException(_))
362    }
363}
364impl ::std::error::Error for GetRuleError {
365    fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
366        match self {
367            Self::AccessDeniedException(_inner) => ::std::option::Option::Some(_inner),
368            Self::InternalServerException(_inner) => ::std::option::Option::Some(_inner),
369            Self::ResourceNotFoundException(_inner) => ::std::option::Option::Some(_inner),
370            Self::ThrottlingException(_inner) => ::std::option::Option::Some(_inner),
371            Self::ValidationException(_inner) => ::std::option::Option::Some(_inner),
372            Self::UnauthorizedException(_inner) => ::std::option::Option::Some(_inner),
373            Self::Unhandled(_inner) => ::std::option::Option::Some(&*_inner.source),
374        }
375    }
376}
377impl ::std::fmt::Display for GetRuleError {
378    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
379        match self {
380            Self::AccessDeniedException(_inner) => _inner.fmt(f),
381            Self::InternalServerException(_inner) => _inner.fmt(f),
382            Self::ResourceNotFoundException(_inner) => _inner.fmt(f),
383            Self::ThrottlingException(_inner) => _inner.fmt(f),
384            Self::ValidationException(_inner) => _inner.fmt(f),
385            Self::UnauthorizedException(_inner) => _inner.fmt(f),
386            Self::Unhandled(_inner) => {
387                if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
388                    write!(f, "unhandled error ({code})")
389                } else {
390                    f.write_str("unhandled error")
391                }
392            }
393        }
394    }
395}
396impl ::aws_smithy_types::retry::ProvideErrorKind for GetRuleError {
397    fn code(&self) -> ::std::option::Option<&str> {
398        ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self)
399    }
400    fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> {
401        match self {
402            Self::InternalServerException(inner) => ::std::option::Option::Some(inner.retryable_error_kind()),
403            Self::ThrottlingException(inner) => ::std::option::Option::Some(inner.retryable_error_kind()),
404            _ => ::std::option::Option::None,
405        }
406    }
407}
408impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for GetRuleError {
409    fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
410        match self {
411            Self::AccessDeniedException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
412            Self::InternalServerException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
413            Self::ResourceNotFoundException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
414            Self::ThrottlingException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
415            Self::ValidationException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
416            Self::UnauthorizedException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
417            Self::Unhandled(_inner) => &_inner.meta,
418        }
419    }
420}
421impl ::aws_smithy_runtime_api::client::result::CreateUnhandledError for GetRuleError {
422    fn create_unhandled_error(
423        source: ::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>,
424        meta: ::std::option::Option<::aws_smithy_types::error::ErrorMetadata>,
425    ) -> Self {
426        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
427            source,
428            meta: meta.unwrap_or_default(),
429        })
430    }
431}
432impl ::aws_types::request_id::RequestId for crate::operation::get_rule::GetRuleError {
433    fn request_id(&self) -> Option<&str> {
434        self.meta().request_id()
435    }
436}
437
438pub use crate::operation::get_rule::_get_rule_output::GetRuleOutput;
439
440pub use crate::operation::get_rule::_get_rule_input::GetRuleInput;
441
442mod _get_rule_input;
443
444mod _get_rule_output;
445
446/// Builders
447pub mod builders;