// Copyright 2016 Istio Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

// $title: List
// $description: Adapter that performs whitelist or blacklist checks.
// $location: https://istio.io/docs/reference/config/policy-and-telemetry/adapters/list.html
// $supported_templates: listentry
// $aliases:
// $  - /docs/reference/config/adapters/list.html

// The `list` adapter makes it possible to perform simple whitelist or blacklist
// checks. You can configure the adapter with the list to check, or you can point
// it to a URL from where the list should be fetched. Lists can be simple strings,
// IP addresses, or regex patterns.
//
// This adapter supports the [listentry template](https://istio.io/docs/reference/config/policy-and-telemetry/templates/listentry/).
package adapter.list.config;

import "google/protobuf/duration.proto";
import "gogoproto/gogo.proto";

option go_package="config";
option (gogoproto.goproto_getters_all) = false;
option (gogoproto.equal_all) = false;
option (gogoproto.gostring_all) = false;

// Configuration format for the `list` adapter.
message Params {
    // Where to find the list to check against. This may be omitted for a completely local list.
    string provider_url = 1;

    // Determines how often the provider is polled for
    // an updated list
    google.protobuf.Duration refresh_interval = 2 [(gogoproto.nullable) = false, (gogoproto.stdduration) = true];

    // Indicates how long to keep a list before discarding it.
    // Typically, the TTL value should be set to noticeably longer (> 2x) than the
    // refresh interval to ensure continued operation in the face of transient
    // server outages.
    google.protobuf.Duration ttl = 3 [(gogoproto.nullable) = false, (gogoproto.stdduration) = true];

    // Indicates the amount of time a caller of this adapter can cache an answer
    // before it should ask the adapter again.
    google.protobuf.Duration caching_interval = 4 [(gogoproto.nullable) = false, (gogoproto.stdduration) = true];

    // Indicates the number of times a caller of this adapter can use a cached answer
    // before it should ask the adapter again.
    int32 caching_use_count = 5;

    // List entries that are consulted first, before the list from the server
    repeated string overrides = 6;

    // Determines the type of list that the adapter is consulting.
    enum ListEntryType {
        // List entries are treated as plain strings.
        STRINGS = 0;

        // List entries are treated as case-insensitive strings.
        CASE_INSENSITIVE_STRINGS = 1;

        // List entries are treated as IP addresses and ranges.
        IP_ADDRESSES = 2;

        // List entries are treated as re2 regexp. See [here](https://github.com/google/re2/wiki/Syntax) for the supported syntax.
        REGEX = 3;
    }

    // Determines the kind of list entry and overrides.
    ListEntryType entry_type = 7;

    // Whether the list operates as a blacklist or a whitelist.
    bool blacklist = 8;
}
