Skip to content

Instantly share code, notes, and snippets.

@underscorephil
Last active December 18, 2015 19:29
Show Gist options
  • Save underscorephil/5833237 to your computer and use it in GitHub Desktop.
Save underscorephil/5833237 to your computer and use it in GitHub Desktop.
import SoftLayer
from pprint import pprint as pp
client = SoftLayer.Client(username=apiUsername, api_key=apiKey)
mask = {
'hardware': {
'datacenter': {},
'privateIpAddress': {},
'primaryNetworkComponent': {
'primaryIpAddressRecord': {
'subnet': {}
}
},
'primaryBackendNetworkComponent': {
'primaryIpAddressRecord': {
'subnet': {}
}
}
}
}
# Using the iterator to chunk download all results
hardware = [hardware for hardware in client['Account'].getHardware(
iter=True, chunk=100)]
pp.pprint(hardware)
# Using limit and offset
resultAmount = 100
offset = 0
hardware = []
while True:
result = client['Account'].getHardware(limit=100, offset=offset)
if len(result) < 1:
break
for server in result:
hardware.append(server)
offset += 100
pp.pprint(hardware)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment