A simple client for Palo Alto Networks firewall API
panxapi.js is a simple Node.js client for Palo Alto Networks firewall API.
A key can be specified, during creation of the client like this:
var client = panxapicreatePanClienthost : 'firewall.example.com'key : 'yourkey' // optionalprotocol : 'https' // optional
Or it can be generated with the keygen method:
var client = panxapicreatePanClienthost : 'firewall.example.com'clientkeygen'username' 'password'if err throw errconsole.logclientkey // outputs URI decoded keyconsole.logxml // outputs XML
In addition to the XML response, an elementtree object is provided as a convenience.
Once the client has a key, you can make further API requests. You'll want to review the vendor's documentation for more info on the parameters, but here is an example of retrieving the hostname for a firewall's configuration :
// ... remember to create the client and set the key first ...var params =type : 'config'action : 'get'xpath : '/config/devices/entry/deviceconfig/system/hostname'clientrequestparamsconsole.logxml // outputs XML response
$ npm install panxapi
Most of the test can be run with:
$ npm test
Running the acceptance tests requires having access to a Palo Alto firewall and having a filled settings.json similar to the example-settings.json. Once you have that, you can run :
$ mocha -R spec test/acceptance/*