Class: CloudflareClient::Zone::Firewall::WAFPackage::RuleGroup

Inherits:
Base show all
Defined in:
lib/cloudflare_client/zone/firewall/waf_package/rule_group.rb

Constant Summary collapse

VALID_MODES =
%w[on off]
VALID_ORDERS =
%w[mode rules_count]

Constants inherited from CloudflareClient::Zone::Firewall::WAFPackage

VALID_ACTION_MODES, VALID_SENSITIVITIES

Constants inherited from CloudflareClient::Zone

VALID_ZONE_STATUSES

Constants inherited from CloudflareClient

API_BASE, POSSIBLE_API_SETTINGS, VALID_BUNDLE_METHODS, VALID_DIRECTIONS, VALID_MATCHES, VERSION

Instance Attribute Summary

Attributes inherited from Base

#package_id

Attributes inherited from Base

#zone_id

Instance Method Summary collapse

Methods inherited from Base

#initialize

Methods inherited from Base

#initialize

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

#initialize

Constructor Details

This class inherits a constructor from CloudflareClient::Zone::Firewall::WAFPackage::Base

Instance Method Details

#list(name: nil, mode: 'on', rules_count: 0, page: 1, per_page: 50, order: 'mode', direction: 'desc', match: 'all') ⇒ Object

waf_rule_groups



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/cloudflare_client/zone/firewall/waf_package/rule_group.rb', line 7

def list(name: nil, mode: 'on', rules_count: 0, page: 1, per_page: 50, order: 'mode', direction: 'desc', match: 'all')
  params = {page: page, per_page: per_page}

  valid_value_check(:mode, mode, VALID_MODES)
  params[:mode] = mode

  #FIXME: rules_count doesn't make any sense, ask CF
  valid_value_check(:order, order, VALID_ORDERS)
  params[:order] = order

  valid_value_check(:direction, direction, VALID_DIRECTIONS)
  params[:direction] = direction

  valid_value_check(:match, match, VALID_MATCHES)
  params[:match] = match

  cf_get(path: "/zones/#{zone_id}/firewall/waf/packages/#{package_id}/groups", params: params)
end

#show(id:) ⇒ Object

details of a waf rule group



28
29
30
31
32
# File 'lib/cloudflare_client/zone/firewall/waf_package/rule_group.rb', line 28

def show(id:)
  id_check('id', id)

  cf_get(path: "/zones/#{zone_id}/firewall/waf/packages/#{package_id}/groups/#{id}")
end

#update(id:, mode: 'on') ⇒ Object

updates a waf rule group



36
37
38
39
40
41
# File 'lib/cloudflare_client/zone/firewall/waf_package/rule_group.rb', line 36

def update(id:, mode: 'on')
  id_check('id', id)
  valid_value_check(:mode, mode, VALID_MODES)

  cf_patch(path: "/zones/#{zone_id}/firewall/waf/packages/#{package_id}/groups/#{id}", data: {mode: mode})
end