-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
236 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
Permission templates endpoint | ||
============================= | ||
|
||
`Permission templates documentation <https://developers.lokalise.com/reference/list-all-permission-templates>`_ | ||
|
||
Fetch all permission templates | ||
------------------------------ | ||
|
||
.. py:function:: permission_templates(team_id) | ||
:param team_id: ID of the team | ||
:type team_id: str or int | ||
|
||
Example: | ||
|
||
.. code-block:: python | ||
templates = client.permission_templates(12345) | ||
template.id # => 1 | ||
template.role # => "Manager" | ||
template.permissions # => ['branches_main_modify', ...] | ||
template.description # => 'Manage project settings ...' | ||
template.tag # => 'Full access' | ||
template.tagColor # => 'green' | ||
template.tagInfo # => '' | ||
template.doesEnableAllReadOnlyLanguages # => true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
""" | ||
lokalise.collections.permission_templates | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
Module containing permission templates collection. | ||
""" | ||
|
||
from .base_collection import BaseCollection | ||
from ..models.permission_template import PermissionTemplateModel | ||
|
||
|
||
class PermissionTemplatesCollection(BaseCollection): | ||
"""Describes permission templates. | ||
""" | ||
DATA_KEY = "roles" | ||
MODEL_KLASS = PermissionTemplateModel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
""" | ||
lokalise.endpoints.permission_templates_endpoint | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
Module containing permission templates endpoint. | ||
""" | ||
from .base_endpoint import BaseEndpoint | ||
|
||
|
||
class PermissionTemplatesEndpoint(BaseEndpoint): | ||
"""Describes permission templates endpoint. | ||
""" | ||
PATH = "teams/$parent_id/roles" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,4 +22,5 @@ class ContributorModel(BaseModel): | |
"is_reviewer", | ||
"languages", | ||
"admin_rights", | ||
"role_id", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
""" | ||
lokalise.models.permission_template | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
Module containing permission template. | ||
""" | ||
|
||
from .base_model import BaseModel | ||
|
||
|
||
class PermissionTemplateModel(BaseModel): | ||
"""Describes permission template. | ||
""" | ||
|
||
ATTRS = [ | ||
'id', | ||
'role', | ||
'permissions', | ||
'description', | ||
'tag', | ||
'tagColor', | ||
'tagInfo', | ||
'doesEnableAllReadOnlyLanguages', | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
tests/cassettes/permission_templates_test/test_permission_templates.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
interactions: | ||
- request: | ||
body: null | ||
headers: | ||
Accept: | ||
- application/json | ||
Connection: | ||
- keep-alive | ||
User-Agent: | ||
- python-lokalise-api plugin/2.1.1 | ||
x-api-token: | ||
- FILTERED | ||
method: GET | ||
uri: https://api.lokalise.com/api2/teams/176692/roles | ||
response: | ||
body: | ||
string: '{"roles":[{"id":1,"role":"Manager","permissions":["activity","branches_main_modify","branches_create","branches_merge","statistics","tasks","contributors","settings","manage_languages","download","upload","glossary_delete","glossary_edit","manage_keys","screenshots","review","custom_status_modify"],"description":"Manage | ||
project settings, contributors and tasks","tag":"Full access","tagColor":"green","tagInfo":null,"doesEnableAllReadOnlyLanguages":true},{"id":2,"role":"Developer","permissions":["activity","branches_main_modify","branches_create","download","upload","manage_keys","screenshots"],"description":"Create | ||
keys, upload and download content","tag":"Advanced","tagColor":"cyan","tagInfo":null,"doesEnableAllReadOnlyLanguages":true},{"id":3,"role":"Content | ||
creator","permissions":["activity","manage_keys","manage_languages","screenshots","branches_main_modify"],"description":"Create, | ||
translate and edit keys, manage screenshots","tag":"Advanced","tagColor":"cyan","tagInfo":null,"doesEnableAllReadOnlyLanguages":true},{"id":4,"role":"Reviewer","permissions":["branches_main_modify","review","custom_status_modify"],"description":"Translate | ||
keys, control key statuses","tag":"Basic","tagColor":"grey","tagInfo":"All | ||
users, regardless of their assigned roles and permissions, are granted entry-level | ||
access, such as: View glossary, View source content, Collaborate via comments, | ||
Limited access to editor, Generate API tokens","doesEnableAllReadOnlyLanguages":false},{"id":5,"role":"Translator","permissions":["branches_main_modify"],"description":"Translate | ||
keys","tag":"Basic","tagColor":"grey","tagInfo":"All users, regardless of | ||
their assigned roles and permissions, are granted entry-level access, such | ||
as: View glossary, View source content, Collaborate via comments, Limited | ||
access to editor, Generate API tokens","doesEnableAllReadOnlyLanguages":false}]}' | ||
headers: | ||
Cache-Control: | ||
- max-age=-172800, must-revalidate, no-cache, no-store, private | ||
Connection: | ||
- keep-alive | ||
Content-Type: | ||
- application/json | ||
Date: | ||
- Tue, 15 Oct 2024 16:26:21 GMT | ||
Expires: | ||
- Thu, 17 Oct 2024 16:26:21 GMT | ||
Referrer-Policy: | ||
- origin | ||
Server: | ||
- nginx | ||
Set-Cookie: | ||
- PHPSESSID=deleted; expires=Mon, 16-Oct-2023 16:26:20 GMT; Max-Age=0; path=/; | ||
httponly | ||
Strict-Transport-Security: | ||
- max-age=31536000 | ||
Transfer-Encoding: | ||
- chunked | ||
Vary: | ||
- Accept-Encoding | ||
X-Content-Type-Options: | ||
- nosniff | ||
X-Frame-Options: | ||
- deny | ||
X-Lokalise-Process-Id: | ||
- aa5c55d8-3117-40a6-bbba-d781e1ee9dcf | ||
X-Pagination-Limit: | ||
- '5' | ||
X-Pagination-Page: | ||
- '1' | ||
X-Pagination-Page-Count: | ||
- '1' | ||
X-Pagination-Total-Count: | ||
- '5' | ||
X-XSS-Protection: | ||
- 1; mode=block | ||
pragma: | ||
- no-cache | ||
status: | ||
code: 200 | ||
message: OK | ||
version: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
""" | ||
Tests for the PermissionTemplates endpoint. | ||
""" | ||
|
||
import pytest | ||
|
||
|
||
TEAM_ID = 176692 | ||
|
||
|
||
@pytest.mark.vcr | ||
def test_permission_templates(client): | ||
"""Tests fetching of all permission templates | ||
""" | ||
templates = client.permission_templates(TEAM_ID) | ||
|
||
template = templates.items[0] | ||
|
||
assert template.id == 1 | ||
assert template.role == 'Manager' | ||
assert 'branches_main_modify' in template.permissions | ||
assert template.description == 'Manage project settings, contributors and tasks' | ||
assert template.tag == 'Full access' | ||
assert template.tagColor == 'green' | ||
assert template.tagInfo is None | ||
assert template.doesEnableAllReadOnlyLanguages is True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters