Last active
December 18, 2015 19:29
-
-
Save underscorephil/5833237 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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