syntax = "proto3";
package spire.api.types;
option go_package = "github.com/spiffe/spire-api-sdk/proto/spire/api/types";

message Selector {
    // The type of the selector. This is typically the name of the plugin that
    // produces the selector.
    string type = 1;

    // The value of the selector.
    string value = 2;
}

message SelectorMatch {
    enum MatchBehavior {
        // Indicates that the selectors in this match are equal to the
        // candidate selectors, independent of ordering.
        // Example:
        //   Given:
        //     - 'e1 { Selectors: ["a:1", "b:2", "c:3"]}'
        //     - 'e2 { Selectors: ["a:1", "b:2"]}'
        //     - 'e3 { Selectors: ["a:1"]}'
        //   Operation:
        //     - MATCH_EXACT ["a:1", "b:2"]
        //   Entries that match:
        //     - 'e2'
        MATCH_EXACT = 0;

        // Indicates that all candidates which have a non-empty subset
        // of the provided set of selectors will match.
        // Example:
        //   Given:
        //     - 'e1 { Selectors: ["a:1", "b:2", "c:3"]}'
        //     - 'e2 { Selectors: ["a:1", "b:2"]}'
        //     - 'e3 { Selectors: ["a:1"]}'
        //   Operation:
        //     - MATCH_SUBSET ["a:1"]
        //   Entries that match:
        //     - 'e1'
        MATCH_SUBSET = 1;

        // Indicates that all candidates which are a superset
        // of the provided selectors will match.
        // Example:
        //   Given:
        //     - 'e1 { Selectors: ["a:1", "b:2", "c:3"]}'
        //     - 'e2 { Selectors: ["a:1", "b:2"]}'
        //     - 'e3 { Selectors: ["a:1"]}'
        //   Operation:
        //     - MATCH_SUPERSET ["a:1", "b:2"]
        //   Entries that match:
        //     - 'e1'
        //     - 'e2'
        MATCH_SUPERSET = 2;

        // Indicates that all candidates which have at least one
        // of the provided set of selectors will match.
        // Example:
        //   Given:
        //     - 'e1 { Selectors: ["a:1", "b:2", "c:3"]}'
        //     - 'e2 { Selectors: ["a:1", "b:2"]}'
        //     - 'e3 { Selectors: ["a:1"]}'
        //   Operation:
        //     - MATCH_ANY ["a:1"]
        //   Entries that match:
        //     - 'e1'
        //     - 'e2'
        //     - 'e3'
        MATCH_ANY = 3;

    }

    // The set of selectors to match on.
    repeated Selector selectors = 1;

    // How to match the selectors.
    MatchBehavior match = 2;
}
