Class: CloudflareClient::Railgun
- Inherits:
-
CloudflareClient
- Object
- CloudflareClient
- CloudflareClient::Railgun
- Defined in:
- lib/cloudflare_client/railgun.rb
Constant Summary
Constants inherited from CloudflareClient
API_BASE, POSSIBLE_API_SETTINGS, VALID_BUNDLE_METHODS, VALID_DIRECTIONS, VALID_MATCHES, VERSION
Instance Method Summary collapse
-
#create(name:) ⇒ Object
create(name: ‘name of railgun’).
-
#delete(id:) ⇒ Object
delete a railgun.
-
#disable(id:) ⇒ Object
Disable a railgun.
-
#enable(id:) ⇒ Object
Enable a railgun.
-
#list(page: 1, per_page: 50, direction: 'desc') ⇒ Object
Get all the railguns.
-
#show(id:) ⇒ Object
Get a single railgun.
-
#zones(id:) ⇒ Object
Get CF zones associated with a railgun.
Methods inherited from CloudflareClient
Constructor Details
This class inherits a constructor from CloudflareClient
Instance Method Details
#create(name:) ⇒ Object
create(name: ‘name of railgun’)
5 6 7 8 9 |
# File 'lib/cloudflare_client/railgun.rb', line 5 def create(name:) raise 'Railgun name cannot be nil' if name.nil? data = {name: name} cf_post(path: '/railguns', data: data) end |
#delete(id:) ⇒ Object
delete a railgun
47 48 49 50 |
# File 'lib/cloudflare_client/railgun.rb', line 47 def delete(id:) raise 'must provide the id of the railgun' if id.nil? cf_delete(path: "/railguns/#{id}") end |
#disable(id:) ⇒ Object
Disable a railgun
41 42 43 |
# File 'lib/cloudflare_client/railgun.rb', line 41 def disable(id:) update_enabled(id: id, enabled: false) end |
#enable(id:) ⇒ Object
Enable a railgun
35 36 37 |
# File 'lib/cloudflare_client/railgun.rb', line 35 def enable(id:) update_enabled(id: id, enabled: true) end |
#list(page: 1, per_page: 50, direction: 'desc') ⇒ Object
Get all the railguns
13 14 15 16 17 |
# File 'lib/cloudflare_client/railgun.rb', line 13 def list(page: 1, per_page: 50, direction: 'desc') raise 'direction must be either desc | asc' unless direction == 'desc' || direction == 'asc' params = {page: page, per_page: per_page, direction: direction} cf_get(path: '/railguns', params: params) end |
#show(id:) ⇒ Object
Get a single railgun
21 22 23 24 |
# File 'lib/cloudflare_client/railgun.rb', line 21 def show(id:) raise 'must provide the id of the railgun' if id.nil? cf_get(path: "/railguns/#{id}") end |
#zones(id:) ⇒ Object
Get CF zones associated with a railgun
28 29 30 31 |
# File 'lib/cloudflare_client/railgun.rb', line 28 def zones(id:) raise 'must provide the id of the railgun' if id.nil? cf_get(path: "/railguns/#{id}/zones") end |