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

Implement batch actions. #32

Merged
merged 1 commit into from
Dec 9, 2014
Merged

Implement batch actions. #32

merged 1 commit into from
Dec 9, 2014

Conversation

danielgtaylor
Copy link
Member

This change implements batch actions on collections:

s3.Bucket('boto3').objects.delete()

It does the following:

  • Create a CollectionFactory class to generate subclasses of
    CollectionManager and ResourceCollection.
  • Update the ResourceFactory to use the new CollectionFactory.
  • Add a public pages() method to collections. This returns entire
    pages of resource instances and it used by __iter__ as well.
  • Add batch actions as methods via the new CollectionFactory.
  • Add a BatchAction subclass of Action which does the following:
    1. Get a page of results from the collection's operation
    2. Build parameters for the batch action operation
    3. Call the batch action operation
    4. Repeat until no more pages
  • Makes some previously public members private on Action as these
    should never have been public.
  • Update documentation to include collection classes.
  • Fix a couple minor documentation issues.
  • Add tests to cover the new functionality.

cc @jamesls, @kyleknap

@danielgtaylor danielgtaylor added the enhancement This issue requests an improvement to a current feature. label Nov 26, 2014
@danielgtaylor danielgtaylor self-assigned this Nov 26, 2014
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.0%) when pulling cfa443437b6012d341518a25a321bf79847fc796 on batch-actions into ab3b951 on develop.

@kyleknap
Copy link
Contributor

kyleknap commented Dec 4, 2014

Looks good. 🚢 You may want to add a test that does a Collection.page_size().pages() to ensure that you never run into issues for that case. I would picture a test similar to the test you did for limit()

This change implements batch actions on collections:

```python
s3.Bucket('boto3').objects.delete()
```

It does the following:

* Create a `CollectionFactory` class to generate subclasses of
  `CollectionManager` and `ResourceCollection`.
* Update the `ResourceFactory` to use the new `CollectionFactory`.
* Add a public `pages()` method to collections. This returns entire
  pages of resource instances and it used by `__iter__` as well.
* Add batch actions as methods via the new `CollectionFactory`.
* Add a `BatchAction` subclass of `Action` which does the following:

    1. Get a page of results from the collection's operation
    2. Build parameters for the batch action operation
    3. Call the batch action operation
    4. Repeat until no more pages

* Makes some previously public members private on `Action` as these
  should never have been public.
* Update documentation to include collection classes.
* Add tests to cover the new functionality.
@danielgtaylor
Copy link
Member Author

@kyleknap I've rebased onto the latest develop and added a test to ensure page_size is adhered to when calling .pages().

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.0%) when pulling 30463ab on batch-actions into 8ea77b9 on develop.

@kyleknap
Copy link
Contributor

kyleknap commented Dec 8, 2014

Thanks! 🚢

danielgtaylor added a commit that referenced this pull request Dec 9, 2014
@danielgtaylor danielgtaylor merged commit 75864e6 into develop Dec 9, 2014
@danielgtaylor danielgtaylor deleted the batch-actions branch December 9, 2014 00:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This issue requests an improvement to a current feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants