fastly_api/models/
rate_limiter.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
/*
 * Fastly API
 *
 * 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/) 
 *
 */




#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
pub struct RateLimiter {
    /// A human readable name for the rate limiting rule.
    #[serde(rename = "name", skip_serializing_if = "Option::is_none")]
    pub name: Option<String>,
    /// The name of an Edge Dictionary containing URIs as keys. If not defined or `null`, all origin URIs will be rate limited.
    #[serde(rename = "uri_dictionary_name", skip_serializing_if = "Option::is_none")]
    pub uri_dictionary_name: Option<String>,
    /// Array of HTTP methods to apply rate limiting to.
    #[serde(rename = "http_methods", skip_serializing_if = "Option::is_none")]
    pub http_methods: Option<std::collections::HashSet<HttpMethods>>,
    /// Upper limit of requests per second allowed by the rate limiter.
    #[serde(rename = "rps_limit", skip_serializing_if = "Option::is_none")]
    pub rps_limit: Option<i32>,
    /// Number of seconds during which the RPS limit must be exceeded in order to trigger a violation.
    #[serde(rename = "window_size", skip_serializing_if = "Option::is_none")]
    pub window_size: Option<WindowSize>,
    /// 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`.
    #[serde(rename = "client_key", skip_serializing_if = "Option::is_none")]
    pub client_key: Option<Vec<String>>,
    /// Length of time in minutes that the rate limiter is in effect after the initial violation is detected.
    #[serde(rename = "penalty_box_duration", skip_serializing_if = "Option::is_none")]
    pub penalty_box_duration: Option<i32>,
    /// The action to take when a rate limiter violation is detected.
    #[serde(rename = "action", skip_serializing_if = "Option::is_none")]
    pub action: Option<Action>,
    /// Custom response to be sent when the rate limit is exceeded. Required if `action` is `response`.
    #[serde(rename = "response", skip_serializing_if = "Option::is_none")]
    pub response: Option<::std::collections::HashMap<String, String>>,
    /// 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.
    #[serde(rename = "response_object_name", skip_serializing_if = "Option::is_none")]
    pub response_object_name: Option<String>,
    /// 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.
    #[serde(rename = "logger_type", skip_serializing_if = "Option::is_none")]
    pub logger_type: Option<LoggerType>,
    /// Revision number of the rate limiting feature implementation. Defaults to the most recent revision.
    #[serde(rename = "feature_revision", skip_serializing_if = "Option::is_none")]
    pub feature_revision: Option<i32>,
}

impl RateLimiter {
    pub fn new() -> RateLimiter {
        RateLimiter {
            name: None,
            uri_dictionary_name: None,
            http_methods: None,
            rps_limit: None,
            window_size: None,
            client_key: None,
            penalty_box_duration: None,
            action: None,
            response: None,
            response_object_name: None,
            logger_type: None,
            feature_revision: None,
        }
    }
}

/// Array of HTTP methods to apply rate limiting to.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum HttpMethods {
    #[serde(rename = "HEAD")]
    HEAD,
    #[serde(rename = "OPTIONS")]
    OPTIONS,
    #[serde(rename = "GET")]
    GET,
    #[serde(rename = "POST")]
    POST,
    #[serde(rename = "PUT")]
    PUT,
    #[serde(rename = "PATCH")]
    PATCH,
    #[serde(rename = "DELETE")]
    DELETE,
    #[serde(rename = "TRACE")]
    TRACE,
}

impl Default for HttpMethods {
    fn default() -> HttpMethods {
        Self::HEAD
    }
}
/// Number of seconds during which the RPS limit must be exceeded in order to trigger a violation.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum WindowSize {
    #[serde(rename = "1")]
    WindowSizeOneSecond,
    #[serde(rename = "10")]
    WindowSizeTenSeconds,
    #[serde(rename = "60")]
    WindowSizeOneMinute,
}

impl Default for WindowSize {
    fn default() -> WindowSize {
        Self::WindowSizeOneSecond
    }
}
/// The action to take when a rate limiter violation is detected.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Action {
    #[serde(rename = "response")]
    Response,
    #[serde(rename = "response_object")]
    ResponseObject,
    #[serde(rename = "log_only")]
    LogOnly,
}

impl Default for Action {
    fn default() -> Action {
        Self::Response
    }
}
/// 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.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum LoggerType {
    #[serde(rename = "azureblob")]
    Azureblob,
    #[serde(rename = "bigquery")]
    Bigquery,
    #[serde(rename = "cloudfiles")]
    Cloudfiles,
    #[serde(rename = "datadog")]
    Datadog,
    #[serde(rename = "digitalocean")]
    Digitalocean,
    #[serde(rename = "elasticsearch")]
    Elasticsearch,
    #[serde(rename = "ftp")]
    Ftp,
    #[serde(rename = "gcs")]
    Gcs,
    #[serde(rename = "googleanalytics")]
    Googleanalytics,
    #[serde(rename = "heroku")]
    Heroku,
    #[serde(rename = "honeycomb")]
    Honeycomb,
    #[serde(rename = "http")]
    Http,
    #[serde(rename = "https")]
    Https,
    #[serde(rename = "kafka")]
    Kafka,
    #[serde(rename = "kinesis")]
    Kinesis,
    #[serde(rename = "logentries")]
    Logentries,
    #[serde(rename = "loggly")]
    Loggly,
    #[serde(rename = "logshuttle")]
    Logshuttle,
    #[serde(rename = "newrelic")]
    Newrelic,
    #[serde(rename = "newrelicotlp")]
    Newrelicotlp,
    #[serde(rename = "openstack")]
    Openstack,
    #[serde(rename = "papertrail")]
    Papertrail,
    #[serde(rename = "pubsub")]
    Pubsub,
    #[serde(rename = "s3")]
    S3,
    #[serde(rename = "scalyr")]
    Scalyr,
    #[serde(rename = "sftp")]
    Sftp,
    #[serde(rename = "splunk")]
    Splunk,
    #[serde(rename = "stackdriver")]
    Stackdriver,
    #[serde(rename = "sumologic")]
    Sumologic,
    #[serde(rename = "syslog")]
    Syslog,
}

impl Default for LoggerType {
    fn default() -> LoggerType {
        Self::Azureblob
    }
}