05-20-2016 02:51 PM
This exports all hosts in a network..
curl -k1 -u user:pass -o list.txt -X GET https://22.214.171.124/wapi/v1.2/ipv4address?network=0.0.0.0/24
1. How do I request (all) EAs be included in output?
2. How do I request only specific fields (only specific regular fields, only specific EAs)?
3. How do I request CSV as output format?
05-21-2016 12:09 PM
1) add '_return_fields+=extattrs.
BUT, there can be multiple objects with the same IP address, and they could have different EAs. So what youi get back isn't very reliable.
2) you can't get back a subset of EAs, for other fields just add them to the _return_fields.
3) you need to use the '/fileop' method. But you can't export IP addresses via CSV.
05-23-2016 01:15 PM - edited 05-24-2016 09:19 AM
Maybe I asked the question with too many specifics or you are assuming more competence using APIs than I have. Ignore any other information I've provided...and hold my hand.
How do I export via WAPI what I see in when I browse to [data management > ipam > (enter subnet to view IPs/hosts/etc)] inclusive of EAs (that are applied to hosts)?
If easier to bulk-export by zone, that may be fine also.
05-24-2016 10:55 AM
The "plus equals extattrs' means "also return all extensible attributes and values". Give this one a try:
curl -k1 -u user:pass -o list.txt -X GET 'https://126.96.36.199/wapi/v1.2/ipv4address' -d 'network=0.0.0.0/24' -d '_return_fields%2b=extattrs'
05-24-2016 04:32 PM
Thanks, that's close.
A few other fields I'm interested in - if I specify them (aliases,comments) it errors out.
This seems to work
1. List ipv4 addresses in the network...
curl -k1 -u user:pass -o list.txt -X GET 'https://188.8.131.52/wapi/v2.1/ipv4address' -d 'network=0.0.0.0/24'
2. Find the record:host objects in that output and do this for each of them...
curl -k1 -u user:pass -o list.txt -X GET 'https://184.108.40.206/wapi/v2.1/record:host/<string>:<fqdn>/Internal' -d _return_fields%2B="extattrs,aliases,comment"
However, I'd like to avoid iterating through individual objects like that (could take a tremendous amount of time for the number of records I ultimately want to use this to fetch).
Thought I might get everything in one get by searching for record:host by network - but that returns an error (can't search for record:host by network it seems)...
curl -k1 -u user:pass -o list.txt -X GET 'https://220.127.116.11/wapi/v2.1/record:host' -d 'network=0.0.0.0/24' -d _return_fields%2B="extattrs,aliases,comment"
05-25-2016 06:36 PM
While you can't search for all hosts within a network, you can use a regular expression to match a network address. For example if the containing network is a Class-C, you could do this:
curl -k1 -u user:pass -o list.txt -X GET 'https://18.104.22.168/wapi/v2.1/record:host' -d 'ipv4addr=~10.20.30'