aws_sdk_s3/client/
customize.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3impl<E, B> CustomizableOperation<crate::operation::upload_part::UploadPartOutput, E, B> {
4    /// Disable payload signing for this request.
5    ///
6    /// **WARNING:** This is an advanced feature that removes
7    /// the cost of signing a request payload by removing a data
8    /// integrity check. Not all services/operations support
9    /// this feature.
10    pub fn disable_payload_signing(self) -> Self {
11        self.runtime_plugin(::aws_runtime::auth::PayloadSigningOverrideRuntimePlugin::unsigned())
12    }
13}
14
15impl<E, B> CustomizableOperation<crate::operation::put_object::PutObjectOutput, E, B> {
16    /// Disable payload signing for this request.
17    ///
18    /// **WARNING:** This is an advanced feature that removes
19    /// the cost of signing a request payload by removing a data
20    /// integrity check. Not all services/operations support
21    /// this feature.
22    pub fn disable_payload_signing(self) -> Self {
23        self.runtime_plugin(::aws_runtime::auth::PayloadSigningOverrideRuntimePlugin::unsigned())
24    }
25}
26
27/// `CustomizableOperation` allows for configuring a single operation invocation before it is sent.
28pub struct CustomizableOperation<T, E, B> {
29    customizable_send: B,
30    config_override: ::std::option::Option<crate::config::Builder>,
31    interceptors: Vec<::aws_smithy_runtime_api::client::interceptors::SharedInterceptor>,
32    runtime_plugins: Vec<::aws_smithy_runtime_api::client::runtime_plugin::SharedRuntimePlugin>,
33    _output: ::std::marker::PhantomData<T>,
34    _error: ::std::marker::PhantomData<E>,
35}
36
37impl<T, E, B> CustomizableOperation<T, E, B> {
38    /// Creates a new `CustomizableOperation` from `customizable_send`.
39    #[allow(dead_code)] // unused when a service does not provide any operations
40    pub(crate) fn new(customizable_send: B) -> Self {
41        Self {
42            customizable_send,
43            config_override: ::std::option::Option::None,
44            interceptors: vec![],
45            runtime_plugins: vec![],
46            _output: ::std::marker::PhantomData,
47            _error: ::std::marker::PhantomData,
48        }
49    }
50
51    pub(crate) fn execute<U>(self, f: impl ::std::ops::FnOnce(B, crate::config::Builder) -> U) -> U {
52        let mut config_override = self.config_override.unwrap_or_default();
53        self.interceptors.into_iter().for_each(|interceptor| {
54            config_override.push_interceptor(interceptor);
55        });
56        self.runtime_plugins.into_iter().for_each(|plugin| {
57            config_override.push_runtime_plugin(plugin);
58        });
59        f(self.customizable_send, config_override)
60    }
61
62    /// Adds an [interceptor](::aws_smithy_runtime_api::client::interceptors::Intercept) that runs at specific stages of the request execution pipeline.
63    ///
64    /// Note that interceptors can also be added to `CustomizableOperation` by `config_override`,
65    /// `map_request`, and `mutate_request` (the last two are implemented via interceptors under the hood).
66    /// The order in which those user-specified operation interceptors are invoked should not be relied upon
67    /// as it is an implementation detail.
68    pub fn interceptor(mut self, interceptor: impl ::aws_smithy_runtime_api::client::interceptors::Intercept + 'static) -> Self {
69        self.interceptors
70            .push(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::new(interceptor));
71        self
72    }
73
74    /// Adds a runtime plugin.
75    #[allow(unused)]
76    pub(crate) fn runtime_plugin(mut self, runtime_plugin: impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin + 'static) -> Self {
77        self.runtime_plugins
78            .push(::aws_smithy_runtime_api::client::runtime_plugin::SharedRuntimePlugin::new(runtime_plugin));
79        self
80    }
81
82    /// Allows for customizing the operation's request.
83    pub fn map_request<F, MapE>(mut self, f: F) -> Self
84    where
85        F: ::std::ops::Fn(
86                ::aws_smithy_runtime_api::client::orchestrator::HttpRequest,
87            ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, MapE>
88            + ::std::marker::Send
89            + ::std::marker::Sync
90            + 'static,
91        MapE: ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static,
92    {
93        self.interceptors
94            .push(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::new(
95                ::aws_smithy_runtime::client::interceptors::MapRequestInterceptor::new(f),
96            ));
97        self
98    }
99
100    /// Convenience for `map_request` where infallible direct mutation of request is acceptable.
101    pub fn mutate_request<F>(mut self, f: F) -> Self
102    where
103        F: ::std::ops::Fn(&mut ::aws_smithy_runtime_api::client::orchestrator::HttpRequest) + ::std::marker::Send + ::std::marker::Sync + 'static,
104    {
105        self.interceptors
106            .push(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::new(
107                ::aws_smithy_runtime::client::interceptors::MutateRequestInterceptor::new(f),
108            ));
109        self
110    }
111
112    /// Overrides config for a single operation invocation.
113    ///
114    /// `config_override` is applied to the operation configuration level.
115    /// The fields in the builder that are `Some` override those applied to the service
116    /// configuration level. For instance,
117    ///
118    /// | Config A           | overridden by Config B | = Config C         |
119    /// |--------------------|------------------------|--------------------|
120    /// | field_1: None,     | field_1: Some(v2),     | field_1: Some(v2), |
121    /// | field_2: Some(v1), | field_2: Some(v2),     | field_2: Some(v2), |
122    /// | field_3: Some(v1), | field_3: None,         | field_3: Some(v1), |
123    pub fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
124        self.config_override = Some(config_override.into());
125        self
126    }
127
128    /// Sends the request and returns the response.
129    pub async fn send(self) -> crate::client::customize::internal::SendResult<T, E>
130    where
131        E: std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static,
132        B: crate::client::customize::internal::CustomizableSend<T, E>,
133    {
134        self.execute(|sender, config| sender.send(config)).await
135    }
136
137    /// Sends the request and returns the response.
138    #[allow(unused_mut)]
139    pub async fn presigned(
140        mut self,
141        presigning_config: crate::presigning::PresigningConfig,
142    ) -> ::std::result::Result<crate::presigning::PresignedRequest, crate::error::SdkError<E>>
143    where
144        E: std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static,
145        B: crate::client::customize::internal::CustomizablePresigned<E>,
146    {
147        self.execute(move |sender, conf| sender.presign(conf, presigning_config)).await
148    }
149}
150
151pub(crate) mod internal;