xds_api/generated/
envoy.extensions.common.ratelimit.v3.rs

1// This file is @generated by prost-build.
2/// A RateLimitDescriptor is a list of hierarchical entries that are used by the service to
3/// determine the final rate limit key and overall allowed limit. Here are some examples of how
4/// they might be used for the domain "envoy".
5///
6/// .. code-block:: cpp
7///
8///    \["authenticated": "false"\], \["remote_address": "10.0.0.1"\]
9///
10/// What it does: Limits all unauthenticated traffic for the IP address 10.0.0.1. The
11/// configuration supplies a default limit for the *remote_address* key. If there is a desire to
12/// raise the limit for 10.0.0.1 or block it entirely it can be specified directly in the
13/// configuration.
14///
15/// .. code-block:: cpp
16///
17///    \["authenticated": "false"\], \["path": "/foo/bar"\]
18///
19/// What it does: Limits all unauthenticated traffic globally for a specific path (or prefix if
20/// configured that way in the service).
21///
22/// .. code-block:: cpp
23///
24///    \["authenticated": "false"\], \["path": "/foo/bar"\], \["remote_address": "10.0.0.1"\]
25///
26/// What it does: Limits unauthenticated traffic to a specific path for a specific IP address.
27/// Like (1) we can raise/block specific IP addresses if we want with an override configuration.
28///
29/// .. code-block:: cpp
30///
31///    \["authenticated": "true"\], \["client_id": "foo"\]
32///
33/// What it does: Limits all traffic for an authenticated client "foo"
34///
35/// .. code-block:: cpp
36///
37///    \["authenticated": "true"\], \["client_id": "foo"\], \["path": "/foo/bar"\]
38///
39/// What it does: Limits traffic to a specific path for an authenticated client "foo"
40///
41/// The idea behind the API is that (1)/(2)/(3) and (4)/(5) can be sent in 1 request if desired.
42/// This enables building complex application scenarios with a generic backend.
43///
44/// Optionally the descriptor can contain a limit override under a "limit" key, that specifies
45/// the number of requests per unit to use instead of the number configured in the
46/// rate limiting service.
47#[derive(Clone, PartialEq, ::prost::Message)]
48pub struct RateLimitDescriptor {
49    /// Descriptor entries.
50    #[prost(message, repeated, tag = "1")]
51    pub entries: ::prost::alloc::vec::Vec<rate_limit_descriptor::Entry>,
52    /// Optional rate limit override to supply to the ratelimit service.
53    #[prost(message, optional, tag = "2")]
54    pub limit: ::core::option::Option<rate_limit_descriptor::RateLimitOverride>,
55}
56/// Nested message and enum types in `RateLimitDescriptor`.
57pub mod rate_limit_descriptor {
58    #[derive(Clone, PartialEq, ::prost::Message)]
59    pub struct Entry {
60        /// Descriptor key.
61        #[prost(string, tag = "1")]
62        pub key: ::prost::alloc::string::String,
63        /// Descriptor value.
64        #[prost(string, tag = "2")]
65        pub value: ::prost::alloc::string::String,
66    }
67    impl ::prost::Name for Entry {
68        const NAME: &'static str = "Entry";
69        const PACKAGE: &'static str = "envoy.extensions.common.ratelimit.v3";
70        fn full_name() -> ::prost::alloc::string::String {
71            "envoy.extensions.common.ratelimit.v3.RateLimitDescriptor.Entry".into()
72        }
73        fn type_url() -> ::prost::alloc::string::String {
74            "type.googleapis.com/envoy.extensions.common.ratelimit.v3.RateLimitDescriptor.Entry"
75                .into()
76        }
77    }
78    /// Override rate limit to apply to this descriptor instead of the limit
79    /// configured in the rate limit service. See :ref:`rate limit override
80    /// <config_http_filters_rate_limit_rate_limit_override>` for more information.
81    #[derive(Clone, Copy, PartialEq, ::prost::Message)]
82    pub struct RateLimitOverride {
83        /// The number of requests per unit of time.
84        #[prost(uint32, tag = "1")]
85        pub requests_per_unit: u32,
86        /// The unit of time.
87        #[prost(
88            enumeration = "super::super::super::super::super::r#type::v3::RateLimitUnit",
89            tag = "2"
90        )]
91        pub unit: i32,
92    }
93    impl ::prost::Name for RateLimitOverride {
94        const NAME: &'static str = "RateLimitOverride";
95        const PACKAGE: &'static str = "envoy.extensions.common.ratelimit.v3";
96        fn full_name() -> ::prost::alloc::string::String {
97            "envoy.extensions.common.ratelimit.v3.RateLimitDescriptor.RateLimitOverride"
98                .into()
99        }
100        fn type_url() -> ::prost::alloc::string::String {
101            "type.googleapis.com/envoy.extensions.common.ratelimit.v3.RateLimitDescriptor.RateLimitOverride"
102                .into()
103        }
104    }
105}
106impl ::prost::Name for RateLimitDescriptor {
107    const NAME: &'static str = "RateLimitDescriptor";
108    const PACKAGE: &'static str = "envoy.extensions.common.ratelimit.v3";
109    fn full_name() -> ::prost::alloc::string::String {
110        "envoy.extensions.common.ratelimit.v3.RateLimitDescriptor".into()
111    }
112    fn type_url() -> ::prost::alloc::string::String {
113        "type.googleapis.com/envoy.extensions.common.ratelimit.v3.RateLimitDescriptor"
114            .into()
115    }
116}
117#[derive(Clone, PartialEq, ::prost::Message)]
118pub struct LocalRateLimitDescriptor {
119    /// Descriptor entries.
120    #[prost(message, repeated, tag = "1")]
121    pub entries: ::prost::alloc::vec::Vec<rate_limit_descriptor::Entry>,
122    /// Token Bucket algorithm for local ratelimiting.
123    #[prost(message, optional, tag = "2")]
124    pub token_bucket: ::core::option::Option<
125        super::super::super::super::r#type::v3::TokenBucket,
126    >,
127}
128impl ::prost::Name for LocalRateLimitDescriptor {
129    const NAME: &'static str = "LocalRateLimitDescriptor";
130    const PACKAGE: &'static str = "envoy.extensions.common.ratelimit.v3";
131    fn full_name() -> ::prost::alloc::string::String {
132        "envoy.extensions.common.ratelimit.v3.LocalRateLimitDescriptor".into()
133    }
134    fn type_url() -> ::prost::alloc::string::String {
135        "type.googleapis.com/envoy.extensions.common.ratelimit.v3.LocalRateLimitDescriptor"
136            .into()
137    }
138}
139/// Defines the version of the standard to use for X-RateLimit headers.
140#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
141#[repr(i32)]
142pub enum XRateLimitHeadersRfcVersion {
143    /// X-RateLimit headers disabled.
144    Off = 0,
145    /// Use `draft RFC Version 03 <<https://tools.ietf.org/id/draft-polli-ratelimit-headers-03.html>`_> where 3 headers will be added:
146    ///
147    /// * ``X-RateLimit-Limit`` - indicates the request-quota associated to the
148    ///    client in the current time-window followed by the description of the
149    ///    quota policy. The value is returned by the maximum tokens of the token bucket.
150    /// * ``X-RateLimit-Remaining`` - indicates the remaining requests in the
151    ///    current time-window. The value is returned by the remaining tokens in the token bucket.
152    /// * ``X-RateLimit-Reset`` - indicates the number of seconds until reset of
153    ///    the current time-window. The value is returned by the remaining fill interval of the token bucket.
154    DraftVersion03 = 1,
155}
156impl XRateLimitHeadersRfcVersion {
157    /// String value of the enum field names used in the ProtoBuf definition.
158    ///
159    /// The values are not transformed in any way and thus are considered stable
160    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
161    pub fn as_str_name(&self) -> &'static str {
162        match self {
163            Self::Off => "OFF",
164            Self::DraftVersion03 => "DRAFT_VERSION_03",
165        }
166    }
167    /// Creates an enum from field names used in the ProtoBuf definition.
168    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
169        match value {
170            "OFF" => Some(Self::Off),
171            "DRAFT_VERSION_03" => Some(Self::DraftVersion03),
172            _ => None,
173        }
174    }
175}
176#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
177#[repr(i32)]
178pub enum VhRateLimitsOptions {
179    /// Use the virtual host rate limits unless the route has a rate limit policy.
180    Override = 0,
181    /// Use the virtual host rate limits even if the route has a rate limit policy.
182    Include = 1,
183    /// Ignore the virtual host rate limits even if the route does not have a rate limit policy.
184    Ignore = 2,
185}
186impl VhRateLimitsOptions {
187    /// String value of the enum field names used in the ProtoBuf definition.
188    ///
189    /// The values are not transformed in any way and thus are considered stable
190    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
191    pub fn as_str_name(&self) -> &'static str {
192        match self {
193            Self::Override => "OVERRIDE",
194            Self::Include => "INCLUDE",
195            Self::Ignore => "IGNORE",
196        }
197    }
198    /// Creates an enum from field names used in the ProtoBuf definition.
199    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
200        match value {
201            "OVERRIDE" => Some(Self::Override),
202            "INCLUDE" => Some(Self::Include),
203            "IGNORE" => Some(Self::Ignore),
204            _ => None,
205        }
206    }
207}