Class: CpMgmt::Network

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

Instance Method Summary collapse

Instance Method Details

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

Adds a network



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

def add(name, subnet, subnet_mask, options={})
  client = CpMgmt.configuration.client
  CpMgmt.logged_in?
  params = {name: name, subnet: subnet, "subnet-mask": subnet_mask}
  body = params.merge(options).to_json

  response = client.post do |req|
    req.url '/web_api/add-network'
    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 network



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/cp_mgmt/network.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-network'
    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 network



35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/cp_mgmt/network.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-network'
    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 networks



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

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

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