Class: CloudflareClient::Railgun

Inherits:
CloudflareClient show all
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

Constructor Details

#initialize(*args) ⇒ Railgun

Railgun methods



4
5
6
# File 'lib/cloudflare_client/railgun.rb', line 4

def initialize(*args)
  super
end

Instance Method Details

#create(name:) ⇒ Object

create(name: ‘name of railgun’)



10
11
12
13
14
# File 'lib/cloudflare_client/railgun.rb', line 10

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



52
53
54
55
# File 'lib/cloudflare_client/railgun.rb', line 52

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



46
47
48
# File 'lib/cloudflare_client/railgun.rb', line 46

def disable(id:)
  update_enabled(id: id, enabled: false)
end

#enable(id:) ⇒ Object

Enable a railgun



40
41
42
# File 'lib/cloudflare_client/railgun.rb', line 40

def enable(id:)
  update_enabled(id: id, enabled: true)
end

#list(page: 1, per_page: 50, direction: 'desc') ⇒ Object

Get all the railguns



18
19
20
21
22
# File 'lib/cloudflare_client/railgun.rb', line 18

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



26
27
28
29
# File 'lib/cloudflare_client/railgun.rb', line 26

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



33
34
35
36
# File 'lib/cloudflare_client/railgun.rb', line 33

def zones(id:)
  raise 'must provide the id of the railgun' if id.nil?
  cf_get(path: "/railguns/#{id}/zones")
end