// Copyright 2025 Envoy Project 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 envoy.extensions.filters.common.dependency.v3;

import "udpa/annotations/status.proto";
import "validate/validate.proto";

option java_package = "io.envoyproxy.envoy.extensions.filters.common.dependency.v3";
option java_outer_classname = "DependencyProto";
option java_multiple_files = true;
option go_package = "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/common/dependency/v3;dependencyv3";
option (udpa.annotations.file_status).package_version_status = ACTIVE;

// [#protodoc-title: Filter dependency specification]

// Dependency specification and string identifier.
message Dependency {
  enum DependencyType {
    HEADER = 0;
    FILTER_STATE_KEY = 1;
    DYNAMIC_METADATA = 2;
  }

  // The kind of dependency.
  DependencyType type = 1;

  // The string identifier for the dependency.
  string name = 2 [(validate.rules).string = {min_len: 1}];
}

// Dependency specification for a filter. For a filter chain to be valid, any
// dependency that is required must be provided by an earlier filter.
message FilterDependencies {
  // A list of dependencies required on the decode path.
  repeated Dependency decode_required = 1;

  // A list of dependencies provided on the decode path.
  repeated Dependency decode_provided = 2;

  // A list of dependencies required on the encode path.
  repeated Dependency encode_required = 3;

  // A list of dependencies provided on the encode path.
  repeated Dependency encode_provided = 4;
}

// Matching requirements for a filter. For a match tree to be used with a filter, the match
// requirements must be satisfied.
//
// This protobuf is provided by the filter implementation as a way to communicate the matching
// requirements to the filter factories, allowing for config rejection if the requirements are
// not satisfied.
message MatchingRequirements {
  message DataInputAllowList {
    // An explicit list of data inputs that are allowed to be used with this filter.
    repeated string type_url = 1;
  }

  DataInputAllowList data_input_allow_list = 1;
}
