label-studio-sdk 1.0.2__py3-none-any.whl → 1.0.4__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 +20 -1
- label_studio_sdk/actions/client.py +8 -8
- label_studio_sdk/annotations/client.py +24 -24
- label_studio_sdk/base_client.py +3 -0
- label_studio_sdk/core/client_wrapper.py +1 -1
- label_studio_sdk/core/http_client.py +36 -8
- label_studio_sdk/core/request_options.py +2 -2
- label_studio_sdk/export_storage/__init__.py +2 -1
- label_studio_sdk/export_storage/azure/client.py +28 -28
- label_studio_sdk/export_storage/client.py +7 -4
- label_studio_sdk/export_storage/gcs/client.py +28 -28
- label_studio_sdk/export_storage/local/client.py +28 -28
- label_studio_sdk/export_storage/redis/client.py +28 -28
- label_studio_sdk/export_storage/s3/client.py +28 -28
- label_studio_sdk/export_storage/s3s/__init__.py +2 -0
- label_studio_sdk/export_storage/s3s/client.py +836 -0
- label_studio_sdk/files/client.py +24 -24
- label_studio_sdk/import_storage/__init__.py +2 -1
- label_studio_sdk/import_storage/azure/client.py +28 -28
- label_studio_sdk/import_storage/client.py +7 -4
- label_studio_sdk/import_storage/gcs/client.py +28 -28
- label_studio_sdk/import_storage/local/client.py +28 -28
- label_studio_sdk/import_storage/redis/client.py +28 -28
- label_studio_sdk/import_storage/s3/client.py +28 -28
- label_studio_sdk/import_storage/s3s/__init__.py +2 -0
- label_studio_sdk/import_storage/s3s/client.py +1054 -0
- label_studio_sdk/label_interface/base.py +2 -2
- label_studio_sdk/label_interface/control_tags.py +32 -18
- label_studio_sdk/label_interface/create.py +241 -0
- label_studio_sdk/label_interface/interface.py +68 -0
- label_studio_sdk/label_interface/object_tags.py +26 -10
- label_studio_sdk/label_interface/objects.py +5 -5
- label_studio_sdk/ml/client.py +36 -36
- label_studio_sdk/predictions/client.py +24 -24
- label_studio_sdk/projects/__init__.py +8 -2
- label_studio_sdk/projects/client.py +232 -69
- label_studio_sdk/projects/client_ext.py +16 -1
- label_studio_sdk/projects/exports/client.py +38 -38
- label_studio_sdk/projects/types/__init__.py +2 -1
- label_studio_sdk/projects/types/projects_update_response.py +96 -0
- label_studio_sdk/tasks/client.py +70 -60
- label_studio_sdk/tasks/client_ext.py +4 -0
- label_studio_sdk/types/__init__.py +16 -0
- label_studio_sdk/types/base_task.py +4 -2
- label_studio_sdk/types/base_task_file_upload.py +5 -0
- label_studio_sdk/types/base_task_updated_by.py +5 -0
- label_studio_sdk/types/data_manager_task_serializer.py +3 -2
- label_studio_sdk/types/data_manager_task_serializer_annotators_item.py +5 -0
- label_studio_sdk/types/s3s_export_storage.py +80 -0
- label_studio_sdk/types/s3s_import_storage.py +129 -0
- label_studio_sdk/types/s3s_import_storage_status.py +7 -0
- label_studio_sdk/types/task.py +3 -2
- label_studio_sdk/types/task_annotators_item.py +5 -0
- label_studio_sdk/types/workspace.py +77 -0
- label_studio_sdk/users/client.py +32 -32
- label_studio_sdk/views/client.py +24 -24
- label_studio_sdk/webhooks/client.py +24 -24
- label_studio_sdk/workspaces/__init__.py +6 -0
- label_studio_sdk/workspaces/client.py +569 -0
- label_studio_sdk/workspaces/members/__init__.py +5 -0
- label_studio_sdk/workspaces/members/client.py +297 -0
- label_studio_sdk/workspaces/members/types/__init__.py +6 -0
- label_studio_sdk/workspaces/members/types/members_create_response.py +32 -0
- label_studio_sdk/workspaces/members/types/members_list_response_item.py +32 -0
- {label_studio_sdk-1.0.2.dist-info → label_studio_sdk-1.0.4.dist-info}/METADATA +11 -12
- {label_studio_sdk-1.0.2.dist-info → label_studio_sdk-1.0.4.dist-info}/RECORD +67 -46
- {label_studio_sdk-1.0.2.dist-info → label_studio_sdk-1.0.4.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,836 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
from json.decoder import JSONDecodeError
|
|
5
|
+
|
|
6
|
+
from ...core.api_error import ApiError
|
|
7
|
+
from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
8
|
+
from ...core.jsonable_encoder import jsonable_encoder
|
|
9
|
+
from ...core.pydantic_utilities import pydantic_v1
|
|
10
|
+
from ...core.request_options import RequestOptions
|
|
11
|
+
from ...types.s3s_export_storage import S3SExportStorage
|
|
12
|
+
|
|
13
|
+
# this is used as the default value for optional parameters
|
|
14
|
+
OMIT = typing.cast(typing.Any, ...)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class S3SClient:
|
|
18
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
19
|
+
self._client_wrapper = client_wrapper
|
|
20
|
+
|
|
21
|
+
def list(
|
|
22
|
+
self, *, project: typing.Optional[int] = None, request_options: typing.Optional[RequestOptions] = None
|
|
23
|
+
) -> typing.List[S3SExportStorage]:
|
|
24
|
+
"""
|
|
25
|
+
You can connect your S3 bucket to Label Studio as a source storage or target storage. Use this API request to get a list of all S3 export (target) storage connections for a specific project.
|
|
26
|
+
|
|
27
|
+
The project ID can be found in the URL when viewing the project in Label Studio, or you can retrieve all project IDs using [List all projects](../projects/list).
|
|
28
|
+
|
|
29
|
+
For more information about working with external storage, see [Sync data from external storage](https://labelstud.io/guide/storage).
|
|
30
|
+
|
|
31
|
+
Parameters
|
|
32
|
+
----------
|
|
33
|
+
project : typing.Optional[int]
|
|
34
|
+
Project ID
|
|
35
|
+
|
|
36
|
+
request_options : typing.Optional[RequestOptions]
|
|
37
|
+
Request-specific configuration.
|
|
38
|
+
|
|
39
|
+
Returns
|
|
40
|
+
-------
|
|
41
|
+
typing.List[S3SExportStorage]
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
Examples
|
|
45
|
+
--------
|
|
46
|
+
from label_studio_sdk.client import LabelStudio
|
|
47
|
+
|
|
48
|
+
client = LabelStudio(
|
|
49
|
+
api_key="YOUR_API_KEY",
|
|
50
|
+
)
|
|
51
|
+
client.export_storage.s3s.list()
|
|
52
|
+
"""
|
|
53
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
54
|
+
"api/storages/export/s3s", method="GET", params={"project": project}, request_options=request_options
|
|
55
|
+
)
|
|
56
|
+
try:
|
|
57
|
+
if 200 <= _response.status_code < 300:
|
|
58
|
+
return pydantic_v1.parse_obj_as(typing.List[S3SExportStorage], _response.json()) # type: ignore
|
|
59
|
+
_response_json = _response.json()
|
|
60
|
+
except JSONDecodeError:
|
|
61
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
62
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
63
|
+
|
|
64
|
+
def create(
|
|
65
|
+
self,
|
|
66
|
+
*,
|
|
67
|
+
can_delete_objects: typing.Optional[bool] = OMIT,
|
|
68
|
+
title: typing.Optional[str] = OMIT,
|
|
69
|
+
description: typing.Optional[str] = OMIT,
|
|
70
|
+
project: typing.Optional[int] = OMIT,
|
|
71
|
+
bucket: typing.Optional[str] = OMIT,
|
|
72
|
+
prefix: typing.Optional[str] = OMIT,
|
|
73
|
+
external_id: typing.Optional[str] = OMIT,
|
|
74
|
+
role_arn: typing.Optional[str] = OMIT,
|
|
75
|
+
region_name: typing.Optional[str] = OMIT,
|
|
76
|
+
s3endpoint: typing.Optional[str] = OMIT,
|
|
77
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
78
|
+
) -> S3SExportStorage:
|
|
79
|
+
"""
|
|
80
|
+
Create a new target storage connection to a S3 bucket with IAM role access.
|
|
81
|
+
|
|
82
|
+
For information about the required fields and prerequisites, see [Amazon S3](https://docs.humansignal.com/guide/storage#Set-up-an-S3-connection-with-IAM-role-access) in the Label Studio documentation.
|
|
83
|
+
|
|
84
|
+
Parameters
|
|
85
|
+
----------
|
|
86
|
+
can_delete_objects : typing.Optional[bool]
|
|
87
|
+
Deletion from storage enabled.
|
|
88
|
+
|
|
89
|
+
title : typing.Optional[str]
|
|
90
|
+
Storage title
|
|
91
|
+
|
|
92
|
+
description : typing.Optional[str]
|
|
93
|
+
Storage description
|
|
94
|
+
|
|
95
|
+
project : typing.Optional[int]
|
|
96
|
+
Project ID
|
|
97
|
+
|
|
98
|
+
bucket : typing.Optional[str]
|
|
99
|
+
S3 bucket name
|
|
100
|
+
|
|
101
|
+
prefix : typing.Optional[str]
|
|
102
|
+
S3 bucket prefix
|
|
103
|
+
|
|
104
|
+
external_id : typing.Optional[str]
|
|
105
|
+
AWS External ID
|
|
106
|
+
|
|
107
|
+
role_arn : typing.Optional[str]
|
|
108
|
+
AWS Role ARN
|
|
109
|
+
|
|
110
|
+
region_name : typing.Optional[str]
|
|
111
|
+
AWS Region
|
|
112
|
+
|
|
113
|
+
s3endpoint : typing.Optional[str]
|
|
114
|
+
S3 Endpoint
|
|
115
|
+
|
|
116
|
+
request_options : typing.Optional[RequestOptions]
|
|
117
|
+
Request-specific configuration.
|
|
118
|
+
|
|
119
|
+
Returns
|
|
120
|
+
-------
|
|
121
|
+
S3SExportStorage
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
Examples
|
|
125
|
+
--------
|
|
126
|
+
from label_studio_sdk.client import LabelStudio
|
|
127
|
+
|
|
128
|
+
client = LabelStudio(
|
|
129
|
+
api_key="YOUR_API_KEY",
|
|
130
|
+
)
|
|
131
|
+
client.export_storage.s3s.create()
|
|
132
|
+
"""
|
|
133
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
134
|
+
"api/storages/export/s3s",
|
|
135
|
+
method="POST",
|
|
136
|
+
json={
|
|
137
|
+
"can_delete_objects": can_delete_objects,
|
|
138
|
+
"title": title,
|
|
139
|
+
"description": description,
|
|
140
|
+
"project": project,
|
|
141
|
+
"bucket": bucket,
|
|
142
|
+
"prefix": prefix,
|
|
143
|
+
"external_id": external_id,
|
|
144
|
+
"role_arn": role_arn,
|
|
145
|
+
"region_name": region_name,
|
|
146
|
+
"s3_endpoint": s3endpoint,
|
|
147
|
+
},
|
|
148
|
+
request_options=request_options,
|
|
149
|
+
omit=OMIT,
|
|
150
|
+
)
|
|
151
|
+
try:
|
|
152
|
+
if 200 <= _response.status_code < 300:
|
|
153
|
+
return pydantic_v1.parse_obj_as(S3SExportStorage, _response.json()) # type: ignore
|
|
154
|
+
_response_json = _response.json()
|
|
155
|
+
except JSONDecodeError:
|
|
156
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
157
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
158
|
+
|
|
159
|
+
def get(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> S3SExportStorage:
|
|
160
|
+
"""
|
|
161
|
+
Get a specific S3 export storage connection. You will need to provide the export storage ID. You can find this using [List export storages](list).
|
|
162
|
+
|
|
163
|
+
Parameters
|
|
164
|
+
----------
|
|
165
|
+
id : int
|
|
166
|
+
Export storage ID
|
|
167
|
+
|
|
168
|
+
request_options : typing.Optional[RequestOptions]
|
|
169
|
+
Request-specific configuration.
|
|
170
|
+
|
|
171
|
+
Returns
|
|
172
|
+
-------
|
|
173
|
+
S3SExportStorage
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
Examples
|
|
177
|
+
--------
|
|
178
|
+
from label_studio_sdk.client import LabelStudio
|
|
179
|
+
|
|
180
|
+
client = LabelStudio(
|
|
181
|
+
api_key="YOUR_API_KEY",
|
|
182
|
+
)
|
|
183
|
+
client.export_storage.s3s.get(
|
|
184
|
+
id=1,
|
|
185
|
+
)
|
|
186
|
+
"""
|
|
187
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
188
|
+
f"api/storages/export/s3s/{jsonable_encoder(id)}", method="GET", request_options=request_options
|
|
189
|
+
)
|
|
190
|
+
try:
|
|
191
|
+
if 200 <= _response.status_code < 300:
|
|
192
|
+
return pydantic_v1.parse_obj_as(S3SExportStorage, _response.json()) # type: ignore
|
|
193
|
+
_response_json = _response.json()
|
|
194
|
+
except JSONDecodeError:
|
|
195
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
196
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
197
|
+
|
|
198
|
+
def delete(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> None:
|
|
199
|
+
"""
|
|
200
|
+
Delete a specific S3 export storage connection. You will need to provide the export storage ID. You can find this using [List export storages](list).
|
|
201
|
+
|
|
202
|
+
Parameters
|
|
203
|
+
----------
|
|
204
|
+
id : int
|
|
205
|
+
Export storage ID
|
|
206
|
+
|
|
207
|
+
request_options : typing.Optional[RequestOptions]
|
|
208
|
+
Request-specific configuration.
|
|
209
|
+
|
|
210
|
+
Returns
|
|
211
|
+
-------
|
|
212
|
+
None
|
|
213
|
+
|
|
214
|
+
Examples
|
|
215
|
+
--------
|
|
216
|
+
from label_studio_sdk.client import LabelStudio
|
|
217
|
+
|
|
218
|
+
client = LabelStudio(
|
|
219
|
+
api_key="YOUR_API_KEY",
|
|
220
|
+
)
|
|
221
|
+
client.export_storage.s3s.delete(
|
|
222
|
+
id=1,
|
|
223
|
+
)
|
|
224
|
+
"""
|
|
225
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
226
|
+
f"api/storages/export/s3s/{jsonable_encoder(id)}", method="DELETE", request_options=request_options
|
|
227
|
+
)
|
|
228
|
+
try:
|
|
229
|
+
if 200 <= _response.status_code < 300:
|
|
230
|
+
return
|
|
231
|
+
_response_json = _response.json()
|
|
232
|
+
except JSONDecodeError:
|
|
233
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
234
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
235
|
+
|
|
236
|
+
def update(
|
|
237
|
+
self,
|
|
238
|
+
id: int,
|
|
239
|
+
*,
|
|
240
|
+
can_delete_objects: typing.Optional[bool] = OMIT,
|
|
241
|
+
title: typing.Optional[str] = OMIT,
|
|
242
|
+
description: typing.Optional[str] = OMIT,
|
|
243
|
+
project: typing.Optional[int] = OMIT,
|
|
244
|
+
bucket: typing.Optional[str] = OMIT,
|
|
245
|
+
prefix: typing.Optional[str] = OMIT,
|
|
246
|
+
external_id: typing.Optional[str] = OMIT,
|
|
247
|
+
role_arn: typing.Optional[str] = OMIT,
|
|
248
|
+
region_name: typing.Optional[str] = OMIT,
|
|
249
|
+
s3endpoint: typing.Optional[str] = OMIT,
|
|
250
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
251
|
+
) -> S3SExportStorage:
|
|
252
|
+
"""
|
|
253
|
+
Update a specific S3 export storage connection. You will need to provide the export storage ID. You can find this using [List export storages](list).
|
|
254
|
+
|
|
255
|
+
Parameters
|
|
256
|
+
----------
|
|
257
|
+
id : int
|
|
258
|
+
Export storage ID
|
|
259
|
+
|
|
260
|
+
can_delete_objects : typing.Optional[bool]
|
|
261
|
+
Deletion from storage enabled.
|
|
262
|
+
|
|
263
|
+
title : typing.Optional[str]
|
|
264
|
+
Storage title
|
|
265
|
+
|
|
266
|
+
description : typing.Optional[str]
|
|
267
|
+
Storage description
|
|
268
|
+
|
|
269
|
+
project : typing.Optional[int]
|
|
270
|
+
Project ID
|
|
271
|
+
|
|
272
|
+
bucket : typing.Optional[str]
|
|
273
|
+
S3 bucket name
|
|
274
|
+
|
|
275
|
+
prefix : typing.Optional[str]
|
|
276
|
+
S3 bucket prefix
|
|
277
|
+
|
|
278
|
+
external_id : typing.Optional[str]
|
|
279
|
+
AWS External ID
|
|
280
|
+
|
|
281
|
+
role_arn : typing.Optional[str]
|
|
282
|
+
AWS Role ARN
|
|
283
|
+
|
|
284
|
+
region_name : typing.Optional[str]
|
|
285
|
+
AWS Region
|
|
286
|
+
|
|
287
|
+
s3endpoint : typing.Optional[str]
|
|
288
|
+
S3 Endpoint
|
|
289
|
+
|
|
290
|
+
request_options : typing.Optional[RequestOptions]
|
|
291
|
+
Request-specific configuration.
|
|
292
|
+
|
|
293
|
+
Returns
|
|
294
|
+
-------
|
|
295
|
+
S3SExportStorage
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
Examples
|
|
299
|
+
--------
|
|
300
|
+
from label_studio_sdk.client import LabelStudio
|
|
301
|
+
|
|
302
|
+
client = LabelStudio(
|
|
303
|
+
api_key="YOUR_API_KEY",
|
|
304
|
+
)
|
|
305
|
+
client.export_storage.s3s.update(
|
|
306
|
+
id=1,
|
|
307
|
+
)
|
|
308
|
+
"""
|
|
309
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
310
|
+
f"api/storages/export/s3s/{jsonable_encoder(id)}",
|
|
311
|
+
method="PATCH",
|
|
312
|
+
json={
|
|
313
|
+
"can_delete_objects": can_delete_objects,
|
|
314
|
+
"title": title,
|
|
315
|
+
"description": description,
|
|
316
|
+
"project": project,
|
|
317
|
+
"bucket": bucket,
|
|
318
|
+
"prefix": prefix,
|
|
319
|
+
"external_id": external_id,
|
|
320
|
+
"role_arn": role_arn,
|
|
321
|
+
"region_name": region_name,
|
|
322
|
+
"s3_endpoint": s3endpoint,
|
|
323
|
+
},
|
|
324
|
+
request_options=request_options,
|
|
325
|
+
omit=OMIT,
|
|
326
|
+
)
|
|
327
|
+
try:
|
|
328
|
+
if 200 <= _response.status_code < 300:
|
|
329
|
+
return pydantic_v1.parse_obj_as(S3SExportStorage, _response.json()) # type: ignore
|
|
330
|
+
_response_json = _response.json()
|
|
331
|
+
except JSONDecodeError:
|
|
332
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
333
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
334
|
+
|
|
335
|
+
def validate(
|
|
336
|
+
self,
|
|
337
|
+
*,
|
|
338
|
+
can_delete_objects: typing.Optional[bool] = OMIT,
|
|
339
|
+
title: typing.Optional[str] = OMIT,
|
|
340
|
+
description: typing.Optional[str] = OMIT,
|
|
341
|
+
project: typing.Optional[int] = OMIT,
|
|
342
|
+
bucket: typing.Optional[str] = OMIT,
|
|
343
|
+
prefix: typing.Optional[str] = OMIT,
|
|
344
|
+
external_id: typing.Optional[str] = OMIT,
|
|
345
|
+
role_arn: typing.Optional[str] = OMIT,
|
|
346
|
+
region_name: typing.Optional[str] = OMIT,
|
|
347
|
+
s3endpoint: typing.Optional[str] = OMIT,
|
|
348
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
349
|
+
) -> None:
|
|
350
|
+
"""
|
|
351
|
+
Validate a specific S3 export storage connection. This is useful to ensure that the storage configuration settings are correct and operational before attempting to export data.
|
|
352
|
+
|
|
353
|
+
Parameters
|
|
354
|
+
----------
|
|
355
|
+
can_delete_objects : typing.Optional[bool]
|
|
356
|
+
Deletion from storage enabled.
|
|
357
|
+
|
|
358
|
+
title : typing.Optional[str]
|
|
359
|
+
Storage title
|
|
360
|
+
|
|
361
|
+
description : typing.Optional[str]
|
|
362
|
+
Storage description
|
|
363
|
+
|
|
364
|
+
project : typing.Optional[int]
|
|
365
|
+
Project ID
|
|
366
|
+
|
|
367
|
+
bucket : typing.Optional[str]
|
|
368
|
+
S3 bucket name
|
|
369
|
+
|
|
370
|
+
prefix : typing.Optional[str]
|
|
371
|
+
S3 bucket prefix
|
|
372
|
+
|
|
373
|
+
external_id : typing.Optional[str]
|
|
374
|
+
AWS External ID
|
|
375
|
+
|
|
376
|
+
role_arn : typing.Optional[str]
|
|
377
|
+
AWS Role ARN
|
|
378
|
+
|
|
379
|
+
region_name : typing.Optional[str]
|
|
380
|
+
AWS Region
|
|
381
|
+
|
|
382
|
+
s3endpoint : typing.Optional[str]
|
|
383
|
+
S3 Endpoint
|
|
384
|
+
|
|
385
|
+
request_options : typing.Optional[RequestOptions]
|
|
386
|
+
Request-specific configuration.
|
|
387
|
+
|
|
388
|
+
Returns
|
|
389
|
+
-------
|
|
390
|
+
None
|
|
391
|
+
|
|
392
|
+
Examples
|
|
393
|
+
--------
|
|
394
|
+
from label_studio_sdk.client import LabelStudio
|
|
395
|
+
|
|
396
|
+
client = LabelStudio(
|
|
397
|
+
api_key="YOUR_API_KEY",
|
|
398
|
+
)
|
|
399
|
+
client.export_storage.s3s.validate()
|
|
400
|
+
"""
|
|
401
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
402
|
+
"api/storages/export/s3s/validate",
|
|
403
|
+
method="POST",
|
|
404
|
+
json={
|
|
405
|
+
"can_delete_objects": can_delete_objects,
|
|
406
|
+
"title": title,
|
|
407
|
+
"description": description,
|
|
408
|
+
"project": project,
|
|
409
|
+
"bucket": bucket,
|
|
410
|
+
"prefix": prefix,
|
|
411
|
+
"external_id": external_id,
|
|
412
|
+
"role_arn": role_arn,
|
|
413
|
+
"region_name": region_name,
|
|
414
|
+
"s3_endpoint": s3endpoint,
|
|
415
|
+
},
|
|
416
|
+
request_options=request_options,
|
|
417
|
+
omit=OMIT,
|
|
418
|
+
)
|
|
419
|
+
try:
|
|
420
|
+
if 200 <= _response.status_code < 300:
|
|
421
|
+
return
|
|
422
|
+
_response_json = _response.json()
|
|
423
|
+
except JSONDecodeError:
|
|
424
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
425
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
426
|
+
|
|
427
|
+
|
|
428
|
+
class AsyncS3SClient:
|
|
429
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
430
|
+
self._client_wrapper = client_wrapper
|
|
431
|
+
|
|
432
|
+
async def list(
|
|
433
|
+
self, *, project: typing.Optional[int] = None, request_options: typing.Optional[RequestOptions] = None
|
|
434
|
+
) -> typing.List[S3SExportStorage]:
|
|
435
|
+
"""
|
|
436
|
+
You can connect your S3 bucket to Label Studio as a source storage or target storage. Use this API request to get a list of all S3 export (target) storage connections for a specific project.
|
|
437
|
+
|
|
438
|
+
The project ID can be found in the URL when viewing the project in Label Studio, or you can retrieve all project IDs using [List all projects](../projects/list).
|
|
439
|
+
|
|
440
|
+
For more information about working with external storage, see [Sync data from external storage](https://labelstud.io/guide/storage).
|
|
441
|
+
|
|
442
|
+
Parameters
|
|
443
|
+
----------
|
|
444
|
+
project : typing.Optional[int]
|
|
445
|
+
Project ID
|
|
446
|
+
|
|
447
|
+
request_options : typing.Optional[RequestOptions]
|
|
448
|
+
Request-specific configuration.
|
|
449
|
+
|
|
450
|
+
Returns
|
|
451
|
+
-------
|
|
452
|
+
typing.List[S3SExportStorage]
|
|
453
|
+
|
|
454
|
+
|
|
455
|
+
Examples
|
|
456
|
+
--------
|
|
457
|
+
from label_studio_sdk.client import AsyncLabelStudio
|
|
458
|
+
|
|
459
|
+
client = AsyncLabelStudio(
|
|
460
|
+
api_key="YOUR_API_KEY",
|
|
461
|
+
)
|
|
462
|
+
await client.export_storage.s3s.list()
|
|
463
|
+
"""
|
|
464
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
465
|
+
"api/storages/export/s3s", method="GET", params={"project": project}, request_options=request_options
|
|
466
|
+
)
|
|
467
|
+
try:
|
|
468
|
+
if 200 <= _response.status_code < 300:
|
|
469
|
+
return pydantic_v1.parse_obj_as(typing.List[S3SExportStorage], _response.json()) # type: ignore
|
|
470
|
+
_response_json = _response.json()
|
|
471
|
+
except JSONDecodeError:
|
|
472
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
473
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
474
|
+
|
|
475
|
+
async def create(
|
|
476
|
+
self,
|
|
477
|
+
*,
|
|
478
|
+
can_delete_objects: typing.Optional[bool] = OMIT,
|
|
479
|
+
title: typing.Optional[str] = OMIT,
|
|
480
|
+
description: typing.Optional[str] = OMIT,
|
|
481
|
+
project: typing.Optional[int] = OMIT,
|
|
482
|
+
bucket: typing.Optional[str] = OMIT,
|
|
483
|
+
prefix: typing.Optional[str] = OMIT,
|
|
484
|
+
external_id: typing.Optional[str] = OMIT,
|
|
485
|
+
role_arn: typing.Optional[str] = OMIT,
|
|
486
|
+
region_name: typing.Optional[str] = OMIT,
|
|
487
|
+
s3endpoint: typing.Optional[str] = OMIT,
|
|
488
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
489
|
+
) -> S3SExportStorage:
|
|
490
|
+
"""
|
|
491
|
+
Create a new target storage connection to a S3 bucket with IAM role access.
|
|
492
|
+
|
|
493
|
+
For information about the required fields and prerequisites, see [Amazon S3](https://docs.humansignal.com/guide/storage#Set-up-an-S3-connection-with-IAM-role-access) in the Label Studio documentation.
|
|
494
|
+
|
|
495
|
+
Parameters
|
|
496
|
+
----------
|
|
497
|
+
can_delete_objects : typing.Optional[bool]
|
|
498
|
+
Deletion from storage enabled.
|
|
499
|
+
|
|
500
|
+
title : typing.Optional[str]
|
|
501
|
+
Storage title
|
|
502
|
+
|
|
503
|
+
description : typing.Optional[str]
|
|
504
|
+
Storage description
|
|
505
|
+
|
|
506
|
+
project : typing.Optional[int]
|
|
507
|
+
Project ID
|
|
508
|
+
|
|
509
|
+
bucket : typing.Optional[str]
|
|
510
|
+
S3 bucket name
|
|
511
|
+
|
|
512
|
+
prefix : typing.Optional[str]
|
|
513
|
+
S3 bucket prefix
|
|
514
|
+
|
|
515
|
+
external_id : typing.Optional[str]
|
|
516
|
+
AWS External ID
|
|
517
|
+
|
|
518
|
+
role_arn : typing.Optional[str]
|
|
519
|
+
AWS Role ARN
|
|
520
|
+
|
|
521
|
+
region_name : typing.Optional[str]
|
|
522
|
+
AWS Region
|
|
523
|
+
|
|
524
|
+
s3endpoint : typing.Optional[str]
|
|
525
|
+
S3 Endpoint
|
|
526
|
+
|
|
527
|
+
request_options : typing.Optional[RequestOptions]
|
|
528
|
+
Request-specific configuration.
|
|
529
|
+
|
|
530
|
+
Returns
|
|
531
|
+
-------
|
|
532
|
+
S3SExportStorage
|
|
533
|
+
|
|
534
|
+
|
|
535
|
+
Examples
|
|
536
|
+
--------
|
|
537
|
+
from label_studio_sdk.client import AsyncLabelStudio
|
|
538
|
+
|
|
539
|
+
client = AsyncLabelStudio(
|
|
540
|
+
api_key="YOUR_API_KEY",
|
|
541
|
+
)
|
|
542
|
+
await client.export_storage.s3s.create()
|
|
543
|
+
"""
|
|
544
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
545
|
+
"api/storages/export/s3s",
|
|
546
|
+
method="POST",
|
|
547
|
+
json={
|
|
548
|
+
"can_delete_objects": can_delete_objects,
|
|
549
|
+
"title": title,
|
|
550
|
+
"description": description,
|
|
551
|
+
"project": project,
|
|
552
|
+
"bucket": bucket,
|
|
553
|
+
"prefix": prefix,
|
|
554
|
+
"external_id": external_id,
|
|
555
|
+
"role_arn": role_arn,
|
|
556
|
+
"region_name": region_name,
|
|
557
|
+
"s3_endpoint": s3endpoint,
|
|
558
|
+
},
|
|
559
|
+
request_options=request_options,
|
|
560
|
+
omit=OMIT,
|
|
561
|
+
)
|
|
562
|
+
try:
|
|
563
|
+
if 200 <= _response.status_code < 300:
|
|
564
|
+
return pydantic_v1.parse_obj_as(S3SExportStorage, _response.json()) # type: ignore
|
|
565
|
+
_response_json = _response.json()
|
|
566
|
+
except JSONDecodeError:
|
|
567
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
568
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
569
|
+
|
|
570
|
+
async def get(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> S3SExportStorage:
|
|
571
|
+
"""
|
|
572
|
+
Get a specific S3 export storage connection. You will need to provide the export storage ID. You can find this using [List export storages](list).
|
|
573
|
+
|
|
574
|
+
Parameters
|
|
575
|
+
----------
|
|
576
|
+
id : int
|
|
577
|
+
Export storage ID
|
|
578
|
+
|
|
579
|
+
request_options : typing.Optional[RequestOptions]
|
|
580
|
+
Request-specific configuration.
|
|
581
|
+
|
|
582
|
+
Returns
|
|
583
|
+
-------
|
|
584
|
+
S3SExportStorage
|
|
585
|
+
|
|
586
|
+
|
|
587
|
+
Examples
|
|
588
|
+
--------
|
|
589
|
+
from label_studio_sdk.client import AsyncLabelStudio
|
|
590
|
+
|
|
591
|
+
client = AsyncLabelStudio(
|
|
592
|
+
api_key="YOUR_API_KEY",
|
|
593
|
+
)
|
|
594
|
+
await client.export_storage.s3s.get(
|
|
595
|
+
id=1,
|
|
596
|
+
)
|
|
597
|
+
"""
|
|
598
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
599
|
+
f"api/storages/export/s3s/{jsonable_encoder(id)}", method="GET", request_options=request_options
|
|
600
|
+
)
|
|
601
|
+
try:
|
|
602
|
+
if 200 <= _response.status_code < 300:
|
|
603
|
+
return pydantic_v1.parse_obj_as(S3SExportStorage, _response.json()) # type: ignore
|
|
604
|
+
_response_json = _response.json()
|
|
605
|
+
except JSONDecodeError:
|
|
606
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
607
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
608
|
+
|
|
609
|
+
async def delete(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> None:
|
|
610
|
+
"""
|
|
611
|
+
Delete a specific S3 export storage connection. You will need to provide the export storage ID. You can find this using [List export storages](list).
|
|
612
|
+
|
|
613
|
+
Parameters
|
|
614
|
+
----------
|
|
615
|
+
id : int
|
|
616
|
+
Export storage ID
|
|
617
|
+
|
|
618
|
+
request_options : typing.Optional[RequestOptions]
|
|
619
|
+
Request-specific configuration.
|
|
620
|
+
|
|
621
|
+
Returns
|
|
622
|
+
-------
|
|
623
|
+
None
|
|
624
|
+
|
|
625
|
+
Examples
|
|
626
|
+
--------
|
|
627
|
+
from label_studio_sdk.client import AsyncLabelStudio
|
|
628
|
+
|
|
629
|
+
client = AsyncLabelStudio(
|
|
630
|
+
api_key="YOUR_API_KEY",
|
|
631
|
+
)
|
|
632
|
+
await client.export_storage.s3s.delete(
|
|
633
|
+
id=1,
|
|
634
|
+
)
|
|
635
|
+
"""
|
|
636
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
637
|
+
f"api/storages/export/s3s/{jsonable_encoder(id)}", method="DELETE", request_options=request_options
|
|
638
|
+
)
|
|
639
|
+
try:
|
|
640
|
+
if 200 <= _response.status_code < 300:
|
|
641
|
+
return
|
|
642
|
+
_response_json = _response.json()
|
|
643
|
+
except JSONDecodeError:
|
|
644
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
645
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
646
|
+
|
|
647
|
+
async def update(
|
|
648
|
+
self,
|
|
649
|
+
id: int,
|
|
650
|
+
*,
|
|
651
|
+
can_delete_objects: typing.Optional[bool] = OMIT,
|
|
652
|
+
title: typing.Optional[str] = OMIT,
|
|
653
|
+
description: typing.Optional[str] = OMIT,
|
|
654
|
+
project: typing.Optional[int] = OMIT,
|
|
655
|
+
bucket: typing.Optional[str] = OMIT,
|
|
656
|
+
prefix: typing.Optional[str] = OMIT,
|
|
657
|
+
external_id: typing.Optional[str] = OMIT,
|
|
658
|
+
role_arn: typing.Optional[str] = OMIT,
|
|
659
|
+
region_name: typing.Optional[str] = OMIT,
|
|
660
|
+
s3endpoint: typing.Optional[str] = OMIT,
|
|
661
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
662
|
+
) -> S3SExportStorage:
|
|
663
|
+
"""
|
|
664
|
+
Update a specific S3 export storage connection. You will need to provide the export storage ID. You can find this using [List export storages](list).
|
|
665
|
+
|
|
666
|
+
Parameters
|
|
667
|
+
----------
|
|
668
|
+
id : int
|
|
669
|
+
Export storage ID
|
|
670
|
+
|
|
671
|
+
can_delete_objects : typing.Optional[bool]
|
|
672
|
+
Deletion from storage enabled.
|
|
673
|
+
|
|
674
|
+
title : typing.Optional[str]
|
|
675
|
+
Storage title
|
|
676
|
+
|
|
677
|
+
description : typing.Optional[str]
|
|
678
|
+
Storage description
|
|
679
|
+
|
|
680
|
+
project : typing.Optional[int]
|
|
681
|
+
Project ID
|
|
682
|
+
|
|
683
|
+
bucket : typing.Optional[str]
|
|
684
|
+
S3 bucket name
|
|
685
|
+
|
|
686
|
+
prefix : typing.Optional[str]
|
|
687
|
+
S3 bucket prefix
|
|
688
|
+
|
|
689
|
+
external_id : typing.Optional[str]
|
|
690
|
+
AWS External ID
|
|
691
|
+
|
|
692
|
+
role_arn : typing.Optional[str]
|
|
693
|
+
AWS Role ARN
|
|
694
|
+
|
|
695
|
+
region_name : typing.Optional[str]
|
|
696
|
+
AWS Region
|
|
697
|
+
|
|
698
|
+
s3endpoint : typing.Optional[str]
|
|
699
|
+
S3 Endpoint
|
|
700
|
+
|
|
701
|
+
request_options : typing.Optional[RequestOptions]
|
|
702
|
+
Request-specific configuration.
|
|
703
|
+
|
|
704
|
+
Returns
|
|
705
|
+
-------
|
|
706
|
+
S3SExportStorage
|
|
707
|
+
|
|
708
|
+
|
|
709
|
+
Examples
|
|
710
|
+
--------
|
|
711
|
+
from label_studio_sdk.client import AsyncLabelStudio
|
|
712
|
+
|
|
713
|
+
client = AsyncLabelStudio(
|
|
714
|
+
api_key="YOUR_API_KEY",
|
|
715
|
+
)
|
|
716
|
+
await client.export_storage.s3s.update(
|
|
717
|
+
id=1,
|
|
718
|
+
)
|
|
719
|
+
"""
|
|
720
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
721
|
+
f"api/storages/export/s3s/{jsonable_encoder(id)}",
|
|
722
|
+
method="PATCH",
|
|
723
|
+
json={
|
|
724
|
+
"can_delete_objects": can_delete_objects,
|
|
725
|
+
"title": title,
|
|
726
|
+
"description": description,
|
|
727
|
+
"project": project,
|
|
728
|
+
"bucket": bucket,
|
|
729
|
+
"prefix": prefix,
|
|
730
|
+
"external_id": external_id,
|
|
731
|
+
"role_arn": role_arn,
|
|
732
|
+
"region_name": region_name,
|
|
733
|
+
"s3_endpoint": s3endpoint,
|
|
734
|
+
},
|
|
735
|
+
request_options=request_options,
|
|
736
|
+
omit=OMIT,
|
|
737
|
+
)
|
|
738
|
+
try:
|
|
739
|
+
if 200 <= _response.status_code < 300:
|
|
740
|
+
return pydantic_v1.parse_obj_as(S3SExportStorage, _response.json()) # type: ignore
|
|
741
|
+
_response_json = _response.json()
|
|
742
|
+
except JSONDecodeError:
|
|
743
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
744
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
745
|
+
|
|
746
|
+
async def validate(
|
|
747
|
+
self,
|
|
748
|
+
*,
|
|
749
|
+
can_delete_objects: typing.Optional[bool] = OMIT,
|
|
750
|
+
title: typing.Optional[str] = OMIT,
|
|
751
|
+
description: typing.Optional[str] = OMIT,
|
|
752
|
+
project: typing.Optional[int] = OMIT,
|
|
753
|
+
bucket: typing.Optional[str] = OMIT,
|
|
754
|
+
prefix: typing.Optional[str] = OMIT,
|
|
755
|
+
external_id: typing.Optional[str] = OMIT,
|
|
756
|
+
role_arn: typing.Optional[str] = OMIT,
|
|
757
|
+
region_name: typing.Optional[str] = OMIT,
|
|
758
|
+
s3endpoint: typing.Optional[str] = OMIT,
|
|
759
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
760
|
+
) -> None:
|
|
761
|
+
"""
|
|
762
|
+
Validate a specific S3 export storage connection. This is useful to ensure that the storage configuration settings are correct and operational before attempting to export data.
|
|
763
|
+
|
|
764
|
+
Parameters
|
|
765
|
+
----------
|
|
766
|
+
can_delete_objects : typing.Optional[bool]
|
|
767
|
+
Deletion from storage enabled.
|
|
768
|
+
|
|
769
|
+
title : typing.Optional[str]
|
|
770
|
+
Storage title
|
|
771
|
+
|
|
772
|
+
description : typing.Optional[str]
|
|
773
|
+
Storage description
|
|
774
|
+
|
|
775
|
+
project : typing.Optional[int]
|
|
776
|
+
Project ID
|
|
777
|
+
|
|
778
|
+
bucket : typing.Optional[str]
|
|
779
|
+
S3 bucket name
|
|
780
|
+
|
|
781
|
+
prefix : typing.Optional[str]
|
|
782
|
+
S3 bucket prefix
|
|
783
|
+
|
|
784
|
+
external_id : typing.Optional[str]
|
|
785
|
+
AWS External ID
|
|
786
|
+
|
|
787
|
+
role_arn : typing.Optional[str]
|
|
788
|
+
AWS Role ARN
|
|
789
|
+
|
|
790
|
+
region_name : typing.Optional[str]
|
|
791
|
+
AWS Region
|
|
792
|
+
|
|
793
|
+
s3endpoint : typing.Optional[str]
|
|
794
|
+
S3 Endpoint
|
|
795
|
+
|
|
796
|
+
request_options : typing.Optional[RequestOptions]
|
|
797
|
+
Request-specific configuration.
|
|
798
|
+
|
|
799
|
+
Returns
|
|
800
|
+
-------
|
|
801
|
+
None
|
|
802
|
+
|
|
803
|
+
Examples
|
|
804
|
+
--------
|
|
805
|
+
from label_studio_sdk.client import AsyncLabelStudio
|
|
806
|
+
|
|
807
|
+
client = AsyncLabelStudio(
|
|
808
|
+
api_key="YOUR_API_KEY",
|
|
809
|
+
)
|
|
810
|
+
await client.export_storage.s3s.validate()
|
|
811
|
+
"""
|
|
812
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
813
|
+
"api/storages/export/s3s/validate",
|
|
814
|
+
method="POST",
|
|
815
|
+
json={
|
|
816
|
+
"can_delete_objects": can_delete_objects,
|
|
817
|
+
"title": title,
|
|
818
|
+
"description": description,
|
|
819
|
+
"project": project,
|
|
820
|
+
"bucket": bucket,
|
|
821
|
+
"prefix": prefix,
|
|
822
|
+
"external_id": external_id,
|
|
823
|
+
"role_arn": role_arn,
|
|
824
|
+
"region_name": region_name,
|
|
825
|
+
"s3_endpoint": s3endpoint,
|
|
826
|
+
},
|
|
827
|
+
request_options=request_options,
|
|
828
|
+
omit=OMIT,
|
|
829
|
+
)
|
|
830
|
+
try:
|
|
831
|
+
if 200 <= _response.status_code < 300:
|
|
832
|
+
return
|
|
833
|
+
_response_json = _response.json()
|
|
834
|
+
except JSONDecodeError:
|
|
835
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
836
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|