use std::fmt::Write;
pub mod create_token_input {
#[derive(std::clone::Clone, std::cmp::PartialEq, std::default::Default, std::fmt::Debug)]
pub struct Builder {
pub(crate) client_id: std::option::Option<std::string::String>,
pub(crate) client_secret: std::option::Option<std::string::String>,
pub(crate) grant_type: std::option::Option<std::string::String>,
pub(crate) device_code: std::option::Option<std::string::String>,
pub(crate) code: std::option::Option<std::string::String>,
pub(crate) refresh_token: std::option::Option<std::string::String>,
pub(crate) scope: std::option::Option<std::vec::Vec<std::string::String>>,
pub(crate) redirect_uri: std::option::Option<std::string::String>,
}
impl Builder {
pub fn client_id(mut self, input: impl Into<std::string::String>) -> Self {
self.client_id = Some(input.into());
self
}
pub fn set_client_id(mut self, input: std::option::Option<std::string::String>) -> Self {
self.client_id = input;
self
}
pub fn client_secret(mut self, input: impl Into<std::string::String>) -> Self {
self.client_secret = Some(input.into());
self
}
pub fn set_client_secret(
mut self,
input: std::option::Option<std::string::String>,
) -> Self {
self.client_secret = input;
self
}
pub fn grant_type(mut self, input: impl Into<std::string::String>) -> Self {
self.grant_type = Some(input.into());
self
}
pub fn set_grant_type(mut self, input: std::option::Option<std::string::String>) -> Self {
self.grant_type = input;
self
}
pub fn device_code(mut self, input: impl Into<std::string::String>) -> Self {
self.device_code = Some(input.into());
self
}
pub fn set_device_code(mut self, input: std::option::Option<std::string::String>) -> Self {
self.device_code = input;
self
}
pub fn code(mut self, input: impl Into<std::string::String>) -> Self {
self.code = Some(input.into());
self
}
pub fn set_code(mut self, input: std::option::Option<std::string::String>) -> Self {
self.code = input;
self
}
pub fn refresh_token(mut self, input: impl Into<std::string::String>) -> Self {
self.refresh_token = Some(input.into());
self
}
pub fn set_refresh_token(
mut self,
input: std::option::Option<std::string::String>,
) -> Self {
self.refresh_token = input;
self
}
pub fn scope(mut self, input: impl Into<std::string::String>) -> Self {
let mut v = self.scope.unwrap_or_default();
v.push(input.into());
self.scope = Some(v);
self
}
pub fn set_scope(
mut self,
input: std::option::Option<std::vec::Vec<std::string::String>>,
) -> Self {
self.scope = input;
self
}
pub fn redirect_uri(mut self, input: impl Into<std::string::String>) -> Self {
self.redirect_uri = Some(input.into());
self
}
pub fn set_redirect_uri(mut self, input: std::option::Option<std::string::String>) -> Self {
self.redirect_uri = input;
self
}
pub fn build(
self,
) -> Result<crate::input::CreateTokenInput, aws_smithy_http::operation::error::BuildError>
{
Ok(crate::input::CreateTokenInput {
client_id: self.client_id,
client_secret: self.client_secret,
grant_type: self.grant_type,
device_code: self.device_code,
code: self.code,
refresh_token: self.refresh_token,
scope: self.scope,
redirect_uri: self.redirect_uri,
})
}
}
}
impl CreateTokenInput {
#[allow(unused_mut)]
#[allow(clippy::let_and_return)]
#[allow(clippy::needless_borrow)]
pub async fn make_operation(
&self,
_config: &crate::config::Config,
) -> std::result::Result<
aws_smithy_http::operation::Operation<
crate::operation::CreateToken,
aws_http::retry::AwsResponseRetryClassifier,
>,
aws_smithy_http::operation::error::BuildError,
> {
let params_result = crate::endpoint::Params::builder()
.set_region(_config.region.as_ref().map(|r| r.as_ref().to_owned()))
.set_use_dual_stack(_config.use_dual_stack)
.set_use_fips(_config.use_fips)
.set_endpoint(_config.endpoint_url.clone())
.build()
.map_err(|err| {
aws_smithy_http::endpoint::ResolveEndpointError::from_source(
"could not construct endpoint parameters",
err,
)
});
let (endpoint_result, params) = match params_result {
Ok(params) => (
_config.endpoint_resolver.resolve_endpoint(¶ms),
Some(params),
),
Err(e) => (Err(e), None),
};
let mut request = {
fn uri_base(
_input: &crate::input::CreateTokenInput,
output: &mut String,
) -> Result<(), aws_smithy_http::operation::error::BuildError> {
write!(output, "/token").expect("formatting should succeed");
Ok(())
}
#[allow(clippy::unnecessary_wraps)]
fn update_http_builder(
input: &crate::input::CreateTokenInput,
builder: http::request::Builder,
) -> std::result::Result<
http::request::Builder,
aws_smithy_http::operation::error::BuildError,
> {
let mut uri = String::new();
uri_base(input, &mut uri)?;
Ok(builder.method("POST").uri(uri))
}
let mut builder = update_http_builder(&self, http::request::Builder::new())?;
builder = aws_smithy_http::header::set_request_header_if_absent(
builder,
http::header::CONTENT_TYPE,
"application/json",
);
builder
};
let mut properties = aws_smithy_http::property_bag::SharedPropertyBag::new();
#[allow(clippy::useless_conversion)]
let body = aws_smithy_http::body::SdkBody::from(
crate::operation_ser::serialize_operation_crate_operation_create_token(&self)?,
);
if let Some(content_length) = body.content_length() {
request = aws_smithy_http::header::set_request_header_if_absent(
request,
http::header::CONTENT_LENGTH,
content_length,
);
}
let request = request.body(body).expect("should be valid request");
let mut request = aws_smithy_http::operation::Request::from_parts(request, properties);
request.properties_mut().insert(endpoint_result);
if let Some(params) = params {
request.properties_mut().insert(params);
}
request
.properties_mut()
.insert(aws_smithy_http::http_versions::DEFAULT_HTTP_VERSION_LIST.clone());
let mut user_agent = aws_http::user_agent::AwsUserAgent::new_from_environment(
aws_types::os_shim_internal::Env::real(),
crate::API_METADATA.clone(),
);
if let Some(app_name) = _config.app_name() {
user_agent = user_agent.with_app_name(app_name.clone());
}
request.properties_mut().insert(user_agent);
let mut signing_config = aws_sig_auth::signer::OperationSigningConfig::default_config();
signing_config.signing_requirements = aws_sig_auth::signer::SigningRequirements::Disabled;
request.properties_mut().insert(signing_config);
request
.properties_mut()
.insert(aws_types::SigningService::from_static(
_config.signing_service(),
));
if let Some(region) = &_config.region {
request
.properties_mut()
.insert(aws_types::region::SigningRegion::from(region.clone()));
}
if let Some(region) = &_config.region {
request.properties_mut().insert(region.clone());
}
aws_http::auth::set_credentials_cache(
&mut request.properties_mut(),
_config.credentials_cache.clone(),
);
let op = aws_smithy_http::operation::Operation::new(
request,
crate::operation::CreateToken::new(),
)
.with_metadata(aws_smithy_http::operation::Metadata::new(
"CreateToken",
"ssooidc",
));
let op = op.with_retry_classifier(aws_http::retry::AwsResponseRetryClassifier::new());
Ok(op)
}
pub fn builder() -> crate::input::create_token_input::Builder {
crate::input::create_token_input::Builder::default()
}
}
pub mod register_client_input {
#[derive(std::clone::Clone, std::cmp::PartialEq, std::default::Default, std::fmt::Debug)]
pub struct Builder {
pub(crate) client_name: std::option::Option<std::string::String>,
pub(crate) client_type: std::option::Option<std::string::String>,
pub(crate) scopes: std::option::Option<std::vec::Vec<std::string::String>>,
}
impl Builder {
pub fn client_name(mut self, input: impl Into<std::string::String>) -> Self {
self.client_name = Some(input.into());
self
}
pub fn set_client_name(mut self, input: std::option::Option<std::string::String>) -> Self {
self.client_name = input;
self
}
pub fn client_type(mut self, input: impl Into<std::string::String>) -> Self {
self.client_type = Some(input.into());
self
}
pub fn set_client_type(mut self, input: std::option::Option<std::string::String>) -> Self {
self.client_type = input;
self
}
pub fn scopes(mut self, input: impl Into<std::string::String>) -> Self {
let mut v = self.scopes.unwrap_or_default();
v.push(input.into());
self.scopes = Some(v);
self
}
pub fn set_scopes(
mut self,
input: std::option::Option<std::vec::Vec<std::string::String>>,
) -> Self {
self.scopes = input;
self
}
pub fn build(
self,
) -> Result<crate::input::RegisterClientInput, aws_smithy_http::operation::error::BuildError>
{
Ok(crate::input::RegisterClientInput {
client_name: self.client_name,
client_type: self.client_type,
scopes: self.scopes,
})
}
}
}
impl RegisterClientInput {
#[allow(unused_mut)]
#[allow(clippy::let_and_return)]
#[allow(clippy::needless_borrow)]
pub async fn make_operation(
&self,
_config: &crate::config::Config,
) -> std::result::Result<
aws_smithy_http::operation::Operation<
crate::operation::RegisterClient,
aws_http::retry::AwsResponseRetryClassifier,
>,
aws_smithy_http::operation::error::BuildError,
> {
let params_result = crate::endpoint::Params::builder()
.set_region(_config.region.as_ref().map(|r| r.as_ref().to_owned()))
.set_use_dual_stack(_config.use_dual_stack)
.set_use_fips(_config.use_fips)
.set_endpoint(_config.endpoint_url.clone())
.build()
.map_err(|err| {
aws_smithy_http::endpoint::ResolveEndpointError::from_source(
"could not construct endpoint parameters",
err,
)
});
let (endpoint_result, params) = match params_result {
Ok(params) => (
_config.endpoint_resolver.resolve_endpoint(¶ms),
Some(params),
),
Err(e) => (Err(e), None),
};
let mut request = {
fn uri_base(
_input: &crate::input::RegisterClientInput,
output: &mut String,
) -> Result<(), aws_smithy_http::operation::error::BuildError> {
write!(output, "/client/register").expect("formatting should succeed");
Ok(())
}
#[allow(clippy::unnecessary_wraps)]
fn update_http_builder(
input: &crate::input::RegisterClientInput,
builder: http::request::Builder,
) -> std::result::Result<
http::request::Builder,
aws_smithy_http::operation::error::BuildError,
> {
let mut uri = String::new();
uri_base(input, &mut uri)?;
Ok(builder.method("POST").uri(uri))
}
let mut builder = update_http_builder(&self, http::request::Builder::new())?;
builder = aws_smithy_http::header::set_request_header_if_absent(
builder,
http::header::CONTENT_TYPE,
"application/json",
);
builder
};
let mut properties = aws_smithy_http::property_bag::SharedPropertyBag::new();
#[allow(clippy::useless_conversion)]
let body = aws_smithy_http::body::SdkBody::from(
crate::operation_ser::serialize_operation_crate_operation_register_client(&self)?,
);
if let Some(content_length) = body.content_length() {
request = aws_smithy_http::header::set_request_header_if_absent(
request,
http::header::CONTENT_LENGTH,
content_length,
);
}
let request = request.body(body).expect("should be valid request");
let mut request = aws_smithy_http::operation::Request::from_parts(request, properties);
request.properties_mut().insert(endpoint_result);
if let Some(params) = params {
request.properties_mut().insert(params);
}
request
.properties_mut()
.insert(aws_smithy_http::http_versions::DEFAULT_HTTP_VERSION_LIST.clone());
let mut user_agent = aws_http::user_agent::AwsUserAgent::new_from_environment(
aws_types::os_shim_internal::Env::real(),
crate::API_METADATA.clone(),
);
if let Some(app_name) = _config.app_name() {
user_agent = user_agent.with_app_name(app_name.clone());
}
request.properties_mut().insert(user_agent);
let mut signing_config = aws_sig_auth::signer::OperationSigningConfig::default_config();
signing_config.signing_requirements = aws_sig_auth::signer::SigningRequirements::Disabled;
request.properties_mut().insert(signing_config);
request
.properties_mut()
.insert(aws_types::SigningService::from_static(
_config.signing_service(),
));
if let Some(region) = &_config.region {
request
.properties_mut()
.insert(aws_types::region::SigningRegion::from(region.clone()));
}
if let Some(region) = &_config.region {
request.properties_mut().insert(region.clone());
}
aws_http::auth::set_credentials_cache(
&mut request.properties_mut(),
_config.credentials_cache.clone(),
);
let op = aws_smithy_http::operation::Operation::new(
request,
crate::operation::RegisterClient::new(),
)
.with_metadata(aws_smithy_http::operation::Metadata::new(
"RegisterClient",
"ssooidc",
));
let op = op.with_retry_classifier(aws_http::retry::AwsResponseRetryClassifier::new());
Ok(op)
}
pub fn builder() -> crate::input::register_client_input::Builder {
crate::input::register_client_input::Builder::default()
}
}
pub mod start_device_authorization_input {
#[derive(std::clone::Clone, std::cmp::PartialEq, std::default::Default, std::fmt::Debug)]
pub struct Builder {
pub(crate) client_id: std::option::Option<std::string::String>,
pub(crate) client_secret: std::option::Option<std::string::String>,
pub(crate) start_url: std::option::Option<std::string::String>,
}
impl Builder {
pub fn client_id(mut self, input: impl Into<std::string::String>) -> Self {
self.client_id = Some(input.into());
self
}
pub fn set_client_id(mut self, input: std::option::Option<std::string::String>) -> Self {
self.client_id = input;
self
}
pub fn client_secret(mut self, input: impl Into<std::string::String>) -> Self {
self.client_secret = Some(input.into());
self
}
pub fn set_client_secret(
mut self,
input: std::option::Option<std::string::String>,
) -> Self {
self.client_secret = input;
self
}
pub fn start_url(mut self, input: impl Into<std::string::String>) -> Self {
self.start_url = Some(input.into());
self
}
pub fn set_start_url(mut self, input: std::option::Option<std::string::String>) -> Self {
self.start_url = input;
self
}
pub fn build(
self,
) -> Result<
crate::input::StartDeviceAuthorizationInput,
aws_smithy_http::operation::error::BuildError,
> {
Ok(crate::input::StartDeviceAuthorizationInput {
client_id: self.client_id,
client_secret: self.client_secret,
start_url: self.start_url,
})
}
}
}
impl StartDeviceAuthorizationInput {
#[allow(unused_mut)]
#[allow(clippy::let_and_return)]
#[allow(clippy::needless_borrow)]
pub async fn make_operation(
&self,
_config: &crate::config::Config,
) -> std::result::Result<
aws_smithy_http::operation::Operation<
crate::operation::StartDeviceAuthorization,
aws_http::retry::AwsResponseRetryClassifier,
>,
aws_smithy_http::operation::error::BuildError,
> {
let params_result = crate::endpoint::Params::builder()
.set_region(_config.region.as_ref().map(|r| r.as_ref().to_owned()))
.set_use_dual_stack(_config.use_dual_stack)
.set_use_fips(_config.use_fips)
.set_endpoint(_config.endpoint_url.clone())
.build()
.map_err(|err| {
aws_smithy_http::endpoint::ResolveEndpointError::from_source(
"could not construct endpoint parameters",
err,
)
});
let (endpoint_result, params) = match params_result {
Ok(params) => (
_config.endpoint_resolver.resolve_endpoint(¶ms),
Some(params),
),
Err(e) => (Err(e), None),
};
let mut request = {
fn uri_base(
_input: &crate::input::StartDeviceAuthorizationInput,
output: &mut String,
) -> Result<(), aws_smithy_http::operation::error::BuildError> {
write!(output, "/device_authorization").expect("formatting should succeed");
Ok(())
}
#[allow(clippy::unnecessary_wraps)]
fn update_http_builder(
input: &crate::input::StartDeviceAuthorizationInput,
builder: http::request::Builder,
) -> std::result::Result<
http::request::Builder,
aws_smithy_http::operation::error::BuildError,
> {
let mut uri = String::new();
uri_base(input, &mut uri)?;
Ok(builder.method("POST").uri(uri))
}
let mut builder = update_http_builder(&self, http::request::Builder::new())?;
builder = aws_smithy_http::header::set_request_header_if_absent(
builder,
http::header::CONTENT_TYPE,
"application/json",
);
builder
};
let mut properties = aws_smithy_http::property_bag::SharedPropertyBag::new();
#[allow(clippy::useless_conversion)]
let body = aws_smithy_http::body::SdkBody::from(
crate::operation_ser::serialize_operation_crate_operation_start_device_authorization(
&self,
)?,
);
if let Some(content_length) = body.content_length() {
request = aws_smithy_http::header::set_request_header_if_absent(
request,
http::header::CONTENT_LENGTH,
content_length,
);
}
let request = request.body(body).expect("should be valid request");
let mut request = aws_smithy_http::operation::Request::from_parts(request, properties);
request.properties_mut().insert(endpoint_result);
if let Some(params) = params {
request.properties_mut().insert(params);
}
request
.properties_mut()
.insert(aws_smithy_http::http_versions::DEFAULT_HTTP_VERSION_LIST.clone());
let mut user_agent = aws_http::user_agent::AwsUserAgent::new_from_environment(
aws_types::os_shim_internal::Env::real(),
crate::API_METADATA.clone(),
);
if let Some(app_name) = _config.app_name() {
user_agent = user_agent.with_app_name(app_name.clone());
}
request.properties_mut().insert(user_agent);
let mut signing_config = aws_sig_auth::signer::OperationSigningConfig::default_config();
signing_config.signing_requirements = aws_sig_auth::signer::SigningRequirements::Disabled;
request.properties_mut().insert(signing_config);
request
.properties_mut()
.insert(aws_types::SigningService::from_static(
_config.signing_service(),
));
if let Some(region) = &_config.region {
request
.properties_mut()
.insert(aws_types::region::SigningRegion::from(region.clone()));
}
if let Some(region) = &_config.region {
request.properties_mut().insert(region.clone());
}
aws_http::auth::set_credentials_cache(
&mut request.properties_mut(),
_config.credentials_cache.clone(),
);
let op = aws_smithy_http::operation::Operation::new(
request,
crate::operation::StartDeviceAuthorization::new(),
)
.with_metadata(aws_smithy_http::operation::Metadata::new(
"StartDeviceAuthorization",
"ssooidc",
));
let op = op.with_retry_classifier(aws_http::retry::AwsResponseRetryClassifier::new());
Ok(op)
}
pub fn builder() -> crate::input::start_device_authorization_input::Builder {
crate::input::start_device_authorization_input::Builder::default()
}
}
#[allow(missing_docs)] #[non_exhaustive]
#[derive(std::clone::Clone, std::cmp::PartialEq, std::fmt::Debug)]
pub struct StartDeviceAuthorizationInput {
#[doc(hidden)]
pub client_id: std::option::Option<std::string::String>,
#[doc(hidden)]
pub client_secret: std::option::Option<std::string::String>,
#[doc(hidden)]
pub start_url: std::option::Option<std::string::String>,
}
impl StartDeviceAuthorizationInput {
pub fn client_id(&self) -> std::option::Option<&str> {
self.client_id.as_deref()
}
pub fn client_secret(&self) -> std::option::Option<&str> {
self.client_secret.as_deref()
}
pub fn start_url(&self) -> std::option::Option<&str> {
self.start_url.as_deref()
}
}
#[allow(missing_docs)] #[non_exhaustive]
#[derive(std::clone::Clone, std::cmp::PartialEq, std::fmt::Debug)]
pub struct RegisterClientInput {
#[doc(hidden)]
pub client_name: std::option::Option<std::string::String>,
#[doc(hidden)]
pub client_type: std::option::Option<std::string::String>,
#[doc(hidden)]
pub scopes: std::option::Option<std::vec::Vec<std::string::String>>,
}
impl RegisterClientInput {
pub fn client_name(&self) -> std::option::Option<&str> {
self.client_name.as_deref()
}
pub fn client_type(&self) -> std::option::Option<&str> {
self.client_type.as_deref()
}
pub fn scopes(&self) -> std::option::Option<&[std::string::String]> {
self.scopes.as_deref()
}
}
#[allow(missing_docs)] #[non_exhaustive]
#[derive(std::clone::Clone, std::cmp::PartialEq, std::fmt::Debug)]
pub struct CreateTokenInput {
#[doc(hidden)]
pub client_id: std::option::Option<std::string::String>,
#[doc(hidden)]
pub client_secret: std::option::Option<std::string::String>,
#[doc(hidden)]
pub grant_type: std::option::Option<std::string::String>,
#[doc(hidden)]
pub device_code: std::option::Option<std::string::String>,
#[doc(hidden)]
pub code: std::option::Option<std::string::String>,
#[doc(hidden)]
pub refresh_token: std::option::Option<std::string::String>,
#[doc(hidden)]
pub scope: std::option::Option<std::vec::Vec<std::string::String>>,
#[doc(hidden)]
pub redirect_uri: std::option::Option<std::string::String>,
}
impl CreateTokenInput {
pub fn client_id(&self) -> std::option::Option<&str> {
self.client_id.as_deref()
}
pub fn client_secret(&self) -> std::option::Option<&str> {
self.client_secret.as_deref()
}
pub fn grant_type(&self) -> std::option::Option<&str> {
self.grant_type.as_deref()
}
pub fn device_code(&self) -> std::option::Option<&str> {
self.device_code.as_deref()
}
pub fn code(&self) -> std::option::Option<&str> {
self.code.as_deref()
}
pub fn refresh_token(&self) -> std::option::Option<&str> {
self.refresh_token.as_deref()
}
pub fn scope(&self) -> std::option::Option<&[std::string::String]> {
self.scope.as_deref()
}
pub fn redirect_uri(&self) -> std::option::Option<&str> {
self.redirect_uri.as_deref()
}
}