XPath Behavioral Differences (Optional)

XPath selection behavior is different for get and show requests:

Action Element Attribute Text node >1 node Non-
  node node character   absolute
      data   path
show Yes Yes Yes No Yes
get Yes Yes No Yes No

Lab 12

  1. Use panxapi.py to perform get and show requests on the XPath "/config/mgt-config/users/entry" (matches > 1 node).
  2. Use panxapi.py to perform get and show requests on the XPath "/config/mgt-config/users" (matches 1 node).
  3. Use panxapi.py to perform get and show requests on the XPath "mgt-config" (relative location path).

Best Practice

Always use absolute XPath (start with slash /).

Solution

Matches > 1 node:

$ panxapi.py -g "/config/mgt-config/users/entry"
get: success [code="19"]
$ panxapi.py -s "/config/mgt-config/users/entry"
show: error: "No such node"

Matches 1 node:

$ panxapi.py -g "/config/mgt-config/users"
get: success [code="19"]
$ panxapi.py -s "/config/mgt-config/users"
show: success

Relative location path:

$ panxapi.py -g "mgt-config"
get: unauth [code="16"]: "Unauthorized request"
$ panxapi.py -s "mgt-config"
show: success