Class: CloudflareClient::Zone::RateLimit
- Inherits:
-
Base
- Object
- CloudflareClient
- CloudflareClient::Zone
- Base
- CloudflareClient::Zone::RateLimit
- Defined in:
- lib/cloudflare_client/zone/rate_limit.rb
Constant Summary collapse
- DOC_URL =
'https://api.cloudflare.com/#rate-limits-for-a-zone-create-a-ratelimit'.freeze
Constants inherited from CloudflareClient::Zone
Constants inherited from CloudflareClient
API_BASE, POSSIBLE_API_SETTINGS, VALID_BUNDLE_METHODS, VALID_DIRECTIONS, VALID_MATCHES, VERSION
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#create(match:, threshold:, period:, action:, id: nil, disabled: nil, description: nil, bypass: nil) ⇒ Object
Create a zone rate limit.
-
#delete(id:) ⇒ Object
delete zone rate limit.
-
#list(page: 1, per_page: 50) ⇒ Object
list zone rate limits.
-
#show(id:) ⇒ Object
get details for a zone rate limit.
-
#update(id:, match:, action:, threshold:, period:, disabled: nil, description: nil, bypass: nil) ⇒ Object
update zone rate limit.
Methods inherited from Base
Methods inherited from CloudflareClient::Zone
#create_zone, #delete_zone, #edit_zone, #purge_zone_cache, #update_zone_settings, #zone, #zone_activation_check, #zone_setting, #zone_settings, #zones
Methods inherited from CloudflareClient
Constructor Details
This class inherits a constructor from CloudflareClient::Zone::Base
Instance Method Details
#create(match:, threshold:, period:, action:, id: nil, disabled: nil, description: nil, bypass: nil) ⇒ Object
Create a zone rate limit
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/cloudflare_client/zone/rate_limit.rb', line 17 def create(match:, threshold:, period:, action:, id: nil, disabled: nil, description: nil, bypass: nil) common_checks(match, action, threshold, period) data = {match: match, threshold: threshold, period: period, action: action} data[:id] = id unless id.nil? unless disabled.nil? valid_value_check(:disabled, disabled, [true, false]) data[:disabled] = disabled end cf_post(path: "/zones/#{zone_id}/rate_limits", data: data) end |
#delete(id:) ⇒ Object
delete zone rate limit
59 60 61 62 63 |
# File 'lib/cloudflare_client/zone/rate_limit.rb', line 59 def delete(id:) id_check('id', id) cf_delete(path: "/zones/#{zone_id}/rate_limits/#{id}") end |
#list(page: 1, per_page: 50) ⇒ Object
list zone rate limits
9 10 11 12 13 |
# File 'lib/cloudflare_client/zone/rate_limit.rb', line 9 def list(page: 1, per_page: 50) params = {page: page, per_page: per_page} cf_get(path: "/zones/#{zone_id}/rate_limits", params: params) end |
#show(id:) ⇒ Object
get details for a zone rate limit
33 34 35 36 37 |
# File 'lib/cloudflare_client/zone/rate_limit.rb', line 33 def show(id:) id_check('id', id) cf_get(path: "/zones/#{zone_id}/rate_limits/#{id}") end |
#update(id:, match:, action:, threshold:, period:, disabled: nil, description: nil, bypass: nil) ⇒ Object
update zone rate limit
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/cloudflare_client/zone/rate_limit.rb', line 41 def update(id:, match:, action:, threshold:, period:, disabled: nil, description: nil, bypass: nil) id_check('id', id) common_checks(match, action, threshold, period) data = {match: match, threshold: threshold, period: period, action: action} data[:id] = id unless id.nil? data[:description] = description unless description.nil? unless disabled.nil? valid_value_check(:disabled, disabled, [true, false]) data[:disabled] = disabled end cf_put(path: "/zones/#{zone_id}/rate_limits/#{id}", data: data) end |