Class: CloudflareClient::Organization::AccessRule
- Inherits:
-
CloudflareClient::Organization
- Object
- CloudflareClient
- CloudflareClient::Organization
- CloudflareClient::Organization::AccessRule
- Defined in:
- lib/cloudflare_client/organization/access_rule.rb
Constant Summary collapse
- VALID_MODES =
%w[block challenge whitelist].freeze
- VALID_CONFIG_TARGETS =
%w[ip ip_range country_code].freeze
- VALID_ORDERS =
%w[configuration_target configuration_value mode].freeze
Constants inherited from CloudflareClient
API_BASE, POSSIBLE_API_SETTINGS, VALID_BUNDLE_METHODS, VALID_DIRECTIONS, VALID_MATCHES, VERSION
Instance Attribute Summary
Attributes inherited from CloudflareClient::Organization
Instance Method Summary collapse
-
#create(mode:, configuration:, notes: nil) ⇒ Object
create access rule.
-
#delete(id:) ⇒ Object
delete org access rule.
-
#list(notes: nil, mode: nil, match: 'all', configuration_value: nil, order: nil, page: 1, per_page: 50, configuration_target: nil, direction: 'desc') ⇒ Object
list access rules.
Methods inherited from CloudflareClient::Organization
Methods inherited from CloudflareClient
Constructor Details
This class inherits a constructor from CloudflareClient::Organization
Instance Method Details
#create(mode:, configuration:, notes: nil) ⇒ Object
create access rule
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/cloudflare_client/organization/access_rule.rb', line 53 def create(mode:, configuration:, notes: nil) non_empty_hash_check(:configuration, configuration) valid_value_check(:mode, mode, VALID_MODES) #TODO: validate config objects? data = {mode: mode, configuration: configuration} data[:notes] = notes unless notes.nil? cf_post(path: "/organizations/#{org_id}/firewall/access_rules/rules", data: data) end |
#delete(id:) ⇒ Object
delete org access rule
72 73 74 75 |
# File 'lib/cloudflare_client/organization/access_rule.rb', line 72 def delete(id:) id_check('id', id) cf_delete(path: "/organizations/#{org_id}/firewall/access_rules/rules/#{id}") end |
#list(notes: nil, mode: nil, match: 'all', configuration_value: nil, order: nil, page: 1, per_page: 50, configuration_target: nil, direction: 'desc') ⇒ Object
list access rules
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 |
# File 'lib/cloudflare_client/organization/access_rule.rb', line 12 def list(notes: nil, mode: nil, match: 'all', configuration_value: nil, order: nil, page: 1, per_page: 50, configuration_target: nil, direction: 'desc') params = {page: page, per_page: per_page} unless notes.nil? basic_type_check(:notes, notes, String) params[:notes] = notes end unless mode.nil? valid_value_check(:mode, mode, VALID_MODES) params[:mode] = mode end unless match.nil? valid_value_check(:match, match, VALID_MATCHES) params[:match] = match end params[:configuration_value] = configuration_value unless configuration_value.nil? #FIXME: check this against the api unless order.nil? valid_value_check(:order, order, VALID_ORDERS) params[:order] = order end unless configuration_target.nil? valid_value_check(:configuration_target, configuration_target, VALID_CONFIG_TARGETS) params[:configuration_target] = configuration_target end unless direction.nil? valid_value_check(:direction, direction, VALID_DIRECTIONS) params[:direction] = direction end cf_get(path: "/organizations/#{org_id}/firewall/access_rules/rules", params: params) end |