label-studio-sdk 0.0.34__py3-none-any.whl → 1.0.1__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 (272) hide show
  1. label_studio_sdk/__init__.py +232 -9
  2. label_studio_sdk/_extensions/label_studio_tools/__init__.py +0 -0
  3. label_studio_sdk/_extensions/label_studio_tools/core/__init__.py +0 -0
  4. label_studio_sdk/_extensions/label_studio_tools/core/label_config.py +163 -0
  5. label_studio_sdk/_extensions/label_studio_tools/core/utils/__init__.py +0 -0
  6. label_studio_sdk/_extensions/label_studio_tools/core/utils/exceptions.py +2 -0
  7. label_studio_sdk/_extensions/label_studio_tools/core/utils/io.py +228 -0
  8. label_studio_sdk/_extensions/label_studio_tools/core/utils/params.py +45 -0
  9. label_studio_sdk/_extensions/label_studio_tools/etl/__init__.py +1 -0
  10. label_studio_sdk/_extensions/label_studio_tools/etl/beam.py +34 -0
  11. label_studio_sdk/_extensions/label_studio_tools/etl/example.py +17 -0
  12. label_studio_sdk/_extensions/label_studio_tools/etl/registry.py +67 -0
  13. label_studio_sdk/_extensions/label_studio_tools/postprocessing/__init__.py +0 -0
  14. label_studio_sdk/_extensions/label_studio_tools/postprocessing/video.py +97 -0
  15. label_studio_sdk/_extensions/pager_ext.py +49 -0
  16. label_studio_sdk/_legacy/__init__.py +11 -0
  17. label_studio_sdk/_legacy/client.py +471 -0
  18. label_studio_sdk/_legacy/objects.py +74 -0
  19. label_studio_sdk/{project.py → _legacy/project.py} +2 -2
  20. label_studio_sdk/{schema → _legacy/schema}/label_config_schema.json +14 -14
  21. label_studio_sdk/actions/__init__.py +27 -0
  22. label_studio_sdk/actions/client.py +223 -0
  23. label_studio_sdk/actions/types/__init__.py +25 -0
  24. label_studio_sdk/actions/types/actions_create_request_filters.py +43 -0
  25. label_studio_sdk/actions/types/actions_create_request_filters_conjunction.py +5 -0
  26. label_studio_sdk/actions/types/actions_create_request_filters_items_item.py +49 -0
  27. label_studio_sdk/actions/types/actions_create_request_filters_items_item_filter.py +31 -0
  28. label_studio_sdk/actions/types/actions_create_request_filters_items_item_operator.py +23 -0
  29. label_studio_sdk/actions/types/actions_create_request_id.py +19 -0
  30. label_studio_sdk/actions/types/actions_create_request_ordering_item.py +31 -0
  31. label_studio_sdk/actions/types/actions_create_request_selected_items.py +10 -0
  32. label_studio_sdk/actions/types/actions_create_request_selected_items_excluded.py +39 -0
  33. label_studio_sdk/actions/types/actions_create_request_selected_items_included.py +39 -0
  34. label_studio_sdk/annotations/__init__.py +2 -0
  35. label_studio_sdk/annotations/client.py +750 -0
  36. label_studio_sdk/base_client.py +183 -0
  37. label_studio_sdk/client.py +17 -463
  38. label_studio_sdk/converter/__init__.py +7 -0
  39. label_studio_sdk/converter/audio.py +56 -0
  40. label_studio_sdk/converter/brush.py +452 -0
  41. label_studio_sdk/converter/converter.py +1175 -0
  42. label_studio_sdk/converter/exports/__init__.py +0 -0
  43. label_studio_sdk/converter/exports/csv.py +82 -0
  44. label_studio_sdk/converter/exports/csv2.py +103 -0
  45. label_studio_sdk/converter/funsd.py +85 -0
  46. label_studio_sdk/converter/imports/__init__.py +0 -0
  47. label_studio_sdk/converter/imports/coco.py +314 -0
  48. label_studio_sdk/converter/imports/colors.py +198 -0
  49. label_studio_sdk/converter/imports/label_config.py +45 -0
  50. label_studio_sdk/converter/imports/pathtrack.py +269 -0
  51. label_studio_sdk/converter/imports/yolo.py +236 -0
  52. label_studio_sdk/converter/main.py +202 -0
  53. label_studio_sdk/converter/utils.py +473 -0
  54. label_studio_sdk/core/__init__.py +33 -0
  55. label_studio_sdk/core/api_error.py +15 -0
  56. label_studio_sdk/core/client_wrapper.py +55 -0
  57. label_studio_sdk/core/datetime_utils.py +28 -0
  58. label_studio_sdk/core/file.py +38 -0
  59. label_studio_sdk/core/http_client.py +447 -0
  60. label_studio_sdk/core/jsonable_encoder.py +99 -0
  61. label_studio_sdk/core/pagination.py +87 -0
  62. label_studio_sdk/core/pydantic_utilities.py +28 -0
  63. label_studio_sdk/core/query_encoder.py +33 -0
  64. label_studio_sdk/core/remove_none_from_dict.py +11 -0
  65. label_studio_sdk/core/request_options.py +32 -0
  66. label_studio_sdk/environment.py +7 -0
  67. label_studio_sdk/errors/__init__.py +6 -0
  68. label_studio_sdk/errors/bad_request_error.py +8 -0
  69. label_studio_sdk/errors/internal_server_error.py +8 -0
  70. label_studio_sdk/export_storage/__init__.py +28 -0
  71. label_studio_sdk/export_storage/azure/__init__.py +5 -0
  72. label_studio_sdk/export_storage/azure/client.py +888 -0
  73. label_studio_sdk/export_storage/azure/types/__init__.py +6 -0
  74. label_studio_sdk/export_storage/azure/types/azure_create_response.py +67 -0
  75. label_studio_sdk/export_storage/azure/types/azure_update_response.py +67 -0
  76. label_studio_sdk/export_storage/client.py +107 -0
  77. label_studio_sdk/export_storage/gcs/__init__.py +5 -0
  78. label_studio_sdk/export_storage/gcs/client.py +888 -0
  79. label_studio_sdk/export_storage/gcs/types/__init__.py +6 -0
  80. label_studio_sdk/export_storage/gcs/types/gcs_create_response.py +67 -0
  81. label_studio_sdk/export_storage/gcs/types/gcs_update_response.py +67 -0
  82. label_studio_sdk/export_storage/local/__init__.py +5 -0
  83. label_studio_sdk/export_storage/local/client.py +834 -0
  84. label_studio_sdk/export_storage/local/types/__init__.py +6 -0
  85. label_studio_sdk/export_storage/local/types/local_create_response.py +57 -0
  86. label_studio_sdk/export_storage/local/types/local_update_response.py +57 -0
  87. label_studio_sdk/export_storage/redis/__init__.py +5 -0
  88. label_studio_sdk/export_storage/redis/client.py +918 -0
  89. label_studio_sdk/export_storage/redis/types/__init__.py +6 -0
  90. label_studio_sdk/export_storage/redis/types/redis_create_response.py +72 -0
  91. label_studio_sdk/export_storage/redis/types/redis_update_response.py +72 -0
  92. label_studio_sdk/export_storage/s3/__init__.py +5 -0
  93. label_studio_sdk/export_storage/s3/client.py +1008 -0
  94. label_studio_sdk/export_storage/s3/types/__init__.py +6 -0
  95. label_studio_sdk/export_storage/s3/types/s3create_response.py +89 -0
  96. label_studio_sdk/export_storage/s3/types/s3update_response.py +89 -0
  97. label_studio_sdk/export_storage/types/__init__.py +5 -0
  98. label_studio_sdk/export_storage/types/export_storage_list_types_response_item.py +30 -0
  99. label_studio_sdk/files/__init__.py +2 -0
  100. label_studio_sdk/files/client.py +556 -0
  101. label_studio_sdk/import_storage/__init__.py +28 -0
  102. label_studio_sdk/import_storage/azure/__init__.py +5 -0
  103. label_studio_sdk/import_storage/azure/client.py +988 -0
  104. label_studio_sdk/import_storage/azure/types/__init__.py +6 -0
  105. label_studio_sdk/import_storage/azure/types/azure_create_response.py +82 -0
  106. label_studio_sdk/import_storage/azure/types/azure_update_response.py +82 -0
  107. label_studio_sdk/import_storage/client.py +107 -0
  108. label_studio_sdk/import_storage/gcs/__init__.py +5 -0
  109. label_studio_sdk/import_storage/gcs/client.py +988 -0
  110. label_studio_sdk/import_storage/gcs/types/__init__.py +6 -0
  111. label_studio_sdk/import_storage/gcs/types/gcs_create_response.py +82 -0
  112. label_studio_sdk/import_storage/gcs/types/gcs_update_response.py +82 -0
  113. label_studio_sdk/import_storage/local/__init__.py +5 -0
  114. label_studio_sdk/import_storage/local/client.py +836 -0
  115. label_studio_sdk/import_storage/local/types/__init__.py +6 -0
  116. label_studio_sdk/import_storage/local/types/local_create_response.py +57 -0
  117. label_studio_sdk/import_storage/local/types/local_update_response.py +57 -0
  118. label_studio_sdk/import_storage/redis/__init__.py +5 -0
  119. label_studio_sdk/import_storage/redis/client.py +924 -0
  120. label_studio_sdk/import_storage/redis/types/__init__.py +6 -0
  121. label_studio_sdk/import_storage/redis/types/redis_create_response.py +72 -0
  122. label_studio_sdk/import_storage/redis/types/redis_update_response.py +72 -0
  123. label_studio_sdk/import_storage/s3/__init__.py +5 -0
  124. label_studio_sdk/import_storage/s3/client.py +1138 -0
  125. label_studio_sdk/import_storage/s3/types/__init__.py +6 -0
  126. label_studio_sdk/import_storage/s3/types/s3create_response.py +109 -0
  127. label_studio_sdk/import_storage/s3/types/s3update_response.py +109 -0
  128. label_studio_sdk/import_storage/types/__init__.py +5 -0
  129. label_studio_sdk/import_storage/types/import_storage_list_types_response_item.py +30 -0
  130. label_studio_sdk/label_interface/base.py +10 -0
  131. label_studio_sdk/label_interface/control_tags.py +109 -71
  132. label_studio_sdk/label_interface/data_examples.json +96 -0
  133. label_studio_sdk/label_interface/interface.py +102 -53
  134. label_studio_sdk/label_interface/object_tags.py +8 -13
  135. label_studio_sdk/label_interface/region.py +33 -1
  136. label_studio_sdk/ml/__init__.py +19 -0
  137. label_studio_sdk/ml/client.py +981 -0
  138. label_studio_sdk/ml/types/__init__.py +17 -0
  139. label_studio_sdk/ml/types/ml_create_request_auth_method.py +5 -0
  140. label_studio_sdk/ml/types/ml_create_response.py +78 -0
  141. label_studio_sdk/ml/types/ml_create_response_auth_method.py +5 -0
  142. label_studio_sdk/ml/types/ml_update_request_auth_method.py +5 -0
  143. label_studio_sdk/ml/types/ml_update_response.py +78 -0
  144. label_studio_sdk/ml/types/ml_update_response_auth_method.py +5 -0
  145. label_studio_sdk/predictions/__init__.py +2 -0
  146. label_studio_sdk/predictions/client.py +638 -0
  147. label_studio_sdk/projects/__init__.py +6 -0
  148. label_studio_sdk/projects/client.py +1055 -0
  149. label_studio_sdk/projects/client_ext.py +19 -0
  150. label_studio_sdk/projects/exports/__init__.py +2 -0
  151. label_studio_sdk/projects/exports/client.py +930 -0
  152. label_studio_sdk/projects/types/__init__.py +7 -0
  153. label_studio_sdk/projects/types/projects_create_response.py +96 -0
  154. label_studio_sdk/projects/types/projects_import_tasks_response.py +71 -0
  155. label_studio_sdk/projects/types/projects_list_response.py +33 -0
  156. label_studio_sdk/py.typed +0 -0
  157. label_studio_sdk/tasks/__init__.py +5 -0
  158. label_studio_sdk/tasks/client.py +835 -0
  159. label_studio_sdk/tasks/client_ext.py +18 -0
  160. label_studio_sdk/tasks/types/__init__.py +6 -0
  161. label_studio_sdk/tasks/types/tasks_list_request_fields.py +5 -0
  162. label_studio_sdk/tasks/types/tasks_list_response.py +48 -0
  163. label_studio_sdk/types/__init__.py +115 -0
  164. label_studio_sdk/types/annotation.py +116 -0
  165. label_studio_sdk/types/annotation_filter_options.py +42 -0
  166. label_studio_sdk/types/annotation_last_action.py +19 -0
  167. label_studio_sdk/types/azure_blob_export_storage.py +112 -0
  168. label_studio_sdk/types/azure_blob_export_storage_status.py +7 -0
  169. label_studio_sdk/types/azure_blob_import_storage.py +113 -0
  170. label_studio_sdk/types/azure_blob_import_storage_status.py +7 -0
  171. label_studio_sdk/types/base_task.py +113 -0
  172. label_studio_sdk/types/base_user.py +42 -0
  173. label_studio_sdk/types/converted_format.py +36 -0
  174. label_studio_sdk/types/converted_format_status.py +5 -0
  175. label_studio_sdk/types/export.py +48 -0
  176. label_studio_sdk/types/export_convert.py +32 -0
  177. label_studio_sdk/types/export_create.py +54 -0
  178. label_studio_sdk/types/export_create_status.py +5 -0
  179. label_studio_sdk/types/export_status.py +5 -0
  180. label_studio_sdk/types/file_upload.py +30 -0
  181. label_studio_sdk/types/filter.py +53 -0
  182. label_studio_sdk/types/filter_group.py +35 -0
  183. label_studio_sdk/types/gcs_export_storage.py +112 -0
  184. label_studio_sdk/types/gcs_export_storage_status.py +7 -0
  185. label_studio_sdk/types/gcs_import_storage.py +113 -0
  186. label_studio_sdk/types/gcs_import_storage_status.py +7 -0
  187. label_studio_sdk/types/local_files_export_storage.py +97 -0
  188. label_studio_sdk/types/local_files_export_storage_status.py +7 -0
  189. label_studio_sdk/types/local_files_import_storage.py +92 -0
  190. label_studio_sdk/types/local_files_import_storage_status.py +7 -0
  191. label_studio_sdk/types/ml_backend.py +89 -0
  192. label_studio_sdk/types/ml_backend_auth_method.py +5 -0
  193. label_studio_sdk/types/ml_backend_state.py +5 -0
  194. label_studio_sdk/types/prediction.py +78 -0
  195. label_studio_sdk/types/project.py +198 -0
  196. label_studio_sdk/types/project_import.py +63 -0
  197. label_studio_sdk/types/project_import_status.py +5 -0
  198. label_studio_sdk/types/project_label_config.py +32 -0
  199. label_studio_sdk/types/project_sampling.py +7 -0
  200. label_studio_sdk/types/project_skip_queue.py +5 -0
  201. label_studio_sdk/types/redis_export_storage.py +117 -0
  202. label_studio_sdk/types/redis_export_storage_status.py +7 -0
  203. label_studio_sdk/types/redis_import_storage.py +112 -0
  204. label_studio_sdk/types/redis_import_storage_status.py +7 -0
  205. label_studio_sdk/types/s3export_storage.py +134 -0
  206. label_studio_sdk/types/s3export_storage_status.py +7 -0
  207. label_studio_sdk/types/s3import_storage.py +140 -0
  208. label_studio_sdk/types/s3import_storage_status.py +7 -0
  209. label_studio_sdk/types/serialization_option.py +36 -0
  210. label_studio_sdk/types/serialization_options.py +45 -0
  211. label_studio_sdk/types/task.py +157 -0
  212. label_studio_sdk/types/task_filter_options.py +49 -0
  213. label_studio_sdk/types/user_simple.py +37 -0
  214. label_studio_sdk/types/view.py +55 -0
  215. label_studio_sdk/types/webhook.py +67 -0
  216. label_studio_sdk/types/webhook_actions_item.py +21 -0
  217. label_studio_sdk/types/webhook_serializer_for_update.py +67 -0
  218. label_studio_sdk/types/webhook_serializer_for_update_actions_item.py +21 -0
  219. label_studio_sdk/users/__init__.py +5 -0
  220. label_studio_sdk/users/client.py +830 -0
  221. label_studio_sdk/users/types/__init__.py +6 -0
  222. label_studio_sdk/users/types/users_get_token_response.py +36 -0
  223. label_studio_sdk/users/types/users_reset_token_response.py +36 -0
  224. label_studio_sdk/version.py +4 -0
  225. label_studio_sdk/views/__init__.py +35 -0
  226. label_studio_sdk/views/client.py +564 -0
  227. label_studio_sdk/views/types/__init__.py +33 -0
  228. label_studio_sdk/views/types/views_create_request_data.py +43 -0
  229. label_studio_sdk/views/types/views_create_request_data_filters.py +43 -0
  230. label_studio_sdk/views/types/views_create_request_data_filters_conjunction.py +5 -0
  231. label_studio_sdk/views/types/views_create_request_data_filters_items_item.py +49 -0
  232. label_studio_sdk/views/types/views_create_request_data_filters_items_item_filter.py +31 -0
  233. label_studio_sdk/views/types/views_create_request_data_filters_items_item_operator.py +23 -0
  234. label_studio_sdk/views/types/views_create_request_data_ordering_item.py +31 -0
  235. label_studio_sdk/views/types/views_update_request_data.py +43 -0
  236. label_studio_sdk/views/types/views_update_request_data_filters.py +43 -0
  237. label_studio_sdk/views/types/views_update_request_data_filters_conjunction.py +5 -0
  238. label_studio_sdk/views/types/views_update_request_data_filters_items_item.py +49 -0
  239. label_studio_sdk/views/types/views_update_request_data_filters_items_item_filter.py +31 -0
  240. label_studio_sdk/views/types/views_update_request_data_filters_items_item_operator.py +23 -0
  241. label_studio_sdk/views/types/views_update_request_data_ordering_item.py +31 -0
  242. label_studio_sdk/webhooks/__init__.py +5 -0
  243. label_studio_sdk/webhooks/client.py +636 -0
  244. label_studio_sdk/webhooks/types/__init__.py +5 -0
  245. label_studio_sdk/webhooks/types/webhooks_update_request_actions_item.py +21 -0
  246. label_studio_sdk-1.0.1.dist-info/METADATA +163 -0
  247. label_studio_sdk-1.0.1.dist-info/RECORD +256 -0
  248. {label_studio_sdk-0.0.34.dist-info → label_studio_sdk-1.0.1.dist-info}/WHEEL +1 -2
  249. label_studio_sdk/objects.py +0 -35
  250. label_studio_sdk-0.0.34.dist-info/LICENSE +0 -201
  251. label_studio_sdk-0.0.34.dist-info/METADATA +0 -24
  252. label_studio_sdk-0.0.34.dist-info/RECORD +0 -37
  253. label_studio_sdk-0.0.34.dist-info/top_level.txt +0 -2
  254. tests/test_client.py +0 -37
  255. tests/test_export.py +0 -105
  256. tests/test_interface/__init__.py +0 -1
  257. tests/test_interface/configs.py +0 -137
  258. tests/test_interface/mockups.py +0 -22
  259. tests/test_interface/test_compat.py +0 -64
  260. tests/test_interface/test_control_tags.py +0 -55
  261. tests/test_interface/test_data_generation.py +0 -45
  262. tests/test_interface/test_lpi.py +0 -15
  263. tests/test_interface/test_main.py +0 -196
  264. tests/test_interface/test_object_tags.py +0 -36
  265. tests/test_interface/test_region.py +0 -36
  266. tests/test_interface/test_validate_summary.py +0 -35
  267. tests/test_interface/test_validation.py +0 -59
  268. {tests → label_studio_sdk/_extensions}/__init__.py +0 -0
  269. /label_studio_sdk/{exceptions.py → _legacy/exceptions.py} +0 -0
  270. /label_studio_sdk/{users.py → _legacy/users.py} +0 -0
  271. /label_studio_sdk/{utils.py → _legacy/utils.py} +0 -0
  272. /label_studio_sdk/{workspaces.py → _legacy/workspaces.py} +0 -0
@@ -0,0 +1,1138 @@
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.s3import_storage import S3ImportStorage
12
+ from .types.s3create_response import S3CreateResponse
13
+ from .types.s3update_response import S3UpdateResponse
14
+
15
+ # this is used as the default value for optional parameters
16
+ OMIT = typing.cast(typing.Any, ...)
17
+
18
+
19
+ class S3Client:
20
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
21
+ self._client_wrapper = client_wrapper
22
+
23
+ def list(
24
+ self, *, project: typing.Optional[int] = None, request_options: typing.Optional[RequestOptions] = None
25
+ ) -> typing.List[S3ImportStorage]:
26
+ """
27
+ 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 Google import (source) storage connections for a specific project.
28
+
29
+ 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).
30
+
31
+ For more information about working with external storage, see [Sync data from external storage](https://labelstud.io/guide/storage).
32
+
33
+ Parameters
34
+ ----------
35
+ project : typing.Optional[int]
36
+ Project ID
37
+
38
+ request_options : typing.Optional[RequestOptions]
39
+ Request-specific configuration.
40
+
41
+ Returns
42
+ -------
43
+ typing.List[S3ImportStorage]
44
+
45
+
46
+ Examples
47
+ --------
48
+ from label_studio_sdk.client import LabelStudio
49
+
50
+ client = LabelStudio(
51
+ api_key="YOUR_API_KEY",
52
+ )
53
+ client.import_storage.s3.list()
54
+ """
55
+ _response = self._client_wrapper.httpx_client.request(
56
+ "api/storages/s3/", method="GET", params={"project": project}, request_options=request_options
57
+ )
58
+ if 200 <= _response.status_code < 300:
59
+ return pydantic_v1.parse_obj_as(typing.List[S3ImportStorage], _response.json()) # type: ignore
60
+ try:
61
+ _response_json = _response.json()
62
+ except JSONDecodeError:
63
+ raise ApiError(status_code=_response.status_code, body=_response.text)
64
+ raise ApiError(status_code=_response.status_code, body=_response_json)
65
+
66
+ def create(
67
+ self,
68
+ *,
69
+ regex_filter: typing.Optional[str] = OMIT,
70
+ use_blob_urls: typing.Optional[bool] = OMIT,
71
+ presign: typing.Optional[bool] = OMIT,
72
+ presign_ttl: typing.Optional[int] = OMIT,
73
+ recursive_scan: typing.Optional[bool] = OMIT,
74
+ title: typing.Optional[str] = OMIT,
75
+ description: typing.Optional[str] = OMIT,
76
+ project: typing.Optional[int] = OMIT,
77
+ bucket: typing.Optional[str] = OMIT,
78
+ prefix: typing.Optional[str] = OMIT,
79
+ aws_access_key_id: typing.Optional[str] = OMIT,
80
+ aws_secret_access_key: typing.Optional[str] = OMIT,
81
+ aws_session_token: typing.Optional[str] = OMIT,
82
+ aws_sse_kms_key_id: typing.Optional[str] = OMIT,
83
+ region_name: typing.Optional[str] = OMIT,
84
+ s3endpoint: typing.Optional[str] = OMIT,
85
+ request_options: typing.Optional[RequestOptions] = None,
86
+ ) -> S3CreateResponse:
87
+ """
88
+ Create a new source storage connection to a S3 bucket.
89
+
90
+ For information about the required fields and prerequisites, see [Amazon S3](https://labelstud.io/guide/storage#Amazon-S3) in the Label Studio documentation.
91
+
92
+ <Info>Ensure you configure CORS before adding cloud storage. This ensures you will be able to see the content of the data rather than just a link.</Info>
93
+
94
+ <Tip>After you add the storage, you should validate the connection before attempting to sync your data. Your data will not be imported until you [sync your connection](sync).</Tip>
95
+
96
+ Parameters
97
+ ----------
98
+ regex_filter : typing.Optional[str]
99
+ Cloud storage regex for filtering objects. You must specify it otherwise no objects will be imported.
100
+
101
+ use_blob_urls : typing.Optional[bool]
102
+ Interpret objects as BLOBs and generate URLs. For example, if your bucket contains images, you can use this option to generate URLs for these images. If set to False, it will read the content of the file and load it into Label Studio.
103
+
104
+ presign : typing.Optional[bool]
105
+ Presign URLs for download
106
+
107
+ presign_ttl : typing.Optional[int]
108
+ Presign TTL in minutes
109
+
110
+ recursive_scan : typing.Optional[bool]
111
+ Scan recursively
112
+
113
+ title : typing.Optional[str]
114
+ Storage title
115
+
116
+ description : typing.Optional[str]
117
+ Storage description
118
+
119
+ project : typing.Optional[int]
120
+ Project ID
121
+
122
+ bucket : typing.Optional[str]
123
+ S3 bucket name
124
+
125
+ prefix : typing.Optional[str]
126
+ S3 bucket prefix
127
+
128
+ aws_access_key_id : typing.Optional[str]
129
+ AWS_ACCESS_KEY_ID
130
+
131
+ aws_secret_access_key : typing.Optional[str]
132
+ AWS_SECRET_ACCESS_KEY
133
+
134
+ aws_session_token : typing.Optional[str]
135
+ AWS_SESSION_TOKEN
136
+
137
+ aws_sse_kms_key_id : typing.Optional[str]
138
+ AWS SSE KMS Key ID
139
+
140
+ region_name : typing.Optional[str]
141
+ AWS Region
142
+
143
+ s3endpoint : typing.Optional[str]
144
+ S3 Endpoint
145
+
146
+ request_options : typing.Optional[RequestOptions]
147
+ Request-specific configuration.
148
+
149
+ Returns
150
+ -------
151
+ S3CreateResponse
152
+
153
+
154
+ Examples
155
+ --------
156
+ from label_studio_sdk.client import LabelStudio
157
+
158
+ client = LabelStudio(
159
+ api_key="YOUR_API_KEY",
160
+ )
161
+ client.import_storage.s3.create()
162
+ """
163
+ _response = self._client_wrapper.httpx_client.request(
164
+ "api/storages/s3/",
165
+ method="POST",
166
+ json={
167
+ "regex_filter": regex_filter,
168
+ "use_blob_urls": use_blob_urls,
169
+ "presign": presign,
170
+ "presign_ttl": presign_ttl,
171
+ "recursive_scan": recursive_scan,
172
+ "title": title,
173
+ "description": description,
174
+ "project": project,
175
+ "bucket": bucket,
176
+ "prefix": prefix,
177
+ "aws_access_key_id": aws_access_key_id,
178
+ "aws_secret_access_key": aws_secret_access_key,
179
+ "aws_session_token": aws_session_token,
180
+ "aws_sse_kms_key_id": aws_sse_kms_key_id,
181
+ "region_name": region_name,
182
+ "s3_endpoint": s3endpoint,
183
+ },
184
+ request_options=request_options,
185
+ omit=OMIT,
186
+ )
187
+ if 200 <= _response.status_code < 300:
188
+ return pydantic_v1.parse_obj_as(S3CreateResponse, _response.json()) # type: ignore
189
+ try:
190
+ _response_json = _response.json()
191
+ except JSONDecodeError:
192
+ raise ApiError(status_code=_response.status_code, body=_response.text)
193
+ raise ApiError(status_code=_response.status_code, body=_response_json)
194
+
195
+ def validate(
196
+ self,
197
+ *,
198
+ id: typing.Optional[int] = OMIT,
199
+ regex_filter: typing.Optional[str] = OMIT,
200
+ use_blob_urls: typing.Optional[bool] = OMIT,
201
+ presign: typing.Optional[bool] = OMIT,
202
+ presign_ttl: typing.Optional[int] = OMIT,
203
+ recursive_scan: typing.Optional[bool] = OMIT,
204
+ title: typing.Optional[str] = OMIT,
205
+ description: typing.Optional[str] = OMIT,
206
+ project: typing.Optional[int] = OMIT,
207
+ bucket: typing.Optional[str] = OMIT,
208
+ prefix: typing.Optional[str] = OMIT,
209
+ aws_access_key_id: typing.Optional[str] = OMIT,
210
+ aws_secret_access_key: typing.Optional[str] = OMIT,
211
+ aws_session_token: typing.Optional[str] = OMIT,
212
+ aws_sse_kms_key_id: typing.Optional[str] = OMIT,
213
+ region_name: typing.Optional[str] = OMIT,
214
+ s3endpoint: typing.Optional[str] = OMIT,
215
+ request_options: typing.Optional[RequestOptions] = None,
216
+ ) -> None:
217
+ """
218
+ Validate a specific S3 import storage connection. This is useful to ensure that the storage configuration settings are correct and operational before attempting to import data.
219
+
220
+ Parameters
221
+ ----------
222
+ id : typing.Optional[int]
223
+ Storage ID. If set, storage with specified ID will be updated
224
+
225
+ regex_filter : typing.Optional[str]
226
+ Cloud storage regex for filtering objects. You must specify it otherwise no objects will be imported.
227
+
228
+ use_blob_urls : typing.Optional[bool]
229
+ Interpret objects as BLOBs and generate URLs. For example, if your bucket contains images, you can use this option to generate URLs for these images. If set to False, it will read the content of the file and load it into Label Studio.
230
+
231
+ presign : typing.Optional[bool]
232
+ Presign URLs for download
233
+
234
+ presign_ttl : typing.Optional[int]
235
+ Presign TTL in minutes
236
+
237
+ recursive_scan : typing.Optional[bool]
238
+ Scan recursively
239
+
240
+ title : typing.Optional[str]
241
+ Storage title
242
+
243
+ description : typing.Optional[str]
244
+ Storage description
245
+
246
+ project : typing.Optional[int]
247
+ Project ID
248
+
249
+ bucket : typing.Optional[str]
250
+ S3 bucket name
251
+
252
+ prefix : typing.Optional[str]
253
+ S3 bucket prefix
254
+
255
+ aws_access_key_id : typing.Optional[str]
256
+ AWS_ACCESS_KEY_ID
257
+
258
+ aws_secret_access_key : typing.Optional[str]
259
+ AWS_SECRET_ACCESS_KEY
260
+
261
+ aws_session_token : typing.Optional[str]
262
+ AWS_SESSION_TOKEN
263
+
264
+ aws_sse_kms_key_id : typing.Optional[str]
265
+ AWS SSE KMS Key ID
266
+
267
+ region_name : typing.Optional[str]
268
+ AWS Region
269
+
270
+ s3endpoint : typing.Optional[str]
271
+ S3 Endpoint
272
+
273
+ request_options : typing.Optional[RequestOptions]
274
+ Request-specific configuration.
275
+
276
+ Returns
277
+ -------
278
+ None
279
+
280
+ Examples
281
+ --------
282
+ from label_studio_sdk.client import LabelStudio
283
+
284
+ client = LabelStudio(
285
+ api_key="YOUR_API_KEY",
286
+ )
287
+ client.import_storage.s3.validate()
288
+ """
289
+ _response = self._client_wrapper.httpx_client.request(
290
+ "api/storages/s3/validate",
291
+ method="POST",
292
+ json={
293
+ "id": id,
294
+ "regex_filter": regex_filter,
295
+ "use_blob_urls": use_blob_urls,
296
+ "presign": presign,
297
+ "presign_ttl": presign_ttl,
298
+ "recursive_scan": recursive_scan,
299
+ "title": title,
300
+ "description": description,
301
+ "project": project,
302
+ "bucket": bucket,
303
+ "prefix": prefix,
304
+ "aws_access_key_id": aws_access_key_id,
305
+ "aws_secret_access_key": aws_secret_access_key,
306
+ "aws_session_token": aws_session_token,
307
+ "aws_sse_kms_key_id": aws_sse_kms_key_id,
308
+ "region_name": region_name,
309
+ "s3_endpoint": s3endpoint,
310
+ },
311
+ request_options=request_options,
312
+ omit=OMIT,
313
+ )
314
+ if 200 <= _response.status_code < 300:
315
+ return
316
+ try:
317
+ _response_json = _response.json()
318
+ except JSONDecodeError:
319
+ raise ApiError(status_code=_response.status_code, body=_response.text)
320
+ raise ApiError(status_code=_response.status_code, body=_response_json)
321
+
322
+ def get(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> S3ImportStorage:
323
+ """
324
+ Get a specific S3 import storage connection. You will need to provide the import storage ID. You can find this using [List import storages](list).
325
+
326
+ For more information about working with external storage, see [Sync data from external storage](https://labelstud.io/guide/storage).
327
+
328
+ Parameters
329
+ ----------
330
+ id : int
331
+ A unique integer value identifying this s3 import storage.
332
+
333
+ request_options : typing.Optional[RequestOptions]
334
+ Request-specific configuration.
335
+
336
+ Returns
337
+ -------
338
+ S3ImportStorage
339
+
340
+
341
+ Examples
342
+ --------
343
+ from label_studio_sdk.client import LabelStudio
344
+
345
+ client = LabelStudio(
346
+ api_key="YOUR_API_KEY",
347
+ )
348
+ client.import_storage.s3.get(
349
+ id=1,
350
+ )
351
+ """
352
+ _response = self._client_wrapper.httpx_client.request(
353
+ f"api/storages/s3/{jsonable_encoder(id)}", method="GET", request_options=request_options
354
+ )
355
+ if 200 <= _response.status_code < 300:
356
+ return pydantic_v1.parse_obj_as(S3ImportStorage, _response.json()) # type: ignore
357
+ try:
358
+ _response_json = _response.json()
359
+ except JSONDecodeError:
360
+ raise ApiError(status_code=_response.status_code, body=_response.text)
361
+ raise ApiError(status_code=_response.status_code, body=_response_json)
362
+
363
+ def delete(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> None:
364
+ """
365
+ Delete a specific S3 import storage connection. You will need to provide the import storage ID. You can find this using [List import storages](list).
366
+
367
+ Deleting a source storage connection does not affect tasks with synced data in Label Studio. The sync process is designed to import new or updated tasks from the connected storage into the project, but it does not track deletions of files from the storage. Therefore, if you remove the external storage connection, the tasks that were created from that storage will remain in the project.
368
+
369
+ If you want to remove the tasks that were synced from the external storage, you will need to delete them manually from within the Label Studio UI or use the [Delete tasks](../../tasks/delete-all-tasks) API.
370
+
371
+ Parameters
372
+ ----------
373
+ id : int
374
+ A unique integer value identifying this s3 import storage.
375
+
376
+ request_options : typing.Optional[RequestOptions]
377
+ Request-specific configuration.
378
+
379
+ Returns
380
+ -------
381
+ None
382
+
383
+ Examples
384
+ --------
385
+ from label_studio_sdk.client import LabelStudio
386
+
387
+ client = LabelStudio(
388
+ api_key="YOUR_API_KEY",
389
+ )
390
+ client.import_storage.s3.delete(
391
+ id=1,
392
+ )
393
+ """
394
+ _response = self._client_wrapper.httpx_client.request(
395
+ f"api/storages/s3/{jsonable_encoder(id)}", method="DELETE", request_options=request_options
396
+ )
397
+ if 200 <= _response.status_code < 300:
398
+ return
399
+ try:
400
+ _response_json = _response.json()
401
+ except JSONDecodeError:
402
+ raise ApiError(status_code=_response.status_code, body=_response.text)
403
+ raise ApiError(status_code=_response.status_code, body=_response_json)
404
+
405
+ def update(
406
+ self,
407
+ id: int,
408
+ *,
409
+ regex_filter: typing.Optional[str] = OMIT,
410
+ use_blob_urls: typing.Optional[bool] = OMIT,
411
+ presign: typing.Optional[bool] = OMIT,
412
+ presign_ttl: typing.Optional[int] = OMIT,
413
+ recursive_scan: typing.Optional[bool] = OMIT,
414
+ title: typing.Optional[str] = OMIT,
415
+ description: typing.Optional[str] = OMIT,
416
+ project: typing.Optional[int] = OMIT,
417
+ bucket: typing.Optional[str] = OMIT,
418
+ prefix: typing.Optional[str] = OMIT,
419
+ aws_access_key_id: typing.Optional[str] = OMIT,
420
+ aws_secret_access_key: typing.Optional[str] = OMIT,
421
+ aws_session_token: typing.Optional[str] = OMIT,
422
+ aws_sse_kms_key_id: typing.Optional[str] = OMIT,
423
+ region_name: typing.Optional[str] = OMIT,
424
+ s3endpoint: typing.Optional[str] = OMIT,
425
+ request_options: typing.Optional[RequestOptions] = None,
426
+ ) -> S3UpdateResponse:
427
+ """
428
+ Update a specific S3 import storage connection. You will need to provide the import storage ID. You can find this using [List import storages](list).
429
+
430
+ For more information about working with external storage, see [Sync data from external storage](https://labelstud.io/guide/storage).
431
+
432
+ Parameters
433
+ ----------
434
+ id : int
435
+ A unique integer value identifying this s3 import storage.
436
+
437
+ regex_filter : typing.Optional[str]
438
+ Cloud storage regex for filtering objects. You must specify it otherwise no objects will be imported.
439
+
440
+ use_blob_urls : typing.Optional[bool]
441
+ Interpret objects as BLOBs and generate URLs. For example, if your bucket contains images, you can use this option to generate URLs for these images. If set to False, it will read the content of the file and load it into Label Studio.
442
+
443
+ presign : typing.Optional[bool]
444
+ Presign URLs for download
445
+
446
+ presign_ttl : typing.Optional[int]
447
+ Presign TTL in minutes
448
+
449
+ recursive_scan : typing.Optional[bool]
450
+ Scan recursively
451
+
452
+ title : typing.Optional[str]
453
+ Storage title
454
+
455
+ description : typing.Optional[str]
456
+ Storage description
457
+
458
+ project : typing.Optional[int]
459
+ Project ID
460
+
461
+ bucket : typing.Optional[str]
462
+ S3 bucket name
463
+
464
+ prefix : typing.Optional[str]
465
+ S3 bucket prefix
466
+
467
+ aws_access_key_id : typing.Optional[str]
468
+ AWS_ACCESS_KEY_ID
469
+
470
+ aws_secret_access_key : typing.Optional[str]
471
+ AWS_SECRET_ACCESS_KEY
472
+
473
+ aws_session_token : typing.Optional[str]
474
+ AWS_SESSION_TOKEN
475
+
476
+ aws_sse_kms_key_id : typing.Optional[str]
477
+ AWS SSE KMS Key ID
478
+
479
+ region_name : typing.Optional[str]
480
+ AWS Region
481
+
482
+ s3endpoint : typing.Optional[str]
483
+ S3 Endpoint
484
+
485
+ request_options : typing.Optional[RequestOptions]
486
+ Request-specific configuration.
487
+
488
+ Returns
489
+ -------
490
+ S3UpdateResponse
491
+
492
+
493
+ Examples
494
+ --------
495
+ from label_studio_sdk.client import LabelStudio
496
+
497
+ client = LabelStudio(
498
+ api_key="YOUR_API_KEY",
499
+ )
500
+ client.import_storage.s3.update(
501
+ id=1,
502
+ )
503
+ """
504
+ _response = self._client_wrapper.httpx_client.request(
505
+ f"api/storages/s3/{jsonable_encoder(id)}",
506
+ method="PATCH",
507
+ json={
508
+ "regex_filter": regex_filter,
509
+ "use_blob_urls": use_blob_urls,
510
+ "presign": presign,
511
+ "presign_ttl": presign_ttl,
512
+ "recursive_scan": recursive_scan,
513
+ "title": title,
514
+ "description": description,
515
+ "project": project,
516
+ "bucket": bucket,
517
+ "prefix": prefix,
518
+ "aws_access_key_id": aws_access_key_id,
519
+ "aws_secret_access_key": aws_secret_access_key,
520
+ "aws_session_token": aws_session_token,
521
+ "aws_sse_kms_key_id": aws_sse_kms_key_id,
522
+ "region_name": region_name,
523
+ "s3_endpoint": s3endpoint,
524
+ },
525
+ request_options=request_options,
526
+ omit=OMIT,
527
+ )
528
+ if 200 <= _response.status_code < 300:
529
+ return pydantic_v1.parse_obj_as(S3UpdateResponse, _response.json()) # type: ignore
530
+ try:
531
+ _response_json = _response.json()
532
+ except JSONDecodeError:
533
+ raise ApiError(status_code=_response.status_code, body=_response.text)
534
+ raise ApiError(status_code=_response.status_code, body=_response_json)
535
+
536
+ def sync(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> S3ImportStorage:
537
+ """
538
+ Sync tasks from an S3 import storage connection. You will need to provide the import storage ID. You can find this using [List import storages](list).
539
+
540
+ Sync operations with external buckets only go one way. They either create tasks from objects in the bucket (source/import storage) or push annotations to the output bucket (export/target storage). Changing something on the bucket side doesn’t guarantee consistency in results.
541
+
542
+ <Note>Before proceeding, you should review [How sync operations work - Source storage](https://labelstud.io/guide/storage#Source-storage) to ensure that your data remains secure and private.</Note>
543
+
544
+ Parameters
545
+ ----------
546
+ id : int
547
+ Storage ID
548
+
549
+ request_options : typing.Optional[RequestOptions]
550
+ Request-specific configuration.
551
+
552
+ Returns
553
+ -------
554
+ S3ImportStorage
555
+
556
+
557
+ Examples
558
+ --------
559
+ from label_studio_sdk.client import LabelStudio
560
+
561
+ client = LabelStudio(
562
+ api_key="YOUR_API_KEY",
563
+ )
564
+ client.import_storage.s3.sync(
565
+ id=1,
566
+ )
567
+ """
568
+ _response = self._client_wrapper.httpx_client.request(
569
+ f"api/storages/s3/{jsonable_encoder(id)}/sync", method="POST", request_options=request_options
570
+ )
571
+ if 200 <= _response.status_code < 300:
572
+ return pydantic_v1.parse_obj_as(S3ImportStorage, _response.json()) # type: ignore
573
+ try:
574
+ _response_json = _response.json()
575
+ except JSONDecodeError:
576
+ raise ApiError(status_code=_response.status_code, body=_response.text)
577
+ raise ApiError(status_code=_response.status_code, body=_response_json)
578
+
579
+
580
+ class AsyncS3Client:
581
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
582
+ self._client_wrapper = client_wrapper
583
+
584
+ async def list(
585
+ self, *, project: typing.Optional[int] = None, request_options: typing.Optional[RequestOptions] = None
586
+ ) -> typing.List[S3ImportStorage]:
587
+ """
588
+ 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 Google import (source) storage connections for a specific project.
589
+
590
+ 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).
591
+
592
+ For more information about working with external storage, see [Sync data from external storage](https://labelstud.io/guide/storage).
593
+
594
+ Parameters
595
+ ----------
596
+ project : typing.Optional[int]
597
+ Project ID
598
+
599
+ request_options : typing.Optional[RequestOptions]
600
+ Request-specific configuration.
601
+
602
+ Returns
603
+ -------
604
+ typing.List[S3ImportStorage]
605
+
606
+
607
+ Examples
608
+ --------
609
+ from label_studio_sdk.client import AsyncLabelStudio
610
+
611
+ client = AsyncLabelStudio(
612
+ api_key="YOUR_API_KEY",
613
+ )
614
+ await client.import_storage.s3.list()
615
+ """
616
+ _response = await self._client_wrapper.httpx_client.request(
617
+ "api/storages/s3/", method="GET", params={"project": project}, request_options=request_options
618
+ )
619
+ if 200 <= _response.status_code < 300:
620
+ return pydantic_v1.parse_obj_as(typing.List[S3ImportStorage], _response.json()) # type: ignore
621
+ try:
622
+ _response_json = _response.json()
623
+ except JSONDecodeError:
624
+ raise ApiError(status_code=_response.status_code, body=_response.text)
625
+ raise ApiError(status_code=_response.status_code, body=_response_json)
626
+
627
+ async def create(
628
+ self,
629
+ *,
630
+ regex_filter: typing.Optional[str] = OMIT,
631
+ use_blob_urls: typing.Optional[bool] = OMIT,
632
+ presign: typing.Optional[bool] = OMIT,
633
+ presign_ttl: typing.Optional[int] = OMIT,
634
+ recursive_scan: typing.Optional[bool] = OMIT,
635
+ title: typing.Optional[str] = OMIT,
636
+ description: typing.Optional[str] = OMIT,
637
+ project: typing.Optional[int] = OMIT,
638
+ bucket: typing.Optional[str] = OMIT,
639
+ prefix: typing.Optional[str] = OMIT,
640
+ aws_access_key_id: typing.Optional[str] = OMIT,
641
+ aws_secret_access_key: typing.Optional[str] = OMIT,
642
+ aws_session_token: typing.Optional[str] = OMIT,
643
+ aws_sse_kms_key_id: typing.Optional[str] = OMIT,
644
+ region_name: typing.Optional[str] = OMIT,
645
+ s3endpoint: typing.Optional[str] = OMIT,
646
+ request_options: typing.Optional[RequestOptions] = None,
647
+ ) -> S3CreateResponse:
648
+ """
649
+ Create a new source storage connection to a S3 bucket.
650
+
651
+ For information about the required fields and prerequisites, see [Amazon S3](https://labelstud.io/guide/storage#Amazon-S3) in the Label Studio documentation.
652
+
653
+ <Info>Ensure you configure CORS before adding cloud storage. This ensures you will be able to see the content of the data rather than just a link.</Info>
654
+
655
+ <Tip>After you add the storage, you should validate the connection before attempting to sync your data. Your data will not be imported until you [sync your connection](sync).</Tip>
656
+
657
+ Parameters
658
+ ----------
659
+ regex_filter : typing.Optional[str]
660
+ Cloud storage regex for filtering objects. You must specify it otherwise no objects will be imported.
661
+
662
+ use_blob_urls : typing.Optional[bool]
663
+ Interpret objects as BLOBs and generate URLs. For example, if your bucket contains images, you can use this option to generate URLs for these images. If set to False, it will read the content of the file and load it into Label Studio.
664
+
665
+ presign : typing.Optional[bool]
666
+ Presign URLs for download
667
+
668
+ presign_ttl : typing.Optional[int]
669
+ Presign TTL in minutes
670
+
671
+ recursive_scan : typing.Optional[bool]
672
+ Scan recursively
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
+ aws_access_key_id : typing.Optional[str]
690
+ AWS_ACCESS_KEY_ID
691
+
692
+ aws_secret_access_key : typing.Optional[str]
693
+ AWS_SECRET_ACCESS_KEY
694
+
695
+ aws_session_token : typing.Optional[str]
696
+ AWS_SESSION_TOKEN
697
+
698
+ aws_sse_kms_key_id : typing.Optional[str]
699
+ AWS SSE KMS Key ID
700
+
701
+ region_name : typing.Optional[str]
702
+ AWS Region
703
+
704
+ s3endpoint : typing.Optional[str]
705
+ S3 Endpoint
706
+
707
+ request_options : typing.Optional[RequestOptions]
708
+ Request-specific configuration.
709
+
710
+ Returns
711
+ -------
712
+ S3CreateResponse
713
+
714
+
715
+ Examples
716
+ --------
717
+ from label_studio_sdk.client import AsyncLabelStudio
718
+
719
+ client = AsyncLabelStudio(
720
+ api_key="YOUR_API_KEY",
721
+ )
722
+ await client.import_storage.s3.create()
723
+ """
724
+ _response = await self._client_wrapper.httpx_client.request(
725
+ "api/storages/s3/",
726
+ method="POST",
727
+ json={
728
+ "regex_filter": regex_filter,
729
+ "use_blob_urls": use_blob_urls,
730
+ "presign": presign,
731
+ "presign_ttl": presign_ttl,
732
+ "recursive_scan": recursive_scan,
733
+ "title": title,
734
+ "description": description,
735
+ "project": project,
736
+ "bucket": bucket,
737
+ "prefix": prefix,
738
+ "aws_access_key_id": aws_access_key_id,
739
+ "aws_secret_access_key": aws_secret_access_key,
740
+ "aws_session_token": aws_session_token,
741
+ "aws_sse_kms_key_id": aws_sse_kms_key_id,
742
+ "region_name": region_name,
743
+ "s3_endpoint": s3endpoint,
744
+ },
745
+ request_options=request_options,
746
+ omit=OMIT,
747
+ )
748
+ if 200 <= _response.status_code < 300:
749
+ return pydantic_v1.parse_obj_as(S3CreateResponse, _response.json()) # type: ignore
750
+ try:
751
+ _response_json = _response.json()
752
+ except JSONDecodeError:
753
+ raise ApiError(status_code=_response.status_code, body=_response.text)
754
+ raise ApiError(status_code=_response.status_code, body=_response_json)
755
+
756
+ async def validate(
757
+ self,
758
+ *,
759
+ id: typing.Optional[int] = OMIT,
760
+ regex_filter: typing.Optional[str] = OMIT,
761
+ use_blob_urls: typing.Optional[bool] = OMIT,
762
+ presign: typing.Optional[bool] = OMIT,
763
+ presign_ttl: typing.Optional[int] = OMIT,
764
+ recursive_scan: typing.Optional[bool] = OMIT,
765
+ title: typing.Optional[str] = OMIT,
766
+ description: typing.Optional[str] = OMIT,
767
+ project: typing.Optional[int] = OMIT,
768
+ bucket: typing.Optional[str] = OMIT,
769
+ prefix: typing.Optional[str] = OMIT,
770
+ aws_access_key_id: typing.Optional[str] = OMIT,
771
+ aws_secret_access_key: typing.Optional[str] = OMIT,
772
+ aws_session_token: typing.Optional[str] = OMIT,
773
+ aws_sse_kms_key_id: typing.Optional[str] = OMIT,
774
+ region_name: typing.Optional[str] = OMIT,
775
+ s3endpoint: typing.Optional[str] = OMIT,
776
+ request_options: typing.Optional[RequestOptions] = None,
777
+ ) -> None:
778
+ """
779
+ Validate a specific S3 import storage connection. This is useful to ensure that the storage configuration settings are correct and operational before attempting to import data.
780
+
781
+ Parameters
782
+ ----------
783
+ id : typing.Optional[int]
784
+ Storage ID. If set, storage with specified ID will be updated
785
+
786
+ regex_filter : typing.Optional[str]
787
+ Cloud storage regex for filtering objects. You must specify it otherwise no objects will be imported.
788
+
789
+ use_blob_urls : typing.Optional[bool]
790
+ Interpret objects as BLOBs and generate URLs. For example, if your bucket contains images, you can use this option to generate URLs for these images. If set to False, it will read the content of the file and load it into Label Studio.
791
+
792
+ presign : typing.Optional[bool]
793
+ Presign URLs for download
794
+
795
+ presign_ttl : typing.Optional[int]
796
+ Presign TTL in minutes
797
+
798
+ recursive_scan : typing.Optional[bool]
799
+ Scan recursively
800
+
801
+ title : typing.Optional[str]
802
+ Storage title
803
+
804
+ description : typing.Optional[str]
805
+ Storage description
806
+
807
+ project : typing.Optional[int]
808
+ Project ID
809
+
810
+ bucket : typing.Optional[str]
811
+ S3 bucket name
812
+
813
+ prefix : typing.Optional[str]
814
+ S3 bucket prefix
815
+
816
+ aws_access_key_id : typing.Optional[str]
817
+ AWS_ACCESS_KEY_ID
818
+
819
+ aws_secret_access_key : typing.Optional[str]
820
+ AWS_SECRET_ACCESS_KEY
821
+
822
+ aws_session_token : typing.Optional[str]
823
+ AWS_SESSION_TOKEN
824
+
825
+ aws_sse_kms_key_id : typing.Optional[str]
826
+ AWS SSE KMS Key ID
827
+
828
+ region_name : typing.Optional[str]
829
+ AWS Region
830
+
831
+ s3endpoint : typing.Optional[str]
832
+ S3 Endpoint
833
+
834
+ request_options : typing.Optional[RequestOptions]
835
+ Request-specific configuration.
836
+
837
+ Returns
838
+ -------
839
+ None
840
+
841
+ Examples
842
+ --------
843
+ from label_studio_sdk.client import AsyncLabelStudio
844
+
845
+ client = AsyncLabelStudio(
846
+ api_key="YOUR_API_KEY",
847
+ )
848
+ await client.import_storage.s3.validate()
849
+ """
850
+ _response = await self._client_wrapper.httpx_client.request(
851
+ "api/storages/s3/validate",
852
+ method="POST",
853
+ json={
854
+ "id": id,
855
+ "regex_filter": regex_filter,
856
+ "use_blob_urls": use_blob_urls,
857
+ "presign": presign,
858
+ "presign_ttl": presign_ttl,
859
+ "recursive_scan": recursive_scan,
860
+ "title": title,
861
+ "description": description,
862
+ "project": project,
863
+ "bucket": bucket,
864
+ "prefix": prefix,
865
+ "aws_access_key_id": aws_access_key_id,
866
+ "aws_secret_access_key": aws_secret_access_key,
867
+ "aws_session_token": aws_session_token,
868
+ "aws_sse_kms_key_id": aws_sse_kms_key_id,
869
+ "region_name": region_name,
870
+ "s3_endpoint": s3endpoint,
871
+ },
872
+ request_options=request_options,
873
+ omit=OMIT,
874
+ )
875
+ if 200 <= _response.status_code < 300:
876
+ return
877
+ try:
878
+ _response_json = _response.json()
879
+ except JSONDecodeError:
880
+ raise ApiError(status_code=_response.status_code, body=_response.text)
881
+ raise ApiError(status_code=_response.status_code, body=_response_json)
882
+
883
+ async def get(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> S3ImportStorage:
884
+ """
885
+ Get a specific S3 import storage connection. You will need to provide the import storage ID. You can find this using [List import storages](list).
886
+
887
+ For more information about working with external storage, see [Sync data from external storage](https://labelstud.io/guide/storage).
888
+
889
+ Parameters
890
+ ----------
891
+ id : int
892
+ A unique integer value identifying this s3 import storage.
893
+
894
+ request_options : typing.Optional[RequestOptions]
895
+ Request-specific configuration.
896
+
897
+ Returns
898
+ -------
899
+ S3ImportStorage
900
+
901
+
902
+ Examples
903
+ --------
904
+ from label_studio_sdk.client import AsyncLabelStudio
905
+
906
+ client = AsyncLabelStudio(
907
+ api_key="YOUR_API_KEY",
908
+ )
909
+ await client.import_storage.s3.get(
910
+ id=1,
911
+ )
912
+ """
913
+ _response = await self._client_wrapper.httpx_client.request(
914
+ f"api/storages/s3/{jsonable_encoder(id)}", method="GET", request_options=request_options
915
+ )
916
+ if 200 <= _response.status_code < 300:
917
+ return pydantic_v1.parse_obj_as(S3ImportStorage, _response.json()) # type: ignore
918
+ try:
919
+ _response_json = _response.json()
920
+ except JSONDecodeError:
921
+ raise ApiError(status_code=_response.status_code, body=_response.text)
922
+ raise ApiError(status_code=_response.status_code, body=_response_json)
923
+
924
+ async def delete(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> None:
925
+ """
926
+ Delete a specific S3 import storage connection. You will need to provide the import storage ID. You can find this using [List import storages](list).
927
+
928
+ Deleting a source storage connection does not affect tasks with synced data in Label Studio. The sync process is designed to import new or updated tasks from the connected storage into the project, but it does not track deletions of files from the storage. Therefore, if you remove the external storage connection, the tasks that were created from that storage will remain in the project.
929
+
930
+ If you want to remove the tasks that were synced from the external storage, you will need to delete them manually from within the Label Studio UI or use the [Delete tasks](../../tasks/delete-all-tasks) API.
931
+
932
+ Parameters
933
+ ----------
934
+ id : int
935
+ A unique integer value identifying this s3 import storage.
936
+
937
+ request_options : typing.Optional[RequestOptions]
938
+ Request-specific configuration.
939
+
940
+ Returns
941
+ -------
942
+ None
943
+
944
+ Examples
945
+ --------
946
+ from label_studio_sdk.client import AsyncLabelStudio
947
+
948
+ client = AsyncLabelStudio(
949
+ api_key="YOUR_API_KEY",
950
+ )
951
+ await client.import_storage.s3.delete(
952
+ id=1,
953
+ )
954
+ """
955
+ _response = await self._client_wrapper.httpx_client.request(
956
+ f"api/storages/s3/{jsonable_encoder(id)}", method="DELETE", request_options=request_options
957
+ )
958
+ if 200 <= _response.status_code < 300:
959
+ return
960
+ try:
961
+ _response_json = _response.json()
962
+ except JSONDecodeError:
963
+ raise ApiError(status_code=_response.status_code, body=_response.text)
964
+ raise ApiError(status_code=_response.status_code, body=_response_json)
965
+
966
+ async def update(
967
+ self,
968
+ id: int,
969
+ *,
970
+ regex_filter: typing.Optional[str] = OMIT,
971
+ use_blob_urls: typing.Optional[bool] = OMIT,
972
+ presign: typing.Optional[bool] = OMIT,
973
+ presign_ttl: typing.Optional[int] = OMIT,
974
+ recursive_scan: typing.Optional[bool] = OMIT,
975
+ title: typing.Optional[str] = OMIT,
976
+ description: typing.Optional[str] = OMIT,
977
+ project: typing.Optional[int] = OMIT,
978
+ bucket: typing.Optional[str] = OMIT,
979
+ prefix: typing.Optional[str] = OMIT,
980
+ aws_access_key_id: typing.Optional[str] = OMIT,
981
+ aws_secret_access_key: typing.Optional[str] = OMIT,
982
+ aws_session_token: typing.Optional[str] = OMIT,
983
+ aws_sse_kms_key_id: typing.Optional[str] = OMIT,
984
+ region_name: typing.Optional[str] = OMIT,
985
+ s3endpoint: typing.Optional[str] = OMIT,
986
+ request_options: typing.Optional[RequestOptions] = None,
987
+ ) -> S3UpdateResponse:
988
+ """
989
+ Update a specific S3 import storage connection. You will need to provide the import storage ID. You can find this using [List import storages](list).
990
+
991
+ For more information about working with external storage, see [Sync data from external storage](https://labelstud.io/guide/storage).
992
+
993
+ Parameters
994
+ ----------
995
+ id : int
996
+ A unique integer value identifying this s3 import storage.
997
+
998
+ regex_filter : typing.Optional[str]
999
+ Cloud storage regex for filtering objects. You must specify it otherwise no objects will be imported.
1000
+
1001
+ use_blob_urls : typing.Optional[bool]
1002
+ Interpret objects as BLOBs and generate URLs. For example, if your bucket contains images, you can use this option to generate URLs for these images. If set to False, it will read the content of the file and load it into Label Studio.
1003
+
1004
+ presign : typing.Optional[bool]
1005
+ Presign URLs for download
1006
+
1007
+ presign_ttl : typing.Optional[int]
1008
+ Presign TTL in minutes
1009
+
1010
+ recursive_scan : typing.Optional[bool]
1011
+ Scan recursively
1012
+
1013
+ title : typing.Optional[str]
1014
+ Storage title
1015
+
1016
+ description : typing.Optional[str]
1017
+ Storage description
1018
+
1019
+ project : typing.Optional[int]
1020
+ Project ID
1021
+
1022
+ bucket : typing.Optional[str]
1023
+ S3 bucket name
1024
+
1025
+ prefix : typing.Optional[str]
1026
+ S3 bucket prefix
1027
+
1028
+ aws_access_key_id : typing.Optional[str]
1029
+ AWS_ACCESS_KEY_ID
1030
+
1031
+ aws_secret_access_key : typing.Optional[str]
1032
+ AWS_SECRET_ACCESS_KEY
1033
+
1034
+ aws_session_token : typing.Optional[str]
1035
+ AWS_SESSION_TOKEN
1036
+
1037
+ aws_sse_kms_key_id : typing.Optional[str]
1038
+ AWS SSE KMS Key ID
1039
+
1040
+ region_name : typing.Optional[str]
1041
+ AWS Region
1042
+
1043
+ s3endpoint : typing.Optional[str]
1044
+ S3 Endpoint
1045
+
1046
+ request_options : typing.Optional[RequestOptions]
1047
+ Request-specific configuration.
1048
+
1049
+ Returns
1050
+ -------
1051
+ S3UpdateResponse
1052
+
1053
+
1054
+ Examples
1055
+ --------
1056
+ from label_studio_sdk.client import AsyncLabelStudio
1057
+
1058
+ client = AsyncLabelStudio(
1059
+ api_key="YOUR_API_KEY",
1060
+ )
1061
+ await client.import_storage.s3.update(
1062
+ id=1,
1063
+ )
1064
+ """
1065
+ _response = await self._client_wrapper.httpx_client.request(
1066
+ f"api/storages/s3/{jsonable_encoder(id)}",
1067
+ method="PATCH",
1068
+ json={
1069
+ "regex_filter": regex_filter,
1070
+ "use_blob_urls": use_blob_urls,
1071
+ "presign": presign,
1072
+ "presign_ttl": presign_ttl,
1073
+ "recursive_scan": recursive_scan,
1074
+ "title": title,
1075
+ "description": description,
1076
+ "project": project,
1077
+ "bucket": bucket,
1078
+ "prefix": prefix,
1079
+ "aws_access_key_id": aws_access_key_id,
1080
+ "aws_secret_access_key": aws_secret_access_key,
1081
+ "aws_session_token": aws_session_token,
1082
+ "aws_sse_kms_key_id": aws_sse_kms_key_id,
1083
+ "region_name": region_name,
1084
+ "s3_endpoint": s3endpoint,
1085
+ },
1086
+ request_options=request_options,
1087
+ omit=OMIT,
1088
+ )
1089
+ if 200 <= _response.status_code < 300:
1090
+ return pydantic_v1.parse_obj_as(S3UpdateResponse, _response.json()) # type: ignore
1091
+ try:
1092
+ _response_json = _response.json()
1093
+ except JSONDecodeError:
1094
+ raise ApiError(status_code=_response.status_code, body=_response.text)
1095
+ raise ApiError(status_code=_response.status_code, body=_response_json)
1096
+
1097
+ async def sync(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> S3ImportStorage:
1098
+ """
1099
+ Sync tasks from an S3 import storage connection. You will need to provide the import storage ID. You can find this using [List import storages](list).
1100
+
1101
+ Sync operations with external buckets only go one way. They either create tasks from objects in the bucket (source/import storage) or push annotations to the output bucket (export/target storage). Changing something on the bucket side doesn’t guarantee consistency in results.
1102
+
1103
+ <Note>Before proceeding, you should review [How sync operations work - Source storage](https://labelstud.io/guide/storage#Source-storage) to ensure that your data remains secure and private.</Note>
1104
+
1105
+ Parameters
1106
+ ----------
1107
+ id : int
1108
+ Storage ID
1109
+
1110
+ request_options : typing.Optional[RequestOptions]
1111
+ Request-specific configuration.
1112
+
1113
+ Returns
1114
+ -------
1115
+ S3ImportStorage
1116
+
1117
+
1118
+ Examples
1119
+ --------
1120
+ from label_studio_sdk.client import AsyncLabelStudio
1121
+
1122
+ client = AsyncLabelStudio(
1123
+ api_key="YOUR_API_KEY",
1124
+ )
1125
+ await client.import_storage.s3.sync(
1126
+ id=1,
1127
+ )
1128
+ """
1129
+ _response = await self._client_wrapper.httpx_client.request(
1130
+ f"api/storages/s3/{jsonable_encoder(id)}/sync", method="POST", request_options=request_options
1131
+ )
1132
+ if 200 <= _response.status_code < 300:
1133
+ return pydantic_v1.parse_obj_as(S3ImportStorage, _response.json()) # type: ignore
1134
+ try:
1135
+ _response_json = _response.json()
1136
+ except JSONDecodeError:
1137
+ raise ApiError(status_code=_response.status_code, body=_response.text)
1138
+ raise ApiError(status_code=_response.status_code, body=_response_json)