// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
pub use crate::operation::get_o_auth_token::_get_o_auth_token_input::GetOAuthTokenInputBuilder;
pub use crate::operation::get_o_auth_token::_get_o_auth_token_output::GetOAuthTokenOutputBuilder;
impl crate::operation::get_o_auth_token::builders::GetOAuthTokenInputBuilder {
/// Sends a request with this input using the given client.
pub async fn send_with(
self,
client: &crate::Client,
) -> ::std::result::Result<
crate::operation::get_o_auth_token::GetOAuthTokenOutput,
::aws_smithy_runtime_api::client::result::SdkError<
crate::operation::get_o_auth_token::GetOAuthTokenError,
::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
>,
> {
let mut fluent_builder = client.get_o_auth_token();
fluent_builder.inner = self;
fluent_builder.send().await
}
}
/// Fluent builder constructing a request to `GetOAuthToken`.
///
/// <p>Retrieves an OAuth access token from a credential provider. The broker authenticates to the provider's authorization server with the client credentials configured on the provider, obtains a token, and returns it — so your workload never handles the provider's client secret.</p>
/// <p>The broker caches the access token it obtains until that token expires, or for up to one hour when the token's own lifetime is longer than an hour. A call made while a cached token is still valid returns that token instead of requesting a new one; set <code>forceAuthentication</code> to bypass the cache and force a fresh request to the authorization server.</p>
/// <p>The grant type you name must be one the provider allows. CLIENT_CREDENTIALS returns a token representing the workload itself; TOKEN_EXCHANGE returns a token that preserves the identity of the caller the workload is acting for; AUTHORIZATION_CODE returns a token representing an end user who granted consent, and requires a consent session that user has already completed, named in <code>sessionUri</code>; JWT_AUTHORIZATION_GRANT presents a signed JWT as the grant, so no client secret is sent on the token request. Of the supported vendors, only Microsoft Entra ID accepts this grant today: Entra implements on-behalf-of delegation with the RFC 7523 JWT bearer grant (<code>urn:ietf:params:oauth:grant-type:jwt-bearer</code>), where other authorization servers use RFC 8693 token exchange.</p>
#[derive(::std::clone::Clone, ::std::fmt::Debug)]
pub struct GetOAuthTokenFluentBuilder {
handle: ::std::sync::Arc<crate::client::Handle>,
inner: crate::operation::get_o_auth_token::builders::GetOAuthTokenInputBuilder,
config_override: ::std::option::Option<crate::config::Builder>,
}
impl
crate::client::customize::internal::CustomizableSend<
crate::operation::get_o_auth_token::GetOAuthTokenOutput,
crate::operation::get_o_auth_token::GetOAuthTokenError,
> for GetOAuthTokenFluentBuilder
{
fn send(
self,
config_override: crate::config::Builder,
) -> crate::client::customize::internal::BoxFuture<
crate::client::customize::internal::SendResult<
crate::operation::get_o_auth_token::GetOAuthTokenOutput,
crate::operation::get_o_auth_token::GetOAuthTokenError,
>,
> {
::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
}
}
impl GetOAuthTokenFluentBuilder {
/// Creates a new `GetOAuthTokenFluentBuilder`.
pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
Self {
handle,
inner: ::std::default::Default::default(),
config_override: ::std::option::Option::None,
}
}
/// Access the GetOAuthToken as a reference.
pub fn as_input(&self) -> &crate::operation::get_o_auth_token::builders::GetOAuthTokenInputBuilder {
&self.inner
}
/// Sends the request and returns the response.
///
/// If an error occurs, an `SdkError` will be returned with additional details that
/// can be matched against.
///
/// By default, any retryable failures will be retried twice. Retry behavior
/// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
/// set when configuring the client.
pub async fn send(
self,
) -> ::std::result::Result<
crate::operation::get_o_auth_token::GetOAuthTokenOutput,
::aws_smithy_runtime_api::client::result::SdkError<
crate::operation::get_o_auth_token::GetOAuthTokenError,
::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
>,
> {
let input = self
.inner
.build()
.map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
let runtime_plugins = crate::operation::get_o_auth_token::GetOAuthToken::operation_runtime_plugins(
self.handle.runtime_plugins.clone(),
&self.handle.conf,
self.config_override,
);
crate::operation::get_o_auth_token::GetOAuthToken::orchestrate(&runtime_plugins, input).await
}
/// Consumes this builder, creating a customizable operation that can be modified before being sent.
pub fn customize(
self,
) -> crate::client::customize::CustomizableOperation<
crate::operation::get_o_auth_token::GetOAuthTokenOutput,
crate::operation::get_o_auth_token::GetOAuthTokenError,
Self,
> {
crate::client::customize::CustomizableOperation::new(self)
}
pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
self.set_config_override(::std::option::Option::Some(config_override.into()));
self
}
pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
self.config_override = config_override;
self
}
/// <p>Amazon Resource Name of the credential provider to obtain the token from. The provider must be an OAuth provider and must be READY.</p>
pub fn credential_provider_arn(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
self.inner = self.inner.credential_provider_arn(input.into());
self
}
/// <p>Amazon Resource Name of the credential provider to obtain the token from. The provider must be an OAuth provider and must be READY.</p>
pub fn set_credential_provider_arn(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
self.inner = self.inner.set_credential_provider_arn(input);
self
}
/// <p>Amazon Resource Name of the credential provider to obtain the token from. The provider must be an OAuth provider and must be READY.</p>
pub fn get_credential_provider_arn(&self) -> &::std::option::Option<::std::string::String> {
self.inner.get_credential_provider_arn()
}
/// <p>How the token is obtained. Must be one of the grant types the provider allows; a grant the provider does not allow is rejected.</p>
pub fn grant_type(mut self, input: crate::types::GrantType) -> Self {
self.inner = self.inner.grant_type(input);
self
}
/// <p>How the token is obtained. Must be one of the grant types the provider allows; a grant the provider does not allow is rejected.</p>
pub fn set_grant_type(mut self, input: ::std::option::Option<crate::types::GrantType>) -> Self {
self.inner = self.inner.set_grant_type(input);
self
}
/// <p>How the token is obtained. Must be one of the grant types the provider allows; a grant the provider does not allow is rejected.</p>
pub fn get_grant_type(&self) -> &::std::option::Option<crate::types::GrantType> {
self.inner.get_grant_type()
}
///
/// Appends an item to `scopes`.
///
/// To override the contents of this collection use [`set_scopes`](Self::set_scopes).
///
/// <p>The OAuth scopes to request from the authorization server.</p>
pub fn scopes(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
self.inner = self.inner.scopes(input.into());
self
}
/// <p>The OAuth scopes to request from the authorization server.</p>
pub fn set_scopes(mut self, input: ::std::option::Option<::std::vec::Vec<::std::string::String>>) -> Self {
self.inner = self.inner.set_scopes(input);
self
}
/// <p>The OAuth scopes to request from the authorization server.</p>
pub fn get_scopes(&self) -> &::std::option::Option<::std::vec::Vec<::std::string::String>> {
self.inner.get_scopes()
}
///
/// Appends an item to `resources`.
///
/// To override the contents of this collection use [`set_resources`](Self::set_resources).
///
/// <p>Resource indicators (RFC 8707) naming the APIs this token is for. Omit unless the authorization server requires them.</p>
pub fn resources(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
self.inner = self.inner.resources(input.into());
self
}
/// <p>Resource indicators (RFC 8707) naming the APIs this token is for. Omit unless the authorization server requires them.</p>
pub fn set_resources(mut self, input: ::std::option::Option<::std::vec::Vec<::std::string::String>>) -> Self {
self.inner = self.inner.set_resources(input);
self
}
/// <p>Resource indicators (RFC 8707) naming the APIs this token is for. Omit unless the authorization server requires them.</p>
pub fn get_resources(&self) -> &::std::option::Option<::std::vec::Vec<::std::string::String>> {
self.inner.get_resources()
}
///
/// Appends an item to `audiences`.
///
/// To override the contents of this collection use [`set_audiences`](Self::set_audiences).
///
/// <p>Audience values (RFC 8693) naming the intended recipients of this token. Omit unless the authorization server requires them.</p>
pub fn audiences(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
self.inner = self.inner.audiences(input.into());
self
}
/// <p>Audience values (RFC 8693) naming the intended recipients of this token. Omit unless the authorization server requires them.</p>
pub fn set_audiences(mut self, input: ::std::option::Option<::std::vec::Vec<::std::string::String>>) -> Self {
self.inner = self.inner.set_audiences(input);
self
}
/// <p>Audience values (RFC 8693) naming the intended recipients of this token. Omit unless the authorization server requires them.</p>
pub fn get_audiences(&self) -> &::std::option::Option<::std::vec::Vec<::std::string::String>> {
self.inner.get_audiences()
}
///
/// Adds a key-value pair to `customParameters`.
///
/// To override the contents of this collection use [`set_custom_parameters`](Self::set_custom_parameters).
///
/// <p>Extra parameters to include in the request to the authorization server, for vendor extensions. Added to the standard OAuth parameters; they never override them.</p>
pub fn custom_parameters(
mut self,
k: impl ::std::convert::Into<::std::string::String>,
v: impl ::std::convert::Into<::std::string::String>,
) -> Self {
self.inner = self.inner.custom_parameters(k.into(), v.into());
self
}
/// <p>Extra parameters to include in the request to the authorization server, for vendor extensions. Added to the standard OAuth parameters; they never override them.</p>
pub fn set_custom_parameters(
mut self,
input: ::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>>,
) -> Self {
self.inner = self.inner.set_custom_parameters(input);
self
}
/// <p>Extra parameters to include in the request to the authorization server, for vendor extensions. Added to the standard OAuth parameters; they never override them.</p>
pub fn get_custom_parameters(&self) -> &::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>> {
self.inner.get_custom_parameters()
}
/// <p>Request a new token from the authorization server even when the broker already holds a valid one for this provider. Defaults to false, which returns the held token when one is available.</p>
pub fn force_authentication(mut self, input: bool) -> Self {
self.inner = self.inner.force_authentication(input);
self
}
/// <p>Request a new token from the authorization server even when the broker already holds a valid one for this provider. Defaults to false, which returns the held token when one is available.</p>
pub fn set_force_authentication(mut self, input: ::std::option::Option<bool>) -> Self {
self.inner = self.inner.set_force_authentication(input);
self
}
/// <p>Request a new token from the authorization server even when the broker already holds a valid one for this provider. Defaults to false, which returns the held token when one is available.</p>
pub fn get_force_authentication(&self) -> &::std::option::Option<bool> {
self.inner.get_force_authentication()
}
/// <p>Return the token obtained for a consent session that a user has already completed. Supply the handle returned when the session was started.</p>
pub fn session_uri(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
self.inner = self.inner.session_uri(input.into());
self
}
/// <p>Return the token obtained for a consent session that a user has already completed. Supply the handle returned when the session was started.</p>
pub fn set_session_uri(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
self.inner = self.inner.set_session_uri(input);
self
}
/// <p>Return the token obtained for a consent session that a user has already completed. Supply the handle returned when the session was started.</p>
pub fn get_session_uri(&self) -> &::std::option::Option<::std::string::String> {
self.inner.get_session_uri()
}
}