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.

Files changed (30) hide show
  1. label_studio_sdk/__init__.py +18 -0
  2. label_studio_sdk/base_client.py +4 -0
  3. label_studio_sdk/core/client_wrapper.py +1 -1
  4. label_studio_sdk/label_interface/control_tags.py +38 -0
  5. label_studio_sdk/label_interface/data_examples.json +10 -0
  6. label_studio_sdk/label_interface/interface.py +13 -0
  7. label_studio_sdk/label_interface/object_tags.py +9 -0
  8. label_studio_sdk/ml/client.py +124 -0
  9. label_studio_sdk/organizations/__init__.py +3 -2
  10. label_studio_sdk/organizations/client.py +536 -1
  11. label_studio_sdk/organizations/invites/__init__.py +2 -0
  12. label_studio_sdk/organizations/invites/client.py +368 -0
  13. label_studio_sdk/organizations/types/__init__.py +5 -0
  14. label_studio_sdk/organizations/types/patched_default_role_request_custom_scripts_editable_by.py +7 -0
  15. label_studio_sdk/project_templates/__init__.py +2 -0
  16. label_studio_sdk/project_templates/client.py +909 -0
  17. label_studio_sdk/types/__init__.py +14 -0
  18. label_studio_sdk/types/default_role.py +75 -0
  19. label_studio_sdk/types/default_role_custom_scripts_editable_by.py +7 -0
  20. label_studio_sdk/types/lse_project.py +223 -0
  21. label_studio_sdk/types/lse_project_sampling.py +7 -0
  22. label_studio_sdk/types/lse_project_skip_queue.py +7 -0
  23. label_studio_sdk/types/lse_task.py +1 -1
  24. label_studio_sdk/types/lse_task_serializer_for_reviewers.py +1 -1
  25. label_studio_sdk/types/project_template.py +41 -0
  26. label_studio_sdk/types/project_template_request.py +38 -0
  27. {label_studio_sdk-2.0.6.dist-info → label_studio_sdk-2.0.7.dist-info}/METADATA +1 -1
  28. {label_studio_sdk-2.0.6.dist-info → label_studio_sdk-2.0.7.dist-info}/RECORD +30 -17
  29. {label_studio_sdk-2.0.6.dist-info → label_studio_sdk-2.0.7.dist-info}/LICENSE +0 -0
  30. {label_studio_sdk-2.0.6.dist-info → label_studio_sdk-2.0.7.dist-info}/WHEEL +0 -0
@@ -0,0 +1,909 @@
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.project_template import ProjectTemplate
7
+ from ..core.unchecked_base_model import construct_type
8
+ from json.decoder import JSONDecodeError
9
+ from ..core.api_error import ApiError
10
+ from ..core.jsonable_encoder import jsonable_encoder
11
+ from ..types.lse_project import LseProject
12
+ from ..core.client_wrapper import AsyncClientWrapper
13
+
14
+ # this is used as the default value for optional parameters
15
+ OMIT = typing.cast(typing.Any, ...)
16
+
17
+
18
+ class ProjectTemplatesClient:
19
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
20
+ self._client_wrapper = client_wrapper
21
+
22
+ def list(
23
+ self, *, ordering: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None
24
+ ) -> typing.List[ProjectTemplate]:
25
+ """
26
+ Get a list of all project templates for an organization.
27
+
28
+ Parameters
29
+ ----------
30
+ ordering : typing.Optional[str]
31
+ Which field to use when ordering the results.
32
+
33
+ request_options : typing.Optional[RequestOptions]
34
+ Request-specific configuration.
35
+
36
+ Returns
37
+ -------
38
+ typing.List[ProjectTemplate]
39
+
40
+
41
+ Examples
42
+ --------
43
+ from label_studio_sdk import LabelStudio
44
+
45
+ client = LabelStudio(
46
+ api_key="YOUR_API_KEY",
47
+ )
48
+ client.project_templates.list()
49
+ """
50
+ _response = self._client_wrapper.httpx_client.request(
51
+ "api/project-templates/",
52
+ method="GET",
53
+ params={
54
+ "ordering": ordering,
55
+ },
56
+ request_options=request_options,
57
+ )
58
+ try:
59
+ if 200 <= _response.status_code < 300:
60
+ return typing.cast(
61
+ typing.List[ProjectTemplate],
62
+ construct_type(
63
+ type_=typing.List[ProjectTemplate], # type: ignore
64
+ object_=_response.json(),
65
+ ),
66
+ )
67
+ _response_json = _response.json()
68
+ except JSONDecodeError:
69
+ raise ApiError(status_code=_response.status_code, body=_response.text)
70
+ raise ApiError(status_code=_response.status_code, body=_response_json)
71
+
72
+ def create(
73
+ self,
74
+ *,
75
+ name: str,
76
+ project_id: int,
77
+ assignment_settings: typing.Optional[typing.Optional[typing.Any]] = OMIT,
78
+ created_by: typing.Optional[int] = OMIT,
79
+ custom_script: typing.Optional[str] = OMIT,
80
+ description: typing.Optional[str] = OMIT,
81
+ organization: typing.Optional[int] = OMIT,
82
+ project_settings: typing.Optional[typing.Optional[typing.Any]] = OMIT,
83
+ require_comment_on_skip: typing.Optional[bool] = OMIT,
84
+ review_settings: typing.Optional[typing.Optional[typing.Any]] = OMIT,
85
+ show_unused_data_columns_to_annotators: typing.Optional[bool] = OMIT,
86
+ tags: typing.Optional[typing.Optional[typing.Any]] = OMIT,
87
+ request_options: typing.Optional[RequestOptions] = None,
88
+ ) -> ProjectTemplate:
89
+ """
90
+ Create a project template for an organization.
91
+
92
+ Parameters
93
+ ----------
94
+ name : str
95
+
96
+ project_id : int
97
+
98
+ assignment_settings : typing.Optional[typing.Optional[typing.Any]]
99
+
100
+ created_by : typing.Optional[int]
101
+
102
+ custom_script : typing.Optional[str]
103
+ custom script for projects created from this template
104
+
105
+ description : typing.Optional[str]
106
+
107
+ organization : typing.Optional[int]
108
+
109
+ project_settings : typing.Optional[typing.Optional[typing.Any]]
110
+
111
+ require_comment_on_skip : typing.Optional[bool]
112
+ flag to require comment on skip
113
+
114
+ review_settings : typing.Optional[typing.Optional[typing.Any]]
115
+
116
+ show_unused_data_columns_to_annotators : typing.Optional[bool]
117
+
118
+ tags : typing.Optional[typing.Optional[typing.Any]]
119
+
120
+ request_options : typing.Optional[RequestOptions]
121
+ Request-specific configuration.
122
+
123
+ Returns
124
+ -------
125
+ ProjectTemplate
126
+
127
+
128
+ Examples
129
+ --------
130
+ from label_studio_sdk import LabelStudio
131
+
132
+ client = LabelStudio(
133
+ api_key="YOUR_API_KEY",
134
+ )
135
+ client.project_templates.create(
136
+ name="name",
137
+ project_id=1,
138
+ )
139
+ """
140
+ _response = self._client_wrapper.httpx_client.request(
141
+ "api/project-templates/",
142
+ method="POST",
143
+ json={
144
+ "assignment_settings": assignment_settings,
145
+ "created_by": created_by,
146
+ "custom_script": custom_script,
147
+ "description": description,
148
+ "name": name,
149
+ "organization": organization,
150
+ "project_id": project_id,
151
+ "project_settings": project_settings,
152
+ "require_comment_on_skip": require_comment_on_skip,
153
+ "review_settings": review_settings,
154
+ "show_unused_data_columns_to_annotators": show_unused_data_columns_to_annotators,
155
+ "tags": tags,
156
+ },
157
+ request_options=request_options,
158
+ omit=OMIT,
159
+ )
160
+ try:
161
+ if 200 <= _response.status_code < 300:
162
+ return typing.cast(
163
+ ProjectTemplate,
164
+ construct_type(
165
+ type_=ProjectTemplate, # type: ignore
166
+ object_=_response.json(),
167
+ ),
168
+ )
169
+ _response_json = _response.json()
170
+ except JSONDecodeError:
171
+ raise ApiError(status_code=_response.status_code, body=_response.text)
172
+ raise ApiError(status_code=_response.status_code, body=_response_json)
173
+
174
+ def get(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> ProjectTemplate:
175
+ """
176
+ Get a specific project template by ID for an organization.
177
+
178
+ Parameters
179
+ ----------
180
+ id : int
181
+
182
+ request_options : typing.Optional[RequestOptions]
183
+ Request-specific configuration.
184
+
185
+ Returns
186
+ -------
187
+ ProjectTemplate
188
+
189
+
190
+ Examples
191
+ --------
192
+ from label_studio_sdk import LabelStudio
193
+
194
+ client = LabelStudio(
195
+ api_key="YOUR_API_KEY",
196
+ )
197
+ client.project_templates.get(
198
+ id=1,
199
+ )
200
+ """
201
+ _response = self._client_wrapper.httpx_client.request(
202
+ f"api/project-templates/{jsonable_encoder(id)}",
203
+ method="GET",
204
+ request_options=request_options,
205
+ )
206
+ try:
207
+ if 200 <= _response.status_code < 300:
208
+ return typing.cast(
209
+ ProjectTemplate,
210
+ construct_type(
211
+ type_=ProjectTemplate, # type: ignore
212
+ object_=_response.json(),
213
+ ),
214
+ )
215
+ _response_json = _response.json()
216
+ except JSONDecodeError:
217
+ raise ApiError(status_code=_response.status_code, body=_response.text)
218
+ raise ApiError(status_code=_response.status_code, body=_response_json)
219
+
220
+ def delete(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> None:
221
+ """
222
+ Delete a specific project template by ID for an organization.
223
+
224
+ Parameters
225
+ ----------
226
+ id : int
227
+
228
+ request_options : typing.Optional[RequestOptions]
229
+ Request-specific configuration.
230
+
231
+ Returns
232
+ -------
233
+ None
234
+
235
+ Examples
236
+ --------
237
+ from label_studio_sdk import LabelStudio
238
+
239
+ client = LabelStudio(
240
+ api_key="YOUR_API_KEY",
241
+ )
242
+ client.project_templates.delete(
243
+ id=1,
244
+ )
245
+ """
246
+ _response = self._client_wrapper.httpx_client.request(
247
+ f"api/project-templates/{jsonable_encoder(id)}",
248
+ method="DELETE",
249
+ request_options=request_options,
250
+ )
251
+ try:
252
+ if 200 <= _response.status_code < 300:
253
+ return
254
+ _response_json = _response.json()
255
+ except JSONDecodeError:
256
+ raise ApiError(status_code=_response.status_code, body=_response.text)
257
+ raise ApiError(status_code=_response.status_code, body=_response_json)
258
+
259
+ def update(
260
+ self,
261
+ id: int,
262
+ *,
263
+ assignment_settings: typing.Optional[typing.Optional[typing.Any]] = OMIT,
264
+ created_by: typing.Optional[int] = OMIT,
265
+ custom_script: typing.Optional[str] = OMIT,
266
+ description: typing.Optional[str] = OMIT,
267
+ name: typing.Optional[str] = OMIT,
268
+ organization: typing.Optional[int] = OMIT,
269
+ project_id: typing.Optional[int] = OMIT,
270
+ project_settings: typing.Optional[typing.Optional[typing.Any]] = OMIT,
271
+ require_comment_on_skip: typing.Optional[bool] = OMIT,
272
+ review_settings: typing.Optional[typing.Optional[typing.Any]] = OMIT,
273
+ show_unused_data_columns_to_annotators: typing.Optional[bool] = OMIT,
274
+ tags: typing.Optional[typing.Optional[typing.Any]] = OMIT,
275
+ request_options: typing.Optional[RequestOptions] = None,
276
+ ) -> ProjectTemplate:
277
+ """
278
+ Update the details of a specific project template by ID for an organization.
279
+
280
+ Parameters
281
+ ----------
282
+ id : int
283
+
284
+ assignment_settings : typing.Optional[typing.Optional[typing.Any]]
285
+
286
+ created_by : typing.Optional[int]
287
+
288
+ custom_script : typing.Optional[str]
289
+ custom script for projects created from this template
290
+
291
+ description : typing.Optional[str]
292
+
293
+ name : typing.Optional[str]
294
+
295
+ organization : typing.Optional[int]
296
+
297
+ project_id : typing.Optional[int]
298
+
299
+ project_settings : typing.Optional[typing.Optional[typing.Any]]
300
+
301
+ require_comment_on_skip : typing.Optional[bool]
302
+ flag to require comment on skip
303
+
304
+ review_settings : typing.Optional[typing.Optional[typing.Any]]
305
+
306
+ show_unused_data_columns_to_annotators : typing.Optional[bool]
307
+
308
+ tags : typing.Optional[typing.Optional[typing.Any]]
309
+
310
+ request_options : typing.Optional[RequestOptions]
311
+ Request-specific configuration.
312
+
313
+ Returns
314
+ -------
315
+ ProjectTemplate
316
+
317
+
318
+ Examples
319
+ --------
320
+ from label_studio_sdk import LabelStudio
321
+
322
+ client = LabelStudio(
323
+ api_key="YOUR_API_KEY",
324
+ )
325
+ client.project_templates.update(
326
+ id=1,
327
+ )
328
+ """
329
+ _response = self._client_wrapper.httpx_client.request(
330
+ f"api/project-templates/{jsonable_encoder(id)}",
331
+ method="PATCH",
332
+ json={
333
+ "assignment_settings": assignment_settings,
334
+ "created_by": created_by,
335
+ "custom_script": custom_script,
336
+ "description": description,
337
+ "name": name,
338
+ "organization": organization,
339
+ "project_id": project_id,
340
+ "project_settings": project_settings,
341
+ "require_comment_on_skip": require_comment_on_skip,
342
+ "review_settings": review_settings,
343
+ "show_unused_data_columns_to_annotators": show_unused_data_columns_to_annotators,
344
+ "tags": tags,
345
+ },
346
+ headers={
347
+ "content-type": "application/json",
348
+ },
349
+ request_options=request_options,
350
+ omit=OMIT,
351
+ )
352
+ try:
353
+ if 200 <= _response.status_code < 300:
354
+ return typing.cast(
355
+ ProjectTemplate,
356
+ construct_type(
357
+ type_=ProjectTemplate, # type: ignore
358
+ object_=_response.json(),
359
+ ),
360
+ )
361
+ _response_json = _response.json()
362
+ except JSONDecodeError:
363
+ raise ApiError(status_code=_response.status_code, body=_response.text)
364
+ raise ApiError(status_code=_response.status_code, body=_response_json)
365
+
366
+ def create_project_from_template(
367
+ self,
368
+ id: int,
369
+ *,
370
+ title: str,
371
+ workspace_id: int,
372
+ description: typing.Optional[str] = OMIT,
373
+ request_options: typing.Optional[RequestOptions] = None,
374
+ ) -> LseProject:
375
+ """
376
+ Create a project from a specific project template by ID for an organization.
377
+
378
+ Parameters
379
+ ----------
380
+ id : int
381
+
382
+ title : str
383
+ The title of the project to be created from the template.
384
+
385
+ workspace_id : int
386
+ A unique integer value identifying the workspace in which to create the project.
387
+
388
+ description : typing.Optional[str]
389
+ A description for the project.
390
+
391
+ request_options : typing.Optional[RequestOptions]
392
+ Request-specific configuration.
393
+
394
+ Returns
395
+ -------
396
+ LseProject
397
+ Project created successfully
398
+
399
+ Examples
400
+ --------
401
+ from label_studio_sdk import LabelStudio
402
+
403
+ client = LabelStudio(
404
+ api_key="YOUR_API_KEY",
405
+ )
406
+ client.project_templates.create_project_from_template(
407
+ id=1,
408
+ title="title",
409
+ workspace_id=1,
410
+ )
411
+ """
412
+ _response = self._client_wrapper.httpx_client.request(
413
+ f"api/project-templates/{jsonable_encoder(id)}/create-project",
414
+ method="POST",
415
+ json={
416
+ "description": description,
417
+ "title": title,
418
+ "workspace_id": workspace_id,
419
+ },
420
+ headers={
421
+ "content-type": "application/json",
422
+ },
423
+ request_options=request_options,
424
+ omit=OMIT,
425
+ )
426
+ try:
427
+ if 200 <= _response.status_code < 300:
428
+ return typing.cast(
429
+ LseProject,
430
+ construct_type(
431
+ type_=LseProject, # type: ignore
432
+ object_=_response.json(),
433
+ ),
434
+ )
435
+ _response_json = _response.json()
436
+ except JSONDecodeError:
437
+ raise ApiError(status_code=_response.status_code, body=_response.text)
438
+ raise ApiError(status_code=_response.status_code, body=_response_json)
439
+
440
+
441
+ class AsyncProjectTemplatesClient:
442
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
443
+ self._client_wrapper = client_wrapper
444
+
445
+ async def list(
446
+ self, *, ordering: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None
447
+ ) -> typing.List[ProjectTemplate]:
448
+ """
449
+ Get a list of all project templates for an organization.
450
+
451
+ Parameters
452
+ ----------
453
+ ordering : typing.Optional[str]
454
+ Which field to use when ordering the results.
455
+
456
+ request_options : typing.Optional[RequestOptions]
457
+ Request-specific configuration.
458
+
459
+ Returns
460
+ -------
461
+ typing.List[ProjectTemplate]
462
+
463
+
464
+ Examples
465
+ --------
466
+ import asyncio
467
+
468
+ from label_studio_sdk import AsyncLabelStudio
469
+
470
+ client = AsyncLabelStudio(
471
+ api_key="YOUR_API_KEY",
472
+ )
473
+
474
+
475
+ async def main() -> None:
476
+ await client.project_templates.list()
477
+
478
+
479
+ asyncio.run(main())
480
+ """
481
+ _response = await self._client_wrapper.httpx_client.request(
482
+ "api/project-templates/",
483
+ method="GET",
484
+ params={
485
+ "ordering": ordering,
486
+ },
487
+ request_options=request_options,
488
+ )
489
+ try:
490
+ if 200 <= _response.status_code < 300:
491
+ return typing.cast(
492
+ typing.List[ProjectTemplate],
493
+ construct_type(
494
+ type_=typing.List[ProjectTemplate], # type: ignore
495
+ object_=_response.json(),
496
+ ),
497
+ )
498
+ _response_json = _response.json()
499
+ except JSONDecodeError:
500
+ raise ApiError(status_code=_response.status_code, body=_response.text)
501
+ raise ApiError(status_code=_response.status_code, body=_response_json)
502
+
503
+ async def create(
504
+ self,
505
+ *,
506
+ name: str,
507
+ project_id: int,
508
+ assignment_settings: typing.Optional[typing.Optional[typing.Any]] = OMIT,
509
+ created_by: typing.Optional[int] = OMIT,
510
+ custom_script: typing.Optional[str] = OMIT,
511
+ description: typing.Optional[str] = OMIT,
512
+ organization: typing.Optional[int] = OMIT,
513
+ project_settings: typing.Optional[typing.Optional[typing.Any]] = OMIT,
514
+ require_comment_on_skip: typing.Optional[bool] = OMIT,
515
+ review_settings: typing.Optional[typing.Optional[typing.Any]] = OMIT,
516
+ show_unused_data_columns_to_annotators: typing.Optional[bool] = OMIT,
517
+ tags: typing.Optional[typing.Optional[typing.Any]] = OMIT,
518
+ request_options: typing.Optional[RequestOptions] = None,
519
+ ) -> ProjectTemplate:
520
+ """
521
+ Create a project template for an organization.
522
+
523
+ Parameters
524
+ ----------
525
+ name : str
526
+
527
+ project_id : int
528
+
529
+ assignment_settings : typing.Optional[typing.Optional[typing.Any]]
530
+
531
+ created_by : typing.Optional[int]
532
+
533
+ custom_script : typing.Optional[str]
534
+ custom script for projects created from this template
535
+
536
+ description : typing.Optional[str]
537
+
538
+ organization : typing.Optional[int]
539
+
540
+ project_settings : typing.Optional[typing.Optional[typing.Any]]
541
+
542
+ require_comment_on_skip : typing.Optional[bool]
543
+ flag to require comment on skip
544
+
545
+ review_settings : typing.Optional[typing.Optional[typing.Any]]
546
+
547
+ show_unused_data_columns_to_annotators : typing.Optional[bool]
548
+
549
+ tags : typing.Optional[typing.Optional[typing.Any]]
550
+
551
+ request_options : typing.Optional[RequestOptions]
552
+ Request-specific configuration.
553
+
554
+ Returns
555
+ -------
556
+ ProjectTemplate
557
+
558
+
559
+ Examples
560
+ --------
561
+ import asyncio
562
+
563
+ from label_studio_sdk import AsyncLabelStudio
564
+
565
+ client = AsyncLabelStudio(
566
+ api_key="YOUR_API_KEY",
567
+ )
568
+
569
+
570
+ async def main() -> None:
571
+ await client.project_templates.create(
572
+ name="name",
573
+ project_id=1,
574
+ )
575
+
576
+
577
+ asyncio.run(main())
578
+ """
579
+ _response = await self._client_wrapper.httpx_client.request(
580
+ "api/project-templates/",
581
+ method="POST",
582
+ json={
583
+ "assignment_settings": assignment_settings,
584
+ "created_by": created_by,
585
+ "custom_script": custom_script,
586
+ "description": description,
587
+ "name": name,
588
+ "organization": organization,
589
+ "project_id": project_id,
590
+ "project_settings": project_settings,
591
+ "require_comment_on_skip": require_comment_on_skip,
592
+ "review_settings": review_settings,
593
+ "show_unused_data_columns_to_annotators": show_unused_data_columns_to_annotators,
594
+ "tags": tags,
595
+ },
596
+ request_options=request_options,
597
+ omit=OMIT,
598
+ )
599
+ try:
600
+ if 200 <= _response.status_code < 300:
601
+ return typing.cast(
602
+ ProjectTemplate,
603
+ construct_type(
604
+ type_=ProjectTemplate, # type: ignore
605
+ object_=_response.json(),
606
+ ),
607
+ )
608
+ _response_json = _response.json()
609
+ except JSONDecodeError:
610
+ raise ApiError(status_code=_response.status_code, body=_response.text)
611
+ raise ApiError(status_code=_response.status_code, body=_response_json)
612
+
613
+ async def get(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> ProjectTemplate:
614
+ """
615
+ Get a specific project template by ID for an organization.
616
+
617
+ Parameters
618
+ ----------
619
+ id : int
620
+
621
+ request_options : typing.Optional[RequestOptions]
622
+ Request-specific configuration.
623
+
624
+ Returns
625
+ -------
626
+ ProjectTemplate
627
+
628
+
629
+ Examples
630
+ --------
631
+ import asyncio
632
+
633
+ from label_studio_sdk import AsyncLabelStudio
634
+
635
+ client = AsyncLabelStudio(
636
+ api_key="YOUR_API_KEY",
637
+ )
638
+
639
+
640
+ async def main() -> None:
641
+ await client.project_templates.get(
642
+ id=1,
643
+ )
644
+
645
+
646
+ asyncio.run(main())
647
+ """
648
+ _response = await self._client_wrapper.httpx_client.request(
649
+ f"api/project-templates/{jsonable_encoder(id)}",
650
+ method="GET",
651
+ request_options=request_options,
652
+ )
653
+ try:
654
+ if 200 <= _response.status_code < 300:
655
+ return typing.cast(
656
+ ProjectTemplate,
657
+ construct_type(
658
+ type_=ProjectTemplate, # type: ignore
659
+ object_=_response.json(),
660
+ ),
661
+ )
662
+ _response_json = _response.json()
663
+ except JSONDecodeError:
664
+ raise ApiError(status_code=_response.status_code, body=_response.text)
665
+ raise ApiError(status_code=_response.status_code, body=_response_json)
666
+
667
+ async def delete(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> None:
668
+ """
669
+ Delete a specific project template by ID for an organization.
670
+
671
+ Parameters
672
+ ----------
673
+ id : int
674
+
675
+ request_options : typing.Optional[RequestOptions]
676
+ Request-specific configuration.
677
+
678
+ Returns
679
+ -------
680
+ None
681
+
682
+ Examples
683
+ --------
684
+ import asyncio
685
+
686
+ from label_studio_sdk import AsyncLabelStudio
687
+
688
+ client = AsyncLabelStudio(
689
+ api_key="YOUR_API_KEY",
690
+ )
691
+
692
+
693
+ async def main() -> None:
694
+ await client.project_templates.delete(
695
+ id=1,
696
+ )
697
+
698
+
699
+ asyncio.run(main())
700
+ """
701
+ _response = await self._client_wrapper.httpx_client.request(
702
+ f"api/project-templates/{jsonable_encoder(id)}",
703
+ method="DELETE",
704
+ request_options=request_options,
705
+ )
706
+ try:
707
+ if 200 <= _response.status_code < 300:
708
+ return
709
+ _response_json = _response.json()
710
+ except JSONDecodeError:
711
+ raise ApiError(status_code=_response.status_code, body=_response.text)
712
+ raise ApiError(status_code=_response.status_code, body=_response_json)
713
+
714
+ async def update(
715
+ self,
716
+ id: int,
717
+ *,
718
+ assignment_settings: typing.Optional[typing.Optional[typing.Any]] = OMIT,
719
+ created_by: typing.Optional[int] = OMIT,
720
+ custom_script: typing.Optional[str] = OMIT,
721
+ description: typing.Optional[str] = OMIT,
722
+ name: typing.Optional[str] = OMIT,
723
+ organization: typing.Optional[int] = OMIT,
724
+ project_id: typing.Optional[int] = OMIT,
725
+ project_settings: typing.Optional[typing.Optional[typing.Any]] = OMIT,
726
+ require_comment_on_skip: typing.Optional[bool] = OMIT,
727
+ review_settings: typing.Optional[typing.Optional[typing.Any]] = OMIT,
728
+ show_unused_data_columns_to_annotators: typing.Optional[bool] = OMIT,
729
+ tags: typing.Optional[typing.Optional[typing.Any]] = OMIT,
730
+ request_options: typing.Optional[RequestOptions] = None,
731
+ ) -> ProjectTemplate:
732
+ """
733
+ Update the details of a specific project template by ID for an organization.
734
+
735
+ Parameters
736
+ ----------
737
+ id : int
738
+
739
+ assignment_settings : typing.Optional[typing.Optional[typing.Any]]
740
+
741
+ created_by : typing.Optional[int]
742
+
743
+ custom_script : typing.Optional[str]
744
+ custom script for projects created from this template
745
+
746
+ description : typing.Optional[str]
747
+
748
+ name : typing.Optional[str]
749
+
750
+ organization : typing.Optional[int]
751
+
752
+ project_id : typing.Optional[int]
753
+
754
+ project_settings : typing.Optional[typing.Optional[typing.Any]]
755
+
756
+ require_comment_on_skip : typing.Optional[bool]
757
+ flag to require comment on skip
758
+
759
+ review_settings : typing.Optional[typing.Optional[typing.Any]]
760
+
761
+ show_unused_data_columns_to_annotators : typing.Optional[bool]
762
+
763
+ tags : typing.Optional[typing.Optional[typing.Any]]
764
+
765
+ request_options : typing.Optional[RequestOptions]
766
+ Request-specific configuration.
767
+
768
+ Returns
769
+ -------
770
+ ProjectTemplate
771
+
772
+
773
+ Examples
774
+ --------
775
+ import asyncio
776
+
777
+ from label_studio_sdk import AsyncLabelStudio
778
+
779
+ client = AsyncLabelStudio(
780
+ api_key="YOUR_API_KEY",
781
+ )
782
+
783
+
784
+ async def main() -> None:
785
+ await client.project_templates.update(
786
+ id=1,
787
+ )
788
+
789
+
790
+ asyncio.run(main())
791
+ """
792
+ _response = await self._client_wrapper.httpx_client.request(
793
+ f"api/project-templates/{jsonable_encoder(id)}",
794
+ method="PATCH",
795
+ json={
796
+ "assignment_settings": assignment_settings,
797
+ "created_by": created_by,
798
+ "custom_script": custom_script,
799
+ "description": description,
800
+ "name": name,
801
+ "organization": organization,
802
+ "project_id": project_id,
803
+ "project_settings": project_settings,
804
+ "require_comment_on_skip": require_comment_on_skip,
805
+ "review_settings": review_settings,
806
+ "show_unused_data_columns_to_annotators": show_unused_data_columns_to_annotators,
807
+ "tags": tags,
808
+ },
809
+ headers={
810
+ "content-type": "application/json",
811
+ },
812
+ request_options=request_options,
813
+ omit=OMIT,
814
+ )
815
+ try:
816
+ if 200 <= _response.status_code < 300:
817
+ return typing.cast(
818
+ ProjectTemplate,
819
+ construct_type(
820
+ type_=ProjectTemplate, # type: ignore
821
+ object_=_response.json(),
822
+ ),
823
+ )
824
+ _response_json = _response.json()
825
+ except JSONDecodeError:
826
+ raise ApiError(status_code=_response.status_code, body=_response.text)
827
+ raise ApiError(status_code=_response.status_code, body=_response_json)
828
+
829
+ async def create_project_from_template(
830
+ self,
831
+ id: int,
832
+ *,
833
+ title: str,
834
+ workspace_id: int,
835
+ description: typing.Optional[str] = OMIT,
836
+ request_options: typing.Optional[RequestOptions] = None,
837
+ ) -> LseProject:
838
+ """
839
+ Create a project from a specific project template by ID for an organization.
840
+
841
+ Parameters
842
+ ----------
843
+ id : int
844
+
845
+ title : str
846
+ The title of the project to be created from the template.
847
+
848
+ workspace_id : int
849
+ A unique integer value identifying the workspace in which to create the project.
850
+
851
+ description : typing.Optional[str]
852
+ A description for the project.
853
+
854
+ request_options : typing.Optional[RequestOptions]
855
+ Request-specific configuration.
856
+
857
+ Returns
858
+ -------
859
+ LseProject
860
+ Project created successfully
861
+
862
+ Examples
863
+ --------
864
+ import asyncio
865
+
866
+ from label_studio_sdk import AsyncLabelStudio
867
+
868
+ client = AsyncLabelStudio(
869
+ api_key="YOUR_API_KEY",
870
+ )
871
+
872
+
873
+ async def main() -> None:
874
+ await client.project_templates.create_project_from_template(
875
+ id=1,
876
+ title="title",
877
+ workspace_id=1,
878
+ )
879
+
880
+
881
+ asyncio.run(main())
882
+ """
883
+ _response = await self._client_wrapper.httpx_client.request(
884
+ f"api/project-templates/{jsonable_encoder(id)}/create-project",
885
+ method="POST",
886
+ json={
887
+ "description": description,
888
+ "title": title,
889
+ "workspace_id": workspace_id,
890
+ },
891
+ headers={
892
+ "content-type": "application/json",
893
+ },
894
+ request_options=request_options,
895
+ omit=OMIT,
896
+ )
897
+ try:
898
+ if 200 <= _response.status_code < 300:
899
+ return typing.cast(
900
+ LseProject,
901
+ construct_type(
902
+ type_=LseProject, # type: ignore
903
+ object_=_response.json(),
904
+ ),
905
+ )
906
+ _response_json = _response.json()
907
+ except JSONDecodeError:
908
+ raise ApiError(status_code=_response.status_code, body=_response.text)
909
+ raise ApiError(status_code=_response.status_code, body=_response_json)