>> Important note: This def is designed to for APIs that support limit and offset, but it should work with other GETs too if the size of the first batch of output is less than the limit. <<
The following is a completely standalone Python Def (Definition/Function) that you can use to get data from the NetApp Cloud Insights REST API. It allows you to run a basic get REST API starting from default offset=0 with default batch size of 10000. It could be expanded to support other CI REST API features (like expands) by allowing additional arguments.
The only thing you might need to do (from the command prompt if you're running Windows) - if you've not already done it - is:
python -m pip install requests
The other imports are included with Python as standard (I think.)
You can essentially just copy and paste the whole def into Python CLI and then use it from the CLI (don't need to write and run scripts.)
Examples of usage:
## FIRST CREATE VARIABLES FOR YOUR API KEY AND TENANT ##
apiKey = "YOUR-VERY-LONG-API-KEY"
yourTenant = "https://YOUR-TENANT.cloudinsights.netapp.com"
## GET THE HOSTS ##
api = "/rest/v1/assets/hosts"
hosts = ciGet(yourTenant,apiKey,api)
## GET THE VMs ##
api = "/rest/v1/assets/virtualmachines"
vms = ciGet(yourTenant,apiKey,api)