Class: Fastly::RateLimiterApi

Inherits:
Object
  • Object
show all
Defined in:
lib/fastly/api/rate_limiter_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ RateLimiterApi

Returns a new instance of RateLimiterApi.



17
18
19
# File 'lib/fastly/api/rate_limiter_api.rb', line 17

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



15
16
17
# File 'lib/fastly/api/rate_limiter_api.rb', line 15

def api_client
  @api_client
end

Instance Method Details

#create_rate_limiter(opts = {}) ⇒ RateLimiterResponse

Create a rate limiter Create a rate limiter for a particular service and version.

Parameters:

  • opts (Hash) (defaults to: {})

    a customizable set of options

Options Hash (opts):

  • :service_id (String)

    Alphanumeric string identifying the service. (required)

  • :version_id (Integer)

    Integer identifying a service version. (required)

  • :name (String)

    A human readable name for the rate limiting rule.

  • :uri_dictionary_name (String)

    The name of an Edge Dictionary containing URIs as keys. If not defined or `null`, all origin URIs will be rate limited.

  • :http_methods (Array<String>)

    Array of HTTP methods to apply rate limiting to.

  • :rps_limit (Integer)

    Upper limit of requests per second allowed by the rate limiter.

  • :window_size (Integer)

    Number of seconds during which the RPS limit must be exceeded in order to trigger a violation.

  • :client_key (Array<String>)

    Array of VCL variables used to generate a counter key to identify a client. Example variables include &#x60;req.http.Fastly-Client-IP&#x60;, &#x60;req.http.User-Agent&#x60;, or a custom header like &#x60;req.http.API-Key&#x60;.

  • :penalty_box_duration (Integer)

    Length of time in minutes that the rate limiter is in effect after the initial violation is detected.

  • :action (String)

    The action to take when a rate limiter violation is detected.

  • :response_object_name (String)

    Name of existing response object. Required if &#x60;action&#x60; is &#x60;response_object&#x60;. Note that the rate limiter response is only updated to reflect the response object content when saving the rate limiter configuration.

  • :logger_type (String)

    Name of the type of logging endpoint to be used when action is &#x60;log_only&#x60;. The logging endpoint type is used to determine the appropriate log format to use when emitting log entries.

  • :feature_revision (Integer)

    Revision number of the rate limiting feature implementation. Defaults to the most recent revision.

Returns:



36
37
38
39
# File 'lib/fastly/api/rate_limiter_api.rb', line 36

def create_rate_limiter(opts = {})
  data, _status_code, _headers = create_rate_limiter_with_http_info(opts)
  data
end

#create_rate_limiter_with_http_info(opts = {}) ⇒ Array<(RateLimiterResponse, Integer, Hash)>

Create a rate limiter Create a rate limiter for a particular service and version.

Parameters:

  • opts (Hash) (defaults to: {})

    a customizable set of options

Options Hash (opts):

  • :service_id (String)

    Alphanumeric string identifying the service. (required)

  • :version_id (Integer)

    Integer identifying a service version. (required)

  • :name (String)

    A human readable name for the rate limiting rule.

  • :uri_dictionary_name (String)

    The name of an Edge Dictionary containing URIs as keys. If not defined or &#x60;null&#x60;, all origin URIs will be rate limited.

  • :http_methods (Array<String>)

    Array of HTTP methods to apply rate limiting to.

  • :rps_limit (Integer)

    Upper limit of requests per second allowed by the rate limiter.

  • :window_size (Integer)

    Number of seconds during which the RPS limit must be exceeded in order to trigger a violation.

  • :client_key (Array<String>)

    Array of VCL variables used to generate a counter key to identify a client. Example variables include &#x60;req.http.Fastly-Client-IP&#x60;, &#x60;req.http.User-Agent&#x60;, or a custom header like &#x60;req.http.API-Key&#x60;.

  • :penalty_box_duration (Integer)

    Length of time in minutes that the rate limiter is in effect after the initial violation is detected.

  • :action (String)

    The action to take when a rate limiter violation is detected.

  • :response_object_name (String)

    Name of existing response object. Required if &#x60;action&#x60; is &#x60;response_object&#x60;. Note that the rate limiter response is only updated to reflect the response object content when saving the rate limiter configuration.

  • :logger_type (String)

    Name of the type of logging endpoint to be used when action is &#x60;log_only&#x60;. The logging endpoint type is used to determine the appropriate log format to use when emitting log entries.

  • :feature_revision (Integer)

    Revision number of the rate limiting feature implementation. Defaults to the most recent revision.

Returns:

  • (Array<(RateLimiterResponse, Integer, Hash)>)

    RateLimiterResponse data, response status code and response headers



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
# File 'lib/fastly/api/rate_limiter_api.rb', line 57

def create_rate_limiter_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: RateLimiterApi.create_rate_limiter ...'
  end
  # unbox the parameters from the hash
  service_id = opts[:'service_id']
  version_id = opts[:'version_id']
  # verify the required parameter 'service_id' is set
  if @api_client.config.client_side_validation && service_id.nil?
    fail ArgumentError, "Missing the required parameter 'service_id' when calling RateLimiterApi.create_rate_limiter"
  end
  # verify the required parameter 'version_id' is set
  if @api_client.config.client_side_validation && version_id.nil?
    fail ArgumentError, "Missing the required parameter 'version_id' when calling RateLimiterApi.create_rate_limiter"
  end
  if @api_client.config.client_side_validation && !opts[:'name'].nil? && opts[:'name'].to_s.length > 255
    fail ArgumentError, 'invalid value for "opts[:"name"]" when calling RateLimiterApi.create_rate_limiter, the character length must be smaller than or equal to 255.'
  end

  if @api_client.config.client_side_validation && !opts[:'name'].nil? && opts[:'name'].to_s.length < 1
    fail ArgumentError, 'invalid value for "opts[:"name"]" when calling RateLimiterApi.create_rate_limiter, the character length must be great than or equal to 1.'
  end

  if @api_client.config.client_side_validation && !opts[:'uri_dictionary_name'].nil? && opts[:'uri_dictionary_name'].to_s.length > 255
    fail ArgumentError, 'invalid value for "opts[:"uri_dictionary_name"]" when calling RateLimiterApi.create_rate_limiter, the character length must be smaller than or equal to 255.'
  end

  if @api_client.config.client_side_validation && !opts[:'uri_dictionary_name'].nil? && opts[:'uri_dictionary_name'].to_s.length < 1
    fail ArgumentError, 'invalid value for "opts[:"uri_dictionary_name"]" when calling RateLimiterApi.create_rate_limiter, the character length must be great than or equal to 1.'
  end

  allowable_values = ["HEAD", "OPTIONS", "GET", "POST", "PUT", "PATCH", "DELETE", "TRACE"]
  if @api_client.config.client_side_validation && opts[:'http_methods'] && !opts[:'http_methods'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"http_methods\", must include one of #{allowable_values}"
  end
  if @api_client.config.client_side_validation && !opts[:'http_methods'].nil? && opts[:'http_methods'].length < 1
    fail ArgumentError, 'invalid value for "opts[:"http_methods"]" when calling RateLimiterApi.create_rate_limiter, number of items must be greater than or equal to 1.'
  end

  if @api_client.config.client_side_validation && !opts[:'rps_limit'].nil? && opts[:'rps_limit'] > 10000
    fail ArgumentError, 'invalid value for "opts[:"rps_limit"]" when calling RateLimiterApi.create_rate_limiter, must be smaller than or equal to 10000.'
  end

  if @api_client.config.client_side_validation && !opts[:'rps_limit'].nil? && opts[:'rps_limit'] < 10
    fail ArgumentError, 'invalid value for "opts[:"rps_limit"]" when calling RateLimiterApi.create_rate_limiter, must be greater than or equal to 10.'
  end

  allowable_values = [1, 10, 60]
  if @api_client.config.client_side_validation && opts[:'window_size'] && !allowable_values.include?(opts[:'window_size'])
    fail ArgumentError, "invalid value for \"window_size\", must be one of #{allowable_values}"
  end
  if @api_client.config.client_side_validation && !opts[:'client_key'].nil? && opts[:'client_key'].length < 1
    fail ArgumentError, 'invalid value for "opts[:"client_key"]" when calling RateLimiterApi.create_rate_limiter, number of items must be greater than or equal to 1.'
  end

  if @api_client.config.client_side_validation && !opts[:'penalty_box_duration'].nil? && opts[:'penalty_box_duration'] > 60
    fail ArgumentError, 'invalid value for "opts[:"penalty_box_duration"]" when calling RateLimiterApi.create_rate_limiter, must be smaller than or equal to 60.'
  end

  if @api_client.config.client_side_validation && !opts[:'penalty_box_duration'].nil? && opts[:'penalty_box_duration'] < 1
    fail ArgumentError, 'invalid value for "opts[:"penalty_box_duration"]" when calling RateLimiterApi.create_rate_limiter, must be greater than or equal to 1.'
  end

  allowable_values = ["response", "response_object", "log_only"]
  if @api_client.config.client_side_validation && opts[:'action'] && !allowable_values.include?(opts[:'action'])
    fail ArgumentError, "invalid value for \"action\", must be one of #{allowable_values}"
  end
  if @api_client.config.client_side_validation && !opts[:'action'].nil? && opts[:'action'].to_s.length < 1
    fail ArgumentError, 'invalid value for "opts[:"action"]" when calling RateLimiterApi.create_rate_limiter, the character length must be great than or equal to 1.'
  end

  if @api_client.config.client_side_validation && !opts[:'response_object_name'].nil? && opts[:'response_object_name'].to_s.length > 255
    fail ArgumentError, 'invalid value for "opts[:"response_object_name"]" when calling RateLimiterApi.create_rate_limiter, the character length must be smaller than or equal to 255.'
  end

  if @api_client.config.client_side_validation && !opts[:'response_object_name'].nil? && opts[:'response_object_name'].to_s.length < 1
    fail ArgumentError, 'invalid value for "opts[:"response_object_name"]" when calling RateLimiterApi.create_rate_limiter, the character length must be great than or equal to 1.'
  end

  allowable_values = ["azureblob", "bigquery", "cloudfiles", "datadog", "digitalocean", "elasticsearch", "ftp", "gcs", "googleanalytics", "heroku", "honeycomb", "http", "https", "kafka", "kinesis", "logentries", "loggly", "logshuttle", "newrelic", "newrelicotlp", "openstack", "papertrail", "pubsub", "s3", "scalyr", "sftp", "splunk", "stackdriver", "sumologic", "syslog"]
  if @api_client.config.client_side_validation && opts[:'logger_type'] && !allowable_values.include?(opts[:'logger_type'])
    fail ArgumentError, "invalid value for \"logger_type\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/service/{service_id}/version/{version_id}/rate-limiters'.sub('{' + 'service_id' + '}', CGI.escape(service_id.to_s)).sub('{' + 'version_id' + '}', CGI.escape(version_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}
  form_params['name'] = opts[:'name'] if !opts[:'name'].nil?
  form_params['uri_dictionary_name'] = opts[:'uri_dictionary_name'] if !opts[:'uri_dictionary_name'].nil?
  form_params['http_methods'] = @api_client.build_collection_param(opts[:'http_methods'], :csv) if !opts[:'http_methods'].nil?
  form_params['rps_limit'] = opts[:'rps_limit'] if !opts[:'rps_limit'].nil?
  form_params['window_size'] = opts[:'window_size'] if !opts[:'window_size'].nil?
  form_params['client_key'] = @api_client.build_collection_param(opts[:'client_key'], :csv) if !opts[:'client_key'].nil?
  form_params['penalty_box_duration'] = opts[:'penalty_box_duration'] if !opts[:'penalty_box_duration'].nil?
  form_params['action'] = opts[:'action'] if !opts[:'action'].nil?
  form_params['response_object_name'] = opts[:'response_object_name'] if !opts[:'response_object_name'].nil?
  form_params['logger_type'] = opts[:'logger_type'] if !opts[:'logger_type'].nil?
  form_params['feature_revision'] = opts[:'feature_revision'] if !opts[:'feature_revision'].nil?

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'RateLimiterResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['token']

  new_options = opts.merge(
    :operation => :"RateLimiterApi.create_rate_limiter",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: RateLimiterApi#create_rate_limiter\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#delete_rate_limiter(opts = {}) ⇒ InlineResponse200

Delete a rate limiter Delete a rate limiter by its ID.

Parameters:

  • opts (Hash) (defaults to: {})

    a customizable set of options

Options Hash (opts):

  • :rate_limiter_id (String)

    Alphanumeric string identifying the rate limiter. (required)

Returns:



200
201
202
203
# File 'lib/fastly/api/rate_limiter_api.rb', line 200

def delete_rate_limiter(opts = {})
  data, _status_code, _headers = delete_rate_limiter_with_http_info(opts)
  data
end

#delete_rate_limiter_with_http_info(opts = {}) ⇒ Array<(InlineResponse200, Integer, Hash)>

Delete a rate limiter Delete a rate limiter by its ID.

Parameters:

  • opts (Hash) (defaults to: {})

    a customizable set of options

Options Hash (opts):

  • :rate_limiter_id (String)

    Alphanumeric string identifying the rate limiter. (required)

Returns:

  • (Array<(InlineResponse200, Integer, Hash)>)

    InlineResponse200 data, response status code and response headers



209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
# File 'lib/fastly/api/rate_limiter_api.rb', line 209

def delete_rate_limiter_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: RateLimiterApi.delete_rate_limiter ...'
  end
  # unbox the parameters from the hash
  rate_limiter_id = opts[:'rate_limiter_id']
  # verify the required parameter 'rate_limiter_id' is set
  if @api_client.config.client_side_validation && rate_limiter_id.nil?
    fail ArgumentError, "Missing the required parameter 'rate_limiter_id' when calling RateLimiterApi.delete_rate_limiter"
  end
  # resource path
  local_var_path = '/rate-limiters/{rate_limiter_id}'.sub('{' + 'rate_limiter_id' + '}', CGI.escape(rate_limiter_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'InlineResponse200'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['token']

  new_options = opts.merge(
    :operation => :"RateLimiterApi.delete_rate_limiter",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: RateLimiterApi#delete_rate_limiter\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_rate_limiter(opts = {}) ⇒ RateLimiterResponse

Get a rate limiter Get a rate limiter by its ID.

Parameters:

  • opts (Hash) (defaults to: {})

    a customizable set of options

Options Hash (opts):

  • :rate_limiter_id (String)

    Alphanumeric string identifying the rate limiter. (required)

Returns:



263
264
265
266
# File 'lib/fastly/api/rate_limiter_api.rb', line 263

def get_rate_limiter(opts = {})
  data, _status_code, _headers = get_rate_limiter_with_http_info(opts)
  data
end

#get_rate_limiter_with_http_info(opts = {}) ⇒ Array<(RateLimiterResponse, Integer, Hash)>

Get a rate limiter Get a rate limiter by its ID.

Parameters:

  • opts (Hash) (defaults to: {})

    a customizable set of options

Options Hash (opts):

  • :rate_limiter_id (String)

    Alphanumeric string identifying the rate limiter. (required)

Returns:

  • (Array<(RateLimiterResponse, Integer, Hash)>)

    RateLimiterResponse data, response status code and response headers



272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
# File 'lib/fastly/api/rate_limiter_api.rb', line 272

def get_rate_limiter_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: RateLimiterApi.get_rate_limiter ...'
  end
  # unbox the parameters from the hash
  rate_limiter_id = opts[:'rate_limiter_id']
  # verify the required parameter 'rate_limiter_id' is set
  if @api_client.config.client_side_validation && rate_limiter_id.nil?
    fail ArgumentError, "Missing the required parameter 'rate_limiter_id' when calling RateLimiterApi.get_rate_limiter"
  end
  # resource path
  local_var_path = '/rate-limiters/{rate_limiter_id}'.sub('{' + 'rate_limiter_id' + '}', CGI.escape(rate_limiter_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'RateLimiterResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['token']

  new_options = opts.merge(
    :operation => :"RateLimiterApi.get_rate_limiter",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: RateLimiterApi#get_rate_limiter\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#list_rate_limiters(opts = {}) ⇒ Array<RateLimiterResponse>

List rate limiters List all rate limiters for a particular service and version.

Parameters:

  • opts (Hash) (defaults to: {})

    a customizable set of options

Options Hash (opts):

  • :service_id (String)

    Alphanumeric string identifying the service. (required)

  • :version_id (Integer)

    Integer identifying a service version. (required)

Returns:



327
328
329
330
# File 'lib/fastly/api/rate_limiter_api.rb', line 327

def list_rate_limiters(opts = {})
  data, _status_code, _headers = list_rate_limiters_with_http_info(opts)
  data
end

#list_rate_limiters_with_http_info(opts = {}) ⇒ Array<(Array<RateLimiterResponse>, Integer, Hash)>

List rate limiters List all rate limiters for a particular service and version.

Parameters:

  • opts (Hash) (defaults to: {})

    a customizable set of options

Options Hash (opts):

  • :service_id (String)

    Alphanumeric string identifying the service. (required)

  • :version_id (Integer)

    Integer identifying a service version. (required)

Returns:

  • (Array<(Array<RateLimiterResponse>, Integer, Hash)>)

    Array<RateLimiterResponse> data, response status code and response headers



337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
# File 'lib/fastly/api/rate_limiter_api.rb', line 337

def list_rate_limiters_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: RateLimiterApi.list_rate_limiters ...'
  end
  # unbox the parameters from the hash
  service_id = opts[:'service_id']
  version_id = opts[:'version_id']
  # verify the required parameter 'service_id' is set
  if @api_client.config.client_side_validation && service_id.nil?
    fail ArgumentError, "Missing the required parameter 'service_id' when calling RateLimiterApi.list_rate_limiters"
  end
  # verify the required parameter 'version_id' is set
  if @api_client.config.client_side_validation && version_id.nil?
    fail ArgumentError, "Missing the required parameter 'version_id' when calling RateLimiterApi.list_rate_limiters"
  end
  # resource path
  local_var_path = '/service/{service_id}/version/{version_id}/rate-limiters'.sub('{' + 'service_id' + '}', CGI.escape(service_id.to_s)).sub('{' + 'version_id' + '}', CGI.escape(version_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'Array<RateLimiterResponse>'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['token']

  new_options = opts.merge(
    :operation => :"RateLimiterApi.list_rate_limiters",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: RateLimiterApi#list_rate_limiters\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#update_rate_limiter(opts = {}) ⇒ RateLimiterResponse

Update a rate limiter Update a rate limiter by its ID.

Parameters:

  • opts (Hash) (defaults to: {})

    a customizable set of options

Options Hash (opts):

  • :rate_limiter_id (String)

    Alphanumeric string identifying the rate limiter. (required)

  • :name (String)

    A human readable name for the rate limiting rule.

  • :uri_dictionary_name (String)

    The name of an Edge Dictionary containing URIs as keys. If not defined or &#x60;null&#x60;, all origin URIs will be rate limited.

  • :http_methods (Array<String>)

    Array of HTTP methods to apply rate limiting to.

  • :rps_limit (Integer)

    Upper limit of requests per second allowed by the rate limiter.

  • :window_size (Integer)

    Number of seconds during which the RPS limit must be exceeded in order to trigger a violation.

  • :client_key (Array<String>)

    Array of VCL variables used to generate a counter key to identify a client. Example variables include &#x60;req.http.Fastly-Client-IP&#x60;, &#x60;req.http.User-Agent&#x60;, or a custom header like &#x60;req.http.API-Key&#x60;.

  • :penalty_box_duration (Integer)

    Length of time in minutes that the rate limiter is in effect after the initial violation is detected.

  • :action (String)

    The action to take when a rate limiter violation is detected.

  • :response_object_name (String)

    Name of existing response object. Required if &#x60;action&#x60; is &#x60;response_object&#x60;. Note that the rate limiter response is only updated to reflect the response object content when saving the rate limiter configuration.

  • :logger_type (String)

    Name of the type of logging endpoint to be used when action is &#x60;log_only&#x60;. The logging endpoint type is used to determine the appropriate log format to use when emitting log entries.

  • :feature_revision (Integer)

    Revision number of the rate limiting feature implementation. Defaults to the most recent revision.

Returns:



407
408
409
410
# File 'lib/fastly/api/rate_limiter_api.rb', line 407

def update_rate_limiter(opts = {})
  data, _status_code, _headers = update_rate_limiter_with_http_info(opts)
  data
end

#update_rate_limiter_with_http_info(opts = {}) ⇒ Array<(RateLimiterResponse, Integer, Hash)>

Update a rate limiter Update a rate limiter by its ID.

Parameters:

  • opts (Hash) (defaults to: {})

    a customizable set of options

Options Hash (opts):

  • :rate_limiter_id (String)

    Alphanumeric string identifying the rate limiter. (required)

  • :name (String)

    A human readable name for the rate limiting rule.

  • :uri_dictionary_name (String)

    The name of an Edge Dictionary containing URIs as keys. If not defined or &#x60;null&#x60;, all origin URIs will be rate limited.

  • :http_methods (Array<String>)

    Array of HTTP methods to apply rate limiting to.

  • :rps_limit (Integer)

    Upper limit of requests per second allowed by the rate limiter.

  • :window_size (Integer)

    Number of seconds during which the RPS limit must be exceeded in order to trigger a violation.

  • :client_key (Array<String>)

    Array of VCL variables used to generate a counter key to identify a client. Example variables include &#x60;req.http.Fastly-Client-IP&#x60;, &#x60;req.http.User-Agent&#x60;, or a custom header like &#x60;req.http.API-Key&#x60;.

  • :penalty_box_duration (Integer)

    Length of time in minutes that the rate limiter is in effect after the initial violation is detected.

  • :action (String)

    The action to take when a rate limiter violation is detected.

  • :response_object_name (String)

    Name of existing response object. Required if &#x60;action&#x60; is &#x60;response_object&#x60;. Note that the rate limiter response is only updated to reflect the response object content when saving the rate limiter configuration.

  • :logger_type (String)

    Name of the type of logging endpoint to be used when action is &#x60;log_only&#x60;. The logging endpoint type is used to determine the appropriate log format to use when emitting log entries.

  • :feature_revision (Integer)

    Revision number of the rate limiting feature implementation. Defaults to the most recent revision.

Returns:

  • (Array<(RateLimiterResponse, Integer, Hash)>)

    RateLimiterResponse data, response status code and response headers



427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
# File 'lib/fastly/api/rate_limiter_api.rb', line 427

def update_rate_limiter_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: RateLimiterApi.update_rate_limiter ...'
  end
  # unbox the parameters from the hash
  rate_limiter_id = opts[:'rate_limiter_id']
  # verify the required parameter 'rate_limiter_id' is set
  if @api_client.config.client_side_validation && rate_limiter_id.nil?
    fail ArgumentError, "Missing the required parameter 'rate_limiter_id' when calling RateLimiterApi.update_rate_limiter"
  end
  if @api_client.config.client_side_validation && !opts[:'name'].nil? && opts[:'name'].to_s.length > 255
    fail ArgumentError, 'invalid value for "opts[:"name"]" when calling RateLimiterApi.update_rate_limiter, the character length must be smaller than or equal to 255.'
  end

  if @api_client.config.client_side_validation && !opts[:'name'].nil? && opts[:'name'].to_s.length < 1
    fail ArgumentError, 'invalid value for "opts[:"name"]" when calling RateLimiterApi.update_rate_limiter, the character length must be great than or equal to 1.'
  end

  if @api_client.config.client_side_validation && !opts[:'uri_dictionary_name'].nil? && opts[:'uri_dictionary_name'].to_s.length > 255
    fail ArgumentError, 'invalid value for "opts[:"uri_dictionary_name"]" when calling RateLimiterApi.update_rate_limiter, the character length must be smaller than or equal to 255.'
  end

  if @api_client.config.client_side_validation && !opts[:'uri_dictionary_name'].nil? && opts[:'uri_dictionary_name'].to_s.length < 1
    fail ArgumentError, 'invalid value for "opts[:"uri_dictionary_name"]" when calling RateLimiterApi.update_rate_limiter, the character length must be great than or equal to 1.'
  end

  allowable_values = ["HEAD", "OPTIONS", "GET", "POST", "PUT", "PATCH", "DELETE", "TRACE"]
  if @api_client.config.client_side_validation && opts[:'http_methods'] && !opts[:'http_methods'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"http_methods\", must include one of #{allowable_values}"
  end
  if @api_client.config.client_side_validation && !opts[:'http_methods'].nil? && opts[:'http_methods'].length < 1
    fail ArgumentError, 'invalid value for "opts[:"http_methods"]" when calling RateLimiterApi.update_rate_limiter, number of items must be greater than or equal to 1.'
  end

  if @api_client.config.client_side_validation && !opts[:'rps_limit'].nil? && opts[:'rps_limit'] > 10000
    fail ArgumentError, 'invalid value for "opts[:"rps_limit"]" when calling RateLimiterApi.update_rate_limiter, must be smaller than or equal to 10000.'
  end

  if @api_client.config.client_side_validation && !opts[:'rps_limit'].nil? && opts[:'rps_limit'] < 10
    fail ArgumentError, 'invalid value for "opts[:"rps_limit"]" when calling RateLimiterApi.update_rate_limiter, must be greater than or equal to 10.'
  end

  allowable_values = [1, 10, 60]
  if @api_client.config.client_side_validation && opts[:'window_size'] && !allowable_values.include?(opts[:'window_size'])
    fail ArgumentError, "invalid value for \"window_size\", must be one of #{allowable_values}"
  end
  if @api_client.config.client_side_validation && !opts[:'client_key'].nil? && opts[:'client_key'].length < 1
    fail ArgumentError, 'invalid value for "opts[:"client_key"]" when calling RateLimiterApi.update_rate_limiter, number of items must be greater than or equal to 1.'
  end

  if @api_client.config.client_side_validation && !opts[:'penalty_box_duration'].nil? && opts[:'penalty_box_duration'] > 60
    fail ArgumentError, 'invalid value for "opts[:"penalty_box_duration"]" when calling RateLimiterApi.update_rate_limiter, must be smaller than or equal to 60.'
  end

  if @api_client.config.client_side_validation && !opts[:'penalty_box_duration'].nil? && opts[:'penalty_box_duration'] < 1
    fail ArgumentError, 'invalid value for "opts[:"penalty_box_duration"]" when calling RateLimiterApi.update_rate_limiter, must be greater than or equal to 1.'
  end

  allowable_values = ["response", "response_object", "log_only"]
  if @api_client.config.client_side_validation && opts[:'action'] && !allowable_values.include?(opts[:'action'])
    fail ArgumentError, "invalid value for \"action\", must be one of #{allowable_values}"
  end
  if @api_client.config.client_side_validation && !opts[:'action'].nil? && opts[:'action'].to_s.length < 1
    fail ArgumentError, 'invalid value for "opts[:"action"]" when calling RateLimiterApi.update_rate_limiter, the character length must be great than or equal to 1.'
  end

  if @api_client.config.client_side_validation && !opts[:'response_object_name'].nil? && opts[:'response_object_name'].to_s.length > 255
    fail ArgumentError, 'invalid value for "opts[:"response_object_name"]" when calling RateLimiterApi.update_rate_limiter, the character length must be smaller than or equal to 255.'
  end

  if @api_client.config.client_side_validation && !opts[:'response_object_name'].nil? && opts[:'response_object_name'].to_s.length < 1
    fail ArgumentError, 'invalid value for "opts[:"response_object_name"]" when calling RateLimiterApi.update_rate_limiter, the character length must be great than or equal to 1.'
  end

  allowable_values = ["azureblob", "bigquery", "cloudfiles", "datadog", "digitalocean", "elasticsearch", "ftp", "gcs", "googleanalytics", "heroku", "honeycomb", "http", "https", "kafka", "kinesis", "logentries", "loggly", "logshuttle", "newrelic", "newrelicotlp", "openstack", "papertrail", "pubsub", "s3", "scalyr", "sftp", "splunk", "stackdriver", "sumologic", "syslog"]
  if @api_client.config.client_side_validation && opts[:'logger_type'] && !allowable_values.include?(opts[:'logger_type'])
    fail ArgumentError, "invalid value for \"logger_type\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/rate-limiters/{rate_limiter_id}'.sub('{' + 'rate_limiter_id' + '}', CGI.escape(rate_limiter_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}
  form_params['name'] = opts[:'name'] if !opts[:'name'].nil?
  form_params['uri_dictionary_name'] = opts[:'uri_dictionary_name'] if !opts[:'uri_dictionary_name'].nil?
  form_params['http_methods'] = @api_client.build_collection_param(opts[:'http_methods'], :csv) if !opts[:'http_methods'].nil?
  form_params['rps_limit'] = opts[:'rps_limit'] if !opts[:'rps_limit'].nil?
  form_params['window_size'] = opts[:'window_size'] if !opts[:'window_size'].nil?
  form_params['client_key'] = @api_client.build_collection_param(opts[:'client_key'], :csv) if !opts[:'client_key'].nil?
  form_params['penalty_box_duration'] = opts[:'penalty_box_duration'] if !opts[:'penalty_box_duration'].nil?
  form_params['action'] = opts[:'action'] if !opts[:'action'].nil?
  form_params['response_object_name'] = opts[:'response_object_name'] if !opts[:'response_object_name'].nil?
  form_params['logger_type'] = opts[:'logger_type'] if !opts[:'logger_type'].nil?
  form_params['feature_revision'] = opts[:'feature_revision'] if !opts[:'feature_revision'].nil?

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'RateLimiterResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['token']

  new_options = opts.merge(
    :operation => :"RateLimiterApi.update_rate_limiter",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: RateLimiterApi#update_rate_limiter\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end