aws_sdk_signin/operation/create_o_auth2_token/
builders.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::create_o_auth2_token::_create_o_auth2_token_output::CreateOAuth2TokenOutputBuilder;
3
4pub use crate::operation::create_o_auth2_token::_create_o_auth2_token_input::CreateOAuth2TokenInputBuilder;
5
6impl crate::operation::create_o_auth2_token::builders::CreateOAuth2TokenInputBuilder {
7                    /// Sends a request with this input using the given client.
8                    pub async fn send_with(self, client: &crate::Client) -> ::std::result::Result<
9                        crate::operation::create_o_auth2_token::CreateOAuth2TokenOutput,
10                        ::aws_smithy_runtime_api::client::result::SdkError<
11                            crate::operation::create_o_auth2_token::CreateOAuth2TokenError,
12                            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse
13                        >
14                    > {
15                        let mut fluent_builder = client.create_o_auth2_token();
16                        fluent_builder.inner = self;
17                        fluent_builder.send().await
18                    }
19                }
20/// Fluent builder constructing a request to `CreateOAuth2Token`.
21/// 
22/// CreateOAuth2Token API Path: /v1/token Request Method: POST Content-Type: application/json or application/x-www-form-urlencoded This API implements OAuth 2.0 flows for AWS Sign-In CLI clients, supporting both: 1. Authorization code redemption (grant_type=authorization_code) - NOT idempotent 2. Token refresh (grant_type=refresh_token) - Idempotent within token validity window The operation behavior is determined by the grant_type parameter in the request body: **Authorization Code Flow (NOT Idempotent):** - JSON or form-encoded body with client_id, grant_type=authorization_code, code, redirect_uri, code_verifier - Returns access_token, token_type, expires_in, refresh_token, and id_token - Each authorization code can only be used ONCE for security (prevents replay attacks) **Token Refresh Flow (Idempotent):** - JSON or form-encoded body with client_id, grant_type=refresh_token, refresh_token - Returns access_token, token_type, expires_in, and refresh_token (no id_token) - Multiple calls with same refresh_token return consistent results within validity window Authentication and authorization: - Confidential clients: sigv4 signing required with signin:ExchangeToken permissions - CLI clients (public): authn/authz skipped based on client_id &amp; grant_type Note: This operation cannot be marked as @idempotent because it handles both idempotent (token refresh) and non-idempotent (auth code redemption) flows in a single endpoint.
23#[derive(::std::clone::Clone, ::std::fmt::Debug)]
24pub struct CreateOAuth2TokenFluentBuilder {
25                handle: ::std::sync::Arc<crate::client::Handle>,
26                inner: crate::operation::create_o_auth2_token::builders::CreateOAuth2TokenInputBuilder,
27config_override: ::std::option::Option<crate::config::Builder>,
28            }
29impl
30                crate::client::customize::internal::CustomizableSend<
31                    crate::operation::create_o_auth2_token::CreateOAuth2TokenOutput,
32                    crate::operation::create_o_auth2_token::CreateOAuth2TokenError,
33                > for CreateOAuth2TokenFluentBuilder
34            {
35                fn send(
36                    self,
37                    config_override: crate::config::Builder,
38                ) -> crate::client::customize::internal::BoxFuture<
39                    crate::client::customize::internal::SendResult<
40                        crate::operation::create_o_auth2_token::CreateOAuth2TokenOutput,
41                        crate::operation::create_o_auth2_token::CreateOAuth2TokenError,
42                    >,
43                > {
44                    ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
45                }
46            }
47impl CreateOAuth2TokenFluentBuilder {
48    /// Creates a new `CreateOAuth2TokenFluentBuilder`.
49                    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
50                        Self {
51                            handle,
52                            inner: ::std::default::Default::default(),
53    config_override: ::std::option::Option::None,
54                        }
55                    }
56    /// Access the CreateOAuth2Token as a reference.
57                    pub fn as_input(&self) -> &crate::operation::create_o_auth2_token::builders::CreateOAuth2TokenInputBuilder {
58                        &self.inner
59                    }
60    /// Sends the request and returns the response.
61                    ///
62                    /// If an error occurs, an `SdkError` will be returned with additional details that
63                    /// can be matched against.
64                    ///
65                    /// By default, any retryable failures will be retried twice. Retry behavior
66                    /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
67                    /// set when configuring the client.
68                    pub async fn send(self) -> ::std::result::Result<crate::operation::create_o_auth2_token::CreateOAuth2TokenOutput, ::aws_smithy_runtime_api::client::result::SdkError<crate::operation::create_o_auth2_token::CreateOAuth2TokenError, ::aws_smithy_runtime_api::client::orchestrator::HttpResponse>> {
69                        let input = self.inner.build().map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
70                        let runtime_plugins = crate::operation::create_o_auth2_token::CreateOAuth2Token::operation_runtime_plugins(
71                            self.handle.runtime_plugins.clone(),
72                            &self.handle.conf,
73                            self.config_override,
74                        );
75                        crate::operation::create_o_auth2_token::CreateOAuth2Token::orchestrate(&runtime_plugins, input).await
76                    }
77    
78                    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
79                    pub fn customize(
80                        self,
81                    ) -> crate::client::customize::CustomizableOperation<crate::operation::create_o_auth2_token::CreateOAuth2TokenOutput, crate::operation::create_o_auth2_token::CreateOAuth2TokenError, Self> {
82                        crate::client::customize::CustomizableOperation::new(self)
83                    }
84    pub(crate) fn config_override(
85                            mut self,
86                            config_override: impl ::std::convert::Into<crate::config::Builder>,
87                        ) -> Self {
88                            self.set_config_override(::std::option::Option::Some(config_override.into()));
89                            self
90                        }
91    
92                        pub(crate) fn set_config_override(
93                            &mut self,
94                            config_override: ::std::option::Option<crate::config::Builder>,
95                        ) -> &mut Self {
96                            self.config_override = config_override;
97                            self
98                        }
99    /// Flattened token operation inputs The specific operation is determined by grant_type in the request body
100    pub fn token_input(mut self, input: crate::types::CreateOAuth2TokenRequestBody) -> Self {
101                    self.inner = self.inner.token_input(input);
102                    self
103                }
104    /// Flattened token operation inputs The specific operation is determined by grant_type in the request body
105    pub fn set_token_input(mut self, input: ::std::option::Option<crate::types::CreateOAuth2TokenRequestBody>) -> Self {
106                    self.inner = self.inner.set_token_input(input);
107                    self
108                }
109    /// Flattened token operation inputs The specific operation is determined by grant_type in the request body
110    pub fn get_token_input(&self) -> &::std::option::Option<crate::types::CreateOAuth2TokenRequestBody> {
111                    self.inner.get_token_input()
112                }
113}
114