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

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

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

option java_package = "io.envoyproxy.envoy.admin.v3";
option java_outer_classname = "ConfigDumpSharedProto";
option java_multiple_files = true;
option go_package = "github.com/envoyproxy/go-control-plane/envoy/admin/v3;adminv3";
option (udpa.annotations.file_status).package_version_status = ACTIVE;

// [#protodoc-title: ConfigDump]

// Resource status from the view of a xDS client, which tells the synchronization
// status between the xDS client and the xDS server.
enum ClientResourceStatus {
  // Resource status is not available/unknown.
  UNKNOWN = 0;

  // Client requested this resource but hasn't received any update from management
  // server. The client will not fail requests, but will queue them until update
  // arrives or the client times out waiting for the resource.
  REQUESTED = 1;

  // This resource has been requested by the client but has either not been
  // delivered by the server or was previously delivered by the server and then
  // subsequently removed from resources provided by the server. For more
  // information, please refer to the :ref:`"Knowing When a Requested Resource
  // Does Not Exist" <xds_protocol_resource_not_existed>` section.
  DOES_NOT_EXIST = 2;

  // Client received this resource and replied with ACK.
  ACKED = 3;

  // Client received this resource and replied with NACK.
  NACKED = 4;

  // Client received an error from the control plane. The attached config
  // dump is the most recent accepted one. If no config is accepted yet,
  // the attached config dump will be empty.
  RECEIVED_ERROR = 5;

  // Client timed out waiting for the resource from the control plane.
  TIMEOUT = 6;
}

message UpdateFailureState {
  option (udpa.annotations.versioning).previous_message_type =
      "envoy.admin.v2alpha.UpdateFailureState";

  // What the component configuration would have been if the update had succeeded.
  // This field may not be populated by xDS clients due to storage overhead.
  google.protobuf.Any failed_configuration = 1;

  // Time of the latest failed update attempt.
  google.protobuf.Timestamp last_update_attempt = 2;

  // Details about the last failed update attempt.
  string details = 3;

  // This is the version of the rejected resource.
  // [#not-implemented-hide:]
  string version_info = 4;
}

// Envoy's listener manager fills this message with all currently known listeners. Listener
// configuration information can be used to recreate an Envoy configuration by populating all
// listeners as static listeners or by returning them in a LDS response.
message ListenersConfigDump {
  option (udpa.annotations.versioning).previous_message_type =
      "envoy.admin.v2alpha.ListenersConfigDump";

  // Describes a statically loaded listener.
  message StaticListener {
    option (udpa.annotations.versioning).previous_message_type =
        "envoy.admin.v2alpha.ListenersConfigDump.StaticListener";

    // The listener config.
    google.protobuf.Any listener = 1;

    // The timestamp when the Listener was last successfully updated.
    google.protobuf.Timestamp last_updated = 2;
  }

  message DynamicListenerState {
    option (udpa.annotations.versioning).previous_message_type =
        "envoy.admin.v2alpha.ListenersConfigDump.DynamicListenerState";

    // This is the per-resource version information. This version is currently taken from the
    // :ref:`version_info <envoy_v3_api_field_service.discovery.v3.DiscoveryResponse.version_info>` field at the time
    // that the listener was loaded. In the future, discrete per-listener versions may be supported
    // by the API.
    string version_info = 1;

    // The listener config.
    google.protobuf.Any listener = 2;

    // The timestamp when the Listener was last successfully updated.
    google.protobuf.Timestamp last_updated = 3;
  }

  // Describes a dynamically loaded listener via the LDS API.
  // [#next-free-field: 7]
  message DynamicListener {
    option (udpa.annotations.versioning).previous_message_type =
        "envoy.admin.v2alpha.ListenersConfigDump.DynamicListener";

    // The name or unique id of this listener, pulled from the DynamicListenerState config.
    string name = 1;

    // The listener state for any active listener by this name.
    // These are listeners that are available to service data plane traffic.
    DynamicListenerState active_state = 2;

    // The listener state for any warming listener by this name.
    // These are listeners that are currently undergoing warming in preparation to service data
    // plane traffic. Note that if attempting to recreate an Envoy configuration from a
    // configuration dump, the warming listeners should generally be discarded.
    DynamicListenerState warming_state = 3;

    // The listener state for any draining listener by this name.
    // These are listeners that are currently undergoing draining in preparation to stop servicing
    // data plane traffic. Note that if attempting to recreate an Envoy configuration from a
    // configuration dump, the draining listeners should generally be discarded.
    DynamicListenerState draining_state = 4;

    // Set if the last update failed, cleared after the next successful update.
    // The ``error_state`` field contains the rejected version of this particular
    // resource along with the reason and timestamp. For successfully updated or
    // acknowledged resource, this field should be empty.
    UpdateFailureState error_state = 5;

    // The client status of this resource.
    // [#not-implemented-hide:]
    ClientResourceStatus client_status = 6;
  }

  // This is the :ref:`version_info <envoy_v3_api_field_service.discovery.v3.DiscoveryResponse.version_info>` in the
  // last processed LDS discovery response. If there are only static bootstrap listeners, this field
  // will be "".
  string version_info = 1;

  // The statically loaded listener configs.
  repeated StaticListener static_listeners = 2;

  // State for any warming, active, or draining listeners.
  repeated DynamicListener dynamic_listeners = 3;
}

// Envoy's cluster manager fills this message with all currently known clusters. Cluster
// configuration information can be used to recreate an Envoy configuration by populating all
// clusters as static clusters or by returning them in a CDS response.
message ClustersConfigDump {
  option (udpa.annotations.versioning).previous_message_type =
      "envoy.admin.v2alpha.ClustersConfigDump";

  // Describes a statically loaded cluster.
  message StaticCluster {
    option (udpa.annotations.versioning).previous_message_type =
        "envoy.admin.v2alpha.ClustersConfigDump.StaticCluster";

    // The cluster config.
    google.protobuf.Any cluster = 1;

    // The timestamp when the Cluster was last updated.
    google.protobuf.Timestamp last_updated = 2;
  }

  // Describes a dynamically loaded cluster via the CDS API.
  // [#next-free-field: 6]
  message DynamicCluster {
    option (udpa.annotations.versioning).previous_message_type =
        "envoy.admin.v2alpha.ClustersConfigDump.DynamicCluster";

    // This is the per-resource version information. This version is currently taken from the
    // :ref:`version_info <envoy_v3_api_field_service.discovery.v3.DiscoveryResponse.version_info>` field at the time
    // that the cluster was loaded. In the future, discrete per-cluster versions may be supported by
    // the API.
    string version_info = 1;

    // The cluster config.
    google.protobuf.Any cluster = 2;

    // The timestamp when the Cluster was last updated.
    google.protobuf.Timestamp last_updated = 3;

    // Set if the last update failed, cleared after the next successful update.
    // The ``error_state`` field contains the rejected version of this particular
    // resource along with the reason and timestamp. For successfully updated or
    // acknowledged resource, this field should be empty.
    // [#not-implemented-hide:]
    UpdateFailureState error_state = 4;

    // The client status of this resource.
    // [#not-implemented-hide:]
    ClientResourceStatus client_status = 5;
  }

  // This is the :ref:`version_info <envoy_v3_api_field_service.discovery.v3.DiscoveryResponse.version_info>` in the
  // last processed CDS discovery response. If there are only static bootstrap clusters, this field
  // will be "".
  string version_info = 1;

  // The statically loaded cluster configs.
  repeated StaticCluster static_clusters = 2;

  // The dynamically loaded active clusters. These are clusters that are available to service
  // data plane traffic.
  repeated DynamicCluster dynamic_active_clusters = 3;

  // The dynamically loaded warming clusters. These are clusters that are currently undergoing
  // warming in preparation to service data plane traffic. Note that if attempting to recreate an
  // Envoy configuration from a configuration dump, the warming clusters should generally be
  // discarded.
  repeated DynamicCluster dynamic_warming_clusters = 4;
}

// Envoy's RDS implementation fills this message with all currently loaded routes, as described by
// their RouteConfiguration objects. Static routes that are either defined in the bootstrap configuration
// or defined inline while configuring listeners are separated from those configured dynamically via RDS.
// Route configuration information can be used to recreate an Envoy configuration by populating all routes
// as static routes or by returning them in RDS responses.
message RoutesConfigDump {
  option (udpa.annotations.versioning).previous_message_type =
      "envoy.admin.v2alpha.RoutesConfigDump";

  message StaticRouteConfig {
    option (udpa.annotations.versioning).previous_message_type =
        "envoy.admin.v2alpha.RoutesConfigDump.StaticRouteConfig";

    // The route config.
    google.protobuf.Any route_config = 1;

    // The timestamp when the Route was last updated.
    google.protobuf.Timestamp last_updated = 2;
  }

  // [#next-free-field: 6]
  message DynamicRouteConfig {
    option (udpa.annotations.versioning).previous_message_type =
        "envoy.admin.v2alpha.RoutesConfigDump.DynamicRouteConfig";

    // This is the per-resource version information. This version is currently taken from the
    // :ref:`version_info <envoy_v3_api_field_service.discovery.v3.DiscoveryResponse.version_info>` field at the time that
    // the route configuration was loaded.
    string version_info = 1;

    // The route config.
    google.protobuf.Any route_config = 2;

    // The timestamp when the Route was last updated.
    google.protobuf.Timestamp last_updated = 3;

    // Set if the last update failed, cleared after the next successful update.
    // The ``error_state`` field contains the rejected version of this particular
    // resource along with the reason and timestamp. For successfully updated or
    // acknowledged resource, this field should be empty.
    // [#not-implemented-hide:]
    UpdateFailureState error_state = 4;

    // The client status of this resource.
    // [#not-implemented-hide:]
    ClientResourceStatus client_status = 5;
  }

  // The statically loaded route configs.
  repeated StaticRouteConfig static_route_configs = 2;

  // The dynamically loaded route configs.
  repeated DynamicRouteConfig dynamic_route_configs = 3;
}

// Envoy's scoped RDS implementation fills this message with all currently loaded route
// configuration scopes (defined via ScopedRouteConfigurationsSet protos). This message lists both
// the scopes defined inline with the higher order object (i.e., the HttpConnectionManager) and the
// dynamically obtained scopes via the SRDS API.
message ScopedRoutesConfigDump {
  option (udpa.annotations.versioning).previous_message_type =
      "envoy.admin.v2alpha.ScopedRoutesConfigDump";

  message InlineScopedRouteConfigs {
    option (udpa.annotations.versioning).previous_message_type =
        "envoy.admin.v2alpha.ScopedRoutesConfigDump.InlineScopedRouteConfigs";

    // The name assigned to the scoped route configurations.
    string name = 1;

    // The scoped route configurations.
    repeated google.protobuf.Any scoped_route_configs = 2;

    // The timestamp when the scoped route config set was last updated.
    google.protobuf.Timestamp last_updated = 3;
  }

  // [#next-free-field: 7]
  message DynamicScopedRouteConfigs {
    option (udpa.annotations.versioning).previous_message_type =
        "envoy.admin.v2alpha.ScopedRoutesConfigDump.DynamicScopedRouteConfigs";

    // The name assigned to the scoped route configurations.
    string name = 1;

    // This is the per-resource version information. This version is currently taken from the
    // :ref:`version_info <envoy_v3_api_field_service.discovery.v3.DiscoveryResponse.version_info>` field at the time that
    // the scoped routes configuration was loaded.
    string version_info = 2;

    // The scoped route configurations.
    repeated google.protobuf.Any scoped_route_configs = 3;

    // The timestamp when the scoped route config set was last updated.
    google.protobuf.Timestamp last_updated = 4;

    // Set if the last update failed, cleared after the next successful update.
    // The ``error_state`` field contains the rejected version of this particular
    // resource along with the reason and timestamp. For successfully updated or
    // acknowledged resource, this field should be empty.
    // [#not-implemented-hide:]
    UpdateFailureState error_state = 5;

    // The client status of this resource.
    // [#not-implemented-hide:]
    ClientResourceStatus client_status = 6;
  }

  // The statically loaded scoped route configs.
  repeated InlineScopedRouteConfigs inline_scoped_route_configs = 1;

  // The dynamically loaded scoped route configs.
  repeated DynamicScopedRouteConfigs dynamic_scoped_route_configs = 2;
}

// Envoy's admin fill this message with all currently known endpoints. Endpoint
// configuration information can be used to recreate an Envoy configuration by populating all
// endpoints as static endpoints or by returning them in an EDS response.
message EndpointsConfigDump {
  message StaticEndpointConfig {
    // The endpoint config.
    google.protobuf.Any endpoint_config = 1;

    // [#not-implemented-hide:] The timestamp when the Endpoint was last updated.
    google.protobuf.Timestamp last_updated = 2;
  }

  // [#next-free-field: 6]
  message DynamicEndpointConfig {
    // [#not-implemented-hide:] This is the per-resource version information. This version is currently taken from the
    // :ref:`version_info <envoy_v3_api_field_service.discovery.v3.DiscoveryResponse.version_info>` field at the time that
    // the endpoint configuration was loaded.
    string version_info = 1;

    // The endpoint config.
    google.protobuf.Any endpoint_config = 2;

    // [#not-implemented-hide:] The timestamp when the Endpoint was last updated.
    google.protobuf.Timestamp last_updated = 3;

    // Set if the last update failed, cleared after the next successful update.
    // The ``error_state`` field contains the rejected version of this particular
    // resource along with the reason and timestamp. For successfully updated or
    // acknowledged resource, this field should be empty.
    // [#not-implemented-hide:]
    UpdateFailureState error_state = 4;

    // The client status of this resource.
    // [#not-implemented-hide:]
    ClientResourceStatus client_status = 5;
  }

  // The statically loaded endpoint configs.
  repeated StaticEndpointConfig static_endpoint_configs = 2;

  // The dynamically loaded endpoint configs.
  repeated DynamicEndpointConfig dynamic_endpoint_configs = 3;
}

// Envoy's ECDS service fills this message with all currently extension
// configuration. Extension configuration information can be used to recreate
// an Envoy ECDS listener and HTTP filters as static filters or by returning
// them in ECDS response.
message EcdsConfigDump {
  option (udpa.annotations.versioning).previous_message_type = "envoy.admin.v2alpha.EcdsConfigDump";

  // [#next-free-field: 6]
  message EcdsFilterConfig {
    option (udpa.annotations.versioning).previous_message_type =
        "envoy.admin.v2alpha.EcdsConfigDump.EcdsFilterConfig";

    // This is the per-resource version information. This version is currently
    // taken from the :ref:`version_info
    // <envoy_v3_api_field_service.discovery.v3.DiscoveryResponse.version_info>`
    // field at the time that the ECDS filter was loaded.
    string version_info = 1;

    // The ECDS filter config.
    google.protobuf.Any ecds_filter = 2;

    // The timestamp when the ECDS filter was last updated.
    google.protobuf.Timestamp last_updated = 3;

    // Set if the last update failed, cleared after the next successful update.
    // The ``error_state`` field contains the rejected version of this
    // particular resource along with the reason and timestamp. For successfully
    // updated or acknowledged resource, this field should be empty.
    // [#not-implemented-hide:]
    UpdateFailureState error_state = 4;

    // The client status of this resource.
    // [#not-implemented-hide:]
    ClientResourceStatus client_status = 5;
  }

  // The ECDS filter configs.
  repeated EcdsFilterConfig ecds_filters = 1;
}
