// Copyright 2017 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";

package adapter.memquota.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;

message Params {
	message Quota {
		option (gogoproto.goproto_getters) = true;
		// The name of the quota
		string name = 1;

		// The upper limit for this quota.
		int64 max_amount = 2;

		// The amount of time allocated quota remains valid before it is
		// automatically released. This is only meaningful for rate limit
		// quotas, otherwise the value must be zero.
		google.protobuf.Duration valid_duration = 3 [(gogoproto.nullable) = false, (gogoproto.stdduration) = true];

		// Overrides associated with this quota.
		// The first matching override is applied.
		repeated Override overrides = 4 [(gogoproto.nullable) = false];
	}
	message Override {
		option (gogoproto.goproto_getters) = true;

		// The specific dimensions for which this override applies.
		// String representation of instance dimensions is used to check against configured dimensions.
		map <string, string> dimensions = 1;

		// The upper limit for this quota.
		int64 max_amount = 2;

		// The amount of time allocated quota remains valid before it is
		// automatically released. This is only meaningful for rate limit
		// quotas, otherwise the value must be zero.
		google.protobuf.Duration valid_duration = 3 [(gogoproto.nullable) = false, (gogoproto.stdduration) = true];
	}

	// The set of known quotas.
	repeated Quota quotas = 1 [(gogoproto.nullable) = false];

	// Minimum number of seconds that deduplication is possible for a given operation.
	google.protobuf.Duration min_deduplication_duration = 2 [(gogoproto.nullable) = false, (gogoproto.stdduration) = true];
}
