label-studio-sdk 2.0.6__py3-none-any.whl → 2.0.8__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- label_studio_sdk/__init__.py +32 -2
- label_studio_sdk/base_client.py +4 -0
- label_studio_sdk/converter/exports/yolo.py +89 -74
- label_studio_sdk/core/client_wrapper.py +1 -1
- label_studio_sdk/import_storage/azure_spi/client.py +30 -0
- label_studio_sdk/label_interface/control_tags.py +38 -0
- label_studio_sdk/label_interface/data_examples.json +10 -0
- label_studio_sdk/label_interface/interface.py +13 -0
- label_studio_sdk/label_interface/object_tags.py +9 -0
- label_studio_sdk/ml/client.py +124 -0
- label_studio_sdk/organizations/__init__.py +3 -2
- label_studio_sdk/organizations/client.py +540 -1
- label_studio_sdk/organizations/invites/__init__.py +2 -0
- label_studio_sdk/organizations/invites/client.py +368 -0
- label_studio_sdk/organizations/permissions/__init__.py +2 -0
- label_studio_sdk/organizations/permissions/client.py +1129 -0
- label_studio_sdk/organizations/types/__init__.py +5 -0
- label_studio_sdk/organizations/types/patched_default_role_request_custom_scripts_editable_by.py +7 -0
- label_studio_sdk/project_templates/__init__.py +2 -0
- label_studio_sdk/project_templates/client.py +909 -0
- label_studio_sdk/projects/__init__.py +30 -0
- label_studio_sdk/projects/client.py +355 -0
- label_studio_sdk/projects/stats/__init__.py +28 -0
- label_studio_sdk/projects/stats/client.py +1002 -43
- label_studio_sdk/projects/stats/types/__init__.py +30 -0
- label_studio_sdk/projects/stats/types/stats_agreement_annotator_response.py +26 -0
- label_studio_sdk/projects/stats/types/stats_data_filters_response.py +23 -0
- label_studio_sdk/projects/stats/types/stats_data_filters_response_user_filters.py +34 -0
- label_studio_sdk/projects/stats/types/stats_data_filters_response_user_filters_stats_item.py +22 -0
- label_studio_sdk/projects/stats/types/stats_finished_tasks_response.py +32 -0
- label_studio_sdk/projects/stats/types/stats_lead_time_response.py +23 -0
- label_studio_sdk/projects/stats/types/stats_lead_time_response_lead_time_stats_item.py +37 -0
- label_studio_sdk/projects/stats/types/stats_user_ground_truth_agreement_response.py +20 -0
- label_studio_sdk/projects/stats/types/stats_user_ground_truth_agreement_response_agreement.py +5 -0
- label_studio_sdk/projects/stats/types/stats_user_prediction_agreement_response.py +24 -0
- label_studio_sdk/projects/stats/types/stats_user_prediction_agreement_response_average_prediction_agreement_per_user.py +5 -0
- label_studio_sdk/projects/stats/types/stats_user_review_score_response.py +22 -0
- label_studio_sdk/projects/stats/types/stats_user_review_score_response_performance_score.py +5 -0
- label_studio_sdk/projects/stats/types/stats_user_review_score_response_review_score.py +5 -0
- label_studio_sdk/projects/types/__init__.py +2 -0
- label_studio_sdk/projects/types/projects_import_predictions_response.py +26 -0
- label_studio_sdk/prompts/versions/client.py +4 -16
- label_studio_sdk/types/__init__.py +26 -2
- label_studio_sdk/types/azure_service_principal_import_storage.py +5 -0
- label_studio_sdk/types/azure_service_principal_import_storage_request.py +5 -0
- label_studio_sdk/types/configurable_permission_option.py +25 -0
- label_studio_sdk/types/configurable_permission_option_default.py +7 -0
- label_studio_sdk/types/default_role.py +75 -0
- label_studio_sdk/types/default_role_custom_scripts_editable_by.py +7 -0
- label_studio_sdk/types/lse_organization.py +2 -2
- label_studio_sdk/types/lse_project.py +223 -0
- label_studio_sdk/types/lse_project_counts.py +46 -0
- label_studio_sdk/types/lse_project_sampling.py +7 -0
- label_studio_sdk/types/lse_project_skip_queue.py +7 -0
- label_studio_sdk/types/lse_task.py +1 -1
- label_studio_sdk/types/lse_task_serializer_for_reviewers.py +1 -1
- label_studio_sdk/types/organization_permission.py +31 -0
- label_studio_sdk/types/organization_permission_request.py +24 -0
- label_studio_sdk/types/paginated_lse_project_counts_list.py +23 -0
- label_studio_sdk/types/project_template.py +41 -0
- label_studio_sdk/types/project_template_request.py +38 -0
- label_studio_sdk/types/who_am_i_user.py +1 -0
- {label_studio_sdk-2.0.6.dist-info → label_studio_sdk-2.0.8.dist-info}/METADATA +1 -1
- {label_studio_sdk-2.0.6.dist-info → label_studio_sdk-2.0.8.dist-info}/RECORD +66 -31
- label_studio_sdk/types/default_role_enum.py +0 -5
- {label_studio_sdk-2.0.6.dist-info → label_studio_sdk-2.0.8.dist-info}/LICENSE +0 -0
- {label_studio_sdk-2.0.6.dist-info → label_studio_sdk-2.0.8.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,1129 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
from ...core.client_wrapper import SyncClientWrapper
|
|
5
|
+
from ...core.request_options import RequestOptions
|
|
6
|
+
from ...types.organization_permission import OrganizationPermission
|
|
7
|
+
from ...core.jsonable_encoder import jsonable_encoder
|
|
8
|
+
from ...core.unchecked_base_model import construct_type
|
|
9
|
+
from json.decoder import JSONDecodeError
|
|
10
|
+
from ...core.api_error import ApiError
|
|
11
|
+
from ...types.role9e7enum import Role9E7Enum
|
|
12
|
+
from ...errors.bad_request_error import BadRequestError
|
|
13
|
+
from ...errors.forbidden_error import ForbiddenError
|
|
14
|
+
from ...types.configurable_permission_option import ConfigurablePermissionOption
|
|
15
|
+
from ...errors.not_found_error import NotFoundError
|
|
16
|
+
from ...core.client_wrapper import AsyncClientWrapper
|
|
17
|
+
|
|
18
|
+
# this is used as the default value for optional parameters
|
|
19
|
+
OMIT = typing.cast(typing.Any, ...)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class PermissionsClient:
|
|
23
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
24
|
+
self._client_wrapper = client_wrapper
|
|
25
|
+
|
|
26
|
+
def list(
|
|
27
|
+
self, id: int, *, ordering: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None
|
|
28
|
+
) -> typing.List[OrganizationPermission]:
|
|
29
|
+
"""
|
|
30
|
+
List all organization-level permission overrides for a given organization.
|
|
31
|
+
|
|
32
|
+
Parameters
|
|
33
|
+
----------
|
|
34
|
+
id : int
|
|
35
|
+
|
|
36
|
+
ordering : typing.Optional[str]
|
|
37
|
+
Which field to use when ordering the results.
|
|
38
|
+
|
|
39
|
+
request_options : typing.Optional[RequestOptions]
|
|
40
|
+
Request-specific configuration.
|
|
41
|
+
|
|
42
|
+
Returns
|
|
43
|
+
-------
|
|
44
|
+
typing.List[OrganizationPermission]
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
Examples
|
|
48
|
+
--------
|
|
49
|
+
from label_studio_sdk import LabelStudio
|
|
50
|
+
|
|
51
|
+
client = LabelStudio(
|
|
52
|
+
api_key="YOUR_API_KEY",
|
|
53
|
+
)
|
|
54
|
+
client.organizations.permissions.list(
|
|
55
|
+
id=1,
|
|
56
|
+
)
|
|
57
|
+
"""
|
|
58
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
59
|
+
f"api/organizations/{jsonable_encoder(id)}/permissions",
|
|
60
|
+
method="GET",
|
|
61
|
+
params={
|
|
62
|
+
"ordering": ordering,
|
|
63
|
+
},
|
|
64
|
+
request_options=request_options,
|
|
65
|
+
)
|
|
66
|
+
try:
|
|
67
|
+
if 200 <= _response.status_code < 300:
|
|
68
|
+
return typing.cast(
|
|
69
|
+
typing.List[OrganizationPermission],
|
|
70
|
+
construct_type(
|
|
71
|
+
type_=typing.List[OrganizationPermission], # type: ignore
|
|
72
|
+
object_=_response.json(),
|
|
73
|
+
),
|
|
74
|
+
)
|
|
75
|
+
_response_json = _response.json()
|
|
76
|
+
except JSONDecodeError:
|
|
77
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
78
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
79
|
+
|
|
80
|
+
def create(
|
|
81
|
+
self,
|
|
82
|
+
id: int,
|
|
83
|
+
*,
|
|
84
|
+
permission: str,
|
|
85
|
+
roles: typing.Optional[typing.Sequence[Role9E7Enum]] = OMIT,
|
|
86
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
87
|
+
) -> OrganizationPermission:
|
|
88
|
+
"""
|
|
89
|
+
Create a new organization-level permission override for a given organization.
|
|
90
|
+
|
|
91
|
+
Parameters
|
|
92
|
+
----------
|
|
93
|
+
id : int
|
|
94
|
+
|
|
95
|
+
permission : str
|
|
96
|
+
|
|
97
|
+
roles : typing.Optional[typing.Sequence[Role9E7Enum]]
|
|
98
|
+
Explicit roles that have this permission within the organization.
|
|
99
|
+
|
|
100
|
+
request_options : typing.Optional[RequestOptions]
|
|
101
|
+
Request-specific configuration.
|
|
102
|
+
|
|
103
|
+
Returns
|
|
104
|
+
-------
|
|
105
|
+
OrganizationPermission
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
Examples
|
|
109
|
+
--------
|
|
110
|
+
from label_studio_sdk import LabelStudio
|
|
111
|
+
|
|
112
|
+
client = LabelStudio(
|
|
113
|
+
api_key="YOUR_API_KEY",
|
|
114
|
+
)
|
|
115
|
+
client.organizations.permissions.create(
|
|
116
|
+
id=1,
|
|
117
|
+
permission="permission",
|
|
118
|
+
)
|
|
119
|
+
"""
|
|
120
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
121
|
+
f"api/organizations/{jsonable_encoder(id)}/permissions",
|
|
122
|
+
method="POST",
|
|
123
|
+
json={
|
|
124
|
+
"permission": permission,
|
|
125
|
+
"roles": roles,
|
|
126
|
+
},
|
|
127
|
+
request_options=request_options,
|
|
128
|
+
omit=OMIT,
|
|
129
|
+
)
|
|
130
|
+
try:
|
|
131
|
+
if 200 <= _response.status_code < 300:
|
|
132
|
+
return typing.cast(
|
|
133
|
+
OrganizationPermission,
|
|
134
|
+
construct_type(
|
|
135
|
+
type_=OrganizationPermission, # type: ignore
|
|
136
|
+
object_=_response.json(),
|
|
137
|
+
),
|
|
138
|
+
)
|
|
139
|
+
if _response.status_code == 400:
|
|
140
|
+
raise BadRequestError(
|
|
141
|
+
typing.cast(
|
|
142
|
+
typing.Optional[typing.Any],
|
|
143
|
+
construct_type(
|
|
144
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
145
|
+
object_=_response.json(),
|
|
146
|
+
),
|
|
147
|
+
)
|
|
148
|
+
)
|
|
149
|
+
if _response.status_code == 403:
|
|
150
|
+
raise ForbiddenError(
|
|
151
|
+
typing.cast(
|
|
152
|
+
typing.Optional[typing.Any],
|
|
153
|
+
construct_type(
|
|
154
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
155
|
+
object_=_response.json(),
|
|
156
|
+
),
|
|
157
|
+
)
|
|
158
|
+
)
|
|
159
|
+
_response_json = _response.json()
|
|
160
|
+
except JSONDecodeError:
|
|
161
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
162
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
163
|
+
|
|
164
|
+
def get_options(
|
|
165
|
+
self, id: int, *, ordering: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None
|
|
166
|
+
) -> typing.List[ConfigurablePermissionOption]:
|
|
167
|
+
"""
|
|
168
|
+
Retrieve the list of configurable permission options (label, tooltip, default role and allowed roles).
|
|
169
|
+
|
|
170
|
+
Parameters
|
|
171
|
+
----------
|
|
172
|
+
id : int
|
|
173
|
+
|
|
174
|
+
ordering : typing.Optional[str]
|
|
175
|
+
Which field to use when ordering the results.
|
|
176
|
+
|
|
177
|
+
request_options : typing.Optional[RequestOptions]
|
|
178
|
+
Request-specific configuration.
|
|
179
|
+
|
|
180
|
+
Returns
|
|
181
|
+
-------
|
|
182
|
+
typing.List[ConfigurablePermissionOption]
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
Examples
|
|
186
|
+
--------
|
|
187
|
+
from label_studio_sdk import LabelStudio
|
|
188
|
+
|
|
189
|
+
client = LabelStudio(
|
|
190
|
+
api_key="YOUR_API_KEY",
|
|
191
|
+
)
|
|
192
|
+
client.organizations.permissions.get_options(
|
|
193
|
+
id=1,
|
|
194
|
+
)
|
|
195
|
+
"""
|
|
196
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
197
|
+
f"api/organizations/{jsonable_encoder(id)}/permissions/options",
|
|
198
|
+
method="GET",
|
|
199
|
+
params={
|
|
200
|
+
"ordering": ordering,
|
|
201
|
+
},
|
|
202
|
+
request_options=request_options,
|
|
203
|
+
)
|
|
204
|
+
try:
|
|
205
|
+
if 200 <= _response.status_code < 300:
|
|
206
|
+
return typing.cast(
|
|
207
|
+
typing.List[ConfigurablePermissionOption],
|
|
208
|
+
construct_type(
|
|
209
|
+
type_=typing.List[ConfigurablePermissionOption], # type: ignore
|
|
210
|
+
object_=_response.json(),
|
|
211
|
+
),
|
|
212
|
+
)
|
|
213
|
+
_response_json = _response.json()
|
|
214
|
+
except JSONDecodeError:
|
|
215
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
216
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
217
|
+
|
|
218
|
+
def get(
|
|
219
|
+
self, id: int, permission: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
220
|
+
) -> OrganizationPermission:
|
|
221
|
+
"""
|
|
222
|
+
Parameters
|
|
223
|
+
----------
|
|
224
|
+
id : int
|
|
225
|
+
|
|
226
|
+
permission : str
|
|
227
|
+
|
|
228
|
+
request_options : typing.Optional[RequestOptions]
|
|
229
|
+
Request-specific configuration.
|
|
230
|
+
|
|
231
|
+
Returns
|
|
232
|
+
-------
|
|
233
|
+
OrganizationPermission
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
Examples
|
|
237
|
+
--------
|
|
238
|
+
from label_studio_sdk import LabelStudio
|
|
239
|
+
|
|
240
|
+
client = LabelStudio(
|
|
241
|
+
api_key="YOUR_API_KEY",
|
|
242
|
+
)
|
|
243
|
+
client.organizations.permissions.get(
|
|
244
|
+
id=1,
|
|
245
|
+
permission="permission",
|
|
246
|
+
)
|
|
247
|
+
"""
|
|
248
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
249
|
+
f"api/organizations/{jsonable_encoder(id)}/permissions/{jsonable_encoder(permission)}",
|
|
250
|
+
method="GET",
|
|
251
|
+
request_options=request_options,
|
|
252
|
+
)
|
|
253
|
+
try:
|
|
254
|
+
if 200 <= _response.status_code < 300:
|
|
255
|
+
return typing.cast(
|
|
256
|
+
OrganizationPermission,
|
|
257
|
+
construct_type(
|
|
258
|
+
type_=OrganizationPermission, # type: ignore
|
|
259
|
+
object_=_response.json(),
|
|
260
|
+
),
|
|
261
|
+
)
|
|
262
|
+
if _response.status_code == 403:
|
|
263
|
+
raise ForbiddenError(
|
|
264
|
+
typing.cast(
|
|
265
|
+
typing.Optional[typing.Any],
|
|
266
|
+
construct_type(
|
|
267
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
268
|
+
object_=_response.json(),
|
|
269
|
+
),
|
|
270
|
+
)
|
|
271
|
+
)
|
|
272
|
+
if _response.status_code == 404:
|
|
273
|
+
raise NotFoundError(
|
|
274
|
+
typing.cast(
|
|
275
|
+
typing.Optional[typing.Any],
|
|
276
|
+
construct_type(
|
|
277
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
278
|
+
object_=_response.json(),
|
|
279
|
+
),
|
|
280
|
+
)
|
|
281
|
+
)
|
|
282
|
+
_response_json = _response.json()
|
|
283
|
+
except JSONDecodeError:
|
|
284
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
285
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
286
|
+
|
|
287
|
+
def replace(
|
|
288
|
+
self,
|
|
289
|
+
id: int,
|
|
290
|
+
permission_: str,
|
|
291
|
+
*,
|
|
292
|
+
permission: str,
|
|
293
|
+
roles: typing.Optional[typing.Sequence[Role9E7Enum]] = OMIT,
|
|
294
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
295
|
+
) -> OrganizationPermission:
|
|
296
|
+
"""
|
|
297
|
+
Replace the organization-level permission override for a given permission key.
|
|
298
|
+
|
|
299
|
+
Parameters
|
|
300
|
+
----------
|
|
301
|
+
id : int
|
|
302
|
+
A unique integer value identifying this organization.
|
|
303
|
+
|
|
304
|
+
permission_ : str
|
|
305
|
+
Permission key to update within the organization.
|
|
306
|
+
|
|
307
|
+
permission : str
|
|
308
|
+
|
|
309
|
+
roles : typing.Optional[typing.Sequence[Role9E7Enum]]
|
|
310
|
+
Explicit roles that have this permission within the organization.
|
|
311
|
+
|
|
312
|
+
request_options : typing.Optional[RequestOptions]
|
|
313
|
+
Request-specific configuration.
|
|
314
|
+
|
|
315
|
+
Returns
|
|
316
|
+
-------
|
|
317
|
+
OrganizationPermission
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
Examples
|
|
321
|
+
--------
|
|
322
|
+
from label_studio_sdk import LabelStudio
|
|
323
|
+
|
|
324
|
+
client = LabelStudio(
|
|
325
|
+
api_key="YOUR_API_KEY",
|
|
326
|
+
)
|
|
327
|
+
client.organizations.permissions.replace(
|
|
328
|
+
id=1,
|
|
329
|
+
permission_="permission",
|
|
330
|
+
permission="permission",
|
|
331
|
+
)
|
|
332
|
+
"""
|
|
333
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
334
|
+
f"api/organizations/{jsonable_encoder(id)}/permissions/{jsonable_encoder(permission_)}",
|
|
335
|
+
method="PUT",
|
|
336
|
+
json={
|
|
337
|
+
"permission": permission,
|
|
338
|
+
"roles": roles,
|
|
339
|
+
},
|
|
340
|
+
request_options=request_options,
|
|
341
|
+
omit=OMIT,
|
|
342
|
+
)
|
|
343
|
+
try:
|
|
344
|
+
if 200 <= _response.status_code < 300:
|
|
345
|
+
return typing.cast(
|
|
346
|
+
OrganizationPermission,
|
|
347
|
+
construct_type(
|
|
348
|
+
type_=OrganizationPermission, # type: ignore
|
|
349
|
+
object_=_response.json(),
|
|
350
|
+
),
|
|
351
|
+
)
|
|
352
|
+
if _response.status_code == 400:
|
|
353
|
+
raise BadRequestError(
|
|
354
|
+
typing.cast(
|
|
355
|
+
typing.Optional[typing.Any],
|
|
356
|
+
construct_type(
|
|
357
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
358
|
+
object_=_response.json(),
|
|
359
|
+
),
|
|
360
|
+
)
|
|
361
|
+
)
|
|
362
|
+
if _response.status_code == 403:
|
|
363
|
+
raise ForbiddenError(
|
|
364
|
+
typing.cast(
|
|
365
|
+
typing.Optional[typing.Any],
|
|
366
|
+
construct_type(
|
|
367
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
368
|
+
object_=_response.json(),
|
|
369
|
+
),
|
|
370
|
+
)
|
|
371
|
+
)
|
|
372
|
+
if _response.status_code == 404:
|
|
373
|
+
raise NotFoundError(
|
|
374
|
+
typing.cast(
|
|
375
|
+
typing.Optional[typing.Any],
|
|
376
|
+
construct_type(
|
|
377
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
378
|
+
object_=_response.json(),
|
|
379
|
+
),
|
|
380
|
+
)
|
|
381
|
+
)
|
|
382
|
+
_response_json = _response.json()
|
|
383
|
+
except JSONDecodeError:
|
|
384
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
385
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
386
|
+
|
|
387
|
+
def delete(self, id: int, permission: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
|
|
388
|
+
"""
|
|
389
|
+
Parameters
|
|
390
|
+
----------
|
|
391
|
+
id : int
|
|
392
|
+
|
|
393
|
+
permission : str
|
|
394
|
+
|
|
395
|
+
request_options : typing.Optional[RequestOptions]
|
|
396
|
+
Request-specific configuration.
|
|
397
|
+
|
|
398
|
+
Returns
|
|
399
|
+
-------
|
|
400
|
+
None
|
|
401
|
+
|
|
402
|
+
Examples
|
|
403
|
+
--------
|
|
404
|
+
from label_studio_sdk import LabelStudio
|
|
405
|
+
|
|
406
|
+
client = LabelStudio(
|
|
407
|
+
api_key="YOUR_API_KEY",
|
|
408
|
+
)
|
|
409
|
+
client.organizations.permissions.delete(
|
|
410
|
+
id=1,
|
|
411
|
+
permission="permission",
|
|
412
|
+
)
|
|
413
|
+
"""
|
|
414
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
415
|
+
f"api/organizations/{jsonable_encoder(id)}/permissions/{jsonable_encoder(permission)}",
|
|
416
|
+
method="DELETE",
|
|
417
|
+
request_options=request_options,
|
|
418
|
+
)
|
|
419
|
+
try:
|
|
420
|
+
if 200 <= _response.status_code < 300:
|
|
421
|
+
return
|
|
422
|
+
if _response.status_code == 403:
|
|
423
|
+
raise ForbiddenError(
|
|
424
|
+
typing.cast(
|
|
425
|
+
typing.Optional[typing.Any],
|
|
426
|
+
construct_type(
|
|
427
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
428
|
+
object_=_response.json(),
|
|
429
|
+
),
|
|
430
|
+
)
|
|
431
|
+
)
|
|
432
|
+
if _response.status_code == 404:
|
|
433
|
+
raise NotFoundError(
|
|
434
|
+
typing.cast(
|
|
435
|
+
typing.Optional[typing.Any],
|
|
436
|
+
construct_type(
|
|
437
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
438
|
+
object_=_response.json(),
|
|
439
|
+
),
|
|
440
|
+
)
|
|
441
|
+
)
|
|
442
|
+
_response_json = _response.json()
|
|
443
|
+
except JSONDecodeError:
|
|
444
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
445
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
446
|
+
|
|
447
|
+
def update(
|
|
448
|
+
self,
|
|
449
|
+
id: int,
|
|
450
|
+
permission: str,
|
|
451
|
+
*,
|
|
452
|
+
patched_organization_permission_request_permission: typing.Optional[str] = OMIT,
|
|
453
|
+
roles: typing.Optional[typing.Sequence[Role9E7Enum]] = OMIT,
|
|
454
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
455
|
+
) -> OrganizationPermission:
|
|
456
|
+
"""
|
|
457
|
+
Partially update the organization-level permission override for a given permission key.
|
|
458
|
+
|
|
459
|
+
Parameters
|
|
460
|
+
----------
|
|
461
|
+
id : int
|
|
462
|
+
|
|
463
|
+
permission : str
|
|
464
|
+
|
|
465
|
+
patched_organization_permission_request_permission : typing.Optional[str]
|
|
466
|
+
|
|
467
|
+
roles : typing.Optional[typing.Sequence[Role9E7Enum]]
|
|
468
|
+
Explicit roles that have this permission within the organization.
|
|
469
|
+
|
|
470
|
+
request_options : typing.Optional[RequestOptions]
|
|
471
|
+
Request-specific configuration.
|
|
472
|
+
|
|
473
|
+
Returns
|
|
474
|
+
-------
|
|
475
|
+
OrganizationPermission
|
|
476
|
+
|
|
477
|
+
|
|
478
|
+
Examples
|
|
479
|
+
--------
|
|
480
|
+
from label_studio_sdk import LabelStudio
|
|
481
|
+
|
|
482
|
+
client = LabelStudio(
|
|
483
|
+
api_key="YOUR_API_KEY",
|
|
484
|
+
)
|
|
485
|
+
client.organizations.permissions.update(
|
|
486
|
+
id=1,
|
|
487
|
+
permission="permission",
|
|
488
|
+
)
|
|
489
|
+
"""
|
|
490
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
491
|
+
f"api/organizations/{jsonable_encoder(id)}/permissions/{jsonable_encoder(permission)}",
|
|
492
|
+
method="PATCH",
|
|
493
|
+
json={
|
|
494
|
+
"permission": patched_organization_permission_request_permission,
|
|
495
|
+
"roles": roles,
|
|
496
|
+
},
|
|
497
|
+
headers={
|
|
498
|
+
"content-type": "application/json",
|
|
499
|
+
},
|
|
500
|
+
request_options=request_options,
|
|
501
|
+
omit=OMIT,
|
|
502
|
+
)
|
|
503
|
+
try:
|
|
504
|
+
if 200 <= _response.status_code < 300:
|
|
505
|
+
return typing.cast(
|
|
506
|
+
OrganizationPermission,
|
|
507
|
+
construct_type(
|
|
508
|
+
type_=OrganizationPermission, # type: ignore
|
|
509
|
+
object_=_response.json(),
|
|
510
|
+
),
|
|
511
|
+
)
|
|
512
|
+
if _response.status_code == 400:
|
|
513
|
+
raise BadRequestError(
|
|
514
|
+
typing.cast(
|
|
515
|
+
typing.Optional[typing.Any],
|
|
516
|
+
construct_type(
|
|
517
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
518
|
+
object_=_response.json(),
|
|
519
|
+
),
|
|
520
|
+
)
|
|
521
|
+
)
|
|
522
|
+
if _response.status_code == 403:
|
|
523
|
+
raise ForbiddenError(
|
|
524
|
+
typing.cast(
|
|
525
|
+
typing.Optional[typing.Any],
|
|
526
|
+
construct_type(
|
|
527
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
528
|
+
object_=_response.json(),
|
|
529
|
+
),
|
|
530
|
+
)
|
|
531
|
+
)
|
|
532
|
+
if _response.status_code == 404:
|
|
533
|
+
raise NotFoundError(
|
|
534
|
+
typing.cast(
|
|
535
|
+
typing.Optional[typing.Any],
|
|
536
|
+
construct_type(
|
|
537
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
538
|
+
object_=_response.json(),
|
|
539
|
+
),
|
|
540
|
+
)
|
|
541
|
+
)
|
|
542
|
+
_response_json = _response.json()
|
|
543
|
+
except JSONDecodeError:
|
|
544
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
545
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
546
|
+
|
|
547
|
+
|
|
548
|
+
class AsyncPermissionsClient:
|
|
549
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
550
|
+
self._client_wrapper = client_wrapper
|
|
551
|
+
|
|
552
|
+
async def list(
|
|
553
|
+
self, id: int, *, ordering: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None
|
|
554
|
+
) -> typing.List[OrganizationPermission]:
|
|
555
|
+
"""
|
|
556
|
+
List all organization-level permission overrides for a given organization.
|
|
557
|
+
|
|
558
|
+
Parameters
|
|
559
|
+
----------
|
|
560
|
+
id : int
|
|
561
|
+
|
|
562
|
+
ordering : typing.Optional[str]
|
|
563
|
+
Which field to use when ordering the results.
|
|
564
|
+
|
|
565
|
+
request_options : typing.Optional[RequestOptions]
|
|
566
|
+
Request-specific configuration.
|
|
567
|
+
|
|
568
|
+
Returns
|
|
569
|
+
-------
|
|
570
|
+
typing.List[OrganizationPermission]
|
|
571
|
+
|
|
572
|
+
|
|
573
|
+
Examples
|
|
574
|
+
--------
|
|
575
|
+
import asyncio
|
|
576
|
+
|
|
577
|
+
from label_studio_sdk import AsyncLabelStudio
|
|
578
|
+
|
|
579
|
+
client = AsyncLabelStudio(
|
|
580
|
+
api_key="YOUR_API_KEY",
|
|
581
|
+
)
|
|
582
|
+
|
|
583
|
+
|
|
584
|
+
async def main() -> None:
|
|
585
|
+
await client.organizations.permissions.list(
|
|
586
|
+
id=1,
|
|
587
|
+
)
|
|
588
|
+
|
|
589
|
+
|
|
590
|
+
asyncio.run(main())
|
|
591
|
+
"""
|
|
592
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
593
|
+
f"api/organizations/{jsonable_encoder(id)}/permissions",
|
|
594
|
+
method="GET",
|
|
595
|
+
params={
|
|
596
|
+
"ordering": ordering,
|
|
597
|
+
},
|
|
598
|
+
request_options=request_options,
|
|
599
|
+
)
|
|
600
|
+
try:
|
|
601
|
+
if 200 <= _response.status_code < 300:
|
|
602
|
+
return typing.cast(
|
|
603
|
+
typing.List[OrganizationPermission],
|
|
604
|
+
construct_type(
|
|
605
|
+
type_=typing.List[OrganizationPermission], # type: ignore
|
|
606
|
+
object_=_response.json(),
|
|
607
|
+
),
|
|
608
|
+
)
|
|
609
|
+
_response_json = _response.json()
|
|
610
|
+
except JSONDecodeError:
|
|
611
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
612
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
613
|
+
|
|
614
|
+
async def create(
|
|
615
|
+
self,
|
|
616
|
+
id: int,
|
|
617
|
+
*,
|
|
618
|
+
permission: str,
|
|
619
|
+
roles: typing.Optional[typing.Sequence[Role9E7Enum]] = OMIT,
|
|
620
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
621
|
+
) -> OrganizationPermission:
|
|
622
|
+
"""
|
|
623
|
+
Create a new organization-level permission override for a given organization.
|
|
624
|
+
|
|
625
|
+
Parameters
|
|
626
|
+
----------
|
|
627
|
+
id : int
|
|
628
|
+
|
|
629
|
+
permission : str
|
|
630
|
+
|
|
631
|
+
roles : typing.Optional[typing.Sequence[Role9E7Enum]]
|
|
632
|
+
Explicit roles that have this permission within the organization.
|
|
633
|
+
|
|
634
|
+
request_options : typing.Optional[RequestOptions]
|
|
635
|
+
Request-specific configuration.
|
|
636
|
+
|
|
637
|
+
Returns
|
|
638
|
+
-------
|
|
639
|
+
OrganizationPermission
|
|
640
|
+
|
|
641
|
+
|
|
642
|
+
Examples
|
|
643
|
+
--------
|
|
644
|
+
import asyncio
|
|
645
|
+
|
|
646
|
+
from label_studio_sdk import AsyncLabelStudio
|
|
647
|
+
|
|
648
|
+
client = AsyncLabelStudio(
|
|
649
|
+
api_key="YOUR_API_KEY",
|
|
650
|
+
)
|
|
651
|
+
|
|
652
|
+
|
|
653
|
+
async def main() -> None:
|
|
654
|
+
await client.organizations.permissions.create(
|
|
655
|
+
id=1,
|
|
656
|
+
permission="permission",
|
|
657
|
+
)
|
|
658
|
+
|
|
659
|
+
|
|
660
|
+
asyncio.run(main())
|
|
661
|
+
"""
|
|
662
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
663
|
+
f"api/organizations/{jsonable_encoder(id)}/permissions",
|
|
664
|
+
method="POST",
|
|
665
|
+
json={
|
|
666
|
+
"permission": permission,
|
|
667
|
+
"roles": roles,
|
|
668
|
+
},
|
|
669
|
+
request_options=request_options,
|
|
670
|
+
omit=OMIT,
|
|
671
|
+
)
|
|
672
|
+
try:
|
|
673
|
+
if 200 <= _response.status_code < 300:
|
|
674
|
+
return typing.cast(
|
|
675
|
+
OrganizationPermission,
|
|
676
|
+
construct_type(
|
|
677
|
+
type_=OrganizationPermission, # type: ignore
|
|
678
|
+
object_=_response.json(),
|
|
679
|
+
),
|
|
680
|
+
)
|
|
681
|
+
if _response.status_code == 400:
|
|
682
|
+
raise BadRequestError(
|
|
683
|
+
typing.cast(
|
|
684
|
+
typing.Optional[typing.Any],
|
|
685
|
+
construct_type(
|
|
686
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
687
|
+
object_=_response.json(),
|
|
688
|
+
),
|
|
689
|
+
)
|
|
690
|
+
)
|
|
691
|
+
if _response.status_code == 403:
|
|
692
|
+
raise ForbiddenError(
|
|
693
|
+
typing.cast(
|
|
694
|
+
typing.Optional[typing.Any],
|
|
695
|
+
construct_type(
|
|
696
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
697
|
+
object_=_response.json(),
|
|
698
|
+
),
|
|
699
|
+
)
|
|
700
|
+
)
|
|
701
|
+
_response_json = _response.json()
|
|
702
|
+
except JSONDecodeError:
|
|
703
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
704
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
705
|
+
|
|
706
|
+
async def get_options(
|
|
707
|
+
self, id: int, *, ordering: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None
|
|
708
|
+
) -> typing.List[ConfigurablePermissionOption]:
|
|
709
|
+
"""
|
|
710
|
+
Retrieve the list of configurable permission options (label, tooltip, default role and allowed roles).
|
|
711
|
+
|
|
712
|
+
Parameters
|
|
713
|
+
----------
|
|
714
|
+
id : int
|
|
715
|
+
|
|
716
|
+
ordering : typing.Optional[str]
|
|
717
|
+
Which field to use when ordering the results.
|
|
718
|
+
|
|
719
|
+
request_options : typing.Optional[RequestOptions]
|
|
720
|
+
Request-specific configuration.
|
|
721
|
+
|
|
722
|
+
Returns
|
|
723
|
+
-------
|
|
724
|
+
typing.List[ConfigurablePermissionOption]
|
|
725
|
+
|
|
726
|
+
|
|
727
|
+
Examples
|
|
728
|
+
--------
|
|
729
|
+
import asyncio
|
|
730
|
+
|
|
731
|
+
from label_studio_sdk import AsyncLabelStudio
|
|
732
|
+
|
|
733
|
+
client = AsyncLabelStudio(
|
|
734
|
+
api_key="YOUR_API_KEY",
|
|
735
|
+
)
|
|
736
|
+
|
|
737
|
+
|
|
738
|
+
async def main() -> None:
|
|
739
|
+
await client.organizations.permissions.get_options(
|
|
740
|
+
id=1,
|
|
741
|
+
)
|
|
742
|
+
|
|
743
|
+
|
|
744
|
+
asyncio.run(main())
|
|
745
|
+
"""
|
|
746
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
747
|
+
f"api/organizations/{jsonable_encoder(id)}/permissions/options",
|
|
748
|
+
method="GET",
|
|
749
|
+
params={
|
|
750
|
+
"ordering": ordering,
|
|
751
|
+
},
|
|
752
|
+
request_options=request_options,
|
|
753
|
+
)
|
|
754
|
+
try:
|
|
755
|
+
if 200 <= _response.status_code < 300:
|
|
756
|
+
return typing.cast(
|
|
757
|
+
typing.List[ConfigurablePermissionOption],
|
|
758
|
+
construct_type(
|
|
759
|
+
type_=typing.List[ConfigurablePermissionOption], # type: ignore
|
|
760
|
+
object_=_response.json(),
|
|
761
|
+
),
|
|
762
|
+
)
|
|
763
|
+
_response_json = _response.json()
|
|
764
|
+
except JSONDecodeError:
|
|
765
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
766
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
767
|
+
|
|
768
|
+
async def get(
|
|
769
|
+
self, id: int, permission: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
770
|
+
) -> OrganizationPermission:
|
|
771
|
+
"""
|
|
772
|
+
Parameters
|
|
773
|
+
----------
|
|
774
|
+
id : int
|
|
775
|
+
|
|
776
|
+
permission : str
|
|
777
|
+
|
|
778
|
+
request_options : typing.Optional[RequestOptions]
|
|
779
|
+
Request-specific configuration.
|
|
780
|
+
|
|
781
|
+
Returns
|
|
782
|
+
-------
|
|
783
|
+
OrganizationPermission
|
|
784
|
+
|
|
785
|
+
|
|
786
|
+
Examples
|
|
787
|
+
--------
|
|
788
|
+
import asyncio
|
|
789
|
+
|
|
790
|
+
from label_studio_sdk import AsyncLabelStudio
|
|
791
|
+
|
|
792
|
+
client = AsyncLabelStudio(
|
|
793
|
+
api_key="YOUR_API_KEY",
|
|
794
|
+
)
|
|
795
|
+
|
|
796
|
+
|
|
797
|
+
async def main() -> None:
|
|
798
|
+
await client.organizations.permissions.get(
|
|
799
|
+
id=1,
|
|
800
|
+
permission="permission",
|
|
801
|
+
)
|
|
802
|
+
|
|
803
|
+
|
|
804
|
+
asyncio.run(main())
|
|
805
|
+
"""
|
|
806
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
807
|
+
f"api/organizations/{jsonable_encoder(id)}/permissions/{jsonable_encoder(permission)}",
|
|
808
|
+
method="GET",
|
|
809
|
+
request_options=request_options,
|
|
810
|
+
)
|
|
811
|
+
try:
|
|
812
|
+
if 200 <= _response.status_code < 300:
|
|
813
|
+
return typing.cast(
|
|
814
|
+
OrganizationPermission,
|
|
815
|
+
construct_type(
|
|
816
|
+
type_=OrganizationPermission, # type: ignore
|
|
817
|
+
object_=_response.json(),
|
|
818
|
+
),
|
|
819
|
+
)
|
|
820
|
+
if _response.status_code == 403:
|
|
821
|
+
raise ForbiddenError(
|
|
822
|
+
typing.cast(
|
|
823
|
+
typing.Optional[typing.Any],
|
|
824
|
+
construct_type(
|
|
825
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
826
|
+
object_=_response.json(),
|
|
827
|
+
),
|
|
828
|
+
)
|
|
829
|
+
)
|
|
830
|
+
if _response.status_code == 404:
|
|
831
|
+
raise NotFoundError(
|
|
832
|
+
typing.cast(
|
|
833
|
+
typing.Optional[typing.Any],
|
|
834
|
+
construct_type(
|
|
835
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
836
|
+
object_=_response.json(),
|
|
837
|
+
),
|
|
838
|
+
)
|
|
839
|
+
)
|
|
840
|
+
_response_json = _response.json()
|
|
841
|
+
except JSONDecodeError:
|
|
842
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
843
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
844
|
+
|
|
845
|
+
async def replace(
|
|
846
|
+
self,
|
|
847
|
+
id: int,
|
|
848
|
+
permission_: str,
|
|
849
|
+
*,
|
|
850
|
+
permission: str,
|
|
851
|
+
roles: typing.Optional[typing.Sequence[Role9E7Enum]] = OMIT,
|
|
852
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
853
|
+
) -> OrganizationPermission:
|
|
854
|
+
"""
|
|
855
|
+
Replace the organization-level permission override for a given permission key.
|
|
856
|
+
|
|
857
|
+
Parameters
|
|
858
|
+
----------
|
|
859
|
+
id : int
|
|
860
|
+
A unique integer value identifying this organization.
|
|
861
|
+
|
|
862
|
+
permission_ : str
|
|
863
|
+
Permission key to update within the organization.
|
|
864
|
+
|
|
865
|
+
permission : str
|
|
866
|
+
|
|
867
|
+
roles : typing.Optional[typing.Sequence[Role9E7Enum]]
|
|
868
|
+
Explicit roles that have this permission within the organization.
|
|
869
|
+
|
|
870
|
+
request_options : typing.Optional[RequestOptions]
|
|
871
|
+
Request-specific configuration.
|
|
872
|
+
|
|
873
|
+
Returns
|
|
874
|
+
-------
|
|
875
|
+
OrganizationPermission
|
|
876
|
+
|
|
877
|
+
|
|
878
|
+
Examples
|
|
879
|
+
--------
|
|
880
|
+
import asyncio
|
|
881
|
+
|
|
882
|
+
from label_studio_sdk import AsyncLabelStudio
|
|
883
|
+
|
|
884
|
+
client = AsyncLabelStudio(
|
|
885
|
+
api_key="YOUR_API_KEY",
|
|
886
|
+
)
|
|
887
|
+
|
|
888
|
+
|
|
889
|
+
async def main() -> None:
|
|
890
|
+
await client.organizations.permissions.replace(
|
|
891
|
+
id=1,
|
|
892
|
+
permission_="permission",
|
|
893
|
+
permission="permission",
|
|
894
|
+
)
|
|
895
|
+
|
|
896
|
+
|
|
897
|
+
asyncio.run(main())
|
|
898
|
+
"""
|
|
899
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
900
|
+
f"api/organizations/{jsonable_encoder(id)}/permissions/{jsonable_encoder(permission_)}",
|
|
901
|
+
method="PUT",
|
|
902
|
+
json={
|
|
903
|
+
"permission": permission,
|
|
904
|
+
"roles": roles,
|
|
905
|
+
},
|
|
906
|
+
request_options=request_options,
|
|
907
|
+
omit=OMIT,
|
|
908
|
+
)
|
|
909
|
+
try:
|
|
910
|
+
if 200 <= _response.status_code < 300:
|
|
911
|
+
return typing.cast(
|
|
912
|
+
OrganizationPermission,
|
|
913
|
+
construct_type(
|
|
914
|
+
type_=OrganizationPermission, # type: ignore
|
|
915
|
+
object_=_response.json(),
|
|
916
|
+
),
|
|
917
|
+
)
|
|
918
|
+
if _response.status_code == 400:
|
|
919
|
+
raise BadRequestError(
|
|
920
|
+
typing.cast(
|
|
921
|
+
typing.Optional[typing.Any],
|
|
922
|
+
construct_type(
|
|
923
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
924
|
+
object_=_response.json(),
|
|
925
|
+
),
|
|
926
|
+
)
|
|
927
|
+
)
|
|
928
|
+
if _response.status_code == 403:
|
|
929
|
+
raise ForbiddenError(
|
|
930
|
+
typing.cast(
|
|
931
|
+
typing.Optional[typing.Any],
|
|
932
|
+
construct_type(
|
|
933
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
934
|
+
object_=_response.json(),
|
|
935
|
+
),
|
|
936
|
+
)
|
|
937
|
+
)
|
|
938
|
+
if _response.status_code == 404:
|
|
939
|
+
raise NotFoundError(
|
|
940
|
+
typing.cast(
|
|
941
|
+
typing.Optional[typing.Any],
|
|
942
|
+
construct_type(
|
|
943
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
944
|
+
object_=_response.json(),
|
|
945
|
+
),
|
|
946
|
+
)
|
|
947
|
+
)
|
|
948
|
+
_response_json = _response.json()
|
|
949
|
+
except JSONDecodeError:
|
|
950
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
951
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
952
|
+
|
|
953
|
+
async def delete(
|
|
954
|
+
self, id: int, permission: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
955
|
+
) -> None:
|
|
956
|
+
"""
|
|
957
|
+
Parameters
|
|
958
|
+
----------
|
|
959
|
+
id : int
|
|
960
|
+
|
|
961
|
+
permission : str
|
|
962
|
+
|
|
963
|
+
request_options : typing.Optional[RequestOptions]
|
|
964
|
+
Request-specific configuration.
|
|
965
|
+
|
|
966
|
+
Returns
|
|
967
|
+
-------
|
|
968
|
+
None
|
|
969
|
+
|
|
970
|
+
Examples
|
|
971
|
+
--------
|
|
972
|
+
import asyncio
|
|
973
|
+
|
|
974
|
+
from label_studio_sdk import AsyncLabelStudio
|
|
975
|
+
|
|
976
|
+
client = AsyncLabelStudio(
|
|
977
|
+
api_key="YOUR_API_KEY",
|
|
978
|
+
)
|
|
979
|
+
|
|
980
|
+
|
|
981
|
+
async def main() -> None:
|
|
982
|
+
await client.organizations.permissions.delete(
|
|
983
|
+
id=1,
|
|
984
|
+
permission="permission",
|
|
985
|
+
)
|
|
986
|
+
|
|
987
|
+
|
|
988
|
+
asyncio.run(main())
|
|
989
|
+
"""
|
|
990
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
991
|
+
f"api/organizations/{jsonable_encoder(id)}/permissions/{jsonable_encoder(permission)}",
|
|
992
|
+
method="DELETE",
|
|
993
|
+
request_options=request_options,
|
|
994
|
+
)
|
|
995
|
+
try:
|
|
996
|
+
if 200 <= _response.status_code < 300:
|
|
997
|
+
return
|
|
998
|
+
if _response.status_code == 403:
|
|
999
|
+
raise ForbiddenError(
|
|
1000
|
+
typing.cast(
|
|
1001
|
+
typing.Optional[typing.Any],
|
|
1002
|
+
construct_type(
|
|
1003
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1004
|
+
object_=_response.json(),
|
|
1005
|
+
),
|
|
1006
|
+
)
|
|
1007
|
+
)
|
|
1008
|
+
if _response.status_code == 404:
|
|
1009
|
+
raise NotFoundError(
|
|
1010
|
+
typing.cast(
|
|
1011
|
+
typing.Optional[typing.Any],
|
|
1012
|
+
construct_type(
|
|
1013
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1014
|
+
object_=_response.json(),
|
|
1015
|
+
),
|
|
1016
|
+
)
|
|
1017
|
+
)
|
|
1018
|
+
_response_json = _response.json()
|
|
1019
|
+
except JSONDecodeError:
|
|
1020
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1021
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1022
|
+
|
|
1023
|
+
async def update(
|
|
1024
|
+
self,
|
|
1025
|
+
id: int,
|
|
1026
|
+
permission: str,
|
|
1027
|
+
*,
|
|
1028
|
+
patched_organization_permission_request_permission: typing.Optional[str] = OMIT,
|
|
1029
|
+
roles: typing.Optional[typing.Sequence[Role9E7Enum]] = OMIT,
|
|
1030
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1031
|
+
) -> OrganizationPermission:
|
|
1032
|
+
"""
|
|
1033
|
+
Partially update the organization-level permission override for a given permission key.
|
|
1034
|
+
|
|
1035
|
+
Parameters
|
|
1036
|
+
----------
|
|
1037
|
+
id : int
|
|
1038
|
+
|
|
1039
|
+
permission : str
|
|
1040
|
+
|
|
1041
|
+
patched_organization_permission_request_permission : typing.Optional[str]
|
|
1042
|
+
|
|
1043
|
+
roles : typing.Optional[typing.Sequence[Role9E7Enum]]
|
|
1044
|
+
Explicit roles that have this permission within the organization.
|
|
1045
|
+
|
|
1046
|
+
request_options : typing.Optional[RequestOptions]
|
|
1047
|
+
Request-specific configuration.
|
|
1048
|
+
|
|
1049
|
+
Returns
|
|
1050
|
+
-------
|
|
1051
|
+
OrganizationPermission
|
|
1052
|
+
|
|
1053
|
+
|
|
1054
|
+
Examples
|
|
1055
|
+
--------
|
|
1056
|
+
import asyncio
|
|
1057
|
+
|
|
1058
|
+
from label_studio_sdk import AsyncLabelStudio
|
|
1059
|
+
|
|
1060
|
+
client = AsyncLabelStudio(
|
|
1061
|
+
api_key="YOUR_API_KEY",
|
|
1062
|
+
)
|
|
1063
|
+
|
|
1064
|
+
|
|
1065
|
+
async def main() -> None:
|
|
1066
|
+
await client.organizations.permissions.update(
|
|
1067
|
+
id=1,
|
|
1068
|
+
permission="permission",
|
|
1069
|
+
)
|
|
1070
|
+
|
|
1071
|
+
|
|
1072
|
+
asyncio.run(main())
|
|
1073
|
+
"""
|
|
1074
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
1075
|
+
f"api/organizations/{jsonable_encoder(id)}/permissions/{jsonable_encoder(permission)}",
|
|
1076
|
+
method="PATCH",
|
|
1077
|
+
json={
|
|
1078
|
+
"permission": patched_organization_permission_request_permission,
|
|
1079
|
+
"roles": roles,
|
|
1080
|
+
},
|
|
1081
|
+
headers={
|
|
1082
|
+
"content-type": "application/json",
|
|
1083
|
+
},
|
|
1084
|
+
request_options=request_options,
|
|
1085
|
+
omit=OMIT,
|
|
1086
|
+
)
|
|
1087
|
+
try:
|
|
1088
|
+
if 200 <= _response.status_code < 300:
|
|
1089
|
+
return typing.cast(
|
|
1090
|
+
OrganizationPermission,
|
|
1091
|
+
construct_type(
|
|
1092
|
+
type_=OrganizationPermission, # type: ignore
|
|
1093
|
+
object_=_response.json(),
|
|
1094
|
+
),
|
|
1095
|
+
)
|
|
1096
|
+
if _response.status_code == 400:
|
|
1097
|
+
raise BadRequestError(
|
|
1098
|
+
typing.cast(
|
|
1099
|
+
typing.Optional[typing.Any],
|
|
1100
|
+
construct_type(
|
|
1101
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1102
|
+
object_=_response.json(),
|
|
1103
|
+
),
|
|
1104
|
+
)
|
|
1105
|
+
)
|
|
1106
|
+
if _response.status_code == 403:
|
|
1107
|
+
raise ForbiddenError(
|
|
1108
|
+
typing.cast(
|
|
1109
|
+
typing.Optional[typing.Any],
|
|
1110
|
+
construct_type(
|
|
1111
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1112
|
+
object_=_response.json(),
|
|
1113
|
+
),
|
|
1114
|
+
)
|
|
1115
|
+
)
|
|
1116
|
+
if _response.status_code == 404:
|
|
1117
|
+
raise NotFoundError(
|
|
1118
|
+
typing.cast(
|
|
1119
|
+
typing.Optional[typing.Any],
|
|
1120
|
+
construct_type(
|
|
1121
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1122
|
+
object_=_response.json(),
|
|
1123
|
+
),
|
|
1124
|
+
)
|
|
1125
|
+
)
|
|
1126
|
+
_response_json = _response.json()
|
|
1127
|
+
except JSONDecodeError:
|
|
1128
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1129
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|