Class: Cloudflare::Firewall::Rules
Constant Summary
Representation::WRAPPER
Instance Method Summary
collapse
Methods included from Paginate
#each, #empty?, #find_by_id
#errors, #messages, #represent, #represent_message, #result, #results, #success?, #to_hash, #to_id
Instance Method Details
#each_by_value(value, &block) ⇒ Object
57
58
59
|
# File 'lib/cloudflare/firewall.rb', line 57
def each_by_value(value, &block)
each(configuration_value: value, &block)
end
|
#representation ⇒ Object
35
36
37
|
# File 'lib/cloudflare/firewall.rb', line 35
def representation
Rule
end
|
#set(mode, value, notes: nil, target: "ip") ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/cloudflare/firewall.rb', line 39
def set(mode, value, notes: nil, target: "ip")
notes ||= "cloudflare gem [#{mode}] #{Time.now.strftime('%m/%d/%y')}"
payload = {mode: mode.to_s, notes: notes, configuration: {target: target, value: value.to_s}}
Rule.post(@resource, payload) do |resource, response|
value = response.read
result = value[:result]
metadata = response.
if id = result[:id]
resource = resource.with(path: id)
end
Rule.new(resource, value: value, metadata: metadata)
end
end
|