Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generator #66

Merged
merged 2 commits into from
Mar 13, 2013
Merged

Generator #66

merged 2 commits into from
Mar 13, 2013

Conversation

sudorandom
Copy link
Contributor

This adds a generator for the API binding. This implements #65

The following bit of code will request all the CCIs 100 at a time until it reaches the end.

cci_iter = client['Account'].getVirtualGuests(iter=True, chunk=100, ...)
for cci in cci_iter:
    print cci['fullyQualifiedDomainName']

This allows for iterating over a set of results in chunks so you don't have to
transfer and then hold the entire dataset in memory.

>>> cci_iter = client['Account'].getVirtualGuests(iter=True, chunk=100, ...)
>>> for cci in cci_iter:
>>>     print cci['fqdn']

Still needs tests.
Example usage below. This will request 10 VMs at a time from the API until 30 total starting after the first 10.
>>> for i, vm in enumerate(c['SoftLayer_Account'].getVirtualGuests(iter=True, chunk=10, limit=30, offset=10)):
>>>     print i, vm['fullyQualifiedDomainName']
CrackerJackMack added a commit that referenced this pull request Mar 13, 2013
This adds a generator for the API binding. Resolves #65
@CrackerJackMack CrackerJackMack merged commit 04869f9 into softlayer:master Mar 13, 2013
@sudorandom sudorandom deleted the generator branch March 15, 2013 23:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants