aws_sdk_ssooidc/client/
customize.rs

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