Mercurial > repos > shellac > sam_consensus_v3
comparison env/lib/python3.9/site-packages/bioblend/galaxy/roles/__init__.py @ 0:4f3585e2f14b draft default tip
"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
author | shellac |
---|---|
date | Mon, 22 Mar 2021 18:12:50 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4f3585e2f14b |
---|---|
1 """ | |
2 Contains possible interactions with the Galaxy Roles | |
3 """ | |
4 from bioblend.galaxy.client import Client | |
5 | |
6 | |
7 class RolesClient(Client): | |
8 | |
9 def __init__(self, galaxy_instance): | |
10 self.module = 'roles' | |
11 super().__init__(galaxy_instance) | |
12 | |
13 def get_roles(self): | |
14 """ | |
15 Displays a collection (list) of roles. | |
16 | |
17 :rtype: list | |
18 :return: A list of dicts with details on individual roles. | |
19 For example:: | |
20 | |
21 [{"id": "f2db41e1fa331b3e", | |
22 "model_class": "Role", | |
23 "name": "Foo", | |
24 "url": "/api/roles/f2db41e1fa331b3e"}, | |
25 {"id": "f597429621d6eb2b", | |
26 "model_class": "Role", | |
27 "name": "Bar", | |
28 "url": "/api/roles/f597429621d6eb2b"}] | |
29 """ | |
30 return self._get() | |
31 | |
32 def show_role(self, role_id): | |
33 """ | |
34 Display information on a single role | |
35 | |
36 :type role_id: str | |
37 :param role_id: Encoded role ID | |
38 | |
39 :rtype: dict | |
40 :return: Details of the given role. | |
41 For example:: | |
42 | |
43 {"description": "Private Role for Foo", | |
44 "id": "f2db41e1fa331b3e", | |
45 "model_class": "Role", | |
46 "name": "Foo", | |
47 "type": "private", | |
48 "url": "/api/roles/f2db41e1fa331b3e"} | |
49 """ | |
50 return self._get(id=role_id) | |
51 | |
52 def create_role(self, role_name, description, user_ids=None, group_ids=None): | |
53 """ | |
54 Create a new role. | |
55 | |
56 :type role_name: str | |
57 :param role_name: A name for the new role | |
58 | |
59 :type description: str | |
60 :param description: Description for the new role | |
61 | |
62 :type user_ids: list | |
63 :param user_ids: A list of encoded user IDs to add to the new role | |
64 | |
65 :type group_ids: list | |
66 :param group_ids: A list of encoded group IDs to add to the new role | |
67 | |
68 :rtype: dict | |
69 :return: Details of the newly created role. | |
70 For example:: | |
71 | |
72 {'description': 'desc', | |
73 'url': '/api/roles/ebfb8f50c6abde6d', | |
74 'model_class': 'Role', | |
75 'type': 'admin', | |
76 'id': 'ebfb8f50c6abde6d', | |
77 'name': 'Foo'} | |
78 | |
79 .. versionchanged:: 0.15.0 | |
80 Changed the return value from a 1-element list to a dict. | |
81 """ | |
82 if user_ids is None: | |
83 user_ids = [] | |
84 if group_ids is None: | |
85 group_ids = [] | |
86 payload = { | |
87 'name': role_name, | |
88 'description': description, | |
89 'user_ids': user_ids, | |
90 'group_ids': group_ids | |
91 } | |
92 ret = self._post(payload) | |
93 if isinstance(ret, list): | |
94 # Galaxy release_20.09 and earlier returned a 1-element list | |
95 ret = ret[0] | |
96 return ret |