From a250d99a121c49eafacdcf132bd1c2010517ec7e Mon Sep 17 00:00:00 2001 From: David Calavera Date: Wed, 21 Feb 2024 08:36:22 -0800 Subject: [PATCH] Rename the Authorizer structs. Make the name more consistent since it's used for multiple versions of Api Gateway. Keep the old names as deprecated. Signed-off-by: David Calavera --- lambda-events/src/event/apigw/mod.rs | 33 ++++++++++++++++------------ 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/lambda-events/src/event/apigw/mod.rs b/lambda-events/src/event/apigw/mod.rs index da84477d..1a9b1f1a 100644 --- a/lambda-events/src/event/apigw/mod.rs +++ b/lambda-events/src/event/apigw/mod.rs @@ -191,11 +191,11 @@ pub struct ApiGatewayV2httpRequestContext { pub authentication: Option, } -/// `ApiGatewayV2httpRequestContextAuthorizerDescription` contains authorizer information for the request context. +/// `ApiGatewayRequestAuthorizer` contains authorizer information for the request context. #[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)] -pub struct ApiGatewayV2httpRequestContextAuthorizerDescription { +pub struct ApiGatewayRequestAuthorizer { #[serde(skip_serializing_if = "Option::is_none")] - pub jwt: Option, + pub jwt: Option, #[serde( bound = "", rename = "lambda", @@ -205,13 +205,13 @@ pub struct ApiGatewayV2httpRequestContextAuthorizerDescription { )] pub fields: HashMap, #[serde(skip_serializing_if = "Option::is_none")] - pub iam: Option, + pub iam: Option, } -/// `ApiGatewayV2httpRequestContextAuthorizerJwtDescription` contains JWT authorizer information for the request context. +/// `ApiGatewayRequestAuthorizerJwtDescription` contains JWT authorizer information for the request context. #[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)] #[serde(rename_all = "camelCase")] -pub struct ApiGatewayV2httpRequestContextAuthorizerJwtDescription { +pub struct ApiGatewayRequestAuthorizerJwtDescription { #[serde(deserialize_with = "deserialize_lambda_map")] #[serde(default)] pub claims: HashMap, @@ -219,10 +219,10 @@ pub struct ApiGatewayV2httpRequestContextAuthorizerJwtDescription { pub scopes: Option>, } -/// `ApiGatewayV2httpRequestContextAuthorizerIamDescription` contains IAM information for the request context. +/// `ApiGatewayRequestAuthorizerIamDescription` contains IAM information for the request context. #[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)] #[serde(rename_all = "camelCase")] -pub struct ApiGatewayV2httpRequestContextAuthorizerIamDescription { +pub struct ApiGatewayRequestAuthorizerIamDescription { #[serde(default)] pub access_key: Option, #[serde(default)] @@ -230,7 +230,7 @@ pub struct ApiGatewayV2httpRequestContextAuthorizerIamDescription { #[serde(default)] pub caller_id: Option, #[serde(skip_serializing_if = "Option::is_none")] - pub cognito_identity: Option, + pub cognito_identity: Option, #[serde(default)] pub principal_org_id: Option, #[serde(default)] @@ -239,10 +239,10 @@ pub struct ApiGatewayV2httpRequestContextAuthorizerIamDescription { pub user_id: Option, } -/// `ApiGatewayV2httpRequestContextAuthorizerCognitoIdentity` contains Cognito identity information for the request context. +/// `ApiGatewayRequestAuthorizerCognitoIdentity` contains Cognito identity information for the request context. #[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)] #[serde(rename_all = "camelCase")] -pub struct ApiGatewayV2httpRequestContextAuthorizerCognitoIdentity { +pub struct ApiGatewayRequestAuthorizerCognitoIdentity { pub amr: Vec, #[serde(default)] pub identity_id: Option, @@ -749,9 +749,14 @@ fn default_http_method() -> Method { Method::GET } -/// `ApiGatewayRequestAuthorizer` is a type alias for `ApiGatewayV2httpRequestContextAuthorizerDescription`. -/// This type is used by all events that receive request authorizer information. -pub type ApiGatewayRequestAuthorizer = ApiGatewayV2httpRequestContextAuthorizerDescription; +#[deprecated = "use `ApiGatewayRequestAuthorizer` instead"] +pub type ApiGatewayV2httpRequestContextAuthorizerDescription = ApiGatewayRequestAuthorizer; +#[deprecated = "use `ApiGatewayRequestAuthorizerJwtDescription` instead"] +pub type ApiGatewayV2httpRequestContextAuthorizerJwtDescription = ApiGatewayRequestAuthorizerJwtDescription; +#[deprecated = "use `ApiGatewayRequestAuthorizerIamDescription` instead"] +pub type ApiGatewayV2httpRequestContextAuthorizerIamDescription = ApiGatewayRequestAuthorizerIamDescription; +#[deprecated = "use `ApiGatewayRequestAuthorizerCognitoIdentity` instead"] +pub type ApiGatewayV2httpRequestContextAuthorizerCognitoIdentity = ApiGatewayRequestAuthorizerCognitoIdentity; impl ApiGatewayRequestAuthorizer { fn is_empty(&self) -> bool {