Introducing SOC Insights for BloxOne Threat Defense: Boost your SOC efficiency with AI-driven insights to eliminate manual work and accelerate investigation and response times. Read the blog announcement here.

API & Integration, DevOps,NetOps,SecOps

Reply

API Search regex for integer extensible attribute

New Member
Posts: 1
2181     2

Hi guys,

 

i am trying to get a list of all networks that have VLAN ID to determine which VLAN ID would be next. However I am not able to build a valid regex with an integer.

 

A normal query for a VLAN gives me this output, so you can see the structure:

/wapi/v2.9.5/network?_return_fields=comment,network,extattrs&*VLAN%20ID=1

 

<list>
  <value type="object">
    <comment>some network</comment>
    <network>X.X.X.X/24</network>
    <extattrs type="object">
       <tag0 name="VLAN ID" type="object">
         <value type="int">1</value>
       </tag0>
     </extattrs>
    <_ref>network/ZG5zLm5ldHdvcmskMTAuMjUwLjAuMC8yNC8w:X.X.X.X/24/default</_ref>
  </value>
</list>
 
There are many networks that doen have a VLAN ID. So I just want to query all networks which have one.
I tried:
/wapi/v2.9.5/network?_return_fields=comment,network,extattrs&*VLAN%20ID>0
/wapi/v2.9.5/network?_return_fields=comment,network,extattrs&*VLAN%20ID=.*
/wapi/v2.9.5/network?_return_fields=comment,network,extattrs&*VLAN%20ID=*
/wapi/v2.9.5/network?_return_fields=comment,network,extattrs&*VLAN%20ID~.*
/wapi/v2.9.5/network?_return_fields=comment,network,extattrs&*VLAN%20ID!=0
/wapi/v2.9.5/network?_return_fields=comment,network,extattrs&*VLAN%20ID=""
and some other things but nothing works.
 
Is there any regex to get the wanted result from the api?
 
Further note:
If I do not use a = symbol the api will interprete it as part of the name the ea has. 
I.e.:/wapi/v2.9.5/network?_return_fields=comment,network,extattrs&*VLAN%20ID>0
{ "Error": "AdmConProtoError: Unknown extensible attribute: VLAN ID>0", 
  "code": "Client.Ibap.Proto", 
  "text": "Unknown extensible attribute: VLAN ID>0"
}

Re: API Search regex for integer extensible attribute

New Member
Posts: 3
2182     2

Hi,

2 years later i encountered the same issue. I could solve it via regex search, which is availble in API v2.12.1.

Using Ansible so the API Call is abstracted:

 

   - name: get all networks with ea vlan
     ansible.builtin.set_fact:
      ib_networks_with_vlan_ea: "{{ lookup('infoblox.nios_modules.nios_lookup', 'network', filter={'*VLAN~': '[0-9]+'}, return_fields=['comment', 'network', 'extattrs'], provider=nios_provider, wantlist=True) }}"
 
It should look like this (maybe needs to be urlencoded):

/wapi/v2.12.1/network?_return_fields=comment,network,extattrs&*VLAN~=[0-9]+

 

not using regex (\d+) since it is not supported:

https://docs.infoblox.com/space/nios86/35886899/Supported+Expressions+for+Search+Parameters 

Re: API Search regex for integer extensible attribute

New Member
Posts: 2
2182     2

Just had an similar issue, but I got it to work by using the >= operator

curl -n 'https://<redacted>/wapi/v2.11.5/network?_return_fields%2B=network,extattrs&network_view=default&*VLAN_ID>=0'
Showing results for 
Search instead for 
Did you mean: 

Recommended for You

Businesses are investing heavily into securing company resources from cyber-attacks form cybercrimin