class PaloAlto::V6::Api

Public Instance Methods

xml_config_for(path:) click to toggle source

Request a configuration based on the starting XML path.

Returns

* +Nokogiri::XML::Document+ - Nokogiri XML document to parse information about

Raises

* +Exception+ - Raises an exception if the request is unsuccessful
# File lib/palo_alto/v6/api.rb, line 35
def xml_config_for(path:)
  virtual_systems_list = []

  # configure options for the request
  options = {}
  options[:url]     = self.endpoint
  options[:method]  = :post
  options[:payload] = { type:   "config",
                        action: "show",
                        key:    self.auth_key,
                        xpath:  path }

  html_result = Helpers::Rest.make_request(options)

  raise "Error obtaining virtual system XML" if html_result.nil?

  # parse the XML data
  data = Nokogiri::XML(html_result)
  raise "Error in response XML: #{data.inspect}" if data.xpath('//response/@status').to_s != "success"
  data
end