Reply

API call to remove options

New Member
Posts: 2
6892     0

Hi All-

 

I am able to retrieve network and DHCP range objects as well as DHCP option values using basic API calls and reference values.  So I have a call like this:

 

h t t p s://1.2.2.1/wapi/v1.2/range/ZG5zLmRoY3BfcmFuZ2UkMTAuMTMuMTIuMTAwLzEwLjEzLjEzLjI1MC8vLzAv:10.13.12.100/10.13.13.250/default/?_return_fields%2B=options

 

And I get:

 

{
"_ref": "range/ZG5zLmRoY3BfcmFuZ2UkMTAuMTMuMTIuMTAwLzEwLjEzLjEzLjI1MC8vLzAv:10.13.12.100/10.13.13.250/default",
"comment": "Test Range",
"end_addr": "10.13.13.250",
"network": "10.13.12.0/23",
"network_view": "default",
"options": [
{
"name": "vendor-encapsulated-options",
"num": 43,
"value": "F1:04:01:02:03:05",
"vendor_class": "DHCP"
},
{
"name": "dhcp-lease-time",
"num": 51,
"use_option": false,
"value": "43200",
"vendor_class": "DHCP"
}
],
"start_addr": "10.13.12.100"
}

 

which is great - these are the parts of the range that are different from the netwok. I would like to get rid of the option 43 value. Every time I try to post anything back I seem to delete the entire range, which is not what I want to do. I have tried to put back various null values to no avail - this was just a guess.

 

I just want to get rid of the dhcp option for the range so it reverts back to the inherited value from the network. How can I accomplish this via API?

 

 

Re: API call to remove options

Moderator
Moderator
Posts: 321
6892     0

Update the existing range with a PUT action, and set the options to an empty array, using square brackets with nothing between them.

 

Here's an example with curl, using JSON formatting for the body:

 

curl -k1 -u admin:infoblox -X PUT "https://192.168.1.2/wapi/v2.1/range/ZG5zLmRoY3BfcmFuZ2UkMTAuMTMuMTIuMTAwLzEwLjEzLjEzLjI1MC8vLzAv:10.13.12.100/10.13.13.250/default" -H "Content-Type: application/json"  -d  '{"options": []}'

 

 

 

 

Re: API call to remove options

New Member
Posts: 2
6892     0

Hi-

 

Thanks for your response.  This worked well to remove all of the options.  Is there a way I can remove a single option like option 242 or option 150?

Re: API call to remove options

Moderator
Moderator
Posts: 321
6892     0

When you change the options, you have to send back the full set of desired options.  So you would need to request the array containing the full list of options, then process the array to remove the unwanted option, and then write back the array in a "put" command.

Re: API call to remove options

Authority
Posts: 11
6893     0

Why not have an options+ or options- args, similar to the EA or ipv4addr?

Re: API call to remove options

Adviser
Posts: 181
6893     0

Hi,

 

As of now, "options" does not support +/- like extattrs or ip4addr.

 

Regards,

Krishna Vasudevan

Re: API call to remove options

[ Edited ]
New Member
Posts: 3
6893     0

thanks for the advice

Showing results for 
Search instead for 
Did you mean: 

Recommended for You