XML API for Global Search

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

XML API for Global Search

L0 Member

Hi All,
I am trying to test XML API for global search . I am trying to use for search security rule with given description . 
ANy help for this.

1 accepted solution

Accepted Solutions

Cyber Elite
Cyber Elite

@D.Verma502651,

This is doing a lot of parsing of the configuration directly and isn't a feature or function that you can interact with via the API. You would need to essentially replicate the functionality (probably in a more targeted manner to make it easier) and find any matches. I've included a very basic example below given your desire to look at security rulebase entries:

 

ExampleDescription = 'This is a test description'
GetSecRulebase = requests.get("https://myFirewallUrl/api/?type=config&action=get&xpath=/config/devices/entry[@name='localhost.localdomain']/vsys/entry[@name='vsys1']/rulebase/security/rules",headers=headers)
SecRulebase = xmltodict.parse(GetSecRulebase.content)
SecEntries = SecRulebase['response']['result']['rules']['entry']
for SecEntry in SecEntries:
    entryName = SecEntry['@name']
    entryDescription = SecEntry['description']
    if entryDescription == str(ExampleDescription):
        print("Entry '" + str(entryName) + "' matches the ExampleDescription")

You could then obviously take this minimal example and update it to account for whatever you are actually attempting to do. 

View solution in original post

1 REPLY 1

Cyber Elite
Cyber Elite

@D.Verma502651,

This is doing a lot of parsing of the configuration directly and isn't a feature or function that you can interact with via the API. You would need to essentially replicate the functionality (probably in a more targeted manner to make it easier) and find any matches. I've included a very basic example below given your desire to look at security rulebase entries:

 

ExampleDescription = 'This is a test description'
GetSecRulebase = requests.get("https://myFirewallUrl/api/?type=config&action=get&xpath=/config/devices/entry[@name='localhost.localdomain']/vsys/entry[@name='vsys1']/rulebase/security/rules",headers=headers)
SecRulebase = xmltodict.parse(GetSecRulebase.content)
SecEntries = SecRulebase['response']['result']['rules']['entry']
for SecEntry in SecEntries:
    entryName = SecEntry['@name']
    entryDescription = SecEntry['description']
    if entryDescription == str(ExampleDescription):
        print("Entry '" + str(entryName) + "' matches the ExampleDescription")

You could then obviously take this minimal example and update it to account for whatever you are actually attempting to do. 

  • 1 accepted solution
  • 3043 Views
  • 1 replies
  • 0 Likes
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!