class CpMgmt::Network

Public Instance Methods

add(name, subnet, subnet_mask, options={}) click to toggle source

Adds a network

# 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) click to toggle source

removes a network

# 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) click to toggle source

Shows a network

# 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_all() click to toggle source

Shows all networks

# 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