[PATCHv2 10/10] REST: Allow projects to be retrieved by linkname

2016-05-10 Thread Andy Doan
Building a user-friendly CLI becomes difficult when project-ids are required. It also makes it almost impossible to work with the current format of the .pwclientrc file. Signed-off-by: Andy Doan --- patchwork/tests/test_rest_api.py | 5 + patchwork/views/rest_api.py | 16 ++

[PATCHv2 09/10] REST: Add query parameters to filter patches by

2016-05-10 Thread Andy Doan
This adds generic filtering support to the PatchworkViewSet as well as useful filtering options for listing patches. DRF has some filter capabilities, but they can really slow down the web interface for large data sets and are a little complex. This approach is pretty simple and works efficiently.

[PATCHv2 07/10] REST: Add Patch.mbox_url

2016-05-10 Thread Andy Doan
Provide a URL to the raw patch. This removes previous functionality added to create_model_serializer thats no longer needed. Signed-off-by: Andy Doan --- patchwork/models.py | 4 patchwork/rest_serializers.py| 7 ++- patchwork/tests/test_rest_api.py | 1 + 3 files chang

[PATCHv2 08/10] REST API: make patch.state a string rather than int

2016-05-10 Thread Andy Doan
The int value isn't very useful and the goal is to move this to an enum over time. Signed-off-by: Andy Doan --- patchwork/rest_serializers.py| 21 - patchwork/tests/test_rest_api.py | 8 +--- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/patchwork/r

[PATCHv2 06/10] REST: Add Patch Checks to the API

2016-05-10 Thread Andy Doan
This exports patch checks via the REST API. The drf-nested-routers package is used to handle the fact Checks are nested under a Patch. Security Constraints: * Anyone (logged in or not) can read all objects. * No one can update/delete objects. * Project maintainers and patch owners may create o

[PATCHv2 05/10] REST: Add Patches to the API

2016-05-10 Thread Andy Doan
This exports patches via the REST API. Security Constraints: * Anyone (logged in or not) can read all objects. * No one can create/delete objects. * Project maintainers are allowed to update (ie "patch" attributes) NOTE: Patch.save was overridden incorrectly and had to be fixed to work with

[PATCHv2 03/10] REST: Add Projects to the API

2016-05-10 Thread Andy Doan
This exports projects via the REST API. Security Constraints: * Anyone (logged in or not) can read all objects. * No one can create/delete objects. * Project maintainers are allowed to update (ie "patch" attributes) Signed-off-by: Andy Doan Inspired-by: Damien Lespiau --- patchwork/rest_

[PATCHv2 04/10] REST: Add Persons to the API

2016-05-10 Thread Andy Doan
This exports person objects via the REST API. Security Constraints: * The API is read-only to authenticated users Signed-off-by: Andy Doan --- patchwork/rest_serializers.py| 7 ++- patchwork/tests/test_rest_api.py | 41 patchwork/views/rest_api

[PATCHv2 02/10] REST: Add base configuration hooks for a REST API

2016-05-10 Thread Andy Doan
This adds the ability to expose a REST API based on the Django REST framework project. Since this project isn't packaged in most current distributions, we ensure that its both installed and enabled before trying to use it. Signed-off-by: Andy Doan Inspired-by: Damien Lespiau --- patchwork/setti

[PATCHv2 01/10] docs: Add prototype API specification

2016-05-10 Thread Andy Doan
From: Stephen Finucane Add specification for a REST API. It documents a number of endpoints for the following objects/models: * Projects * People * Patches * Checks The specification is provided in OpenAPI format [1]. This specification can be used to automatically generate REST client librarie

[PATCHv2 00/10] REST API support

2016-05-10 Thread Andy Doan
This patchset is inspired by the work done by Damien Lespiau. It creates a REST API based on the original spec RFC'd by Stephen Finucane. The only thing I know of that's missing from the patch set are bundles. I think over time the Series support will make them less important, but we could always t

Re: [RFC 06/11] REST: Add Patches to the API

2016-05-10 Thread Andy Doan
On 05/09/2016 08:45 AM, Finucane, Stephen wrote: -def create_model_serializer(model_class): >+def create_model_serializer(model_class, read_only=None): > class PatchworkSerializer(ModelSerializer): > class Meta: > model = model_class >+read_only_fields = rea

Re: [RFC 04/11] REST: Introduce some helper code

2016-05-10 Thread Andy Doan
On 05/09/2016 08:27 AM, Finucane, Stephen wrote: On 15 Apr 13:24, Andy Doan wrote: >DRF lends its self to a lot of repetitive code like: > > Serializer: >Meta: > model = Foo > > ViewSet: > queryset = Foo.objects > > >This reduces the amount of boiler plate code needed for most of

Re: [RFC 11/11] REST: Add States to the API

2016-05-10 Thread Andy Doan
On 05/09/2016 09:10 AM, Finucane, Stephen wrote: I'd like to drop the whole customisable states feature in favour of an enum [1]. Unless you've a good reason to include this, can we avoid putting it into the API? I included this because Patch.state is returned as a numeric ID. We need the stri

Re: [RFC 10/11] REST: Allow projects to be retrieved by linkname

2016-05-10 Thread Andy Doan
On 05/09/2016 09:09 AM, Finucane, Stephen wrote: diff --git a/patchwork/views/rest_api.py b/patchwork/views/rest_api.py >index ae86627..e2ec616 100644 >--- a/patchwork/views/rest_api.py >+++ b/patchwork/views/rest_api.py >@@ -127,6 +127,22 @@ class ProjectViewSet(PatchworkViewSet): > permiss

Re: [RFC 03/11] REST: Add Projects to the API

2016-05-10 Thread Andy Doan
On 05/09/2016 08:25 AM, Finucane, Stephen wrote: +++ b/patchwork/tests/test_rest_api.py +def test_list_simple(self): +"""Validate we can list the default test project.""" +defaults.project.save() +resp = self.client.get('/api/1.0/projects/') Q: Do we want to hard

Re: [RFC 00/11] REST API support

2016-05-10 Thread Andy Doan
On 05/09/2016 09:16 AM, Finucane, Stephen wrote: On 15 Apr 13:23, Andy Doan wrote: This patchset is inspired by the work done by Damien Lespiau. It creates a REST API based on the original spec RFC'd by Stephen Finucane. The only thing I know of that's missing from the patch set are bundles. I t

Re: [RFC 09/11] REST: Add query parameters to filter patches by

2016-05-10 Thread Andy Doan
On 05/09/2016 09:06 AM, Finucane, Stephen wrote: On 15 Apr 13:24, Andy Doan wrote: +def test_query_filters(self): +"""Test out our filtering support.""" +patches = create_patches(4) +project = Project.objects.create( +linkname='foo', name='Foo', listid='

Re: [RFC 08/11] REST: Add Patch mbox to the API

2016-05-10 Thread Andy Doan
On 05/09/2016 09:03 AM, Finucane, Stephen wrote: I don't know what the spec says, but I don't think this endpoint is necessary. We already have a way to get diffs and mboxes, so we can just provide links to that in our original 'patch' response. GitHub do something similar with their 'raw_url' pa

Re: [RFC 07/11] REST: Add Patch Checks to the API

2016-05-10 Thread Andy Doan
On 05/09/2016 08:58 AM, Finucane, Stephen wrote: On 15 Apr 13:24, Andy Doan wrote: + +def test_create(self): +"""Ensure creations can be performed by user of patch.""" +check = { +'state': Check.STATE_SUCCESS, I think we should expose the string value here, ra

Re: [RFC 05/11] REST: Add Persons to the API

2016-05-10 Thread Andy Doan
On 05/09/2016 08:39 AM, Finucane, Stephen wrote: +class PeopleViewSet(PatchworkViewSet): >+permission_classes = (AuthenticatedReadOnly,) >+serializer_class = create_model_serializer(Person) >+ >+ As pointed out in the previous patch, this exposes every attribute of the object including s

Re: [RFC 02/11] REST: Add base configuration hooks for a REST API

2016-05-10 Thread Andy Doan
On 05/09/2016 08:15 AM, Finucane, Stephen wrote: On 15 Apr 13:23, Andy Doan wrote: This adds the ability to expose a REST API based on the Django REST framework project. Since this project isn't packaged in most current distributions, we ensure that its both installed and enabled before trying t