Reply

The definitive list of REST examples

[ Edited ]
Adviser
Posts: 8
361567     10

A common question we are asked is "Do you have some examples of specific REST calls", or "How can I get started with testing the WAPI?".

 

The API docs are good if you need the techincal details, but this post hopes to address the overall fundamentals.

 

The basics:

  • use GET to get/search
  • use POST to add
  • use PUT to modify
  • use DELETE to remove

If you want to modify an object, you have to use a GET to read it first.

This will give you the _ref, which will be the URL you use to make the update.

 

Get a host:

  GET /wapi/v1.2/record:host?name~=test.com

will return:

  {
  "result": [
    {"_ref": "record:host/ZG5zLmhvc3QkLjEyOC5jb20udGVzdC5nZXJpLnRlc3RfaG9zdA:test_host.test.com/default.GerW",
      "name": "test_host.test.com",}
    ],
  },

To modify a host, you then send a PUT to the _ref url:

 

PUT /wapi/v2.3/record:host/ZG5zLmhvc3QkLl9kZWZhdWx0Lm9yZy5naC5mb28:foo.gh.org/default
Content-Type: application/json

    {"ipv4addrs": [
        {
          "ipv4addr": "1.1.1.2"
        }
      ]}

Note: When making POST or PUT requests, it is easier to send the data as 'application/json' in the body of the message, since it lets you send complex data structures in the payload

 

Note: There is no '_return_fields=ALL' option, so if you need are particular field returned, you will have to add it manually to your call with a '_return_fields+=myfield'

 

 

Now, to the examples:

Search for HOST by name:

 GET /wapi/v1.2/record:host?name~=my.fqdn.org

Search for FixedAddress by MAC

 GET /wapi/v1.2/fixedaddress?_return_fields%2B=mac&mac=aa:bb:cc:11:22:33

Search for any objects with an IP address

 GET /wapi/v1.2/ipv4address?status=USED&ip_address=1.1.1.1

Add a HOST

 POST /wapi/v1.2/record:host
 Content-Type: application/json

    { "name":"wapi.test.org",
      "ipv4addrs":[
          {
             "ipv4addr":"1.1.1.21"
          }
        ]
    }

Delete a host
( you need the _ref to the host first )

 DELETE /wapi/v1.2/record:host/ZG5zLmhvc3QkLl9kZWZhdWx0Lm9yZy5naC53YXBp

Update a host, or change the IP address
( you need the _ref to the host first )

 PUT /record:host/ZG5zLmhvc3QkLl9kZWZhdWx0Lm9yZy5naC53YXBp
 Content-Type: application/json

 { 
    "ipv4addrs":[
          { "ipv4addr":"1.1.1.31" }
     ]
 }

Add or remove IP addresses from a HOST
( without altering the original list )
Use 'ipv4addrs+' or 'ipv4addrs-'

 PUT /record:host/ZG5zLmhvc3QkLl9kZWZhdWx0Lm9yZy5naC53YXBp
 Content-Type: application/json

 { 
    "ipv4addrs+":[
          { "ipv4addr":"2.2.2.22" }
          { "ipv4addr":"4.4.4.24" }
     ]
 }

 PUT /record:host/ZG5zLmhvc3QkLl9kZWZhdWx0Lm9yZy5naC53YXBp
 Content-Type: application/json

 { 
    "ipv4addrs-":[
          { "ipv4addr":"3.3.3.33" }
     ]
 }

Add a HOST with next_available IP address from a network

 POST /wapi/v1.2/record:host
 Content-Type: application/json

    { "name":"wapi.test.org",
      "ipv4addrs":[
          {
             "ipv4addr":"func:nextavailableip:10.1.1.0/24"
          }
        ]
    }

'func:' syntax also supports these forms:

    func:nextavailableip:network/ZG54dfgsrDFEFfsfsLzA:10.0.0.0/8/default
    func:nextavailableip:10.0.0.0/8
    func:nextavailableip:10.0.0.0/8,external
    func:nextavailableip:10.0.0.3-10.0.0.10

OR you can use the longhand form:

 POST /wapi/v1.2/record:host
 Content-Type: application/json

    { "name":"wapi.test.org",
      "ipv4addrs":[
            ipv4addr" : {
                "_function" : 'next_available_ip' ,
                "_object_field" : 'value' ,
                "_object" : '10.10.10.0/24' ,
                "_parameters" : {
                   "num" : 1,
                   "exclude" : [ '45.0.1.1' , '45.0.1.2' ],
                }
            }
        ]
    }

Add a HOST with next_available IP address from a network
using a complex search ( e.g Extensible Attributes ).

You need to pass the search criteria in the _object_parameters field
not also that '_object' changes from a reference to a type

 POST /wapi/v1.2/record:host
 Content-Type: application/json

    { "name":"wapi.test.org",
      "ipv4addrs":[
            ipv4addr" : {
                "_function" : 'next_available_ip' ,
                "_object_field" : 'value' ,
                "_object" : 'network'
                "_object_parameters" : {
                    "*Site" : "Santa Clara"
                },
                "_parameters" : {
                   "num" : 1,
                   "exclude" : [ '45.0.1.1' , '45.0.1.2' ],
                }
            }
        ]
    }

Add a HOST with a fixed address

 POST /wapi/v1.2/record:host
 Content-Type: application/json

    { "name":"wapi.test.org",
      "ipv4addrs":[
          {
             "ipv4addr":"1.1.1.21",
             "mac":"aa:bb:cc:11:22:21"
          }
        ]
    }

Add a Fixed address

 POST /wapi/v1.2/fixedaddress
 Content-Type: application/json

 { 
     "ipv4addr": "1.1.1.21",
     "mac": "aa:bb:cc:11:22:21"
 }

Add a Fixed address Reservtion

 POST /wapi/v1.2/fixedaddress
 Content-Type: application/json

 { 
     "ipv4addr": "1.1.1.21",
     "mac": "00:00:00:00:00:00"
 }

Search for a subnet

 GET /wapi/v1.2/network?network=1.1.1.0/24

Get Next Available address from a subnet
( you need the _ref to the subnet first )

 POST /wapi/v1.2/network/ZG5zLm5ldHdvcmsuMC8yNC83?_function=next_available_ip
 Content-Type: application/json

  {"num": 1}

Get the next 5 IP addresses
( you need the _ref to the subnet first )

 POST /wapi/v1.2/network/ZG5zLm5ldHdvcmsuMC8yNC83?_function=next_available_ip
 Content-Type: application/json

  {"num": 5}


Get all the addresses (and records) in a subnet

  GET /wapi/v1.2/ipv4address?network=1.1.1.0/24

Get all the IP addresses in a given range

  GET /wapi/v1.2/ipv4address?ip_address>=1.1.1.1&ip_address<=1.1.1.10

Search for HOSTS by Extensible Attribute
  ( prepend '*' to the front of the EA name )

  GET /wapi/v1.2/record:host?_return_fields%2B=extattrs&*Floor=3rd

Add extensible Attributes to an object

 PUT /wapi/v1.2/record:host/ZG5zLmhvc....
 Content-Type: application/json

 {  
   "extattrs": {
      "Site": { "value": "East" }
   }
 }

Add a HOST with aliases

 POST /wapi/v1.2/record:host
 Content-Type: application/json

 { "name":"wapialiased.test.org",
   "ipv4addrs":[ { "ipv4addr":"1.1.1.21"} ],
   "aliases": [ "remote","pointer" ]
 }

Get all the aliases on a host

  GET /wapi/v1.2/record:host?_return_fields%2B=aliases&name=wapialiased.test.org

Remove or modify aliases from a host
( send an enpty alias list, or a new list )
( you need the _ref to the host first )

 PUT /wapi/v1.2/record:host/ZG5zLmhvc3l9kZWZhdWx0Lm9yZy5naC53YXBpYWxpYXNlZA
 Content-Type: application/json

 {  
   "aliases": [ ]
 }

Add a CNAME

  POST /wapi/v1.2/record:cname
  Content-Type: application/json

  { 
    "name":"cname.test.org",
    "canonical" : "wapi.test.org"
  }

DELETE a CNAME
( you need the _ref to the cname first )

  DELETE /wapi/v1.2/record:cname/ZG5zLmJpbm...

Move a cname to point to a new canonical
( you need the _ref to the cname first )

  PUT /wapi/v1.2/record:cname/ZG5zLmJpbmRfY
  Content-Type: application/json

  { 
    "canonical" : "wapi-new.test.org"
  }

Add a network or a container
( NIOS will auto create the container if it needs to )

  POST /wapi/v1.2/network
  Content-Type: application/json

  {
     "network": "45.0.45.0/24"
  }

Add a network and assign to a member

  POST /wapi/v1.2/network
  Content-Type: application/json
  {
     "network": "45.0.46.0/24",
     "members": [
        {
           "_struct": "dhcpmember",
           "ipv4addr" : "192.168.1.3"
        }
     ]
  }

Add a DHCP range

  POST /wapi/v1.2/range
  Content-Type: application/json
  {
     "start_addr": "45.0.46.20",
     "end_addr": "45.0.46.101",
     "server_association_type": "MEMBER" ,
     "member": 
        {
           "_struct": "dhcpmember",
           "ipv4addr" : "192.168.1.3"
        }
     
  }

Add a DHCP reserved range
( If you don't assign a member, the range just gets created as 'reserved')

  POST /wapi/v1.2/range
  Content-Type: application/json
  {
     "start_addr": "45.0.46.20",
     "end_addr": "45.0.46.101",
  }

Add a zone association to a network

( 'is_default' is a BOOLEAN, so you don't quote the word 'true' )
    PUT /wapi/v1.2/network/ZG5zLm5l...
    Content-Type: application/json

    {
       "zone_associations": [
            {
               "fqdn": "test.org",
               "is_default" : true
            }
       ]
    }

List the zone_associations on a network

   GET /wapi/v1.2/network/ZG5zLm5l...?_return_fields%2B=zone_associations  

Add a zone, of type forward

'forwarding_servers' are the grid members that will forward for that zone

    POST /wapi/v1.2.1/zone_forward

    {
        "fqdn": "foo.com", 
        "forward_to": [
            {"address": "1.1.1.1", "name": "ns.foo.com"},
            {"address": "1.1.1.2", "name": "ns2.foo.com"}],
        "forwarding_servers": [
            {"name": "infoblox2.localdomain"},
            {"name": "infoblox1.localdomain"}
        ]
    }'

Get grid service status

 GET /wapi/v1.4/grid

 POST /wapi/v1.4/grid/b25lLmNsdXN0ZXIkMA:Infoblox?_function=requestrestartservicestatus
 Content-Type: application/json

  {"service_option": "All|DNS|DHCP"}

Restart services

 GET /wapi/v1.4/grid

 POST /wapi/v1.4/grid/b25lLmNsdXN0ZXIkMA:Infoblox?_function=restartservices
 Content-Type: application/json

    {
        "member_order" : "SIMULTANEOUSLY",
        "service_option": "ALL"
    }

  {"service_option": "All|DNS|DHCP"}

Export a database

 POST /wapi/v1.4/fileop?_function=getgriddata
 Content-Type: application/json

    {"type": "BACKUP"}

 GET /http_direct_file_io/...
 Content-type: application/force-download

  And remember to remove the stored file via the token

 POST /wapi/v1.4/fileop?_function=downloadcomplete
 Content-Type: application/json
    
    {"token": "eJydULFuwyAQ3e9...="}

Export a CSV file

 POST /wapi/v1.5/fileop?_function=csv_export
 Content-Type: application/json

    {"_object": "record:host"}

 You will get back a URL for the download, and a token
 for the download session. you can download the file directly
 from the URL

 GET /http_direct_file_io/...
 Content-type: application/force-download

  And remember to remove the stored file via the token

 POST /wapi/v1.4/fileop?_function=downloadcomplete
 Content-Type: application/json
    
    {"token": "eJydULFuwyAQ3e9...="}

Export the results of a WAPI call 

 and save the data to disk
 (Yes, you can cache results )

 POST /wapi/v1.5/fileop?_function=read
 Content-Type: application/json

    {
     "_encoding"      : "JSON"
     "_filename"      : "allhosts.corp.org.json"
     "_object"        : "record:host"
     "_return_fields" : "name,extattrs"
     "zone"           : "corp.org"
    }

 The file will be in a folder 'wapi_output' in the HTTP file distribution

 

 

Thank you!

Not applicable
Posts: 1
361568     10

Great post, helped a lot more than the documentation!

Thanks!!!

New Member
Posts: 1
361568     10

Very helpfull !! 
but it would be great if properly arrange REST commands are added...

e.g : 
For Associating Domain to a Subnet
curl -k -u admin:infoblox -H "Content-Type: application/json" -X PUT https://130.175.209.15/wapi/v1.2.1/network/ZG5zLm5ldHdvcmskMTMwLjE3MS4wLjAvMTYvMA \-d '{ "zone_associations":[{ "fqdn":"aa.eds.com", "is_default":false, "view":"default" }]}'


 

what if you don't want to use

Adviser
Posts: 8
361568     10

what if you don't want to use curl ?

what if you are using some other client to make the REST calls ?

what if you aren't using a linux shell ?

There is something other than

New Member
Posts: 1
361568     10

There is something other than Linux?

Good insctructions. Could we get bit more?

Not applicable
Posts: 1
361568     10
I have problem with adding allow_transfer. Below are curl which I am using to test. I always get a "Missing struct type in allow_transfer." error. Manual is not very helpful curl -k -u admin:admin -H "Content-Type: application/json" -X POST https://1.1.1.1/wapi/v1.2/zone_auth -d '{ "fqdn":"testdomain.com","view": "default","soa_email":"hostmaster@dummy.com","comment":"comment","set_soa_serial_number":true,"soa_serial_number":1,"copy_xfer_to_notify":true,"use_allow_transfer":true,"allow_transfer":[ { "namedacl":"ACL_AUTH"} ]}' curl -k -u admin:admin -H "Content-Type: application/json" -X POST https://1.1.1.1/wapi/v1.2/zone_auth -d '{ "fqdn":"testidomain.fi","view": "default","soa_email":"hostmaster@dummy.com","comment":"comment","set_soa_serial_number":true,"soa_serial_number":1,"copy_xfer_to_notify":true,"use_allow_transfer":true,"allow_transfer":[{"address":"2.2.2.2","address":"3.3.3.3"}]}' Any tips how to make this work?

examples of using ibapauth cookie vs always sending credentials

Authority
Posts: 10
361568     10

My biggest question about this is whether there is some dead-simple / low overhead request that can be used as a throwaway on the first request to get the ibapauth cookie generated?  I assume there is no way to get the cookie generated without making some sort of request.  There isn't a small, plain file of some sort that could be retrieved like nios_version.txt, is there?

simple request to get a cookie

Adviser
Posts: 7
361568     10
Request the Grid object. That's quick and the return is small.

Adding a fixed address

New Member
Posts: 1
361568     10

Hi,

can someone please give me an example for adding a fixed address with curl?

does using ibapauth to maintain a "session" decrease overhead?

Authority
Posts: 10
361568     10

Have been tempted to test this myself just to get a solid empirical answer, but those who can see inside can probably answer based on how it was designed.

Is there real benefit in decreased overhead if one uses the ibapauth cookie to avoid re-authenticating in a series of requests?

I assume the benefit would be greater if the grid is configured to externally authenticate than if accounts are defined internally to the grid.  Right?

Adviser
Posts: 63
361568     10

How about an example for the RANGE object?

yes, using the cookie saves a

Adviser
Posts: 8
361568     10

yes, using the cookie saves a lot of overhead.

the downside is that because it is an HTTPONLY cookie you can't remove it from the browser. so there is no clean logout.

this has been fixed in WAPI version 1.5 with the '/logout' uri

WAPI Documentation?

Not applicable
Posts: 1
361568     10
I have a few questons: - Where is the WAPI documentation? What are all the types that can be used? - For returning a list in chunks of 50 records at a time, _max_results gives me the 50, but how do I do an offset? This might be a cursor question. - Is there an efficient way to get all the record:host objects in a network? I can get all the used ipv4addrs curl -k -u admin:infoblox -X GET https://infoblox/wapi/v1.4.1/ipv4addrs -d 'network=172.26.3.0/24&status=USED&types=HOST' But all I can see to do at the moment is to retrieve the record/host from the objects data element and then call foreach ref in the return list call curl -k -u admin:infoblox -X GET https://infoblox/wapi/v1.4.1/ Why do I need it? Well the host record contains extattrs and a comment that I need as well.

Adding new IP to existing Host Object

Not applicable
Posts: 1
361568     10

Is there any way to add additional IP to a Host object knowing only the _ref but not knowing the list of existing IP addresses? The below example requires to get all v4 and v6 addresses first as this API call overwrites existing addresses.

Update a host, or change the IP address
( you need the _ref to the host first )

 PUT /record:host/ZG5zLmhvc3QkLl9kZWZhdWx0Lm9yZy5naC53YXBp
 Content-Type: application/json

 { 
    "ipv4addrs":[
          { "ipv4addr":"1.1.1.31" }
     ]
 }

Use ipv4addrs+ to add one or more IP addresses to host record

Adviser
Posts: 33
361568     10

If you have an existing host record and you want to add one or more new IP addresses for that host record, you can do that by using the field name 'ipv4addrs+' when you do the HTTP PUT to modify the host record. This does NOT require you to know what the existing IP addresses are for that host. This functionality is documented for WAPI 1.1 (NIOS 6.7) and later, but actually works in WAPI 1.0 (NIOS 6.6) as well.

Here's a working example in Python (with no error checking, obviously):

import requests
import sys
import json

request_params = {'name': 'host1.example.com'}
r = requests.get('https://gm.example.com/wapi/v1.0/record:host',
                 params=request_params,
                 auth=('admin', 'infoblox'))
host_ref = r.json()[0]['_ref']

request_data = {'ipv4addrs+': [{'ipv4addr': '192.168.201.16'}]}
r = requests.put('https://gm.example.com/wapi/v1.0/' + host_ref,
                  data=json.dumps(request_data),
                  auth=('admin', 'infoblox'))

Note that you can add multiple IP addresses by simply including more items in the list:

request_data = {'ipv4addrs+': [{'ipv4addr': '192.168.201.17'},
                               {'ipv4addr': '192.168.201.18'}]}
r = requests.put('https://gm.example.com/wapi/v1.0/' + host_ref,
                  data=json.dumps(request_data),
                  auth=('admin', 'infoblox'))

Finally, note that you can also use the field name 'ipv4addrs-' to remove one or more IP addresses for that host; for example, the following code would remove all the IP addresses added above:

request_data = {'ipv4addrs-': [{'ipv4addr': '192.168.201.16'},
                               {'ipv4addr': '192.168.201.17'},
                               {'ipv4addr': '192.168.201.18'}]}
r = requests.put('https://gm.example.com/wapi/v1.0/' + host_ref,
                  data=json.dumps(request_data),
                  auth=('admin', 'infoblox'))
Guru
Posts: 26
361568     10

All,

I've made this thread sticky/featured, so it should remain "a-top" the list.  If you haven't read about the upcoming changes to the site, please take a look at this blog:  https://community.infoblox.com/blogs/2015/04/01/it-may-be-april-1-no-joke-big-changes-coming-communi...

As we continue to build out the plan for the updates, we want to hear from you.  Please comment on the blog so we can continue to track requests. I'll keep the community updated on a weekly blog.  "Plan the work, and work the plan..."

Best,

Eric

Top-Level Subnet

New Member
Posts: 3
361568     10
I have a Network that has been further Subnetted which displays a folder over the Network from the GUI. I want to be able to directly Query that Object to return the Networks that have been subnetted from that Sub/Network..so on so forth..Is there a call to the API for that?

Listing all subnets within a given subnet

Adviser
Posts: 33
361568     10

I think what you're asking for is as follows: You have a network container, i.e., a subnet that contains other subnets (and that shows up as a folder icon in the Infoblox IPAM view). You would like a list of all subnets that are contained within that network container. So, for example, if 10.0.0.0/8 is a network container, you would like a list of the subnets into which 10.0.0.0/8 has been divided (e.g., 10.1.0.0/16, 10.2.0.0/16, etc.). Note that it is possible that some of these subnets are actually network containers themselves (for example, 10.1.0.0/16 might be further divided into multiple /24 subnets), while some of the subnets are not further divided (for example, 10.2.0.0/16 might be a "leaf" network containing DHCP ranges, etc.).

In the context of the Web API there are network container objects that contain other networks or network containers, and network objects that do not. In order to find out how a given network container is subnetted using the Web API, you have to retrieve the child networks and network containers via two separate searches that reference the parent network container. For example, the following curl command will return all networks (but *not* network containers) within the network container 10.0.0.0/8 :

curl --tlsv1 --insecure --user 'admin:infoblox' 'https://gm.example.com/wapi/v1.0/network?network_container=10.0.0.0/8'

while the command

curl --tlsv1 --insecure --user 'admin:infoblox' 'https://gm.example.com/wapi/v1.0/networkcontainer?network_container=10.0.0.0/8'

will return all network containers (but *not* networks) within 10.0.0.0/8.

Canonical

New Member
Posts: 3
361568     10
Thanks Frank.. How do I Get/Create/Delete Canonicals..(I know I can list all CNAMEs to get all the Canonicals..but how would one only get a List of these?)

Getting a list of all canonical names

Adviser
Posts: 33
361568     10

By "get a list of these" do you mean getting a list of all canonical names pointed to by CNAME records? Canonical names are not stored as a separate database object in the NIOS database. Rather they are simply values stored in the "canonical" field of record:cname objects. So to extract a list of all canonical names you have to first retrieve the list of all record:cname objects and then iterate through that list, extracting the values of the "canonical" field.

Here's an example of how to do that in Python:

# Import the required Python modules.
import requests
import json
import getpass
import sys

# Set parameters to access the NIOS WAPI.
url = 'https://gm.example.com/wapi/v1.0/'
id = 'api-test'  # Userid with WAPI access
valid_cert = True  # False if GM uses self-signed certificate

# Prompt for the API user password.
pw = getpass.getpass('Password for user ' + id + ': ')

# Retrieve all CNAME records (up to a max of 5000) in the default DNS view.
dns_view = 'default'
max_results = -5000
req_params = {'view': dns_view,
              '_max_results': str(max_results)}
r = requests.get(url + 'record:cname',
                 params=req_params,
                 auth=(id, pw),
                 verify=valid_cert)
if r.status_code != requests.codes.ok:
    print r.text
    exit_msg = 'Error {} finding CNAME records: {}'
    sys.exit(exit_msg.format(r.status_code, r.reason))
results = r.json()

# For each CNAME record keep track of the canonical name pointed
# to by that record, by adding the canonical name to a Python set.
canonicals = set()
for result in results:
    canonicals.add(result['canonical'])

# Sort the resulting set of canonical names and print them.
for canonical in sorted(canonicals):
    print canonical

Recall that a canonical name can be any valid domain name; it does not necessarily have to correspond to a DNS record in your NIOS database. So there is no separate operation to create (or delete) a canonical name; you simply use the canonical name as the value of the "canonical" field when creating a record:cname object.

Change a fixed MAC address

New Member
Posts: 1
361568     10

Hi,

it is possible to change a fixed MAC address?

Does anyone know how?

Where's the beef?

Not applicable
Posts: 3
361568     10

Hey all,

I am for a sample for the equlivant for

Infoblox?_function=restartservices

in 1.7.1

When I try:

https://server/wapi/v1.7.1/Infoblox?_function=restartservices

POST Array
(
    [member_order] => SEQUENTIALLY
    [restart_option] => RESTART_IF_NEEDED
    [service_option] => DNS

)

It returns:

{
  "Error": "AdmConProtoError: Unknown object type (Infoblox)",
  "code": "Client.Ibap.Proto",
  "text": "Unknown object type (Infoblox)"
}

How to restart services with WAPI

Adviser
Posts: 33
361568     10

I was able to use the Web API (WAPI version 2.1) to successfully restart services. Based on my testing I believe the key points are as follows:

  1. You need to do a POST request.
  2. The URL must reference the object reference for the grid (as obtained from a previous GET request).
  3. The function name (i.e., "restartservices") and its arguments (e.g., "member_order") must be passed as parameters as part of the URL.

The following example curl command will return the object reference for the grid:

curl --tlsv1 --insecure --user admin:xxxxxx' 'https://gm.example.com/wapi/v2.1/grid

Assuming that the object reference is "grid/b25lLmNsdXN0ZXIkMA:example-grid", the following example curl command will restart services for DNS:

curl --tlsv1 --insecure --user admin:xxxxxx' -X POST 'https://gm.example.com/wapi/v2.1/grid/b25lLmNsdXN0ZXIkMA:example-grid?_function=restartservices&memb...

How to remove a reserved IP

Not applicable
Posts: 1
361568     10
Thanks so much for all the posts above I have 2 questions 1) Release reserved IP addresses 2) Problem with one POST request 1) I used below POST messages to reserve IP { "name":"host1.test.com", "ipv4addrs":[ { "ipv4addr":"func:nextavailableip:10.0.103.0/24" } ] } or { "ipv4addr":"func:nextavailableip:10.0.42.0/24","mac": "00:00:00:00:00:00"} or for DHCP reservation https://10.11.128.24/wapi/v2.0/range?start_addr=xx.xx.xx.xx&end_addr=yy.yy.yy.yy Now I wanted to release the reserved IP. Also 2)I am facing issue with with POST message below with error as : EXPECTED array input for ipv4addrs etc { "name":"new.test.com" , "ipv4addrs": [ { "ipv4addr":"func:nextavailableip:10.0.103.0/24", "_function": "next_available_ip", "_object_field": "value", "_object": "10.10.10.0/24", "_parameters": { "num": 1, "exclude": ["45.0.1.1", "45.0.1.2"] } } ]} Hoping to listen back. Thanks

Removing a host record

Adviser
Posts: 33
361568     10

1. In this case you are using a host record (record:host object) to reserve an IP address, so you need to remove the host record in order to free up the IP address. This is a two-step process: First you need to get the object reference for the host record, using a GET request against a URL like

https://gm.example.com/wapi/v2.1/record:host?name=host1.test.com

For example, a curl command like the following will do this (assuming that you have only a single DNS view or that the name "host1.test.com" is unique across views):

curl --tlsv1 --insecure -user 'admin:infoblox' 'https://gm.example.com/wapi/v2.1/record:host?name=host1.test.com'

The result of this WAPI operation will include a _ref field with an object reference like the following:

record:host/ZG5zLmhvc3QkLl9kZWZhdWx0LmNvbS5leGFtcGxlLnJlc2VydmVk:host1.test.com/default

You then have to send a DELETE request referencing this object reference, for example as follows:

curl --tlsv1 --insecure --user 'admin:infoblox' -X DELETE 'https://gm.example.com/wapi/v2.1/record:host/ZG5zLmhvc3QkLl9kZWZhdWx0LmNvbS5leGFtcGxlLnJlc2VydmVk:ho...

I'll respond to your second question a little later once I have a chance to look at it more closely.

WAPI 1.7.1 Where's the beef?

Not applicable
Posts: 3
361568     10

Can someone point me to the API documentation for 1.7.1 I can not find it anywhere..

OR... alternatively can someone update The definitive rest examples to include 1.7.1? 

OR.. I am looking to search for a record by it's mac address.

https://HOST/wapi/v1.7.1/search?objtype=All&search_string:=00:01:04:FF:A3:01
https://HOST/wapi/v1.7.1/search?objtype=AllNetwork&search_string:=00:01:04:FF:A3:01
https://HOST/wapi/v1.7.1/search?objtype=record:host_ipv4addr&search_string:=00:01:04:FF:A3:01

None of these work.

Thanks

Paul

 

 

1.7.1 documentation, and using the search object

Adviser
Posts: 33
361568     10

"Can someone point me to the API documentation for 1.7.1" You can find documentation for your release of NIOS under the help section of the UI. Click on the blue tab in the upper right that has a question mark (?) in a circle, and then in the resulting navigation bar click on the plus sign (+) for "Documentation". It should contain links to HTML versions of four manuals, including the WAPI manual.

"I am looking to search for a record by it's mac address." I was able to do this using the following Curl command on my NIOS 7.1 (WAPI 2.1) system:

curl --tlsv1 --insecure --user 'admin:infoblox' 'https://gm.example.com/wapi/v1.7.1/search?search_string:=00:80:77:7d:e1:cb'

(In this case the query returned objects relating to a DHCP fixed address I had defined.)

Corrected example for adding a host using next_available_ip

Adviser
Posts: 33
361568     10

The following shows how to add a host record using the next_available_ip function in current (7.x) versions of NIOS; it corrects one of the examples given in the original "Definitive List of REST Examples" above:

curl --tlsv1 --insecure --user 'admin:infoblox' -H "Content-Type: application/json" -X POST https://gm.example.com/wapi/v2.0/record:host -d '{"name": "test.example.com", "ipv4addrs": [{"ipv4addr": {"_object_function": "next_available_ip", "_object": "network", "_object_parameters": {"network": "10.0.0.0/24"}, "_result_field": "ips", "_parameters": {"num": 1, "exclude": ["10.0.0.4"]}}}]}'

A more readable version of the POST body is as follows:

{
    "name": "test.example.com",
    "ipv4addrs": [
        {
            "ipv4addr": {
                "_object_function": "next_available_ip",
                "_object": "network",
                "_object_parameters": {"network": "10.0.0.0/24"},
                "_result_field": "ips",
                "_parameters": {
                    "num": 1,
                    "exclude": ["10.0.0.4"]
                }
            }
        }
    ]
}

Add Permissions

New Member
Posts: 3
361568     10
When creating a Container/Subnet what params do I use on the Object to Set Permissions on the Container/Network?

infoblox WAPI and .Net integration

Not applicable
Posts: 2
361568     10

Hi All,

 

I have to use the Infoblox WAPI with .Net code in a restful approach.Do we have some examples in .Net ?

Showing results for 
Search instead for 
Did you mean: 

Recommended for You