// Copyright 2018 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: Rules
// $description: Describes the rules used to configure Mixer's policy and telemetry features.
// $location: https://istio.io/docs/reference/config/policy-and-telemetry/istio.policy.v1beta1.html

// Describes the rules used to configure Mixer's policy and telemetry features.
package istio.policy.v1beta1;

option go_package="istio.io/api/policy/v1beta1";
option java_package = "io.istio.api.policy.v1beta1";
option java_outer_classname = "TypeProto";

import "google/protobuf/duration.proto";
import "google/protobuf/timestamp.proto";

// An instance field of type Value denotes that the expression for the field is of dynamic type and can evalaute to any
// [ValueType][istio.policy.v1beta1.ValueType] enum values. For example, when
// authoring an instance configuration for a template that has a field `data` of type `istio.policy.v1beta1.Value`,
// both of the following expressions are valid `data: source.ip | ip("0.0.0.0")`, `data: request.id | ""`;
// the resulting type is either ValueType.IP_ADDRESS or ValueType.STRING for the two cases respectively.
//
// Objects of type Value are also passed to the adapters during request-time. There is a 1:1 mapping between
// oneof fields in `Value` and enum values inside `ValueType`. Depending on the expression's evaluated `ValueType`,
// the equivalent oneof field in `Value` is populated by Mixer and passed to the adapters.
message Value {
    oneof value {
        // Used for values of type STRING
        string string_value = 1;

        // Used for values of type INT64
        int64 int64_value = 2;

        // Used for values of type DOUBLE
        double double_value = 3;

        // Used for values of type BOOL
        bool bool_value = 4;

        // Used for values of type IPAddress
        IPAddress ip_address_value = 5;

        // Used for values of type TIMESTAMP
        TimeStamp timestamp_value = 6;

        // Used for values of type DURATION
        Duration duration_value = 7;

        // Used for values of type EmailAddress
        EmailAddress email_address_value = 8;

        // Used for values of type DNSName
        DNSName dns_name_value = 9;

        // Used for values of type Uri
        Uri uri_value = 10;
    }
}

// An instance field of type IPAddress denotes that the expression for the field must evalaute to
// [ValueType.IP_ADDRESS][istio.policy.v1beta1.ValueType.IP_ADDRESS]
//
// Objects of type IPAddress are also passed to the adapters during request-time for the instance fields of
// type IPAddress
message IPAddress {
    // IPAddress encoded as bytes.
    bytes value = 1;
}

// An instance field of type Duration denotes that the expression for the field must evalaute to
// [ValueType.DURATION][istio.policy.v1beta1.ValueType.DURATION]
//
// Objects of type Duration are also passed to the adapters during request-time for the instance fields of
// type Duration
message Duration {
    // Duration encoded as google.protobuf.Duration.
    google.protobuf.Duration value = 1;
}

// An instance field of type TimeStamp denotes that the expression for the field must evalaute to
// [ValueType.TIMESTAMP][istio.policy.v1beta1.ValueType.TIMESTAMP]
//
// Objects of type TimeStamp are also passed to the adapters during request-time for the instance fields of
// type TimeStamp
message TimeStamp {
    // TimeStamp encoded as google.protobuf.Timestamp.
    google.protobuf.Timestamp value = 1;
}

// An instance field of type DNSName denotes that the expression for the field must evalaute to
// [ValueType.DNS_NAME][istio.policy.v1beta1.ValueType.DNS_NAME]
//
// Objects of type DNSName are also passed to the adapters during request-time for the instance fields of
// type DNSName
message DNSName {
    // DNSName encoded as string.
    string value = 1;
}

// DO NOT USE !! Under Development
// An instance field of type EmailAddress denotes that the expression for the field must evalaute to
// [ValueType.EMAIL_ADDRESS][istio.policy.v1beta1.ValueType.EMAIL_ADDRESS]
//
// Objects of type EmailAddress are also passed to the adapters during request-time for the instance fields of
// type EmailAddress
message EmailAddress {
    // EmailAddress encoded as string.
    string value = 1;
}

// DO NOT USE !! Under Development
// An instance field of type Uri denotes that the expression for the field must evalaute to
// [ValueType.URI][istio.policy.v1beta1.ValueType.URI]
//
// Objects of type Uri are also passed to the adapters during request-time for the instance fields of
// type Uri
message Uri {
    // Uri encoded as string.
    string value = 1;
}
