label-studio-sdk 2.0.5__py3-none-any.whl → 2.0.6__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 (72) hide show
  1. label_studio_sdk/__init__.py +52 -0
  2. label_studio_sdk/annotation_history/__init__.py +5 -0
  3. label_studio_sdk/annotation_history/client.py +415 -0
  4. label_studio_sdk/annotation_history/types/__init__.py +5 -0
  5. label_studio_sdk/annotation_history/types/annotation_history_delete_response.py +22 -0
  6. label_studio_sdk/annotation_reviews/__init__.py +2 -0
  7. label_studio_sdk/annotation_reviews/client.py +713 -0
  8. label_studio_sdk/base_client.py +16 -0
  9. label_studio_sdk/blueprints/__init__.py +2 -0
  10. label_studio_sdk/blueprints/client.py +272 -0
  11. label_studio_sdk/core/client_wrapper.py +2 -1
  12. label_studio_sdk/export_storage/__init__.py +2 -2
  13. label_studio_sdk/export_storage/azure_spi/__init__.py +2 -0
  14. label_studio_sdk/export_storage/azure_spi/client.py +1354 -0
  15. label_studio_sdk/export_storage/client.py +8 -0
  16. label_studio_sdk/export_storage/gcswif/__init__.py +2 -0
  17. label_studio_sdk/export_storage/gcswif/client.py +1376 -0
  18. label_studio_sdk/import_storage/__init__.py +2 -2
  19. label_studio_sdk/import_storage/azure_spi/__init__.py +2 -0
  20. label_studio_sdk/import_storage/azure_spi/client.py +1378 -0
  21. label_studio_sdk/import_storage/client.py +8 -0
  22. label_studio_sdk/import_storage/gcswif/__init__.py +2 -0
  23. label_studio_sdk/import_storage/gcswif/client.py +1400 -0
  24. label_studio_sdk/jwt_settings/client.py +10 -8
  25. label_studio_sdk/projects/client.py +8 -0
  26. label_studio_sdk/projects/members/__init__.py +2 -2
  27. label_studio_sdk/projects/members/bulk/client.py +46 -2
  28. label_studio_sdk/projects/members/client.py +4 -0
  29. label_studio_sdk/projects/members/paginated/__init__.py +2 -0
  30. label_studio_sdk/projects/members/paginated/client.py +248 -0
  31. label_studio_sdk/session_policy/__init__.py +2 -0
  32. label_studio_sdk/session_policy/client.py +247 -0
  33. label_studio_sdk/tasks/client.py +371 -0
  34. label_studio_sdk/types/__init__.py +42 -0
  35. label_studio_sdk/types/action_enum.py +19 -0
  36. label_studio_sdk/types/all_roles_project_list.py +1 -1
  37. label_studio_sdk/types/annotation.py +7 -0
  38. label_studio_sdk/types/annotation_history.py +81 -0
  39. label_studio_sdk/types/annotation_history_action.py +7 -0
  40. label_studio_sdk/types/annotation_request.py +7 -0
  41. label_studio_sdk/types/annotation_review.py +61 -0
  42. label_studio_sdk/types/annotation_review_request.py +41 -0
  43. label_studio_sdk/types/azure_service_principal_export_storage.py +114 -0
  44. label_studio_sdk/types/azure_service_principal_export_storage_request.py +107 -0
  45. label_studio_sdk/types/azure_service_principal_import_storage.py +115 -0
  46. label_studio_sdk/types/azure_service_principal_import_storage_request.py +108 -0
  47. label_studio_sdk/types/blueprint.py +41 -0
  48. label_studio_sdk/types/gcswif_export_storage.py +119 -0
  49. label_studio_sdk/types/gcswif_export_storage_request.py +112 -0
  50. label_studio_sdk/types/gcswif_import_storage.py +120 -0
  51. label_studio_sdk/types/gcswif_import_storage_request.py +113 -0
  52. label_studio_sdk/types/lse_project_update.py +1 -0
  53. label_studio_sdk/types/lse_task.py +1 -0
  54. label_studio_sdk/types/lse_task_serializer_for_reviewers.py +1 -0
  55. label_studio_sdk/types/lsejwt_settings.py +1 -5
  56. label_studio_sdk/types/paginated_annotation_history_list.py +23 -0
  57. label_studio_sdk/types/paginated_lse_user_list.py +23 -0
  58. label_studio_sdk/types/paginated_paginated_project_member_list.py +23 -0
  59. label_studio_sdk/types/paginated_project_member.py +50 -0
  60. label_studio_sdk/types/project_member_bulk_assign_roles_request.py +21 -0
  61. label_studio_sdk/types/review_settings.py +5 -0
  62. label_studio_sdk/types/review_settings_request.py +5 -0
  63. label_studio_sdk/types/session_timeout_policy.py +31 -0
  64. label_studio_sdk/types/task_event.py +61 -0
  65. label_studio_sdk/workspaces/members/__init__.py +2 -2
  66. label_studio_sdk/workspaces/members/client.py +4 -0
  67. label_studio_sdk/workspaces/members/paginated/__init__.py +2 -0
  68. label_studio_sdk/workspaces/members/paginated/client.py +212 -0
  69. {label_studio_sdk-2.0.5.dist-info → label_studio_sdk-2.0.6.dist-info}/METADATA +2 -2
  70. {label_studio_sdk-2.0.5.dist-info → label_studio_sdk-2.0.6.dist-info}/RECORD +72 -29
  71. {label_studio_sdk-2.0.5.dist-info → label_studio_sdk-2.0.6.dist-info}/LICENSE +0 -0
  72. {label_studio_sdk-2.0.5.dist-info → label_studio_sdk-2.0.6.dist-info}/WHEEL +0 -0
@@ -0,0 +1,113 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from ..core.unchecked_base_model import UncheckedBaseModel
4
+ import typing
5
+ import pydantic
6
+ import datetime as dt
7
+ from .status_c5a_enum import StatusC5AEnum
8
+ from ..core.pydantic_utilities import IS_PYDANTIC_V2
9
+
10
+
11
+ class GcswifImportStorageRequest(UncheckedBaseModel):
12
+ bucket: typing.Optional[str] = pydantic.Field(default=None)
13
+ """
14
+ GCS bucket name
15
+ """
16
+
17
+ description: typing.Optional[str] = pydantic.Field(default=None)
18
+ """
19
+ Cloud storage description
20
+ """
21
+
22
+ google_application_credentials: typing.Optional[str] = pydantic.Field(default=None)
23
+ """
24
+ The content of GOOGLE_APPLICATION_CREDENTIALS json file
25
+ """
26
+
27
+ google_project_id: typing.Optional[str] = pydantic.Field(default=None)
28
+ """
29
+ Google project ID
30
+ """
31
+
32
+ google_project_number: typing.Optional[str] = pydantic.Field(default=None)
33
+ """
34
+ Google project number
35
+ """
36
+
37
+ google_service_account_email: typing.Optional[str] = pydantic.Field(default=None)
38
+ """
39
+ Google service account email
40
+ """
41
+
42
+ google_wif_pool_id: typing.Optional[str] = pydantic.Field(default=None)
43
+ """
44
+ Google WIF pool ID
45
+ """
46
+
47
+ google_wif_provider_id: typing.Optional[str] = pydantic.Field(default=None)
48
+ """
49
+ Google WIF provider ID
50
+ """
51
+
52
+ last_sync: typing.Optional[dt.datetime] = pydantic.Field(default=None)
53
+ """
54
+ Last sync finished time
55
+ """
56
+
57
+ last_sync_count: typing.Optional[int] = pydantic.Field(default=None)
58
+ """
59
+ Count of tasks synced last time
60
+ """
61
+
62
+ last_sync_job: typing.Optional[str] = pydantic.Field(default=None)
63
+ """
64
+ Last sync job ID
65
+ """
66
+
67
+ meta: typing.Optional[typing.Optional[typing.Any]] = None
68
+ prefix: typing.Optional[str] = pydantic.Field(default=None)
69
+ """
70
+ GCS bucket prefix
71
+ """
72
+
73
+ presign: typing.Optional[bool] = None
74
+ presign_ttl: typing.Optional[int] = pydantic.Field(default=None)
75
+ """
76
+ Presigned URLs TTL (in minutes)
77
+ """
78
+
79
+ project: int = pydantic.Field()
80
+ """
81
+ A unique integer value identifying this project.
82
+ """
83
+
84
+ regex_filter: typing.Optional[str] = pydantic.Field(default=None)
85
+ """
86
+ Cloud storage regex for filtering objects
87
+ """
88
+
89
+ status: typing.Optional[StatusC5AEnum] = None
90
+ synchronizable: typing.Optional[bool] = None
91
+ title: typing.Optional[str] = pydantic.Field(default=None)
92
+ """
93
+ Cloud storage title
94
+ """
95
+
96
+ traceback: typing.Optional[str] = pydantic.Field(default=None)
97
+ """
98
+ Traceback report for the last failed sync
99
+ """
100
+
101
+ use_blob_urls: typing.Optional[bool] = pydantic.Field(default=None)
102
+ """
103
+ Interpret objects as BLOBs and generate URLs
104
+ """
105
+
106
+ if IS_PYDANTIC_V2:
107
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
108
+ else:
109
+
110
+ class Config:
111
+ frozen = True
112
+ smart_union = True
113
+ extra = pydantic.Extra.allow
@@ -156,6 +156,7 @@ class LseProjectUpdate(UncheckedBaseModel):
156
156
  Show a skip button in interface and allow annotators to skip the task
157
157
  """
158
158
 
159
+ show_unused_data_columns_to_annotators: typing.Optional[bool] = None
159
160
  skip_queue: typing.Optional[LseProjectUpdateSkipQueue] = None
160
161
  skipped_annotations_number: int = pydantic.Field()
161
162
  """
@@ -15,6 +15,7 @@ class LseTask(UncheckedBaseModel):
15
15
  """
16
16
 
17
17
  agreement: str
18
+ agreement_filtered: str
18
19
  annotations: str
19
20
  annotations_ids: str
20
21
  annotations_results: str
@@ -15,6 +15,7 @@ class LseTaskSerializerForReviewers(UncheckedBaseModel):
15
15
  """
16
16
 
17
17
  agreement: str
18
+ agreement_filtered: str
18
19
  annotations: str
19
20
  annotations_ids: str
20
21
  annotations_results: str
@@ -7,11 +7,7 @@ from ..core.pydantic_utilities import IS_PYDANTIC_V2
7
7
 
8
8
 
9
9
  class LsejwtSettings(UncheckedBaseModel):
10
- api_token_ttl_days: typing.Optional[int] = pydantic.Field(default=None)
11
- """
12
- Number of days before JWT API tokens expire
13
- """
14
-
10
+ api_token_ttl_days: int
15
11
  api_tokens_enabled: typing.Optional[bool] = pydantic.Field(default=None)
16
12
  """
17
13
  Enable JWT API token authentication for this organization
@@ -0,0 +1,23 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from ..core.unchecked_base_model import UncheckedBaseModel
4
+ import typing
5
+ from .annotation_history import AnnotationHistory
6
+ from ..core.pydantic_utilities import IS_PYDANTIC_V2
7
+ import pydantic
8
+
9
+
10
+ class PaginatedAnnotationHistoryList(UncheckedBaseModel):
11
+ count: int
12
+ next: typing.Optional[str] = None
13
+ previous: typing.Optional[str] = None
14
+ results: typing.List[AnnotationHistory]
15
+
16
+ if IS_PYDANTIC_V2:
17
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
18
+ else:
19
+
20
+ class Config:
21
+ frozen = True
22
+ smart_union = True
23
+ extra = pydantic.Extra.allow
@@ -0,0 +1,23 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from ..core.unchecked_base_model import UncheckedBaseModel
4
+ import typing
5
+ from .lse_user import LseUser
6
+ from ..core.pydantic_utilities import IS_PYDANTIC_V2
7
+ import pydantic
8
+
9
+
10
+ class PaginatedLseUserList(UncheckedBaseModel):
11
+ count: int
12
+ next: typing.Optional[str] = None
13
+ previous: typing.Optional[str] = None
14
+ results: typing.List[LseUser]
15
+
16
+ if IS_PYDANTIC_V2:
17
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
18
+ else:
19
+
20
+ class Config:
21
+ frozen = True
22
+ smart_union = True
23
+ extra = pydantic.Extra.allow
@@ -0,0 +1,23 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from ..core.unchecked_base_model import UncheckedBaseModel
4
+ import typing
5
+ from .paginated_project_member import PaginatedProjectMember
6
+ from ..core.pydantic_utilities import IS_PYDANTIC_V2
7
+ import pydantic
8
+
9
+
10
+ class PaginatedPaginatedProjectMemberList(UncheckedBaseModel):
11
+ count: int
12
+ next: typing.Optional[str] = None
13
+ previous: typing.Optional[str] = None
14
+ results: typing.List[PaginatedProjectMember]
15
+
16
+ if IS_PYDANTIC_V2:
17
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
18
+ else:
19
+
20
+ class Config:
21
+ frozen = True
22
+ smart_union = True
23
+ extra = pydantic.Extra.allow
@@ -0,0 +1,50 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from ..core.unchecked_base_model import UncheckedBaseModel
4
+ import typing
5
+ import pydantic
6
+ import datetime as dt
7
+ from .lse_fields import LseFields
8
+ from .organization_membership import OrganizationMembership
9
+ from ..core.pydantic_utilities import IS_PYDANTIC_V2
10
+
11
+
12
+ class PaginatedProjectMember(UncheckedBaseModel):
13
+ """
14
+ A ModelSerializer that takes additional arguments for
15
+ "fields", "omit" and "expand" in order to
16
+ control which fields are displayed, and whether to replace simple
17
+ values with complex, nested serializations
18
+ """
19
+
20
+ active_organization: typing.Optional[int] = None
21
+ active_organization_meta: str
22
+ allow_newsletters: typing.Optional[bool] = pydantic.Field(default=None)
23
+ """
24
+ Allow sending newsletters to user
25
+ """
26
+
27
+ avatar: str
28
+ custom_hotkeys: typing.Optional[typing.Optional[typing.Any]] = None
29
+ date_joined: typing.Optional[dt.datetime] = None
30
+ email: typing.Optional[str] = None
31
+ first_name: typing.Optional[str] = None
32
+ id: int
33
+ initials: str
34
+ last_activity: dt.datetime
35
+ last_name: typing.Optional[str] = None
36
+ lse_fields: LseFields
37
+ org_membership: typing.List[OrganizationMembership]
38
+ pause: str
39
+ phone: typing.Optional[str] = None
40
+ project_role: str
41
+ username: str
42
+
43
+ if IS_PYDANTIC_V2:
44
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
45
+ else:
46
+
47
+ class Config:
48
+ frozen = True
49
+ smart_union = True
50
+ extra = pydantic.Extra.allow
@@ -0,0 +1,21 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from ..core.unchecked_base_model import UncheckedBaseModel
4
+ from .role9e7enum import Role9E7Enum
5
+ from ..core.pydantic_utilities import IS_PYDANTIC_V2
6
+ import typing
7
+ import pydantic
8
+
9
+
10
+ class ProjectMemberBulkAssignRolesRequest(UncheckedBaseModel):
11
+ role: Role9E7Enum
12
+ user_id: int
13
+
14
+ if IS_PYDANTIC_V2:
15
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
16
+ else:
17
+
18
+ class Config:
19
+ frozen = True
20
+ smart_union = True
21
+ extra = pydantic.Extra.allow
@@ -69,6 +69,11 @@ class ReviewSettings(UncheckedBaseModel):
69
69
  Show instructions to the reviewers before they start
70
70
  """
71
71
 
72
+ show_unused_data_columns_to_reviewers: typing.Optional[bool] = pydantic.Field(default=None)
73
+ """
74
+ If true, Data Manager shows all task.data columns to reviewers; if false, hides columns not referenced by the label interface
75
+ """
76
+
72
77
  if IS_PYDANTIC_V2:
73
78
  model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
74
79
  else:
@@ -69,6 +69,11 @@ class ReviewSettingsRequest(UncheckedBaseModel):
69
69
  Show instructions to the reviewers before they start
70
70
  """
71
71
 
72
+ show_unused_data_columns_to_reviewers: typing.Optional[bool] = pydantic.Field(default=None)
73
+ """
74
+ If true, Data Manager shows all task.data columns to reviewers; if false, hides columns not referenced by the label interface
75
+ """
76
+
72
77
  if IS_PYDANTIC_V2:
73
78
  model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
74
79
  else:
@@ -0,0 +1,31 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from ..core.unchecked_base_model import UncheckedBaseModel
4
+ import datetime as dt
5
+ import typing
6
+ import pydantic
7
+ from ..core.pydantic_utilities import IS_PYDANTIC_V2
8
+
9
+
10
+ class SessionTimeoutPolicy(UncheckedBaseModel):
11
+ created_at: dt.datetime
12
+ max_session_age: typing.Optional[int] = pydantic.Field(default=None)
13
+ """
14
+ Number of minutes that a session can be active before needing to re-login
15
+ """
16
+
17
+ max_time_between_activity: typing.Optional[int] = pydantic.Field(default=None)
18
+ """
19
+ Number of minutes that a session stays active without any activity
20
+ """
21
+
22
+ updated_at: dt.datetime
23
+
24
+ if IS_PYDANTIC_V2:
25
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
26
+ else:
27
+
28
+ class Config:
29
+ frozen = True
30
+ smart_union = True
31
+ extra = pydantic.Extra.allow
@@ -0,0 +1,61 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from ..core.unchecked_base_model import UncheckedBaseModel
4
+ import typing
5
+ import pydantic
6
+ import datetime as dt
7
+ from ..core.pydantic_utilities import IS_PYDANTIC_V2
8
+
9
+
10
+ class TaskEvent(UncheckedBaseModel):
11
+ """
12
+ Serializer for TaskEvent model to handle event creation from frontend.
13
+
14
+ This serializer validates and processes task events sent from the labeling interface,
15
+ ensuring proper data format and automatically setting required relationships.
16
+ """
17
+
18
+ actor: int
19
+ annotation: typing.Optional[int] = pydantic.Field(default=None)
20
+ """
21
+ Annotation ID associated with this event
22
+ """
23
+
24
+ annotation_draft: typing.Optional[int] = pydantic.Field(default=None)
25
+ """
26
+ Draft annotation ID associated with this event
27
+ """
28
+
29
+ created_at: dt.datetime
30
+ event_key: str = pydantic.Field()
31
+ """
32
+ Event type identifier (e.g., "annotation_loaded", "region_finished_drawing")
33
+ """
34
+
35
+ event_time: dt.datetime = pydantic.Field()
36
+ """
37
+ Timestamp when the event occurred (frontend time)
38
+ """
39
+
40
+ id: int
41
+ meta: typing.Optional[typing.Optional[typing.Any]] = None
42
+ organization: int
43
+ project: int
44
+ review: typing.Optional[int] = pydantic.Field(default=None)
45
+ """
46
+ Review ID associated with this event
47
+ """
48
+
49
+ task: int = pydantic.Field()
50
+ """
51
+ Task this event is associated with
52
+ """
53
+
54
+ if IS_PYDANTIC_V2:
55
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
56
+ else:
57
+
58
+ class Config:
59
+ frozen = True
60
+ smart_union = True
61
+ extra = pydantic.Extra.allow
@@ -1,6 +1,6 @@
1
1
  # This file was auto-generated by Fern from our API Definition.
2
2
 
3
- from . import bulk
3
+ from . import bulk, paginated
4
4
  from .bulk import BulkDeleteResponse, BulkPostResponse
5
5
 
6
- __all__ = ["BulkDeleteResponse", "BulkPostResponse", "bulk"]
6
+ __all__ = ["BulkDeleteResponse", "BulkPostResponse", "bulk", "paginated"]
@@ -3,6 +3,7 @@
3
3
  import typing
4
4
  from ...core.client_wrapper import SyncClientWrapper
5
5
  from .bulk.client import BulkClient
6
+ from .paginated.client import PaginatedClient
6
7
  from ...core.request_options import RequestOptions
7
8
  from ...types.workspace_member_list import WorkspaceMemberList
8
9
  from ...core.jsonable_encoder import jsonable_encoder
@@ -12,6 +13,7 @@ from ...core.api_error import ApiError
12
13
  from ...types.workspace_member_create import WorkspaceMemberCreate
13
14
  from ...core.client_wrapper import AsyncClientWrapper
14
15
  from .bulk.client import AsyncBulkClient
16
+ from .paginated.client import AsyncPaginatedClient
15
17
 
16
18
  # this is used as the default value for optional parameters
17
19
  OMIT = typing.cast(typing.Any, ...)
@@ -21,6 +23,7 @@ class MembersClient:
21
23
  def __init__(self, *, client_wrapper: SyncClientWrapper):
22
24
  self._client_wrapper = client_wrapper
23
25
  self.bulk = BulkClient(client_wrapper=self._client_wrapper)
26
+ self.paginated = PaginatedClient(client_wrapper=self._client_wrapper)
24
27
 
25
28
  def list(
26
29
  self, id: int, *, request_options: typing.Optional[RequestOptions] = None
@@ -182,6 +185,7 @@ class AsyncMembersClient:
182
185
  def __init__(self, *, client_wrapper: AsyncClientWrapper):
183
186
  self._client_wrapper = client_wrapper
184
187
  self.bulk = AsyncBulkClient(client_wrapper=self._client_wrapper)
188
+ self.paginated = AsyncPaginatedClient(client_wrapper=self._client_wrapper)
185
189
 
186
190
  async def list(
187
191
  self, id: int, *, request_options: typing.Optional[RequestOptions] = None
@@ -0,0 +1,2 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
@@ -0,0 +1,212 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from ....core.client_wrapper import SyncClientWrapper
4
+ import typing
5
+ from ....core.request_options import RequestOptions
6
+ from ....core.pagination import SyncPager
7
+ from ....types.lse_user import LseUser
8
+ from ....core.jsonable_encoder import jsonable_encoder
9
+ from ....types.paginated_lse_user_list import PaginatedLseUserList
10
+ from ....core.unchecked_base_model import construct_type
11
+ from json.decoder import JSONDecodeError
12
+ from ....core.api_error import ApiError
13
+ from ....core.client_wrapper import AsyncClientWrapper
14
+ from ....core.pagination import AsyncPager
15
+
16
+
17
+ class PaginatedClient:
18
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
19
+ self._client_wrapper = client_wrapper
20
+
21
+ def list(
22
+ self,
23
+ id: int,
24
+ *,
25
+ ids: typing.Optional[str] = None,
26
+ page: typing.Optional[int] = None,
27
+ page_size: typing.Optional[int] = None,
28
+ search: typing.Optional[str] = None,
29
+ request_options: typing.Optional[RequestOptions] = None,
30
+ ) -> SyncPager[LseUser]:
31
+ """
32
+ Retrieve the members for a specific workspace.
33
+
34
+ Parameters
35
+ ----------
36
+ id : int
37
+
38
+ ids : typing.Optional[str]
39
+ Comma-separated list of user IDs to filter by
40
+
41
+ page : typing.Optional[int]
42
+ A page number within the paginated result set.
43
+
44
+ page_size : typing.Optional[int]
45
+ Number of results to return per page.
46
+
47
+ search : typing.Optional[str]
48
+ A search term.
49
+
50
+ request_options : typing.Optional[RequestOptions]
51
+ Request-specific configuration.
52
+
53
+ Returns
54
+ -------
55
+ SyncPager[LseUser]
56
+
57
+
58
+ Examples
59
+ --------
60
+ from label_studio_sdk import LabelStudio
61
+
62
+ client = LabelStudio(
63
+ api_key="YOUR_API_KEY",
64
+ )
65
+ response = client.workspaces.members.paginated.list(
66
+ id=1,
67
+ )
68
+ for item in response:
69
+ yield item
70
+ # alternatively, you can paginate page-by-page
71
+ for page in response.iter_pages():
72
+ yield page
73
+ """
74
+ page = page if page is not None else 1
75
+ _response = self._client_wrapper.httpx_client.request(
76
+ f"api/workspaces/{jsonable_encoder(id)}/memberships/paginated/",
77
+ method="GET",
78
+ params={
79
+ "ids": ids,
80
+ "page": page,
81
+ "page_size": page_size,
82
+ "search": search,
83
+ },
84
+ request_options=request_options,
85
+ )
86
+ try:
87
+ if 200 <= _response.status_code < 300:
88
+ _parsed_response = typing.cast(
89
+ PaginatedLseUserList,
90
+ construct_type(
91
+ type_=PaginatedLseUserList, # type: ignore
92
+ object_=_response.json(),
93
+ ),
94
+ )
95
+ _has_next = True
96
+ _get_next = lambda: self.list(
97
+ id,
98
+ ids=ids,
99
+ page=page + 1,
100
+ page_size=page_size,
101
+ search=search,
102
+ request_options=request_options,
103
+ )
104
+ _items = _parsed_response.results
105
+ return SyncPager(has_next=_has_next, items=_items, get_next=_get_next)
106
+ _response_json = _response.json()
107
+ except JSONDecodeError:
108
+ raise ApiError(status_code=_response.status_code, body=_response.text)
109
+ raise ApiError(status_code=_response.status_code, body=_response_json)
110
+
111
+
112
+ class AsyncPaginatedClient:
113
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
114
+ self._client_wrapper = client_wrapper
115
+
116
+ async def list(
117
+ self,
118
+ id: int,
119
+ *,
120
+ ids: typing.Optional[str] = None,
121
+ page: typing.Optional[int] = None,
122
+ page_size: typing.Optional[int] = None,
123
+ search: typing.Optional[str] = None,
124
+ request_options: typing.Optional[RequestOptions] = None,
125
+ ) -> AsyncPager[LseUser]:
126
+ """
127
+ Retrieve the members for a specific workspace.
128
+
129
+ Parameters
130
+ ----------
131
+ id : int
132
+
133
+ ids : typing.Optional[str]
134
+ Comma-separated list of user IDs to filter by
135
+
136
+ page : typing.Optional[int]
137
+ A page number within the paginated result set.
138
+
139
+ page_size : typing.Optional[int]
140
+ Number of results to return per page.
141
+
142
+ search : typing.Optional[str]
143
+ A search term.
144
+
145
+ request_options : typing.Optional[RequestOptions]
146
+ Request-specific configuration.
147
+
148
+ Returns
149
+ -------
150
+ AsyncPager[LseUser]
151
+
152
+
153
+ Examples
154
+ --------
155
+ import asyncio
156
+
157
+ from label_studio_sdk import AsyncLabelStudio
158
+
159
+ client = AsyncLabelStudio(
160
+ api_key="YOUR_API_KEY",
161
+ )
162
+
163
+
164
+ async def main() -> None:
165
+ response = await client.workspaces.members.paginated.list(
166
+ id=1,
167
+ )
168
+ async for item in response:
169
+ yield item
170
+ # alternatively, you can paginate page-by-page
171
+ async for page in response.iter_pages():
172
+ yield page
173
+
174
+
175
+ asyncio.run(main())
176
+ """
177
+ page = page if page is not None else 1
178
+ _response = await self._client_wrapper.httpx_client.request(
179
+ f"api/workspaces/{jsonable_encoder(id)}/memberships/paginated/",
180
+ method="GET",
181
+ params={
182
+ "ids": ids,
183
+ "page": page,
184
+ "page_size": page_size,
185
+ "search": search,
186
+ },
187
+ request_options=request_options,
188
+ )
189
+ try:
190
+ if 200 <= _response.status_code < 300:
191
+ _parsed_response = typing.cast(
192
+ PaginatedLseUserList,
193
+ construct_type(
194
+ type_=PaginatedLseUserList, # type: ignore
195
+ object_=_response.json(),
196
+ ),
197
+ )
198
+ _has_next = True
199
+ _get_next = lambda: self.list(
200
+ id,
201
+ ids=ids,
202
+ page=page + 1,
203
+ page_size=page_size,
204
+ search=search,
205
+ request_options=request_options,
206
+ )
207
+ _items = _parsed_response.results
208
+ return AsyncPager(has_next=_has_next, items=_items, get_next=_get_next)
209
+ _response_json = _response.json()
210
+ except JSONDecodeError:
211
+ raise ApiError(status_code=_response.status_code, body=_response.text)
212
+ raise ApiError(status_code=_response.status_code, body=_response_json)