Reply
Highlighted

How to PAPI session->search in WAPI?

TKalbas
Techie
Posts: 7
2218     0

Here's an edited excerpt of some working PAPI code that I'm trying to mimic with WAPI in Firefox RESTclient.  The function below is passed the FQDN entered by the user, to confirm it's an actual valid domain in IB.

Bottom line:  How do I do session->search in WAPI with the object being "Infoblox:Smiley Very HappyNS::Zone"???  What can I plug into RESTclient to perform the equivalent function.  Want to understand the WAPI piece before I start to attempt to write any program code.

Thanks.  The code follows below...

# Example valid domains:
#   mydomain.com
#   app.mydomain.com
#   oob.mydomain.com
#   
#   function called with $fqdn = 'bad.mydomain.com' returns False
#   function called with $fqdn = 'app.mydomain.com' returns name
# -------------------------------------------------------------
&FindFQDN;
if ($fqdn eq False) # Check if domain exists in infoblox from FindFQDN results
    {
    $status="Domain Name Not Found";
    &OpError;
    return;
    }


sub FindFQDN

    @ipam_objects = $session->search
        (
        'object'        => 'Infoblox:Smiley Very HappyNS::Zone',
        'name'            => '^'.$fqdn,
        'views'            => "default"
        );
        
    if ($session->status_detail() ne "Operation succeeded")
        {
        $fqdn=False;
        }
    else
        {
        $fqdn=@ipam_objects[0]->name();
        }
# -------------------------------------------------------------

 

Re: How to PAPI session->search in WAPI?

Authority
Posts: 18
2219     0

Hi TKalbas, I'm not sure if this is still relevant, but you can search the WAPI by making sending a GET request, where the URL starts with the type of object you are looking for, and contains the regular expression operator (~=) to match the search string.

 

You can paste the following example in a browser substituting the correct FQDN/IP address for your Grid Master and WAPI version, to find all DNS zones matching "infoblox.com":

 

https://[GridMasterIP]/wapi/v2.0/zone_auth?_return_type=json-pretty&fqdn~=infoblox.com

 

There are more examples of WAPI operations (including searches) in the WAPI documentation section of the Grid Master:

 

https://[GridMasterIP]/wapidoc/additional/sample.html

 

Hope this helps.

Showing results for 
Search instead for 
Do you mean 

Recommended for You