All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.aws.lambda.events.gateway.APIGatewayV2HTTPEvent Maven / Gradle / Ivy


package io.aws.lambda.events.gateway;

import io.aws.lambda.events.BodyBase64Event;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jetbrains.annotations.NotNull;

import java.util.Collections;
import java.util.List;
import java.util.Map;

/**
 * API Gateway v2 event:
 * https://docs.aws.amazon.com/lambda/latest/dg/services-apigateway.html
 */
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
public class APIGatewayV2HTTPEvent extends BodyBase64Event {

    private String version;
    private String routeKey;
    private String rawPath;
    private String rawQueryString;
    private List cookies;
    private Map headers;
    private Map queryStringParameters;
    private Map pathParameters;
    private Map stageVariables;
    private RequestContext requestContext;

    public @NotNull Map getHeaders() {
        return headers == null ? Collections.emptyMap() : headers;
    }

    public @NotNull Map getQueryStringParameters() {
        return queryStringParameters == null ? Collections.emptyMap() : queryStringParameters;
    }

    public @NotNull Map getPathParameters() {
        return pathParameters == null ? Collections.emptyMap() : pathParameters;
    }

    public @NotNull Map getStageVariables() {
        return stageVariables == null ? Collections.emptyMap() : stageVariables;
    }

    public @NotNull List getCookies() {
        return cookies == null ? Collections.emptyList() : cookies;
    }

    @Data
    @Accessors(chain = true)
    public static class RequestContext {

        private String routeKey;
        private String accountId;
        private String stage;
        private String apiId;
        private String domainName;
        private String domainPrefix;
        private String time;
        private long timeEpoch;
        private Http http;
        private Authorizer authorizer;
        private String requestId;

        @Data
        @Accessors(chain = true)
        public static class Authorizer {

            private JWT jwt;
            private IAM iam;
            private Map lambda;

            public @NotNull Map getLambda() {
                return lambda == null ? Collections.emptyMap() : lambda;
            }

            @Data
            @Accessors(chain = true)
            public static class JWT {

                private Map claims;
                private List scopes;

                public @NotNull Map getClaims() {
                    return claims == null ? Collections.emptyMap() : claims;
                }

                public @NotNull List getScopes() {
                    return scopes == null ? Collections.emptyList() : scopes;
                }
            }
        }

        @Data
        @Accessors(chain = true)
        public static class Http {

            private String method;
            private String path;
            private String protocol;
            private String sourceIp;
            private String userAgent;
        }

        @Data
        @Accessors(chain = true)
        public static class IAM {

            private String accessKey;
            private String accountId;
            private String callerId;
            private CognitoIdentity cognitoIdentity;
            private String principalOrgId;
            private String userArn;
            private String userId;
        }

        @Data
        @Accessors(chain = true)
        public static class CognitoIdentity {

            private List amr;
            private String identityId;
            private String identityPoolId;

            public @NotNull List getAmr() {
                return amr == null ? Collections.emptyList() : amr;
            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy