Reply
Highlighted

REST/WAPI export all hosts in network with EAs

Authority
Posts: 22
7350     0

This exports all hosts in a network..

 

 

curl -k1 -u user:pass -o list.txt -X GET https://1.1.1.1/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?

 

Thanks.

Highlighted

Re: REST/WAPI export all hosts in network with EAs

Community Manager
Community Manager
Posts: 248
7350     0

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.

   E.g:  _return_fields%2B=ip_address,discovered_data,extattrs,conflict_types

 

3) you need to use the '/fileop' method. But you can't export IP addresses via CSV.

Highlighted

Re: REST/WAPI export all hosts in network with EAs

[ Edited ]
Authority
Posts: 22
7350     0

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.

 

Thanks.

 

Re: REST/WAPI export all hosts in network with EAs

Community Manager
Community Manager
Posts: 187
7350     0

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://1.1.1.1/wapi/v1.2/ipv4address' -d 'network=0.0.0.0/24' -d '_return_fields%2b=extattrs'
Highlighted

Re: REST/WAPI export all hosts in network with EAs

Authority
Posts: 22
7351     0

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://1.1.1.1/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://1.1.1.1/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://1.1.1.1/wapi/v2.1/record:host'  -d 'network=0.0.0.0/24' -d _return_fields%2B="extattrs,aliases,comment"

 

Highlighted

Re: REST/WAPI export all hosts in network with EAs

Authority
Posts: 22
7351     0

Ooo... I can search by zone. That may do the trick.

Highlighted

Re: REST/WAPI export all hosts in network with EAs

Community Manager
Community Manager
Posts: 187
7351     0

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://1.1.1.1/wapi/v2.1/record:host'  -d 'ipv4addr=~10.20.30'
Showing results for 
Search instead for 
Did you mean: 

Recommended for You