1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
/// <p>The Grant union represents the set of possible configuration options for the selected grant type. Exactly one member of the union must be specified, and must match the grant type selected.</p>
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
pub enum Grant {
/// <p>Configuration options for the <code>authorization_code</code> grant type.</p>
AuthorizationCode(crate::types::AuthorizationCodeGrant),
/// <p>Configuration options for the <code>urn:ietf:params:oauth:grant-type:jwt-bearer</code> grant type.</p>
JwtBearer(crate::types::JwtBearerGrant),
/// <p>Configuration options for the <code>refresh_token</code> grant type.</p>
RefreshToken(crate::types::RefreshTokenGrant),
/// <p>Configuration options for the <code>urn:ietf:params:oauth:grant-type:token-exchange</code> grant type.</p>
TokenExchange(crate::types::TokenExchangeGrant),
/// The `Unknown` variant represents cases where new union variant was received. Consider upgrading the SDK to the latest available version.
/// An unknown enum variant
///
/// _Note: If you encounter this error, consider upgrading your SDK to the latest version._
/// The `Unknown` variant represents cases where the server sent a value that wasn't recognized
/// by the client. This can happen when the server adds new functionality, but the client has not been updated.
/// To investigate this, consider turning on debug logging to print the raw HTTP response.
#[non_exhaustive]
Unknown,
}
impl Grant {
/// Tries to convert the enum instance into [`AuthorizationCode`](crate::types::Grant::AuthorizationCode), extracting the inner [`AuthorizationCodeGrant`](crate::types::AuthorizationCodeGrant).
/// Returns `Err(&Self)` if it can't be converted.
pub fn as_authorization_code(&self) -> ::std::result::Result<&crate::types::AuthorizationCodeGrant, &Self> {
if let Grant::AuthorizationCode(val) = &self {
::std::result::Result::Ok(val)
} else {
::std::result::Result::Err(self)
}
}
/// Returns true if this is a [`AuthorizationCode`](crate::types::Grant::AuthorizationCode).
pub fn is_authorization_code(&self) -> bool {
self.as_authorization_code().is_ok()
}
/// Tries to convert the enum instance into [`JwtBearer`](crate::types::Grant::JwtBearer), extracting the inner [`JwtBearerGrant`](crate::types::JwtBearerGrant).
/// Returns `Err(&Self)` if it can't be converted.
pub fn as_jwt_bearer(&self) -> ::std::result::Result<&crate::types::JwtBearerGrant, &Self> {
if let Grant::JwtBearer(val) = &self {
::std::result::Result::Ok(val)
} else {
::std::result::Result::Err(self)
}
}
/// Returns true if this is a [`JwtBearer`](crate::types::Grant::JwtBearer).
pub fn is_jwt_bearer(&self) -> bool {
self.as_jwt_bearer().is_ok()
}
/// Tries to convert the enum instance into [`RefreshToken`](crate::types::Grant::RefreshToken), extracting the inner [`RefreshTokenGrant`](crate::types::RefreshTokenGrant).
/// Returns `Err(&Self)` if it can't be converted.
pub fn as_refresh_token(&self) -> ::std::result::Result<&crate::types::RefreshTokenGrant, &Self> {
if let Grant::RefreshToken(val) = &self {
::std::result::Result::Ok(val)
} else {
::std::result::Result::Err(self)
}
}
/// Returns true if this is a [`RefreshToken`](crate::types::Grant::RefreshToken).
pub fn is_refresh_token(&self) -> bool {
self.as_refresh_token().is_ok()
}
/// Tries to convert the enum instance into [`TokenExchange`](crate::types::Grant::TokenExchange), extracting the inner [`TokenExchangeGrant`](crate::types::TokenExchangeGrant).
/// Returns `Err(&Self)` if it can't be converted.
pub fn as_token_exchange(&self) -> ::std::result::Result<&crate::types::TokenExchangeGrant, &Self> {
if let Grant::TokenExchange(val) = &self {
::std::result::Result::Ok(val)
} else {
::std::result::Result::Err(self)
}
}
/// Returns true if this is a [`TokenExchange`](crate::types::Grant::TokenExchange).
pub fn is_token_exchange(&self) -> bool {
self.as_token_exchange().is_ok()
}
/// Returns true if the enum instance is the `Unknown` variant.
pub fn is_unknown(&self) -> bool {
matches!(self, Self::Unknown)
}
}