// 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.network.generic_proxy.v3;

import "envoy/config/accesslog/v3/accesslog.proto";
import "envoy/config/core/v3/config_source.proto";
import "envoy/config/core/v3/extension.proto";
import "envoy/extensions/filters/network/generic_proxy/v3/route.proto";
import "envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.proto";

import "xds/annotations/v3/status.proto";

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

option java_package = "io.envoyproxy.envoy.extensions.filters.network.generic_proxy.v3";
option java_outer_classname = "GenericProxyProto";
option java_multiple_files = true;
option go_package = "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/generic_proxy/v3;generic_proxyv3";
option (udpa.annotations.file_status).package_version_status = ACTIVE;
option (xds.annotations.v3.file_status).work_in_progress = true;

// [#protodoc-title: Generic Proxy]
// Generic proxy.
// [#extension: envoy.filters.network.generic_proxy]

// [#next-free-field: 8]
message GenericProxy {
  // The human readable prefix to use when emitting statistics.
  string stat_prefix = 1 [(validate.rules).string = {min_len: 1}];

  // The codec which encodes and decodes the application protocol.
  // [#extension-category: envoy.generic_proxy.codecs]
  config.core.v3.TypedExtensionConfig codec_config = 2
      [(validate.rules).message = {required: true}];

  oneof route_specifier {
    option (validate.required) = true;

    // The generic proxies route table will be dynamically loaded via the meta RDS API.
    GenericRds generic_rds = 3;

    // The route table for the generic proxy is static and is specified in this property.
    RouteConfiguration route_config = 4;
  }

  // A list of individual Layer-7 filters that make up the filter chain for requests made to the
  // proxy. Order matters as the filters are processed sequentially as request events
  // happen.
  // [#extension-category: envoy.generic_proxy.filters]
  repeated config.core.v3.TypedExtensionConfig filters = 5;

  // Tracing configuration for the generic proxy.
  http_connection_manager.v3.HttpConnectionManager.Tracing tracing = 6;

  // Configuration for :ref:`access logs <arch_overview_access_logs>` emitted by generic proxy.
  repeated config.accesslog.v3.AccessLog access_log = 7;
}

message GenericRds {
  // Configuration source specifier for RDS.
  config.core.v3.ConfigSource config_source = 1 [(validate.rules).message = {required: true}];

  // The name of the route configuration. This name will be passed to the RDS API. This allows an
  // Envoy configuration with multiple generic proxies to use different route configurations.
  string route_config_name = 2 [(validate.rules).string = {min_len: 1}];
}
