Mercurial > repos > shellac > sam_consensus_v3
comparison env/lib/python3.9/site-packages/bioblend/galaxy/quotas/__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 Quota | |
3 """ | |
4 from bioblend.galaxy.client import Client | |
5 | |
6 | |
7 class QuotaClient(Client): | |
8 | |
9 def __init__(self, galaxy_instance): | |
10 self.module = 'quotas' | |
11 super().__init__(galaxy_instance) | |
12 | |
13 def get_quotas(self, deleted=False): | |
14 """ | |
15 Get a list of quotas | |
16 | |
17 :type deleted: bool | |
18 :param deleted: Only return quota(s) that have been deleted | |
19 | |
20 :rtype: list | |
21 :return: A list of dicts with details on individual quotas. | |
22 For example:: | |
23 | |
24 [{'id': '0604c8a56abe9a50', | |
25 'model_class': 'Quota', | |
26 'name': 'test ', | |
27 'url': '/api/quotas/0604c8a56abe9a50'}, | |
28 {'id': '1ee267091d0190af', | |
29 'model_class': 'Quota', | |
30 'name': 'workshop', | |
31 'url': '/api/quotas/1ee267091d0190af'}] | |
32 """ | |
33 return self._get(deleted=deleted) | |
34 | |
35 def show_quota(self, quota_id, deleted=False): | |
36 """ | |
37 Display information on a quota | |
38 | |
39 :type quota_id: str | |
40 :param quota_id: Encoded quota ID | |
41 | |
42 :type deleted: bool | |
43 :param deleted: Search for quota in list of ones already marked as deleted | |
44 | |
45 :rtype: dict | |
46 :return: A description of quota. | |
47 For example:: | |
48 | |
49 {'bytes': 107374182400, | |
50 'default': [], | |
51 'description': 'just testing', | |
52 'display_amount': '100.0 GB', | |
53 'groups': [], | |
54 'id': '0604c8a56abe9a50', | |
55 'model_class': 'Quota', | |
56 'name': 'test ', | |
57 'operation': '=', | |
58 'users': []} | |
59 """ | |
60 return self._get(id=quota_id, deleted=deleted) | |
61 | |
62 def create_quota(self, name, description, amount, operation, | |
63 default='no', in_users=None, in_groups=None): | |
64 """ | |
65 Create a new quota | |
66 | |
67 :type name: str | |
68 :param name: Name for the new quota. This must be unique within a Galaxy instance. | |
69 | |
70 :type description: str | |
71 :param description: Quota description | |
72 | |
73 :type amount: str | |
74 :param amount: Quota size (E.g. ``10000MB``, ``99 gb``, ``0.2T``, ``unlimited``) | |
75 | |
76 :type operation: str | |
77 :param operation: One of (``+``, ``-``, ``=``) | |
78 | |
79 :type default: str | |
80 :param default: Whether or not this is a default quota. Valid values | |
81 are ``no``, ``unregistered``, ``registered``. None is | |
82 equivalent to ``no``. | |
83 | |
84 :type in_users: list of str | |
85 :param in_users: A list of user IDs or user emails. | |
86 | |
87 :type in_groups: list of str | |
88 :param in_groups: A list of group IDs or names. | |
89 | |
90 :rtype: dict | |
91 :return: A description of quota. | |
92 For example:: | |
93 | |
94 {'url': '/galaxy/api/quotas/386f14984287a0f7', | |
95 'model_class': 'Quota', | |
96 'message': "Quota 'Testing' has been created with 1 associated users and 0 associated groups.", | |
97 'id': '386f14984287a0f7', | |
98 'name': 'Testing'} | |
99 """ | |
100 payload = { | |
101 'name': name, | |
102 'description': description, | |
103 'amount': amount, | |
104 'operation': operation, | |
105 'default': default | |
106 } | |
107 if in_users: | |
108 payload['in_users'] = in_users | |
109 | |
110 if in_groups: | |
111 payload['in_groups'] = in_groups | |
112 | |
113 return self._post(payload) | |
114 | |
115 def update_quota(self, quota_id, name=None, description=None, amount=None, operation=None, | |
116 default='no', in_users=None, in_groups=None): | |
117 """ | |
118 Update an existing quota | |
119 | |
120 :type quota_id: str | |
121 :param quota_id: Encoded quota ID | |
122 | |
123 :type name: str | |
124 :param name: Name for the new quota. This must be unique within a Galaxy instance. | |
125 | |
126 :type description: str | |
127 :param description: Quota description. If you supply this parameter, | |
128 but not the name, an error will be thrown. | |
129 | |
130 :type amount: str | |
131 :param amount: Quota size (E.g. ``10000MB``, ``99 gb``, ``0.2T``, ``unlimited``) | |
132 | |
133 :type operation: str | |
134 :param operation: One of (``+``, ``-``, ``=``). If you wish to change this | |
135 value, you must also provide the ``amount``, | |
136 otherwise it will not take effect. | |
137 | |
138 :type default: str | |
139 :param default: Whether or not this is a default quota. Valid values | |
140 are ``no``, ``unregistered``, ``registered``. | |
141 Calling this method with ``default="no"`` on a | |
142 non-default quota will throw an error. Not | |
143 passing this parameter is equivalent to passing ``no``. | |
144 | |
145 :type in_users: list of str | |
146 :param in_users: A list of user IDs or user emails. | |
147 | |
148 :type in_groups: list of str | |
149 :param in_groups: A list of group IDs or names. | |
150 | |
151 :rtype: str | |
152 :return: A semicolon separated list of changes to the quota. | |
153 For example:: | |
154 | |
155 "Quota 'Testing-A' has been renamed to 'Testing-B'; Quota 'Testing-e' is now '-100.0 GB'; Quota 'Testing-B' is now the default for unregistered users" | |
156 """ | |
157 payload = { | |
158 'default': default | |
159 } | |
160 if name: | |
161 payload['name'] = name | |
162 | |
163 if description: | |
164 payload['description'] = description | |
165 | |
166 if amount: | |
167 payload['amount'] = amount | |
168 | |
169 if operation: | |
170 payload['operation'] = operation | |
171 | |
172 if in_users: | |
173 payload['in_users'] = in_users | |
174 | |
175 if in_groups: | |
176 payload['in_groups'] = in_groups | |
177 | |
178 return self._put(id=quota_id, payload=payload) | |
179 | |
180 def delete_quota(self, quota_id): | |
181 """ | |
182 Delete a quota | |
183 | |
184 Before a quota can be deleted, the quota must not be a default quota. | |
185 | |
186 :type quota_id: str | |
187 :param quota_id: Encoded quota ID. | |
188 | |
189 :rtype: str | |
190 :return: A description of the changes, mentioning the deleted quota. | |
191 For example:: | |
192 | |
193 "Deleted 1 quotas: Testing-B" | |
194 """ | |
195 return self._delete(id=quota_id) | |
196 | |
197 def undelete_quota(self, quota_id): | |
198 """ | |
199 Undelete a quota | |
200 | |
201 :type quota_id: str | |
202 :param quota_id: Encoded quota ID. | |
203 | |
204 :rtype: str | |
205 :return: A description of the changes, mentioning the undeleted quota. | |
206 For example:: | |
207 | |
208 "Undeleted 1 quotas: Testing-B" | |
209 """ | |
210 url = self._make_url(quota_id, deleted=True) + '/undelete' | |
211 return self._post(url=url, payload={'id': quota_id}) |