// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.jdisc.http.filter.security.athenz;

import com.yahoo.vespa.athenz.api.AthenzResourceName;

import java.util.Optional;

/**
 * Maps a request to an {@link AthenzResourceName} and an action.
 *
 * @author bjorncs
 */
public interface RequestResourceMapper {

    /**
     * @return A resource name + action to use for access control, empty if no access control should be performed.
     */
    Optional<ResourceNameAndAction> getResourceNameAndAction(String method, String uriPath, String uriQuery);

    class ResourceNameAndAction {
        private final AthenzResourceName resourceName;
        private final String action;

        public ResourceNameAndAction(AthenzResourceName resourceName, String action) {
            this.resourceName = resourceName;
            this.action = action;
        }

        public AthenzResourceName resourceName() {
            return resourceName;
        }

        public String action() {
            return action;
        }
    }
}

@@ -1098,16 +1098,255 @@
        %7D
+%0A%0A        @Override%0A        public String toString() %7B%0A            return %22ResourceNameAndAction%7B%22 +%0A                    %22resourceName=%22 + resourceName +%0A                    %22, action='%22 + action + '%5C'' +%0A                    '%7D';%0A        %7D
 %0A    %7D%0A%7D

Add toString() to ResourceNameAndAction