fastly_api/models/
rate_limiter_response.rs

1/*
2 * Fastly API
3 *
4 * Via the Fastly API you can perform any of the operations that are possible within the management console,  including creating services, domains, and backends, configuring rules or uploading your own application code, as well as account operations such as user administration and billing reports. The API is organized into collections of endpoints that allow manipulation of objects related to Fastly services and accounts. For the most accurate and up-to-date API reference content, visit our [Developer Hub](https://www.fastly.com/documentation/reference/api/) 
5 *
6 */
7
8
9
10
11#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
12pub struct RateLimiterResponse {
13    /// A human readable name for the rate limiting rule.
14    #[serde(rename = "name", skip_serializing_if = "Option::is_none")]
15    pub name: Option<String>,
16    /// The name of an Edge Dictionary containing URIs as keys. If not defined or `null`, all origin URIs will be rate limited.
17    #[serde(rename = "uri_dictionary_name", skip_serializing_if = "Option::is_none")]
18    pub uri_dictionary_name: Option<String>,
19    /// Array of HTTP methods to apply rate limiting to.
20    #[serde(rename = "http_methods", skip_serializing_if = "Option::is_none")]
21    pub http_methods: Option<std::collections::HashSet<HttpMethods>>,
22    /// Upper limit of requests per second allowed by the rate limiter.
23    #[serde(rename = "rps_limit", skip_serializing_if = "Option::is_none")]
24    pub rps_limit: Option<i32>,
25    /// Number of seconds during which the RPS limit must be exceeded in order to trigger a violation.
26    #[serde(rename = "window_size", skip_serializing_if = "Option::is_none")]
27    pub window_size: Option<WindowSize>,
28    /// Array of VCL variables used to generate a counter key to identify a client. Example variables include `req.http.Fastly-Client-IP`, `req.http.User-Agent`, or a custom header like `req.http.API-Key`.
29    #[serde(rename = "client_key", skip_serializing_if = "Option::is_none")]
30    pub client_key: Option<Vec<String>>,
31    /// Length of time in minutes that the rate limiter is in effect after the initial violation is detected.
32    #[serde(rename = "penalty_box_duration", skip_serializing_if = "Option::is_none")]
33    pub penalty_box_duration: Option<i32>,
34    /// The action to take when a rate limiter violation is detected.
35    #[serde(rename = "action", skip_serializing_if = "Option::is_none")]
36    pub action: Option<Action>,
37    /// Custom response to be sent when the rate limit is exceeded. Required if `action` is `response`.
38    #[serde(rename = "response", skip_serializing_if = "Option::is_none")]
39    pub response: Option<::std::collections::HashMap<String, String>>,
40    /// Name of existing response object. Required if `action` is `response_object`. Note that the rate limiter response is only updated to reflect the response object content when saving the rate limiter configuration.
41    #[serde(rename = "response_object_name", skip_serializing_if = "Option::is_none")]
42    pub response_object_name: Option<String>,
43    /// Name of the type of logging endpoint to be used when action is `log_only`. The logging endpoint type is used to determine the appropriate log format to use when emitting log entries.
44    #[serde(rename = "logger_type", skip_serializing_if = "Option::is_none")]
45    pub logger_type: Option<LoggerType>,
46    /// Revision number of the rate limiting feature implementation. Defaults to the most recent revision.
47    #[serde(rename = "feature_revision", skip_serializing_if = "Option::is_none")]
48    pub feature_revision: Option<i32>,
49    #[serde(rename = "service_id", skip_serializing_if = "Option::is_none")]
50    pub service_id: Option<Box<String>>,
51    #[serde(rename = "version", skip_serializing_if = "Option::is_none")]
52    pub version: Option<Box<i32>>,
53    /// Date and time in ISO 8601 format.
54    #[serde(rename = "created_at", skip_serializing_if = "Option::is_none")]
55    pub created_at: Option<String>,
56    /// Date and time in ISO 8601 format.
57    #[serde(rename = "deleted_at", skip_serializing_if = "Option::is_none")]
58    pub deleted_at: Option<String>,
59    /// Date and time in ISO 8601 format.
60    #[serde(rename = "updated_at", skip_serializing_if = "Option::is_none")]
61    pub updated_at: Option<String>,
62    /// Alphanumeric string identifying the rate limiter.
63    #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
64    pub id: Option<String>,
65}
66
67impl RateLimiterResponse {
68    pub fn new() -> RateLimiterResponse {
69        RateLimiterResponse {
70            name: None,
71            uri_dictionary_name: None,
72            http_methods: None,
73            rps_limit: None,
74            window_size: None,
75            client_key: None,
76            penalty_box_duration: None,
77            action: None,
78            response: None,
79            response_object_name: None,
80            logger_type: None,
81            feature_revision: None,
82            service_id: None,
83            version: None,
84            created_at: None,
85            deleted_at: None,
86            updated_at: None,
87            id: None,
88        }
89    }
90}
91
92/// Array of HTTP methods to apply rate limiting to.
93#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
94pub enum HttpMethods {
95    #[serde(rename = "HEAD")]
96    HEAD,
97    #[serde(rename = "OPTIONS")]
98    OPTIONS,
99    #[serde(rename = "GET")]
100    GET,
101    #[serde(rename = "POST")]
102    POST,
103    #[serde(rename = "PUT")]
104    PUT,
105    #[serde(rename = "PATCH")]
106    PATCH,
107    #[serde(rename = "DELETE")]
108    DELETE,
109    #[serde(rename = "TRACE")]
110    TRACE,
111}
112
113impl Default for HttpMethods {
114    fn default() -> HttpMethods {
115        Self::HEAD
116    }
117}
118/// Number of seconds during which the RPS limit must be exceeded in order to trigger a violation.
119#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
120pub enum WindowSize {
121    #[serde(rename = "1")]
122    WindowSizeOneSecond,
123    #[serde(rename = "10")]
124    WindowSizeTenSeconds,
125    #[serde(rename = "60")]
126    WindowSizeOneMinute,
127}
128
129impl Default for WindowSize {
130    fn default() -> WindowSize {
131        Self::WindowSizeOneSecond
132    }
133}
134/// The action to take when a rate limiter violation is detected.
135#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
136pub enum Action {
137    #[serde(rename = "response")]
138    Response,
139    #[serde(rename = "response_object")]
140    ResponseObject,
141    #[serde(rename = "log_only")]
142    LogOnly,
143}
144
145impl Default for Action {
146    fn default() -> Action {
147        Self::Response
148    }
149}
150/// Name of the type of logging endpoint to be used when action is `log_only`. The logging endpoint type is used to determine the appropriate log format to use when emitting log entries.
151#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
152pub enum LoggerType {
153    #[serde(rename = "azureblob")]
154    Azureblob,
155    #[serde(rename = "bigquery")]
156    Bigquery,
157    #[serde(rename = "cloudfiles")]
158    Cloudfiles,
159    #[serde(rename = "datadog")]
160    Datadog,
161    #[serde(rename = "digitalocean")]
162    Digitalocean,
163    #[serde(rename = "elasticsearch")]
164    Elasticsearch,
165    #[serde(rename = "ftp")]
166    Ftp,
167    #[serde(rename = "gcs")]
168    Gcs,
169    #[serde(rename = "googleanalytics")]
170    Googleanalytics,
171    #[serde(rename = "heroku")]
172    Heroku,
173    #[serde(rename = "honeycomb")]
174    Honeycomb,
175    #[serde(rename = "http")]
176    Http,
177    #[serde(rename = "https")]
178    Https,
179    #[serde(rename = "kafka")]
180    Kafka,
181    #[serde(rename = "kinesis")]
182    Kinesis,
183    #[serde(rename = "logentries")]
184    Logentries,
185    #[serde(rename = "loggly")]
186    Loggly,
187    #[serde(rename = "logshuttle")]
188    Logshuttle,
189    #[serde(rename = "newrelic")]
190    Newrelic,
191    #[serde(rename = "newrelicotlp")]
192    Newrelicotlp,
193    #[serde(rename = "openstack")]
194    Openstack,
195    #[serde(rename = "papertrail")]
196    Papertrail,
197    #[serde(rename = "pubsub")]
198    Pubsub,
199    #[serde(rename = "s3")]
200    S3,
201    #[serde(rename = "scalyr")]
202    Scalyr,
203    #[serde(rename = "sftp")]
204    Sftp,
205    #[serde(rename = "splunk")]
206    Splunk,
207    #[serde(rename = "stackdriver")]
208    Stackdriver,
209    #[serde(rename = "sumologic")]
210    Sumologic,
211    #[serde(rename = "syslog")]
212    Syslog,
213}
214
215impl Default for LoggerType {
216    fn default() -> LoggerType {
217        Self::Azureblob
218    }
219}
220