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

import "envoy/config/core/v3/config_source.proto";
import "envoy/extensions/filters/network/dubbo_proxy/v3/route.proto";

import "google/protobuf/any.proto";

import "envoy/annotations/deprecation.proto";
import "udpa/annotations/migrate.proto";
import "udpa/annotations/status.proto";
import "udpa/annotations/versioning.proto";
import "validate/validate.proto";

option java_package = "io.envoyproxy.envoy.extensions.filters.network.dubbo_proxy.v3";
option java_outer_classname = "DubboProxyProto";
option java_multiple_files = true;
option go_package = "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/dubbo_proxy/v3;dubbo_proxyv3";
option (udpa.annotations.file_status).package_version_status = ACTIVE;

// [#protodoc-title: Dubbo Proxy]
// Dubbo Proxy :ref:`configuration overview <config_network_filters_dubbo_proxy>`.
// [#extension: envoy.filters.network.dubbo_proxy]

// Dubbo Protocol types supported by Envoy.
enum ProtocolType {
  // the default protocol.
  Dubbo = 0;
}

// Dubbo Serialization types supported by Envoy.
enum SerializationType {
  // the default serialization protocol.
  Hessian2 = 0;
}

message Drds {
  // Configuration source specifier.
  // In case of ``api_config_source`` only aggregated ``api_type`` is supported.
  config.core.v3.ConfigSource config_source = 1 [(validate.rules).message = {required: true}];

  // The name of the multiple route configuration. This allows to use different multiple route
  // configurations. Tells which multiple route configuration should be fetched from the configuration
  // source. Leave unspecified is also valid and means the unnamed multiple route configuration.
  string route_config_name = 2;
}

// [#next-free-field: 8]
message DubboProxy {
  option (udpa.annotations.versioning).previous_message_type =
      "envoy.config.filter.network.dubbo_proxy.v2alpha1.DubboProxy";

  // The human readable prefix to use when emitting statistics.
  string stat_prefix = 1 [(validate.rules).string = {min_len: 1}];

  // Configure the protocol used.
  ProtocolType protocol_type = 2 [(validate.rules).enum = {defined_only: true}];

  // Configure the serialization protocol used.
  SerializationType serialization_type = 3 [(validate.rules).enum = {defined_only: true}];

  // The route table for the connection manager is static and is specified in this property.
  //
  // .. note::
  //
  //   This field is deprecated. Please use ``drds`` or ``multiple_route_config`` first.
  repeated RouteConfiguration route_config = 4
      [deprecated = true, (envoy.annotations.deprecated_at_minor_version) = "3.0"];

  oneof route_specifier {
    // Use xDS to fetch the route configuration. It is invalid to define both ``route_config`` and ``drds``.
    Drds drds = 6 [(udpa.annotations.field_migrate).oneof_promotion = "route_specifier"];

    MultipleRouteConfiguration multiple_route_config = 7;
  }

  // A list of individual Dubbo filters that make up the filter chain for requests made to the
  // Dubbo proxy. Order matters as the filters are processed sequentially. For backwards
  // compatibility, if no dubbo_filters are specified, a default Dubbo router filter
  // (``envoy.filters.dubbo.router``) is used.
  repeated DubboFilter dubbo_filters = 5;
}

// DubboFilter configures a Dubbo filter.
message DubboFilter {
  option (udpa.annotations.versioning).previous_message_type =
      "envoy.config.filter.network.dubbo_proxy.v2alpha1.DubboFilter";

  // The name of the filter to instantiate. The name must match a supported
  // filter.
  string name = 1 [(validate.rules).string = {min_len: 1}];

  // Filter specific configuration which depends on the filter being
  // instantiated. See the supported filters for further documentation.
  google.protobuf.Any config = 2;
}
