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

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

package io.aws.lambda.events.gateway;

import lombok.Data;
import lombok.experimental.Accessors;
import org.jetbrains.annotations.NotNull;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Collections;
import java.util.List;
import java.util.Map;

/**
 * The V2 API Gateway customer authorizer event object as described -
 * https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-lambda-authorizer.html
 *
 */
@Data
@Accessors(chain = true)
public class APIGatewayV2CustomAuthorizerEvent {

    private String version;
    private String type;
    private String routeArn;
    private String routeKey;
    private String rawPath;
    private String rawQueryString;
    private List identitySource;
    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 getIdentitySource() {
        return identitySource == null ? Collections.emptyList() : identitySource;
    }

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

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

        private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("dd/MMM/yyyy:HH:mm:ss Z");

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

        public LocalDateTime getDateTime() {
            return LocalDateTime.parse(time, FORMATTER);
        }
    }

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy