Skip to content

Commit

Permalink
Merge pull request #47 from koordinates/bp-update-permissions-handling
Browse files Browse the repository at this point in the history
Update permission handling
  • Loading branch information
benpearman authored Apr 7, 2024
2 parents b32e9f1 + 9464dcf commit abe5ab3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
5 changes: 5 additions & 0 deletions docs/source/user/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ Publish a specific version of a Layer::
>>> layer_version = client.layers.get(8888).get_version(9999)
>>> layer_version.publish()

Set the permissions of a Layer::

>>> permissions = [{"permission": "view", "group": "everyone"}, {"permission": "admin", "user": 123}]
>>> layer.permissions.set(permissions)


Authentication
==============
Expand Down
4 changes: 2 additions & 2 deletions koordinates/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ def set(self, permissions):
self._URL_KEY, "PUT", "multi"
)
r = self.client.request("PUT", target_url, json=permissions)
if r.status_code != 201:
if r.status_code != 200:
raise exceptions.ServerError(
"Expected 201 response, got %s: %s" % (r.status_code, target_url)
"Expected 200 response, got %s: %s" % (r.status_code, target_url)
)
return self.list()

Expand Down
6 changes: 3 additions & 3 deletions tests/test_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def test_set_layer_permissions(responses, client, layer):
responses.PUT,
target_url,
body=layer_list_permissions_good_simulated_response,
status=201,
status=200,
)
base_url = client.get_url("LAYER", "GET", "single", {"id": layer.id})
target_url = base_url + client.get_url_path("PERMISSION", "GET", "multi")
Expand Down Expand Up @@ -254,7 +254,7 @@ def test_set_set_permissions(responses, client, set_):
responses.PUT,
target_url,
body=set_list_permissions_good_simulated_response,
status=201,
status=200,
)
base_url = client.get_url("SET", "GET", "single", {"id": set_.id})
target_url = base_url + client.get_url_path("PERMISSION", "GET", "multi")
Expand Down Expand Up @@ -388,7 +388,7 @@ def test_source_set_permissions(responses, client, source):
responses.PUT,
target_url,
body=source_list_permissions_good_simulated_response,
status=201,
status=200,
)
base_url = client.get_url("SOURCE", "GET", "single", {"id": source.id})
target_url = base_url + client.get_url_path("PERMISSION", "GET", "multi")
Expand Down

0 comments on commit abe5ab3

Please sign in to comment.