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

Added CRUD methods for Groups #95

Merged
merged 17 commits into from
Sep 15, 2016

Conversation

mansimarkaur
Copy link
Member

Fixes #87
Please let me know if anything's wrong.

@@ -58,7 +60,7 @@ def get(self, endpoint, **kwargs):
class Client(object):

def __init__(self, server_url=None, session=None, auth=None,
bucket="default", collection=None, retry=0, retry_after=None):
bucket="default", group=None, collection=None, retry=0, retry_after=None):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not add group there.

@Natim
Copy link
Member

Natim commented Sep 11, 2016

The code looks good to me. You've got some PEP-8 errors to solve: https://travis-ci.org/Kinto/kinto-http.py/jobs/159055428#L406 but appart from that it looks great thanks 👍

endpoint = self.get_endpoint('groups', bucket=bucket)
return self._paginated(endpoint)

def create_group(self, group=None, bucket=None,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if group is left None here?

We could do a POST on the plural endpoint instead of PUT and let the server generate a group name for us.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do you think we should make the server generate a group name? Using random?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you do a POST /buckets/x/groups the server will randomly generate a group id for you.

➜  ~ echo '{"data":{"members":[]}}' | http POST https://kinto.dev.mozaws.net/v1/buckets/x/groups --auth user:pass
HTTP/1.1 201 Created
Access-Control-Expose-Headers: Retry-After, Content-Length, Alert, Backoff
Connection: keep-alive
Content-Length: 172
Content-Type: application/json; charset=UTF-8
Date: Mon, 12 Sep 2016 08:07:15 GMT
Server: nginx

{
    "data": {
        "id": "1xEdx9UY", 
        "last_modified": 1473667635578, 
        "members": []
    }, 
...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing a POST is giving the error message : "Method not allowed for this endpoint". Am I doing something wrong?

@leplatrem
Copy link
Contributor

This is a fantastic contribution so far! The code is clean, it has some tests... it's very cheerful!

Thank you!

We are used to comment inside the code lines, and it can sound a bit rough sometimes. Don't hesitate to ask questions or raise red flags if you think that's not relevant ;)

There are some details to fix, but we're not far from merging ;)

Happy coding!

@Natim
Copy link
Member

Natim commented Sep 13, 2016

It looks good to me, thanks.

Do you mind adding some documentation in the README and updating the CHANGELOG

@@ -7,7 +7,7 @@ This document describes changes between each past release.
6.3.0 (unreleased)
==================

- Nothing changed yet.
- Added CRUD methods for the endpoint group. (#87)
Copy link
Member

@Natim Natim Sep 13, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR ID is #95 rather than #87. I guess both are fine, but because we are in the CHANGELOG, I like to link to the PR where the actual changes were made.

@leplatrem
Copy link
Contributor

Excellent! I guess we can merge!

The issue number in the changelog is a micro nitpick, we don't have strong consistency for this, plus the pull-request will be linked from the issue itself.

@Natim
Copy link
Member

Natim commented Sep 13, 2016

Yes I just wanted to add some documentation about the new features in the README as well and after that we are ready to merge/release 👍

@@ -117,11 +117,29 @@ If no specific bucket name is provided, the "default" bucket is used.
client.update_bucket('payments', permissions={})

# Or delete a bucket and everything under.
client.delete_bucket('payment')
client.delete_bucket('payment',if_exists=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: space missing between: , if_exists

@@ -246,7 +324,7 @@ def test_single_record_can_overwrite(self):
client.create_collection()
created = client.create_record(data={'foo': 'bar'},
permissions={'read': ['alexis']})

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whitespace :(

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed all the extra blank lines now.

@glasserc
Copy link
Contributor

Looks good, thanks!

@glasserc glasserc merged commit f977331 into Kinto:master Sep 15, 2016
@almet almet removed the in progress label Sep 15, 2016
@Natim
Copy link
Member

Natim commented Sep 16, 2016

Great job @mansimarkaur :) Thanks

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.

5 participants