label-studio-sdk 2.0.6__py3-none-any.whl → 2.0.7__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.
Potentially problematic release.
This version of label-studio-sdk might be problematic. Click here for more details.
- label_studio_sdk/__init__.py +18 -0
- label_studio_sdk/base_client.py +4 -0
- label_studio_sdk/core/client_wrapper.py +1 -1
- 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 +536 -1
- label_studio_sdk/organizations/invites/__init__.py +2 -0
- label_studio_sdk/organizations/invites/client.py +368 -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/types/__init__.py +14 -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_project.py +223 -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/project_template.py +41 -0
- label_studio_sdk/types/project_template_request.py +38 -0
- {label_studio_sdk-2.0.6.dist-info → label_studio_sdk-2.0.7.dist-info}/METADATA +1 -1
- {label_studio_sdk-2.0.6.dist-info → label_studio_sdk-2.0.7.dist-info}/RECORD +30 -17
- {label_studio_sdk-2.0.6.dist-info → label_studio_sdk-2.0.7.dist-info}/LICENSE +0 -0
- {label_studio_sdk-2.0.6.dist-info → label_studio_sdk-2.0.7.dist-info}/WHEEL +0 -0
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
|
2
2
|
|
|
3
|
+
import typing
|
|
3
4
|
from ..core.client_wrapper import SyncClientWrapper
|
|
5
|
+
from .invites.client import InvitesClient
|
|
4
6
|
from .members.client import MembersClient
|
|
5
|
-
import typing
|
|
6
7
|
from ..core.request_options import RequestOptions
|
|
7
8
|
from ..types.organization_invite import OrganizationInvite
|
|
8
9
|
from ..core.unchecked_base_model import construct_type
|
|
@@ -11,13 +12,28 @@ from ..core.api_error import ApiError
|
|
|
11
12
|
from ..types.organization_id import OrganizationId
|
|
12
13
|
from ..types.lse_organization import LseOrganization
|
|
13
14
|
from ..core.jsonable_encoder import jsonable_encoder
|
|
15
|
+
from ..errors.bad_request_error import BadRequestError
|
|
16
|
+
from ..errors.forbidden_error import ForbiddenError
|
|
17
|
+
from ..errors.not_found_error import NotFoundError
|
|
18
|
+
import datetime as dt
|
|
19
|
+
from .types.patched_default_role_request_custom_scripts_editable_by import (
|
|
20
|
+
PatchedDefaultRoleRequestCustomScriptsEditableBy,
|
|
21
|
+
)
|
|
22
|
+
from ..types.default_role_enum import DefaultRoleEnum
|
|
23
|
+
from ..types.default_role import DefaultRole
|
|
24
|
+
from ..core.serialization import convert_and_respect_annotation_metadata
|
|
14
25
|
from ..core.client_wrapper import AsyncClientWrapper
|
|
26
|
+
from .invites.client import AsyncInvitesClient
|
|
15
27
|
from .members.client import AsyncMembersClient
|
|
16
28
|
|
|
29
|
+
# this is used as the default value for optional parameters
|
|
30
|
+
OMIT = typing.cast(typing.Any, ...)
|
|
31
|
+
|
|
17
32
|
|
|
18
33
|
class OrganizationsClient:
|
|
19
34
|
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
20
35
|
self._client_wrapper = client_wrapper
|
|
36
|
+
self.invites = InvitesClient(client_wrapper=self._client_wrapper)
|
|
21
37
|
self.members = MembersClient(client_wrapper=self._client_wrapper)
|
|
22
38
|
|
|
23
39
|
def reset_token(self, *, request_options: typing.Optional[RequestOptions] = None) -> OrganizationInvite:
|
|
@@ -160,10 +176,262 @@ class OrganizationsClient:
|
|
|
160
176
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
161
177
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
162
178
|
|
|
179
|
+
def update(
|
|
180
|
+
self,
|
|
181
|
+
id: int,
|
|
182
|
+
*,
|
|
183
|
+
contact_info: typing.Optional[str] = OMIT,
|
|
184
|
+
created_by: typing.Optional[int] = OMIT,
|
|
185
|
+
custom_scripts_editable_by: typing.Optional[str] = OMIT,
|
|
186
|
+
custom_scripts_enabled: typing.Optional[bool] = OMIT,
|
|
187
|
+
email_notification_settings: typing.Optional[typing.Optional[typing.Any]] = OMIT,
|
|
188
|
+
embed_domains: typing.Optional[typing.Sequence[typing.Dict[str, str]]] = OMIT,
|
|
189
|
+
embed_settings: typing.Optional[typing.Optional[typing.Any]] = OMIT,
|
|
190
|
+
title: typing.Optional[str] = OMIT,
|
|
191
|
+
token: typing.Optional[str] = OMIT,
|
|
192
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
193
|
+
) -> LseOrganization:
|
|
194
|
+
"""
|
|
195
|
+
Update organization details including title, embed domains, and custom scripts settings.
|
|
196
|
+
|
|
197
|
+
Parameters
|
|
198
|
+
----------
|
|
199
|
+
id : int
|
|
200
|
+
|
|
201
|
+
contact_info : typing.Optional[str]
|
|
202
|
+
|
|
203
|
+
created_by : typing.Optional[int]
|
|
204
|
+
|
|
205
|
+
custom_scripts_editable_by : typing.Optional[str]
|
|
206
|
+
|
|
207
|
+
custom_scripts_enabled : typing.Optional[bool]
|
|
208
|
+
|
|
209
|
+
email_notification_settings : typing.Optional[typing.Optional[typing.Any]]
|
|
210
|
+
|
|
211
|
+
embed_domains : typing.Optional[typing.Sequence[typing.Dict[str, str]]]
|
|
212
|
+
|
|
213
|
+
embed_settings : typing.Optional[typing.Optional[typing.Any]]
|
|
214
|
+
|
|
215
|
+
title : typing.Optional[str]
|
|
216
|
+
|
|
217
|
+
token : typing.Optional[str]
|
|
218
|
+
|
|
219
|
+
request_options : typing.Optional[RequestOptions]
|
|
220
|
+
Request-specific configuration.
|
|
221
|
+
|
|
222
|
+
Returns
|
|
223
|
+
-------
|
|
224
|
+
LseOrganization
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
Examples
|
|
228
|
+
--------
|
|
229
|
+
from label_studio_sdk import LabelStudio
|
|
230
|
+
|
|
231
|
+
client = LabelStudio(
|
|
232
|
+
api_key="YOUR_API_KEY",
|
|
233
|
+
)
|
|
234
|
+
client.organizations.update(
|
|
235
|
+
id=1,
|
|
236
|
+
)
|
|
237
|
+
"""
|
|
238
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
239
|
+
f"api/organizations/{jsonable_encoder(id)}",
|
|
240
|
+
method="PATCH",
|
|
241
|
+
json={
|
|
242
|
+
"contact_info": contact_info,
|
|
243
|
+
"created_by": created_by,
|
|
244
|
+
"custom_scripts_editable_by": custom_scripts_editable_by,
|
|
245
|
+
"custom_scripts_enabled": custom_scripts_enabled,
|
|
246
|
+
"email_notification_settings": email_notification_settings,
|
|
247
|
+
"embed_domains": embed_domains,
|
|
248
|
+
"embed_settings": embed_settings,
|
|
249
|
+
"title": title,
|
|
250
|
+
"token": token,
|
|
251
|
+
},
|
|
252
|
+
headers={
|
|
253
|
+
"content-type": "application/json",
|
|
254
|
+
},
|
|
255
|
+
request_options=request_options,
|
|
256
|
+
omit=OMIT,
|
|
257
|
+
)
|
|
258
|
+
try:
|
|
259
|
+
if 200 <= _response.status_code < 300:
|
|
260
|
+
return typing.cast(
|
|
261
|
+
LseOrganization,
|
|
262
|
+
construct_type(
|
|
263
|
+
type_=LseOrganization, # type: ignore
|
|
264
|
+
object_=_response.json(),
|
|
265
|
+
),
|
|
266
|
+
)
|
|
267
|
+
if _response.status_code == 400:
|
|
268
|
+
raise BadRequestError(
|
|
269
|
+
typing.cast(
|
|
270
|
+
typing.Optional[typing.Any],
|
|
271
|
+
construct_type(
|
|
272
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
273
|
+
object_=_response.json(),
|
|
274
|
+
),
|
|
275
|
+
)
|
|
276
|
+
)
|
|
277
|
+
if _response.status_code == 403:
|
|
278
|
+
raise ForbiddenError(
|
|
279
|
+
typing.cast(
|
|
280
|
+
typing.Optional[typing.Any],
|
|
281
|
+
construct_type(
|
|
282
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
283
|
+
object_=_response.json(),
|
|
284
|
+
),
|
|
285
|
+
)
|
|
286
|
+
)
|
|
287
|
+
if _response.status_code == 404:
|
|
288
|
+
raise NotFoundError(
|
|
289
|
+
typing.cast(
|
|
290
|
+
typing.Optional[typing.Any],
|
|
291
|
+
construct_type(
|
|
292
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
293
|
+
object_=_response.json(),
|
|
294
|
+
),
|
|
295
|
+
)
|
|
296
|
+
)
|
|
297
|
+
_response_json = _response.json()
|
|
298
|
+
except JSONDecodeError:
|
|
299
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
300
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
301
|
+
|
|
302
|
+
def update_default_role(
|
|
303
|
+
self,
|
|
304
|
+
id: int,
|
|
305
|
+
*,
|
|
306
|
+
annotator_reviewer_firewall_enabled_at: typing.Optional[dt.datetime] = OMIT,
|
|
307
|
+
custom_scripts_editable_by: typing.Optional[PatchedDefaultRoleRequestCustomScriptsEditableBy] = OMIT,
|
|
308
|
+
custom_scripts_enabled_at: typing.Optional[dt.datetime] = OMIT,
|
|
309
|
+
default_role: typing.Optional[DefaultRoleEnum] = OMIT,
|
|
310
|
+
email_notification_settings: typing.Optional[typing.Optional[typing.Any]] = OMIT,
|
|
311
|
+
embed_domains: typing.Optional[typing.Optional[typing.Any]] = OMIT,
|
|
312
|
+
embed_settings: typing.Optional[typing.Optional[typing.Any]] = OMIT,
|
|
313
|
+
external_id: typing.Optional[str] = OMIT,
|
|
314
|
+
extra_data_on_activity_logs: typing.Optional[bool] = OMIT,
|
|
315
|
+
label_stream_navigation_disabled_at: typing.Optional[dt.datetime] = OMIT,
|
|
316
|
+
organization: typing.Optional[int] = OMIT,
|
|
317
|
+
read_only_quick_view_enabled_at: typing.Optional[dt.datetime] = OMIT,
|
|
318
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
319
|
+
) -> DefaultRole:
|
|
320
|
+
"""
|
|
321
|
+
Update the default role for members of a specific organization.
|
|
322
|
+
|
|
323
|
+
Parameters
|
|
324
|
+
----------
|
|
325
|
+
id : int
|
|
326
|
+
|
|
327
|
+
annotator_reviewer_firewall_enabled_at : typing.Optional[dt.datetime]
|
|
328
|
+
Set to current time to restrict data sharing between annotators and reviewers in the label stream, review stream, and notifications (which will be disabled). In these settings, information about annotator and reviewer identity is suppressed in the UI.
|
|
329
|
+
|
|
330
|
+
custom_scripts_editable_by : typing.Optional[PatchedDefaultRoleRequestCustomScriptsEditableBy]
|
|
331
|
+
Set the minimum user role that can edit custom scripts in the UI.
|
|
332
|
+
|
|
333
|
+
* `AD` - Administrator
|
|
334
|
+
* `MA` - Manager
|
|
335
|
+
|
|
336
|
+
custom_scripts_enabled_at : typing.Optional[dt.datetime]
|
|
337
|
+
Set to current time to enabled custom scripts for this organization. Can only be enabled if no organization members are active members of any other organizations; otherwise an error will be raised. If this occurs, contact the LEAP team for assistance with enabling custom scripts.
|
|
338
|
+
|
|
339
|
+
default_role : typing.Optional[DefaultRoleEnum]
|
|
340
|
+
Default membership role for invited users
|
|
341
|
+
|
|
342
|
+
* `OW` - Owner
|
|
343
|
+
* `AD` - Administrator
|
|
344
|
+
* `MA` - Manager
|
|
345
|
+
* `RE` - Reviewer
|
|
346
|
+
* `AN` - Annotator
|
|
347
|
+
* `DI` - Deactivated
|
|
348
|
+
* `NO` - Not Activated
|
|
349
|
+
|
|
350
|
+
email_notification_settings : typing.Optional[typing.Optional[typing.Any]]
|
|
351
|
+
|
|
352
|
+
embed_domains : typing.Optional[typing.Optional[typing.Any]]
|
|
353
|
+
|
|
354
|
+
embed_settings : typing.Optional[typing.Optional[typing.Any]]
|
|
355
|
+
|
|
356
|
+
external_id : typing.Optional[str]
|
|
357
|
+
External ID to uniquely identify this organization
|
|
358
|
+
|
|
359
|
+
extra_data_on_activity_logs : typing.Optional[bool]
|
|
360
|
+
|
|
361
|
+
label_stream_navigation_disabled_at : typing.Optional[dt.datetime]
|
|
362
|
+
Set to current time to disable the label stream navigation for this organization. This will prevent users from going back in the label stream to view previous labels.
|
|
363
|
+
|
|
364
|
+
organization : typing.Optional[int]
|
|
365
|
+
A unique integer value identifying this organization.
|
|
366
|
+
|
|
367
|
+
read_only_quick_view_enabled_at : typing.Optional[dt.datetime]
|
|
368
|
+
Set to current time to prevent creating or editing annotations in quick view.
|
|
369
|
+
|
|
370
|
+
request_options : typing.Optional[RequestOptions]
|
|
371
|
+
Request-specific configuration.
|
|
372
|
+
|
|
373
|
+
Returns
|
|
374
|
+
-------
|
|
375
|
+
DefaultRole
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
Examples
|
|
379
|
+
--------
|
|
380
|
+
from label_studio_sdk import LabelStudio
|
|
381
|
+
|
|
382
|
+
client = LabelStudio(
|
|
383
|
+
api_key="YOUR_API_KEY",
|
|
384
|
+
)
|
|
385
|
+
client.organizations.update_default_role(
|
|
386
|
+
id=1,
|
|
387
|
+
)
|
|
388
|
+
"""
|
|
389
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
390
|
+
f"api/organizations/{jsonable_encoder(id)}/set-default-role",
|
|
391
|
+
method="PATCH",
|
|
392
|
+
json={
|
|
393
|
+
"annotator_reviewer_firewall_enabled_at": annotator_reviewer_firewall_enabled_at,
|
|
394
|
+
"custom_scripts_editable_by": convert_and_respect_annotation_metadata(
|
|
395
|
+
object_=custom_scripts_editable_by,
|
|
396
|
+
annotation=PatchedDefaultRoleRequestCustomScriptsEditableBy,
|
|
397
|
+
direction="write",
|
|
398
|
+
),
|
|
399
|
+
"custom_scripts_enabled_at": custom_scripts_enabled_at,
|
|
400
|
+
"default_role": default_role,
|
|
401
|
+
"email_notification_settings": email_notification_settings,
|
|
402
|
+
"embed_domains": embed_domains,
|
|
403
|
+
"embed_settings": embed_settings,
|
|
404
|
+
"external_id": external_id,
|
|
405
|
+
"extra_data_on_activity_logs": extra_data_on_activity_logs,
|
|
406
|
+
"label_stream_navigation_disabled_at": label_stream_navigation_disabled_at,
|
|
407
|
+
"organization": organization,
|
|
408
|
+
"read_only_quick_view_enabled_at": read_only_quick_view_enabled_at,
|
|
409
|
+
},
|
|
410
|
+
headers={
|
|
411
|
+
"content-type": "application/json",
|
|
412
|
+
},
|
|
413
|
+
request_options=request_options,
|
|
414
|
+
omit=OMIT,
|
|
415
|
+
)
|
|
416
|
+
try:
|
|
417
|
+
if 200 <= _response.status_code < 300:
|
|
418
|
+
return typing.cast(
|
|
419
|
+
DefaultRole,
|
|
420
|
+
construct_type(
|
|
421
|
+
type_=DefaultRole, # type: ignore
|
|
422
|
+
object_=_response.json(),
|
|
423
|
+
),
|
|
424
|
+
)
|
|
425
|
+
_response_json = _response.json()
|
|
426
|
+
except JSONDecodeError:
|
|
427
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
428
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
429
|
+
|
|
163
430
|
|
|
164
431
|
class AsyncOrganizationsClient:
|
|
165
432
|
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
166
433
|
self._client_wrapper = client_wrapper
|
|
434
|
+
self.invites = AsyncInvitesClient(client_wrapper=self._client_wrapper)
|
|
167
435
|
self.members = AsyncMembersClient(client_wrapper=self._client_wrapper)
|
|
168
436
|
|
|
169
437
|
async def reset_token(self, *, request_options: typing.Optional[RequestOptions] = None) -> OrganizationInvite:
|
|
@@ -329,3 +597,270 @@ class AsyncOrganizationsClient:
|
|
|
329
597
|
except JSONDecodeError:
|
|
330
598
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
331
599
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
600
|
+
|
|
601
|
+
async def update(
|
|
602
|
+
self,
|
|
603
|
+
id: int,
|
|
604
|
+
*,
|
|
605
|
+
contact_info: typing.Optional[str] = OMIT,
|
|
606
|
+
created_by: typing.Optional[int] = OMIT,
|
|
607
|
+
custom_scripts_editable_by: typing.Optional[str] = OMIT,
|
|
608
|
+
custom_scripts_enabled: typing.Optional[bool] = OMIT,
|
|
609
|
+
email_notification_settings: typing.Optional[typing.Optional[typing.Any]] = OMIT,
|
|
610
|
+
embed_domains: typing.Optional[typing.Sequence[typing.Dict[str, str]]] = OMIT,
|
|
611
|
+
embed_settings: typing.Optional[typing.Optional[typing.Any]] = OMIT,
|
|
612
|
+
title: typing.Optional[str] = OMIT,
|
|
613
|
+
token: typing.Optional[str] = OMIT,
|
|
614
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
615
|
+
) -> LseOrganization:
|
|
616
|
+
"""
|
|
617
|
+
Update organization details including title, embed domains, and custom scripts settings.
|
|
618
|
+
|
|
619
|
+
Parameters
|
|
620
|
+
----------
|
|
621
|
+
id : int
|
|
622
|
+
|
|
623
|
+
contact_info : typing.Optional[str]
|
|
624
|
+
|
|
625
|
+
created_by : typing.Optional[int]
|
|
626
|
+
|
|
627
|
+
custom_scripts_editable_by : typing.Optional[str]
|
|
628
|
+
|
|
629
|
+
custom_scripts_enabled : typing.Optional[bool]
|
|
630
|
+
|
|
631
|
+
email_notification_settings : typing.Optional[typing.Optional[typing.Any]]
|
|
632
|
+
|
|
633
|
+
embed_domains : typing.Optional[typing.Sequence[typing.Dict[str, str]]]
|
|
634
|
+
|
|
635
|
+
embed_settings : typing.Optional[typing.Optional[typing.Any]]
|
|
636
|
+
|
|
637
|
+
title : typing.Optional[str]
|
|
638
|
+
|
|
639
|
+
token : typing.Optional[str]
|
|
640
|
+
|
|
641
|
+
request_options : typing.Optional[RequestOptions]
|
|
642
|
+
Request-specific configuration.
|
|
643
|
+
|
|
644
|
+
Returns
|
|
645
|
+
-------
|
|
646
|
+
LseOrganization
|
|
647
|
+
|
|
648
|
+
|
|
649
|
+
Examples
|
|
650
|
+
--------
|
|
651
|
+
import asyncio
|
|
652
|
+
|
|
653
|
+
from label_studio_sdk import AsyncLabelStudio
|
|
654
|
+
|
|
655
|
+
client = AsyncLabelStudio(
|
|
656
|
+
api_key="YOUR_API_KEY",
|
|
657
|
+
)
|
|
658
|
+
|
|
659
|
+
|
|
660
|
+
async def main() -> None:
|
|
661
|
+
await client.organizations.update(
|
|
662
|
+
id=1,
|
|
663
|
+
)
|
|
664
|
+
|
|
665
|
+
|
|
666
|
+
asyncio.run(main())
|
|
667
|
+
"""
|
|
668
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
669
|
+
f"api/organizations/{jsonable_encoder(id)}",
|
|
670
|
+
method="PATCH",
|
|
671
|
+
json={
|
|
672
|
+
"contact_info": contact_info,
|
|
673
|
+
"created_by": created_by,
|
|
674
|
+
"custom_scripts_editable_by": custom_scripts_editable_by,
|
|
675
|
+
"custom_scripts_enabled": custom_scripts_enabled,
|
|
676
|
+
"email_notification_settings": email_notification_settings,
|
|
677
|
+
"embed_domains": embed_domains,
|
|
678
|
+
"embed_settings": embed_settings,
|
|
679
|
+
"title": title,
|
|
680
|
+
"token": token,
|
|
681
|
+
},
|
|
682
|
+
headers={
|
|
683
|
+
"content-type": "application/json",
|
|
684
|
+
},
|
|
685
|
+
request_options=request_options,
|
|
686
|
+
omit=OMIT,
|
|
687
|
+
)
|
|
688
|
+
try:
|
|
689
|
+
if 200 <= _response.status_code < 300:
|
|
690
|
+
return typing.cast(
|
|
691
|
+
LseOrganization,
|
|
692
|
+
construct_type(
|
|
693
|
+
type_=LseOrganization, # type: ignore
|
|
694
|
+
object_=_response.json(),
|
|
695
|
+
),
|
|
696
|
+
)
|
|
697
|
+
if _response.status_code == 400:
|
|
698
|
+
raise BadRequestError(
|
|
699
|
+
typing.cast(
|
|
700
|
+
typing.Optional[typing.Any],
|
|
701
|
+
construct_type(
|
|
702
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
703
|
+
object_=_response.json(),
|
|
704
|
+
),
|
|
705
|
+
)
|
|
706
|
+
)
|
|
707
|
+
if _response.status_code == 403:
|
|
708
|
+
raise ForbiddenError(
|
|
709
|
+
typing.cast(
|
|
710
|
+
typing.Optional[typing.Any],
|
|
711
|
+
construct_type(
|
|
712
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
713
|
+
object_=_response.json(),
|
|
714
|
+
),
|
|
715
|
+
)
|
|
716
|
+
)
|
|
717
|
+
if _response.status_code == 404:
|
|
718
|
+
raise NotFoundError(
|
|
719
|
+
typing.cast(
|
|
720
|
+
typing.Optional[typing.Any],
|
|
721
|
+
construct_type(
|
|
722
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
723
|
+
object_=_response.json(),
|
|
724
|
+
),
|
|
725
|
+
)
|
|
726
|
+
)
|
|
727
|
+
_response_json = _response.json()
|
|
728
|
+
except JSONDecodeError:
|
|
729
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
730
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
731
|
+
|
|
732
|
+
async def update_default_role(
|
|
733
|
+
self,
|
|
734
|
+
id: int,
|
|
735
|
+
*,
|
|
736
|
+
annotator_reviewer_firewall_enabled_at: typing.Optional[dt.datetime] = OMIT,
|
|
737
|
+
custom_scripts_editable_by: typing.Optional[PatchedDefaultRoleRequestCustomScriptsEditableBy] = OMIT,
|
|
738
|
+
custom_scripts_enabled_at: typing.Optional[dt.datetime] = OMIT,
|
|
739
|
+
default_role: typing.Optional[DefaultRoleEnum] = OMIT,
|
|
740
|
+
email_notification_settings: typing.Optional[typing.Optional[typing.Any]] = OMIT,
|
|
741
|
+
embed_domains: typing.Optional[typing.Optional[typing.Any]] = OMIT,
|
|
742
|
+
embed_settings: typing.Optional[typing.Optional[typing.Any]] = OMIT,
|
|
743
|
+
external_id: typing.Optional[str] = OMIT,
|
|
744
|
+
extra_data_on_activity_logs: typing.Optional[bool] = OMIT,
|
|
745
|
+
label_stream_navigation_disabled_at: typing.Optional[dt.datetime] = OMIT,
|
|
746
|
+
organization: typing.Optional[int] = OMIT,
|
|
747
|
+
read_only_quick_view_enabled_at: typing.Optional[dt.datetime] = OMIT,
|
|
748
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
749
|
+
) -> DefaultRole:
|
|
750
|
+
"""
|
|
751
|
+
Update the default role for members of a specific organization.
|
|
752
|
+
|
|
753
|
+
Parameters
|
|
754
|
+
----------
|
|
755
|
+
id : int
|
|
756
|
+
|
|
757
|
+
annotator_reviewer_firewall_enabled_at : typing.Optional[dt.datetime]
|
|
758
|
+
Set to current time to restrict data sharing between annotators and reviewers in the label stream, review stream, and notifications (which will be disabled). In these settings, information about annotator and reviewer identity is suppressed in the UI.
|
|
759
|
+
|
|
760
|
+
custom_scripts_editable_by : typing.Optional[PatchedDefaultRoleRequestCustomScriptsEditableBy]
|
|
761
|
+
Set the minimum user role that can edit custom scripts in the UI.
|
|
762
|
+
|
|
763
|
+
* `AD` - Administrator
|
|
764
|
+
* `MA` - Manager
|
|
765
|
+
|
|
766
|
+
custom_scripts_enabled_at : typing.Optional[dt.datetime]
|
|
767
|
+
Set to current time to enabled custom scripts for this organization. Can only be enabled if no organization members are active members of any other organizations; otherwise an error will be raised. If this occurs, contact the LEAP team for assistance with enabling custom scripts.
|
|
768
|
+
|
|
769
|
+
default_role : typing.Optional[DefaultRoleEnum]
|
|
770
|
+
Default membership role for invited users
|
|
771
|
+
|
|
772
|
+
* `OW` - Owner
|
|
773
|
+
* `AD` - Administrator
|
|
774
|
+
* `MA` - Manager
|
|
775
|
+
* `RE` - Reviewer
|
|
776
|
+
* `AN` - Annotator
|
|
777
|
+
* `DI` - Deactivated
|
|
778
|
+
* `NO` - Not Activated
|
|
779
|
+
|
|
780
|
+
email_notification_settings : typing.Optional[typing.Optional[typing.Any]]
|
|
781
|
+
|
|
782
|
+
embed_domains : typing.Optional[typing.Optional[typing.Any]]
|
|
783
|
+
|
|
784
|
+
embed_settings : typing.Optional[typing.Optional[typing.Any]]
|
|
785
|
+
|
|
786
|
+
external_id : typing.Optional[str]
|
|
787
|
+
External ID to uniquely identify this organization
|
|
788
|
+
|
|
789
|
+
extra_data_on_activity_logs : typing.Optional[bool]
|
|
790
|
+
|
|
791
|
+
label_stream_navigation_disabled_at : typing.Optional[dt.datetime]
|
|
792
|
+
Set to current time to disable the label stream navigation for this organization. This will prevent users from going back in the label stream to view previous labels.
|
|
793
|
+
|
|
794
|
+
organization : typing.Optional[int]
|
|
795
|
+
A unique integer value identifying this organization.
|
|
796
|
+
|
|
797
|
+
read_only_quick_view_enabled_at : typing.Optional[dt.datetime]
|
|
798
|
+
Set to current time to prevent creating or editing annotations in quick view.
|
|
799
|
+
|
|
800
|
+
request_options : typing.Optional[RequestOptions]
|
|
801
|
+
Request-specific configuration.
|
|
802
|
+
|
|
803
|
+
Returns
|
|
804
|
+
-------
|
|
805
|
+
DefaultRole
|
|
806
|
+
|
|
807
|
+
|
|
808
|
+
Examples
|
|
809
|
+
--------
|
|
810
|
+
import asyncio
|
|
811
|
+
|
|
812
|
+
from label_studio_sdk import AsyncLabelStudio
|
|
813
|
+
|
|
814
|
+
client = AsyncLabelStudio(
|
|
815
|
+
api_key="YOUR_API_KEY",
|
|
816
|
+
)
|
|
817
|
+
|
|
818
|
+
|
|
819
|
+
async def main() -> None:
|
|
820
|
+
await client.organizations.update_default_role(
|
|
821
|
+
id=1,
|
|
822
|
+
)
|
|
823
|
+
|
|
824
|
+
|
|
825
|
+
asyncio.run(main())
|
|
826
|
+
"""
|
|
827
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
828
|
+
f"api/organizations/{jsonable_encoder(id)}/set-default-role",
|
|
829
|
+
method="PATCH",
|
|
830
|
+
json={
|
|
831
|
+
"annotator_reviewer_firewall_enabled_at": annotator_reviewer_firewall_enabled_at,
|
|
832
|
+
"custom_scripts_editable_by": convert_and_respect_annotation_metadata(
|
|
833
|
+
object_=custom_scripts_editable_by,
|
|
834
|
+
annotation=PatchedDefaultRoleRequestCustomScriptsEditableBy,
|
|
835
|
+
direction="write",
|
|
836
|
+
),
|
|
837
|
+
"custom_scripts_enabled_at": custom_scripts_enabled_at,
|
|
838
|
+
"default_role": default_role,
|
|
839
|
+
"email_notification_settings": email_notification_settings,
|
|
840
|
+
"embed_domains": embed_domains,
|
|
841
|
+
"embed_settings": embed_settings,
|
|
842
|
+
"external_id": external_id,
|
|
843
|
+
"extra_data_on_activity_logs": extra_data_on_activity_logs,
|
|
844
|
+
"label_stream_navigation_disabled_at": label_stream_navigation_disabled_at,
|
|
845
|
+
"organization": organization,
|
|
846
|
+
"read_only_quick_view_enabled_at": read_only_quick_view_enabled_at,
|
|
847
|
+
},
|
|
848
|
+
headers={
|
|
849
|
+
"content-type": "application/json",
|
|
850
|
+
},
|
|
851
|
+
request_options=request_options,
|
|
852
|
+
omit=OMIT,
|
|
853
|
+
)
|
|
854
|
+
try:
|
|
855
|
+
if 200 <= _response.status_code < 300:
|
|
856
|
+
return typing.cast(
|
|
857
|
+
DefaultRole,
|
|
858
|
+
construct_type(
|
|
859
|
+
type_=DefaultRole, # type: ignore
|
|
860
|
+
object_=_response.json(),
|
|
861
|
+
),
|
|
862
|
+
)
|
|
863
|
+
_response_json = _response.json()
|
|
864
|
+
except JSONDecodeError:
|
|
865
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
866
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|