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,988 @@
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.gcs_import_storage import GcsImportStorage
12
+ from .types.gcs_create_response import GcsCreateResponse
13
+ from .types.gcs_update_response import GcsUpdateResponse
14
+
15
+ # this is used as the default value for optional parameters
16
+ OMIT = typing.cast(typing.Any, ...)
17
+
18
+
19
+ class GcsClient:
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[GcsImportStorage]:
26
+ """
27
+ You can connect your Google Cloud Storage 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[GcsImportStorage]
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.gcs.list()
54
+ """
55
+ _response = self._client_wrapper.httpx_client.request(
56
+ "api/storages/gcs/", 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[GcsImportStorage], _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
+ title: typing.Optional[str] = OMIT,
74
+ description: typing.Optional[str] = OMIT,
75
+ project: typing.Optional[int] = OMIT,
76
+ bucket: typing.Optional[str] = OMIT,
77
+ prefix: typing.Optional[str] = OMIT,
78
+ google_application_credentials: typing.Optional[str] = OMIT,
79
+ google_project_id: typing.Optional[str] = OMIT,
80
+ request_options: typing.Optional[RequestOptions] = None,
81
+ ) -> GcsCreateResponse:
82
+ """
83
+ Create a new source storage connection to a Google Cloud Storage bucket.
84
+
85
+ For information about the required fields and prerequisites, see [Google Cloud Storage](https://labelstud.io/guide/storage#Google-Cloud-Storage) in the Label Studio documentation.
86
+
87
+ <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>
88
+
89
+ <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>
90
+
91
+ Parameters
92
+ ----------
93
+ regex_filter : typing.Optional[str]
94
+ Cloud storage regex for filtering objects. You must specify it otherwise no objects will be imported.
95
+
96
+ use_blob_urls : typing.Optional[bool]
97
+ 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.
98
+
99
+ presign : typing.Optional[bool]
100
+ Presign URLs for direct download
101
+
102
+ presign_ttl : typing.Optional[int]
103
+ Presign TTL in minutes
104
+
105
+ title : typing.Optional[str]
106
+ Storage title
107
+
108
+ description : typing.Optional[str]
109
+ Storage description
110
+
111
+ project : typing.Optional[int]
112
+ Project ID
113
+
114
+ bucket : typing.Optional[str]
115
+ GCS bucket name
116
+
117
+ prefix : typing.Optional[str]
118
+ GCS bucket prefix
119
+
120
+ google_application_credentials : typing.Optional[str]
121
+ The content of GOOGLE_APPLICATION_CREDENTIALS json file. Check official Google Cloud Authentication documentation for more details.
122
+
123
+ google_project_id : typing.Optional[str]
124
+ Google project ID
125
+
126
+ request_options : typing.Optional[RequestOptions]
127
+ Request-specific configuration.
128
+
129
+ Returns
130
+ -------
131
+ GcsCreateResponse
132
+
133
+
134
+ Examples
135
+ --------
136
+ from label_studio_sdk.client import LabelStudio
137
+
138
+ client = LabelStudio(
139
+ api_key="YOUR_API_KEY",
140
+ )
141
+ client.import_storage.gcs.create()
142
+ """
143
+ _response = self._client_wrapper.httpx_client.request(
144
+ "api/storages/gcs/",
145
+ method="POST",
146
+ json={
147
+ "regex_filter": regex_filter,
148
+ "use_blob_urls": use_blob_urls,
149
+ "presign": presign,
150
+ "presign_ttl": presign_ttl,
151
+ "title": title,
152
+ "description": description,
153
+ "project": project,
154
+ "bucket": bucket,
155
+ "prefix": prefix,
156
+ "google_application_credentials": google_application_credentials,
157
+ "google_project_id": google_project_id,
158
+ },
159
+ request_options=request_options,
160
+ omit=OMIT,
161
+ )
162
+ if 200 <= _response.status_code < 300:
163
+ return pydantic_v1.parse_obj_as(GcsCreateResponse, _response.json()) # type: ignore
164
+ try:
165
+ _response_json = _response.json()
166
+ except JSONDecodeError:
167
+ raise ApiError(status_code=_response.status_code, body=_response.text)
168
+ raise ApiError(status_code=_response.status_code, body=_response_json)
169
+
170
+ def validate(
171
+ self,
172
+ *,
173
+ id: typing.Optional[int] = OMIT,
174
+ regex_filter: typing.Optional[str] = OMIT,
175
+ use_blob_urls: typing.Optional[bool] = OMIT,
176
+ presign: typing.Optional[bool] = OMIT,
177
+ presign_ttl: typing.Optional[int] = OMIT,
178
+ title: typing.Optional[str] = OMIT,
179
+ description: typing.Optional[str] = OMIT,
180
+ project: typing.Optional[int] = OMIT,
181
+ bucket: typing.Optional[str] = OMIT,
182
+ prefix: typing.Optional[str] = OMIT,
183
+ google_application_credentials: typing.Optional[str] = OMIT,
184
+ google_project_id: typing.Optional[str] = OMIT,
185
+ request_options: typing.Optional[RequestOptions] = None,
186
+ ) -> None:
187
+ """
188
+ Validate a specific GCS import storage connection. This is useful to ensure that the storage configuration settings are correct and operational before attempting to import data.
189
+
190
+ Parameters
191
+ ----------
192
+ id : typing.Optional[int]
193
+ Storage ID. If set, storage with specified ID will be updated
194
+
195
+ regex_filter : typing.Optional[str]
196
+ Cloud storage regex for filtering objects. You must specify it otherwise no objects will be imported.
197
+
198
+ use_blob_urls : typing.Optional[bool]
199
+ 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.
200
+
201
+ presign : typing.Optional[bool]
202
+ Presign URLs for direct download
203
+
204
+ presign_ttl : typing.Optional[int]
205
+ Presign TTL in minutes
206
+
207
+ title : typing.Optional[str]
208
+ Storage title
209
+
210
+ description : typing.Optional[str]
211
+ Storage description
212
+
213
+ project : typing.Optional[int]
214
+ Project ID
215
+
216
+ bucket : typing.Optional[str]
217
+ GCS bucket name
218
+
219
+ prefix : typing.Optional[str]
220
+ GCS bucket prefix
221
+
222
+ google_application_credentials : typing.Optional[str]
223
+ The content of GOOGLE_APPLICATION_CREDENTIALS json file. Check official Google Cloud Authentication documentation for more details.
224
+
225
+ google_project_id : typing.Optional[str]
226
+ Google project ID
227
+
228
+ request_options : typing.Optional[RequestOptions]
229
+ Request-specific configuration.
230
+
231
+ Returns
232
+ -------
233
+ None
234
+
235
+ Examples
236
+ --------
237
+ from label_studio_sdk.client import LabelStudio
238
+
239
+ client = LabelStudio(
240
+ api_key="YOUR_API_KEY",
241
+ )
242
+ client.import_storage.gcs.validate()
243
+ """
244
+ _response = self._client_wrapper.httpx_client.request(
245
+ "api/storages/gcs/validate",
246
+ method="POST",
247
+ json={
248
+ "id": id,
249
+ "regex_filter": regex_filter,
250
+ "use_blob_urls": use_blob_urls,
251
+ "presign": presign,
252
+ "presign_ttl": presign_ttl,
253
+ "title": title,
254
+ "description": description,
255
+ "project": project,
256
+ "bucket": bucket,
257
+ "prefix": prefix,
258
+ "google_application_credentials": google_application_credentials,
259
+ "google_project_id": google_project_id,
260
+ },
261
+ request_options=request_options,
262
+ omit=OMIT,
263
+ )
264
+ if 200 <= _response.status_code < 300:
265
+ return
266
+ try:
267
+ _response_json = _response.json()
268
+ except JSONDecodeError:
269
+ raise ApiError(status_code=_response.status_code, body=_response.text)
270
+ raise ApiError(status_code=_response.status_code, body=_response_json)
271
+
272
+ def get(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> GcsImportStorage:
273
+ """
274
+ Get a specific GCS import storage connection. You will need to provide the import storage ID. You can find this using [List import storages](list).
275
+
276
+ For more information about working with external storage, see [Sync data from external storage](https://labelstud.io/guide/storage).
277
+
278
+ Parameters
279
+ ----------
280
+ id : int
281
+ A unique integer value identifying this gcs import storage.
282
+
283
+ request_options : typing.Optional[RequestOptions]
284
+ Request-specific configuration.
285
+
286
+ Returns
287
+ -------
288
+ GcsImportStorage
289
+
290
+
291
+ Examples
292
+ --------
293
+ from label_studio_sdk.client import LabelStudio
294
+
295
+ client = LabelStudio(
296
+ api_key="YOUR_API_KEY",
297
+ )
298
+ client.import_storage.gcs.get(
299
+ id=1,
300
+ )
301
+ """
302
+ _response = self._client_wrapper.httpx_client.request(
303
+ f"api/storages/gcs/{jsonable_encoder(id)}", method="GET", request_options=request_options
304
+ )
305
+ if 200 <= _response.status_code < 300:
306
+ return pydantic_v1.parse_obj_as(GcsImportStorage, _response.json()) # type: ignore
307
+ try:
308
+ _response_json = _response.json()
309
+ except JSONDecodeError:
310
+ raise ApiError(status_code=_response.status_code, body=_response.text)
311
+ raise ApiError(status_code=_response.status_code, body=_response_json)
312
+
313
+ def delete(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> None:
314
+ """
315
+ Delete a specific GCS import storage connection. You will need to provide the import storage ID. You can find this using [List import storages](list).
316
+
317
+ 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.
318
+
319
+ 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.
320
+
321
+ Parameters
322
+ ----------
323
+ id : int
324
+ A unique integer value identifying this gcs import storage.
325
+
326
+ request_options : typing.Optional[RequestOptions]
327
+ Request-specific configuration.
328
+
329
+ Returns
330
+ -------
331
+ None
332
+
333
+ Examples
334
+ --------
335
+ from label_studio_sdk.client import LabelStudio
336
+
337
+ client = LabelStudio(
338
+ api_key="YOUR_API_KEY",
339
+ )
340
+ client.import_storage.gcs.delete(
341
+ id=1,
342
+ )
343
+ """
344
+ _response = self._client_wrapper.httpx_client.request(
345
+ f"api/storages/gcs/{jsonable_encoder(id)}", method="DELETE", request_options=request_options
346
+ )
347
+ if 200 <= _response.status_code < 300:
348
+ return
349
+ try:
350
+ _response_json = _response.json()
351
+ except JSONDecodeError:
352
+ raise ApiError(status_code=_response.status_code, body=_response.text)
353
+ raise ApiError(status_code=_response.status_code, body=_response_json)
354
+
355
+ def update(
356
+ self,
357
+ id: int,
358
+ *,
359
+ regex_filter: typing.Optional[str] = OMIT,
360
+ use_blob_urls: typing.Optional[bool] = OMIT,
361
+ presign: typing.Optional[bool] = OMIT,
362
+ presign_ttl: typing.Optional[int] = OMIT,
363
+ title: typing.Optional[str] = OMIT,
364
+ description: typing.Optional[str] = OMIT,
365
+ project: typing.Optional[int] = OMIT,
366
+ bucket: typing.Optional[str] = OMIT,
367
+ prefix: typing.Optional[str] = OMIT,
368
+ google_application_credentials: typing.Optional[str] = OMIT,
369
+ google_project_id: typing.Optional[str] = OMIT,
370
+ request_options: typing.Optional[RequestOptions] = None,
371
+ ) -> GcsUpdateResponse:
372
+ """
373
+ Update a specific GCS import storage connection. You will need to provide the import storage ID. You can find this using [List import storages](list).
374
+
375
+ For more information about working with external storage, see [Sync data from external storage](https://labelstud.io/guide/storage).
376
+
377
+ Parameters
378
+ ----------
379
+ id : int
380
+ A unique integer value identifying this gcs import storage.
381
+
382
+ regex_filter : typing.Optional[str]
383
+ Cloud storage regex for filtering objects. You must specify it otherwise no objects will be imported.
384
+
385
+ use_blob_urls : typing.Optional[bool]
386
+ 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.
387
+
388
+ presign : typing.Optional[bool]
389
+ Presign URLs for direct download
390
+
391
+ presign_ttl : typing.Optional[int]
392
+ Presign TTL in minutes
393
+
394
+ title : typing.Optional[str]
395
+ Storage title
396
+
397
+ description : typing.Optional[str]
398
+ Storage description
399
+
400
+ project : typing.Optional[int]
401
+ Project ID
402
+
403
+ bucket : typing.Optional[str]
404
+ GCS bucket name
405
+
406
+ prefix : typing.Optional[str]
407
+ GCS bucket prefix
408
+
409
+ google_application_credentials : typing.Optional[str]
410
+ The content of GOOGLE_APPLICATION_CREDENTIALS json file. Check official Google Cloud Authentication documentation for more details.
411
+
412
+ google_project_id : typing.Optional[str]
413
+ Google project ID
414
+
415
+ request_options : typing.Optional[RequestOptions]
416
+ Request-specific configuration.
417
+
418
+ Returns
419
+ -------
420
+ GcsUpdateResponse
421
+
422
+
423
+ Examples
424
+ --------
425
+ from label_studio_sdk.client import LabelStudio
426
+
427
+ client = LabelStudio(
428
+ api_key="YOUR_API_KEY",
429
+ )
430
+ client.import_storage.gcs.update(
431
+ id=1,
432
+ )
433
+ """
434
+ _response = self._client_wrapper.httpx_client.request(
435
+ f"api/storages/gcs/{jsonable_encoder(id)}",
436
+ method="PATCH",
437
+ json={
438
+ "regex_filter": regex_filter,
439
+ "use_blob_urls": use_blob_urls,
440
+ "presign": presign,
441
+ "presign_ttl": presign_ttl,
442
+ "title": title,
443
+ "description": description,
444
+ "project": project,
445
+ "bucket": bucket,
446
+ "prefix": prefix,
447
+ "google_application_credentials": google_application_credentials,
448
+ "google_project_id": google_project_id,
449
+ },
450
+ request_options=request_options,
451
+ omit=OMIT,
452
+ )
453
+ if 200 <= _response.status_code < 300:
454
+ return pydantic_v1.parse_obj_as(GcsUpdateResponse, _response.json()) # type: ignore
455
+ try:
456
+ _response_json = _response.json()
457
+ except JSONDecodeError:
458
+ raise ApiError(status_code=_response.status_code, body=_response.text)
459
+ raise ApiError(status_code=_response.status_code, body=_response_json)
460
+
461
+ def sync(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> GcsImportStorage:
462
+ """
463
+ Sync tasks from a GCS import storage connection. You will need to provide the import storage ID. You can find this using [List import storages](list).
464
+
465
+ 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.
466
+
467
+ <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>
468
+
469
+ Parameters
470
+ ----------
471
+ id : int
472
+ Storage ID
473
+
474
+ request_options : typing.Optional[RequestOptions]
475
+ Request-specific configuration.
476
+
477
+ Returns
478
+ -------
479
+ GcsImportStorage
480
+
481
+
482
+ Examples
483
+ --------
484
+ from label_studio_sdk.client import LabelStudio
485
+
486
+ client = LabelStudio(
487
+ api_key="YOUR_API_KEY",
488
+ )
489
+ client.import_storage.gcs.sync(
490
+ id=1,
491
+ )
492
+ """
493
+ _response = self._client_wrapper.httpx_client.request(
494
+ f"api/storages/gcs/{jsonable_encoder(id)}/sync", method="POST", request_options=request_options
495
+ )
496
+ if 200 <= _response.status_code < 300:
497
+ return pydantic_v1.parse_obj_as(GcsImportStorage, _response.json()) # type: ignore
498
+ try:
499
+ _response_json = _response.json()
500
+ except JSONDecodeError:
501
+ raise ApiError(status_code=_response.status_code, body=_response.text)
502
+ raise ApiError(status_code=_response.status_code, body=_response_json)
503
+
504
+
505
+ class AsyncGcsClient:
506
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
507
+ self._client_wrapper = client_wrapper
508
+
509
+ async def list(
510
+ self, *, project: typing.Optional[int] = None, request_options: typing.Optional[RequestOptions] = None
511
+ ) -> typing.List[GcsImportStorage]:
512
+ """
513
+ You can connect your Google Cloud Storage 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.
514
+
515
+ 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).
516
+
517
+ For more information about working with external storage, see [Sync data from external storage](https://labelstud.io/guide/storage).
518
+
519
+ Parameters
520
+ ----------
521
+ project : typing.Optional[int]
522
+ Project ID
523
+
524
+ request_options : typing.Optional[RequestOptions]
525
+ Request-specific configuration.
526
+
527
+ Returns
528
+ -------
529
+ typing.List[GcsImportStorage]
530
+
531
+
532
+ Examples
533
+ --------
534
+ from label_studio_sdk.client import AsyncLabelStudio
535
+
536
+ client = AsyncLabelStudio(
537
+ api_key="YOUR_API_KEY",
538
+ )
539
+ await client.import_storage.gcs.list()
540
+ """
541
+ _response = await self._client_wrapper.httpx_client.request(
542
+ "api/storages/gcs/", method="GET", params={"project": project}, request_options=request_options
543
+ )
544
+ if 200 <= _response.status_code < 300:
545
+ return pydantic_v1.parse_obj_as(typing.List[GcsImportStorage], _response.json()) # type: ignore
546
+ try:
547
+ _response_json = _response.json()
548
+ except JSONDecodeError:
549
+ raise ApiError(status_code=_response.status_code, body=_response.text)
550
+ raise ApiError(status_code=_response.status_code, body=_response_json)
551
+
552
+ async def create(
553
+ self,
554
+ *,
555
+ regex_filter: typing.Optional[str] = OMIT,
556
+ use_blob_urls: typing.Optional[bool] = OMIT,
557
+ presign: typing.Optional[bool] = OMIT,
558
+ presign_ttl: typing.Optional[int] = OMIT,
559
+ title: typing.Optional[str] = OMIT,
560
+ description: typing.Optional[str] = OMIT,
561
+ project: typing.Optional[int] = OMIT,
562
+ bucket: typing.Optional[str] = OMIT,
563
+ prefix: typing.Optional[str] = OMIT,
564
+ google_application_credentials: typing.Optional[str] = OMIT,
565
+ google_project_id: typing.Optional[str] = OMIT,
566
+ request_options: typing.Optional[RequestOptions] = None,
567
+ ) -> GcsCreateResponse:
568
+ """
569
+ Create a new source storage connection to a Google Cloud Storage bucket.
570
+
571
+ For information about the required fields and prerequisites, see [Google Cloud Storage](https://labelstud.io/guide/storage#Google-Cloud-Storage) in the Label Studio documentation.
572
+
573
+ <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>
574
+
575
+ <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>
576
+
577
+ Parameters
578
+ ----------
579
+ regex_filter : typing.Optional[str]
580
+ Cloud storage regex for filtering objects. You must specify it otherwise no objects will be imported.
581
+
582
+ use_blob_urls : typing.Optional[bool]
583
+ 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.
584
+
585
+ presign : typing.Optional[bool]
586
+ Presign URLs for direct download
587
+
588
+ presign_ttl : typing.Optional[int]
589
+ Presign TTL in minutes
590
+
591
+ title : typing.Optional[str]
592
+ Storage title
593
+
594
+ description : typing.Optional[str]
595
+ Storage description
596
+
597
+ project : typing.Optional[int]
598
+ Project ID
599
+
600
+ bucket : typing.Optional[str]
601
+ GCS bucket name
602
+
603
+ prefix : typing.Optional[str]
604
+ GCS bucket prefix
605
+
606
+ google_application_credentials : typing.Optional[str]
607
+ The content of GOOGLE_APPLICATION_CREDENTIALS json file. Check official Google Cloud Authentication documentation for more details.
608
+
609
+ google_project_id : typing.Optional[str]
610
+ Google project ID
611
+
612
+ request_options : typing.Optional[RequestOptions]
613
+ Request-specific configuration.
614
+
615
+ Returns
616
+ -------
617
+ GcsCreateResponse
618
+
619
+
620
+ Examples
621
+ --------
622
+ from label_studio_sdk.client import AsyncLabelStudio
623
+
624
+ client = AsyncLabelStudio(
625
+ api_key="YOUR_API_KEY",
626
+ )
627
+ await client.import_storage.gcs.create()
628
+ """
629
+ _response = await self._client_wrapper.httpx_client.request(
630
+ "api/storages/gcs/",
631
+ method="POST",
632
+ json={
633
+ "regex_filter": regex_filter,
634
+ "use_blob_urls": use_blob_urls,
635
+ "presign": presign,
636
+ "presign_ttl": presign_ttl,
637
+ "title": title,
638
+ "description": description,
639
+ "project": project,
640
+ "bucket": bucket,
641
+ "prefix": prefix,
642
+ "google_application_credentials": google_application_credentials,
643
+ "google_project_id": google_project_id,
644
+ },
645
+ request_options=request_options,
646
+ omit=OMIT,
647
+ )
648
+ if 200 <= _response.status_code < 300:
649
+ return pydantic_v1.parse_obj_as(GcsCreateResponse, _response.json()) # type: ignore
650
+ try:
651
+ _response_json = _response.json()
652
+ except JSONDecodeError:
653
+ raise ApiError(status_code=_response.status_code, body=_response.text)
654
+ raise ApiError(status_code=_response.status_code, body=_response_json)
655
+
656
+ async def validate(
657
+ self,
658
+ *,
659
+ id: typing.Optional[int] = OMIT,
660
+ regex_filter: typing.Optional[str] = OMIT,
661
+ use_blob_urls: typing.Optional[bool] = OMIT,
662
+ presign: typing.Optional[bool] = OMIT,
663
+ presign_ttl: typing.Optional[int] = OMIT,
664
+ title: typing.Optional[str] = OMIT,
665
+ description: typing.Optional[str] = OMIT,
666
+ project: typing.Optional[int] = OMIT,
667
+ bucket: typing.Optional[str] = OMIT,
668
+ prefix: typing.Optional[str] = OMIT,
669
+ google_application_credentials: typing.Optional[str] = OMIT,
670
+ google_project_id: typing.Optional[str] = OMIT,
671
+ request_options: typing.Optional[RequestOptions] = None,
672
+ ) -> None:
673
+ """
674
+ Validate a specific GCS import storage connection. This is useful to ensure that the storage configuration settings are correct and operational before attempting to import data.
675
+
676
+ Parameters
677
+ ----------
678
+ id : typing.Optional[int]
679
+ Storage ID. If set, storage with specified ID will be updated
680
+
681
+ regex_filter : typing.Optional[str]
682
+ Cloud storage regex for filtering objects. You must specify it otherwise no objects will be imported.
683
+
684
+ use_blob_urls : typing.Optional[bool]
685
+ 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.
686
+
687
+ presign : typing.Optional[bool]
688
+ Presign URLs for direct download
689
+
690
+ presign_ttl : typing.Optional[int]
691
+ Presign TTL in minutes
692
+
693
+ title : typing.Optional[str]
694
+ Storage title
695
+
696
+ description : typing.Optional[str]
697
+ Storage description
698
+
699
+ project : typing.Optional[int]
700
+ Project ID
701
+
702
+ bucket : typing.Optional[str]
703
+ GCS bucket name
704
+
705
+ prefix : typing.Optional[str]
706
+ GCS bucket prefix
707
+
708
+ google_application_credentials : typing.Optional[str]
709
+ The content of GOOGLE_APPLICATION_CREDENTIALS json file. Check official Google Cloud Authentication documentation for more details.
710
+
711
+ google_project_id : typing.Optional[str]
712
+ Google project ID
713
+
714
+ request_options : typing.Optional[RequestOptions]
715
+ Request-specific configuration.
716
+
717
+ Returns
718
+ -------
719
+ None
720
+
721
+ Examples
722
+ --------
723
+ from label_studio_sdk.client import AsyncLabelStudio
724
+
725
+ client = AsyncLabelStudio(
726
+ api_key="YOUR_API_KEY",
727
+ )
728
+ await client.import_storage.gcs.validate()
729
+ """
730
+ _response = await self._client_wrapper.httpx_client.request(
731
+ "api/storages/gcs/validate",
732
+ method="POST",
733
+ json={
734
+ "id": id,
735
+ "regex_filter": regex_filter,
736
+ "use_blob_urls": use_blob_urls,
737
+ "presign": presign,
738
+ "presign_ttl": presign_ttl,
739
+ "title": title,
740
+ "description": description,
741
+ "project": project,
742
+ "bucket": bucket,
743
+ "prefix": prefix,
744
+ "google_application_credentials": google_application_credentials,
745
+ "google_project_id": google_project_id,
746
+ },
747
+ request_options=request_options,
748
+ omit=OMIT,
749
+ )
750
+ if 200 <= _response.status_code < 300:
751
+ return
752
+ try:
753
+ _response_json = _response.json()
754
+ except JSONDecodeError:
755
+ raise ApiError(status_code=_response.status_code, body=_response.text)
756
+ raise ApiError(status_code=_response.status_code, body=_response_json)
757
+
758
+ async def get(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> GcsImportStorage:
759
+ """
760
+ Get a specific GCS import storage connection. You will need to provide the import storage ID. You can find this using [List import storages](list).
761
+
762
+ For more information about working with external storage, see [Sync data from external storage](https://labelstud.io/guide/storage).
763
+
764
+ Parameters
765
+ ----------
766
+ id : int
767
+ A unique integer value identifying this gcs import storage.
768
+
769
+ request_options : typing.Optional[RequestOptions]
770
+ Request-specific configuration.
771
+
772
+ Returns
773
+ -------
774
+ GcsImportStorage
775
+
776
+
777
+ Examples
778
+ --------
779
+ from label_studio_sdk.client import AsyncLabelStudio
780
+
781
+ client = AsyncLabelStudio(
782
+ api_key="YOUR_API_KEY",
783
+ )
784
+ await client.import_storage.gcs.get(
785
+ id=1,
786
+ )
787
+ """
788
+ _response = await self._client_wrapper.httpx_client.request(
789
+ f"api/storages/gcs/{jsonable_encoder(id)}", method="GET", request_options=request_options
790
+ )
791
+ if 200 <= _response.status_code < 300:
792
+ return pydantic_v1.parse_obj_as(GcsImportStorage, _response.json()) # type: ignore
793
+ try:
794
+ _response_json = _response.json()
795
+ except JSONDecodeError:
796
+ raise ApiError(status_code=_response.status_code, body=_response.text)
797
+ raise ApiError(status_code=_response.status_code, body=_response_json)
798
+
799
+ async def delete(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> None:
800
+ """
801
+ Delete a specific GCS import storage connection. You will need to provide the import storage ID. You can find this using [List import storages](list).
802
+
803
+ 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.
804
+
805
+ 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.
806
+
807
+ Parameters
808
+ ----------
809
+ id : int
810
+ A unique integer value identifying this gcs import storage.
811
+
812
+ request_options : typing.Optional[RequestOptions]
813
+ Request-specific configuration.
814
+
815
+ Returns
816
+ -------
817
+ None
818
+
819
+ Examples
820
+ --------
821
+ from label_studio_sdk.client import AsyncLabelStudio
822
+
823
+ client = AsyncLabelStudio(
824
+ api_key="YOUR_API_KEY",
825
+ )
826
+ await client.import_storage.gcs.delete(
827
+ id=1,
828
+ )
829
+ """
830
+ _response = await self._client_wrapper.httpx_client.request(
831
+ f"api/storages/gcs/{jsonable_encoder(id)}", method="DELETE", request_options=request_options
832
+ )
833
+ if 200 <= _response.status_code < 300:
834
+ return
835
+ try:
836
+ _response_json = _response.json()
837
+ except JSONDecodeError:
838
+ raise ApiError(status_code=_response.status_code, body=_response.text)
839
+ raise ApiError(status_code=_response.status_code, body=_response_json)
840
+
841
+ async def update(
842
+ self,
843
+ id: int,
844
+ *,
845
+ regex_filter: typing.Optional[str] = OMIT,
846
+ use_blob_urls: typing.Optional[bool] = OMIT,
847
+ presign: typing.Optional[bool] = OMIT,
848
+ presign_ttl: typing.Optional[int] = OMIT,
849
+ title: typing.Optional[str] = OMIT,
850
+ description: typing.Optional[str] = OMIT,
851
+ project: typing.Optional[int] = OMIT,
852
+ bucket: typing.Optional[str] = OMIT,
853
+ prefix: typing.Optional[str] = OMIT,
854
+ google_application_credentials: typing.Optional[str] = OMIT,
855
+ google_project_id: typing.Optional[str] = OMIT,
856
+ request_options: typing.Optional[RequestOptions] = None,
857
+ ) -> GcsUpdateResponse:
858
+ """
859
+ Update a specific GCS import storage connection. You will need to provide the import storage ID. You can find this using [List import storages](list).
860
+
861
+ For more information about working with external storage, see [Sync data from external storage](https://labelstud.io/guide/storage).
862
+
863
+ Parameters
864
+ ----------
865
+ id : int
866
+ A unique integer value identifying this gcs import storage.
867
+
868
+ regex_filter : typing.Optional[str]
869
+ Cloud storage regex for filtering objects. You must specify it otherwise no objects will be imported.
870
+
871
+ use_blob_urls : typing.Optional[bool]
872
+ 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.
873
+
874
+ presign : typing.Optional[bool]
875
+ Presign URLs for direct download
876
+
877
+ presign_ttl : typing.Optional[int]
878
+ Presign TTL in minutes
879
+
880
+ title : typing.Optional[str]
881
+ Storage title
882
+
883
+ description : typing.Optional[str]
884
+ Storage description
885
+
886
+ project : typing.Optional[int]
887
+ Project ID
888
+
889
+ bucket : typing.Optional[str]
890
+ GCS bucket name
891
+
892
+ prefix : typing.Optional[str]
893
+ GCS bucket prefix
894
+
895
+ google_application_credentials : typing.Optional[str]
896
+ The content of GOOGLE_APPLICATION_CREDENTIALS json file. Check official Google Cloud Authentication documentation for more details.
897
+
898
+ google_project_id : typing.Optional[str]
899
+ Google project ID
900
+
901
+ request_options : typing.Optional[RequestOptions]
902
+ Request-specific configuration.
903
+
904
+ Returns
905
+ -------
906
+ GcsUpdateResponse
907
+
908
+
909
+ Examples
910
+ --------
911
+ from label_studio_sdk.client import AsyncLabelStudio
912
+
913
+ client = AsyncLabelStudio(
914
+ api_key="YOUR_API_KEY",
915
+ )
916
+ await client.import_storage.gcs.update(
917
+ id=1,
918
+ )
919
+ """
920
+ _response = await self._client_wrapper.httpx_client.request(
921
+ f"api/storages/gcs/{jsonable_encoder(id)}",
922
+ method="PATCH",
923
+ json={
924
+ "regex_filter": regex_filter,
925
+ "use_blob_urls": use_blob_urls,
926
+ "presign": presign,
927
+ "presign_ttl": presign_ttl,
928
+ "title": title,
929
+ "description": description,
930
+ "project": project,
931
+ "bucket": bucket,
932
+ "prefix": prefix,
933
+ "google_application_credentials": google_application_credentials,
934
+ "google_project_id": google_project_id,
935
+ },
936
+ request_options=request_options,
937
+ omit=OMIT,
938
+ )
939
+ if 200 <= _response.status_code < 300:
940
+ return pydantic_v1.parse_obj_as(GcsUpdateResponse, _response.json()) # type: ignore
941
+ try:
942
+ _response_json = _response.json()
943
+ except JSONDecodeError:
944
+ raise ApiError(status_code=_response.status_code, body=_response.text)
945
+ raise ApiError(status_code=_response.status_code, body=_response_json)
946
+
947
+ async def sync(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> GcsImportStorage:
948
+ """
949
+ Sync tasks from a GCS import storage connection. You will need to provide the import storage ID. You can find this using [List import storages](list).
950
+
951
+ 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.
952
+
953
+ <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>
954
+
955
+ Parameters
956
+ ----------
957
+ id : int
958
+ Storage ID
959
+
960
+ request_options : typing.Optional[RequestOptions]
961
+ Request-specific configuration.
962
+
963
+ Returns
964
+ -------
965
+ GcsImportStorage
966
+
967
+
968
+ Examples
969
+ --------
970
+ from label_studio_sdk.client import AsyncLabelStudio
971
+
972
+ client = AsyncLabelStudio(
973
+ api_key="YOUR_API_KEY",
974
+ )
975
+ await client.import_storage.gcs.sync(
976
+ id=1,
977
+ )
978
+ """
979
+ _response = await self._client_wrapper.httpx_client.request(
980
+ f"api/storages/gcs/{jsonable_encoder(id)}/sync", method="POST", request_options=request_options
981
+ )
982
+ if 200 <= _response.status_code < 300:
983
+ return pydantic_v1.parse_obj_as(GcsImportStorage, _response.json()) # type: ignore
984
+ try:
985
+ _response_json = _response.json()
986
+ except JSONDecodeError:
987
+ raise ApiError(status_code=_response.status_code, body=_response.text)
988
+ raise ApiError(status_code=_response.status_code, body=_response_json)