Wildcards in rest api configuration query?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Wildcards in rest api configuration query?

L2 Linker

Hi,

 

I'm trying to write a reporting tool that will go throguh various device groups and identify rules that have certain keywords (change numbers in my case) in the description.

 

I'm querying panorama configuration and using rest api directly from python (e.g. requests module or pan.xapi)

 

For example, this query works perfectly for me and as a result I get two rules returned back, if description contains only one string CHG99646:

 

/config/devices/entry[@name='localhost.localdomain']/device-group/entry[@name='Perth']/pre-rulebase/security/rules/entry[description="CHG99646"]

 
<response status="success" code="19">
<result total-count="2" count="2">
1 ACCEPTED SOLUTION

Accepted Solutions

What I mean is that PAN is using Xpath, so you can use what Xpath has available:

 

In your case, something like that should work : 

[contains(text(),'whatYouWantHere')]

 

concerning your other question about Global Find and such : it's not exposed to through API unfortunatly. But it's somethign available on my project if you dont mind using it and/or developping in PHP 😉

View solution in original post

13 REPLIES 13

L4 Transporter

Hi,

 

 The API is not designed for that. It has limited support for XPath and pulling data locally is probably the only way. 

 

 There are as well exisiting utilities which can do what you are looking for already, like one of mine here: https://live.paloaltonetworks.com/t5/API-Articles/rules-edit-php-to-manage-edit-export-rules-from-CL...

OK, so Palo Alto decided not to implement %like% in their rest api. Understood.

 

Do you know if there is an op command that I could incorporate instead of using wildcards in the xpath matching? Something similar to global find in panorama gui or a | match when I am running show configuration? I mean, anything that will return a security rule name(s) based on text I want to find in description.

 

Cheers,

Milos

What I mean is that PAN is using Xpath, so you can use what Xpath has available:

 

In your case, something like that should work : 

[contains(text(),'whatYouWantHere')]

 

concerning your other question about Global Find and such : it's not exposed to through API unfortunatly. But it's somethign available on my project if you dont mind using it and/or developping in PHP 😉

I'm trying to use your suggestion with contains text but I am not able to match anything

 

Could you give a full xpath example for matching description field with [contains(text(),'whatYouWantHere')]? I'm missing something when trying to use your suggestion.

 

For the PHP I have minimal knowledge there 🙂

 

Milos

Like what you see?

Show your appreciation!

Click Like if a post is helpful to you or if you just want to show your support.

Click Accept as Solution to acknowledge that the answer to your question has been provided.

The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!

These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!

The LIVEcommunity thanks you for your participation!