Class: CpMgmt::Host

Inherits:
Object
  • Object
show all
Defined in:
lib/cp_mgmt/host.rb

Instance Method Summary collapse

Instance Method Details

#add(name, ip_address, options = {}) ⇒ Object

Adds a host



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/cp_mgmt/host.rb', line 4

def add(name, ip_address, options={})
  client = CpMgmt.configuration.client
  CpMgmt.logged_in?
  params = {name: name, "ip-address": ip_address}
  body = params.merge(options).to_json

  response = client.post do |req|
    req.url '/web_api/add-host'
    req.headers['Content-Type'] = 'application/json'
    req.headers['X-chkp-sid'] = ENV.fetch("sid")
    req.body = body
  end
  CpMgmt.transform_response(response)
end

#remove(name) ⇒ Object

removes a host



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/cp_mgmt/host.rb', line 20

def remove(name)
  client = CpMgmt.configuration.client
  CpMgmt.logged_in?

  body = {name: name}.to_json
  response = client.post do |req|
    req.url '/web_api/delete-host'
    req.headers['Content-Type'] = 'application/json'
    req.headers['X-chkp-sid'] = ENV.fetch("sid")
    req.body = body
  end
  CpMgmt.transform_response(response)
end

#show(name) ⇒ Object

Shows a host



35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/cp_mgmt/host.rb', line 35

def show(name)
  client = CpMgmt.configuration.client
  CpMgmt.logged_in?

  body = {name: name}.to_json
  response = client.post do |req|
    req.url '/web_api/show-host'
    req.headers['Content-Type'] = 'application/json'
    req.headers['X-chkp-sid'] = ENV.fetch("sid")
    req.body = body
  end
  CpMgmt.transform_response(response)
end

#show_allObject

Shows all hosts



50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/cp_mgmt/host.rb', line 50

def show_all
  client = CpMgmt.configuration.client
  CpMgmt.logged_in?

  response = client.post do |req|
    req.url '/web_api/show-hosts'
    req.headers['Content-Type'] = 'application/json'
    req.headers['X-chkp-sid'] = ENV.fetch("sid")
    req.body = "{}"
  end
  CpMgmt.transform_response(response)
end