class CloudflareClient::Zone::RateLimit
Constants
- DOC_URL
Public Instance Methods
create(match:, threshold:, period:, action:, id: nil, disabled: nil, description: nil, bypass: nil)
click to toggle source
Create a zone rate limit
# 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:)
click to toggle source
delete zone rate limit
# 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)
click to toggle source
list zone rate limits
# 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:)
click to toggle source
get details for a zone rate limit
# 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)
click to toggle source
update zone rate limit
# 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
Private Instance Methods
common_checks(match, action, threshold, period)
click to toggle source
# File lib/cloudflare_client/zone/rate_limit.rb, line 67 def common_checks(match, action, threshold, period) raise "match must be a match object #{DOC_URL}" unless match.is_a?(Hash) raise "action must be a action object #{DOC_URL}" unless action.is_a?(Hash) raise 'threshold must be between 1 86400' if !threshold.is_a?(Integer) || !threshold.between?(1, 86400) raise 'period must be between 1 86400' if !period.is_a?(Integer) || !period.between?(1, 86400) end