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.
- label_studio_sdk/__init__.py +232 -9
- label_studio_sdk/_extensions/label_studio_tools/__init__.py +0 -0
- label_studio_sdk/_extensions/label_studio_tools/core/__init__.py +0 -0
- label_studio_sdk/_extensions/label_studio_tools/core/label_config.py +163 -0
- label_studio_sdk/_extensions/label_studio_tools/core/utils/__init__.py +0 -0
- label_studio_sdk/_extensions/label_studio_tools/core/utils/exceptions.py +2 -0
- label_studio_sdk/_extensions/label_studio_tools/core/utils/io.py +228 -0
- label_studio_sdk/_extensions/label_studio_tools/core/utils/params.py +45 -0
- label_studio_sdk/_extensions/label_studio_tools/etl/__init__.py +1 -0
- label_studio_sdk/_extensions/label_studio_tools/etl/beam.py +34 -0
- label_studio_sdk/_extensions/label_studio_tools/etl/example.py +17 -0
- label_studio_sdk/_extensions/label_studio_tools/etl/registry.py +67 -0
- label_studio_sdk/_extensions/label_studio_tools/postprocessing/__init__.py +0 -0
- label_studio_sdk/_extensions/label_studio_tools/postprocessing/video.py +97 -0
- label_studio_sdk/_extensions/pager_ext.py +49 -0
- label_studio_sdk/_legacy/__init__.py +11 -0
- label_studio_sdk/_legacy/client.py +471 -0
- label_studio_sdk/_legacy/objects.py +74 -0
- label_studio_sdk/{project.py → _legacy/project.py} +2 -2
- label_studio_sdk/{schema → _legacy/schema}/label_config_schema.json +14 -14
- label_studio_sdk/actions/__init__.py +27 -0
- label_studio_sdk/actions/client.py +223 -0
- label_studio_sdk/actions/types/__init__.py +25 -0
- label_studio_sdk/actions/types/actions_create_request_filters.py +43 -0
- label_studio_sdk/actions/types/actions_create_request_filters_conjunction.py +5 -0
- label_studio_sdk/actions/types/actions_create_request_filters_items_item.py +49 -0
- label_studio_sdk/actions/types/actions_create_request_filters_items_item_filter.py +31 -0
- label_studio_sdk/actions/types/actions_create_request_filters_items_item_operator.py +23 -0
- label_studio_sdk/actions/types/actions_create_request_id.py +19 -0
- label_studio_sdk/actions/types/actions_create_request_ordering_item.py +31 -0
- label_studio_sdk/actions/types/actions_create_request_selected_items.py +10 -0
- label_studio_sdk/actions/types/actions_create_request_selected_items_excluded.py +39 -0
- label_studio_sdk/actions/types/actions_create_request_selected_items_included.py +39 -0
- label_studio_sdk/annotations/__init__.py +2 -0
- label_studio_sdk/annotations/client.py +750 -0
- label_studio_sdk/base_client.py +183 -0
- label_studio_sdk/client.py +17 -463
- label_studio_sdk/converter/__init__.py +7 -0
- label_studio_sdk/converter/audio.py +56 -0
- label_studio_sdk/converter/brush.py +452 -0
- label_studio_sdk/converter/converter.py +1175 -0
- label_studio_sdk/converter/exports/__init__.py +0 -0
- label_studio_sdk/converter/exports/csv.py +82 -0
- label_studio_sdk/converter/exports/csv2.py +103 -0
- label_studio_sdk/converter/funsd.py +85 -0
- label_studio_sdk/converter/imports/__init__.py +0 -0
- label_studio_sdk/converter/imports/coco.py +314 -0
- label_studio_sdk/converter/imports/colors.py +198 -0
- label_studio_sdk/converter/imports/label_config.py +45 -0
- label_studio_sdk/converter/imports/pathtrack.py +269 -0
- label_studio_sdk/converter/imports/yolo.py +236 -0
- label_studio_sdk/converter/main.py +202 -0
- label_studio_sdk/converter/utils.py +473 -0
- label_studio_sdk/core/__init__.py +33 -0
- label_studio_sdk/core/api_error.py +15 -0
- label_studio_sdk/core/client_wrapper.py +55 -0
- label_studio_sdk/core/datetime_utils.py +28 -0
- label_studio_sdk/core/file.py +38 -0
- label_studio_sdk/core/http_client.py +447 -0
- label_studio_sdk/core/jsonable_encoder.py +99 -0
- label_studio_sdk/core/pagination.py +87 -0
- label_studio_sdk/core/pydantic_utilities.py +28 -0
- label_studio_sdk/core/query_encoder.py +33 -0
- label_studio_sdk/core/remove_none_from_dict.py +11 -0
- label_studio_sdk/core/request_options.py +32 -0
- label_studio_sdk/environment.py +7 -0
- label_studio_sdk/errors/__init__.py +6 -0
- label_studio_sdk/errors/bad_request_error.py +8 -0
- label_studio_sdk/errors/internal_server_error.py +8 -0
- label_studio_sdk/export_storage/__init__.py +28 -0
- label_studio_sdk/export_storage/azure/__init__.py +5 -0
- label_studio_sdk/export_storage/azure/client.py +888 -0
- label_studio_sdk/export_storage/azure/types/__init__.py +6 -0
- label_studio_sdk/export_storage/azure/types/azure_create_response.py +67 -0
- label_studio_sdk/export_storage/azure/types/azure_update_response.py +67 -0
- label_studio_sdk/export_storage/client.py +107 -0
- label_studio_sdk/export_storage/gcs/__init__.py +5 -0
- label_studio_sdk/export_storage/gcs/client.py +888 -0
- label_studio_sdk/export_storage/gcs/types/__init__.py +6 -0
- label_studio_sdk/export_storage/gcs/types/gcs_create_response.py +67 -0
- label_studio_sdk/export_storage/gcs/types/gcs_update_response.py +67 -0
- label_studio_sdk/export_storage/local/__init__.py +5 -0
- label_studio_sdk/export_storage/local/client.py +834 -0
- label_studio_sdk/export_storage/local/types/__init__.py +6 -0
- label_studio_sdk/export_storage/local/types/local_create_response.py +57 -0
- label_studio_sdk/export_storage/local/types/local_update_response.py +57 -0
- label_studio_sdk/export_storage/redis/__init__.py +5 -0
- label_studio_sdk/export_storage/redis/client.py +918 -0
- label_studio_sdk/export_storage/redis/types/__init__.py +6 -0
- label_studio_sdk/export_storage/redis/types/redis_create_response.py +72 -0
- label_studio_sdk/export_storage/redis/types/redis_update_response.py +72 -0
- label_studio_sdk/export_storage/s3/__init__.py +5 -0
- label_studio_sdk/export_storage/s3/client.py +1008 -0
- label_studio_sdk/export_storage/s3/types/__init__.py +6 -0
- label_studio_sdk/export_storage/s3/types/s3create_response.py +89 -0
- label_studio_sdk/export_storage/s3/types/s3update_response.py +89 -0
- label_studio_sdk/export_storage/types/__init__.py +5 -0
- label_studio_sdk/export_storage/types/export_storage_list_types_response_item.py +30 -0
- label_studio_sdk/files/__init__.py +2 -0
- label_studio_sdk/files/client.py +556 -0
- label_studio_sdk/import_storage/__init__.py +28 -0
- label_studio_sdk/import_storage/azure/__init__.py +5 -0
- label_studio_sdk/import_storage/azure/client.py +988 -0
- label_studio_sdk/import_storage/azure/types/__init__.py +6 -0
- label_studio_sdk/import_storage/azure/types/azure_create_response.py +82 -0
- label_studio_sdk/import_storage/azure/types/azure_update_response.py +82 -0
- label_studio_sdk/import_storage/client.py +107 -0
- label_studio_sdk/import_storage/gcs/__init__.py +5 -0
- label_studio_sdk/import_storage/gcs/client.py +988 -0
- label_studio_sdk/import_storage/gcs/types/__init__.py +6 -0
- label_studio_sdk/import_storage/gcs/types/gcs_create_response.py +82 -0
- label_studio_sdk/import_storage/gcs/types/gcs_update_response.py +82 -0
- label_studio_sdk/import_storage/local/__init__.py +5 -0
- label_studio_sdk/import_storage/local/client.py +836 -0
- label_studio_sdk/import_storage/local/types/__init__.py +6 -0
- label_studio_sdk/import_storage/local/types/local_create_response.py +57 -0
- label_studio_sdk/import_storage/local/types/local_update_response.py +57 -0
- label_studio_sdk/import_storage/redis/__init__.py +5 -0
- label_studio_sdk/import_storage/redis/client.py +924 -0
- label_studio_sdk/import_storage/redis/types/__init__.py +6 -0
- label_studio_sdk/import_storage/redis/types/redis_create_response.py +72 -0
- label_studio_sdk/import_storage/redis/types/redis_update_response.py +72 -0
- label_studio_sdk/import_storage/s3/__init__.py +5 -0
- label_studio_sdk/import_storage/s3/client.py +1138 -0
- label_studio_sdk/import_storage/s3/types/__init__.py +6 -0
- label_studio_sdk/import_storage/s3/types/s3create_response.py +109 -0
- label_studio_sdk/import_storage/s3/types/s3update_response.py +109 -0
- label_studio_sdk/import_storage/types/__init__.py +5 -0
- label_studio_sdk/import_storage/types/import_storage_list_types_response_item.py +30 -0
- label_studio_sdk/label_interface/base.py +10 -0
- label_studio_sdk/label_interface/control_tags.py +109 -71
- label_studio_sdk/label_interface/data_examples.json +96 -0
- label_studio_sdk/label_interface/interface.py +102 -53
- label_studio_sdk/label_interface/object_tags.py +8 -13
- label_studio_sdk/label_interface/region.py +33 -1
- label_studio_sdk/ml/__init__.py +19 -0
- label_studio_sdk/ml/client.py +981 -0
- label_studio_sdk/ml/types/__init__.py +17 -0
- label_studio_sdk/ml/types/ml_create_request_auth_method.py +5 -0
- label_studio_sdk/ml/types/ml_create_response.py +78 -0
- label_studio_sdk/ml/types/ml_create_response_auth_method.py +5 -0
- label_studio_sdk/ml/types/ml_update_request_auth_method.py +5 -0
- label_studio_sdk/ml/types/ml_update_response.py +78 -0
- label_studio_sdk/ml/types/ml_update_response_auth_method.py +5 -0
- label_studio_sdk/predictions/__init__.py +2 -0
- label_studio_sdk/predictions/client.py +638 -0
- label_studio_sdk/projects/__init__.py +6 -0
- label_studio_sdk/projects/client.py +1055 -0
- label_studio_sdk/projects/client_ext.py +19 -0
- label_studio_sdk/projects/exports/__init__.py +2 -0
- label_studio_sdk/projects/exports/client.py +930 -0
- label_studio_sdk/projects/types/__init__.py +7 -0
- label_studio_sdk/projects/types/projects_create_response.py +96 -0
- label_studio_sdk/projects/types/projects_import_tasks_response.py +71 -0
- label_studio_sdk/projects/types/projects_list_response.py +33 -0
- label_studio_sdk/py.typed +0 -0
- label_studio_sdk/tasks/__init__.py +5 -0
- label_studio_sdk/tasks/client.py +835 -0
- label_studio_sdk/tasks/client_ext.py +18 -0
- label_studio_sdk/tasks/types/__init__.py +6 -0
- label_studio_sdk/tasks/types/tasks_list_request_fields.py +5 -0
- label_studio_sdk/tasks/types/tasks_list_response.py +48 -0
- label_studio_sdk/types/__init__.py +115 -0
- label_studio_sdk/types/annotation.py +116 -0
- label_studio_sdk/types/annotation_filter_options.py +42 -0
- label_studio_sdk/types/annotation_last_action.py +19 -0
- label_studio_sdk/types/azure_blob_export_storage.py +112 -0
- label_studio_sdk/types/azure_blob_export_storage_status.py +7 -0
- label_studio_sdk/types/azure_blob_import_storage.py +113 -0
- label_studio_sdk/types/azure_blob_import_storage_status.py +7 -0
- label_studio_sdk/types/base_task.py +113 -0
- label_studio_sdk/types/base_user.py +42 -0
- label_studio_sdk/types/converted_format.py +36 -0
- label_studio_sdk/types/converted_format_status.py +5 -0
- label_studio_sdk/types/export.py +48 -0
- label_studio_sdk/types/export_convert.py +32 -0
- label_studio_sdk/types/export_create.py +54 -0
- label_studio_sdk/types/export_create_status.py +5 -0
- label_studio_sdk/types/export_status.py +5 -0
- label_studio_sdk/types/file_upload.py +30 -0
- label_studio_sdk/types/filter.py +53 -0
- label_studio_sdk/types/filter_group.py +35 -0
- label_studio_sdk/types/gcs_export_storage.py +112 -0
- label_studio_sdk/types/gcs_export_storage_status.py +7 -0
- label_studio_sdk/types/gcs_import_storage.py +113 -0
- label_studio_sdk/types/gcs_import_storage_status.py +7 -0
- label_studio_sdk/types/local_files_export_storage.py +97 -0
- label_studio_sdk/types/local_files_export_storage_status.py +7 -0
- label_studio_sdk/types/local_files_import_storage.py +92 -0
- label_studio_sdk/types/local_files_import_storage_status.py +7 -0
- label_studio_sdk/types/ml_backend.py +89 -0
- label_studio_sdk/types/ml_backend_auth_method.py +5 -0
- label_studio_sdk/types/ml_backend_state.py +5 -0
- label_studio_sdk/types/prediction.py +78 -0
- label_studio_sdk/types/project.py +198 -0
- label_studio_sdk/types/project_import.py +63 -0
- label_studio_sdk/types/project_import_status.py +5 -0
- label_studio_sdk/types/project_label_config.py +32 -0
- label_studio_sdk/types/project_sampling.py +7 -0
- label_studio_sdk/types/project_skip_queue.py +5 -0
- label_studio_sdk/types/redis_export_storage.py +117 -0
- label_studio_sdk/types/redis_export_storage_status.py +7 -0
- label_studio_sdk/types/redis_import_storage.py +112 -0
- label_studio_sdk/types/redis_import_storage_status.py +7 -0
- label_studio_sdk/types/s3export_storage.py +134 -0
- label_studio_sdk/types/s3export_storage_status.py +7 -0
- label_studio_sdk/types/s3import_storage.py +140 -0
- label_studio_sdk/types/s3import_storage_status.py +7 -0
- label_studio_sdk/types/serialization_option.py +36 -0
- label_studio_sdk/types/serialization_options.py +45 -0
- label_studio_sdk/types/task.py +157 -0
- label_studio_sdk/types/task_filter_options.py +49 -0
- label_studio_sdk/types/user_simple.py +37 -0
- label_studio_sdk/types/view.py +55 -0
- label_studio_sdk/types/webhook.py +67 -0
- label_studio_sdk/types/webhook_actions_item.py +21 -0
- label_studio_sdk/types/webhook_serializer_for_update.py +67 -0
- label_studio_sdk/types/webhook_serializer_for_update_actions_item.py +21 -0
- label_studio_sdk/users/__init__.py +5 -0
- label_studio_sdk/users/client.py +830 -0
- label_studio_sdk/users/types/__init__.py +6 -0
- label_studio_sdk/users/types/users_get_token_response.py +36 -0
- label_studio_sdk/users/types/users_reset_token_response.py +36 -0
- label_studio_sdk/version.py +4 -0
- label_studio_sdk/views/__init__.py +35 -0
- label_studio_sdk/views/client.py +564 -0
- label_studio_sdk/views/types/__init__.py +33 -0
- label_studio_sdk/views/types/views_create_request_data.py +43 -0
- label_studio_sdk/views/types/views_create_request_data_filters.py +43 -0
- label_studio_sdk/views/types/views_create_request_data_filters_conjunction.py +5 -0
- label_studio_sdk/views/types/views_create_request_data_filters_items_item.py +49 -0
- label_studio_sdk/views/types/views_create_request_data_filters_items_item_filter.py +31 -0
- label_studio_sdk/views/types/views_create_request_data_filters_items_item_operator.py +23 -0
- label_studio_sdk/views/types/views_create_request_data_ordering_item.py +31 -0
- label_studio_sdk/views/types/views_update_request_data.py +43 -0
- label_studio_sdk/views/types/views_update_request_data_filters.py +43 -0
- label_studio_sdk/views/types/views_update_request_data_filters_conjunction.py +5 -0
- label_studio_sdk/views/types/views_update_request_data_filters_items_item.py +49 -0
- label_studio_sdk/views/types/views_update_request_data_filters_items_item_filter.py +31 -0
- label_studio_sdk/views/types/views_update_request_data_filters_items_item_operator.py +23 -0
- label_studio_sdk/views/types/views_update_request_data_ordering_item.py +31 -0
- label_studio_sdk/webhooks/__init__.py +5 -0
- label_studio_sdk/webhooks/client.py +636 -0
- label_studio_sdk/webhooks/types/__init__.py +5 -0
- label_studio_sdk/webhooks/types/webhooks_update_request_actions_item.py +21 -0
- label_studio_sdk-1.0.1.dist-info/METADATA +163 -0
- label_studio_sdk-1.0.1.dist-info/RECORD +256 -0
- {label_studio_sdk-0.0.34.dist-info → label_studio_sdk-1.0.1.dist-info}/WHEEL +1 -2
- label_studio_sdk/objects.py +0 -35
- label_studio_sdk-0.0.34.dist-info/LICENSE +0 -201
- label_studio_sdk-0.0.34.dist-info/METADATA +0 -24
- label_studio_sdk-0.0.34.dist-info/RECORD +0 -37
- label_studio_sdk-0.0.34.dist-info/top_level.txt +0 -2
- tests/test_client.py +0 -37
- tests/test_export.py +0 -105
- tests/test_interface/__init__.py +0 -1
- tests/test_interface/configs.py +0 -137
- tests/test_interface/mockups.py +0 -22
- tests/test_interface/test_compat.py +0 -64
- tests/test_interface/test_control_tags.py +0 -55
- tests/test_interface/test_data_generation.py +0 -45
- tests/test_interface/test_lpi.py +0 -15
- tests/test_interface/test_main.py +0 -196
- tests/test_interface/test_object_tags.py +0 -36
- tests/test_interface/test_region.py +0 -36
- tests/test_interface/test_validate_summary.py +0 -35
- tests/test_interface/test_validation.py +0 -59
- {tests → label_studio_sdk/_extensions}/__init__.py +0 -0
- /label_studio_sdk/{exceptions.py → _legacy/exceptions.py} +0 -0
- /label_studio_sdk/{users.py → _legacy/users.py} +0 -0
- /label_studio_sdk/{utils.py → _legacy/utils.py} +0 -0
- /label_studio_sdk/{workspaces.py → _legacy/workspaces.py} +0 -0
|
@@ -0,0 +1,636 @@
|
|
|
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.webhook import Webhook
|
|
12
|
+
from ..types.webhook_serializer_for_update import WebhookSerializerForUpdate
|
|
13
|
+
from .types.webhooks_update_request_actions_item import WebhooksUpdateRequestActionsItem
|
|
14
|
+
|
|
15
|
+
# this is used as the default value for optional parameters
|
|
16
|
+
OMIT = typing.cast(typing.Any, ...)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class WebhooksClient:
|
|
20
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
21
|
+
self._client_wrapper = client_wrapper
|
|
22
|
+
|
|
23
|
+
def list(
|
|
24
|
+
self, *, project: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None
|
|
25
|
+
) -> typing.List[Webhook]:
|
|
26
|
+
"""
|
|
27
|
+
List all webhooks set up for your organization.
|
|
28
|
+
|
|
29
|
+
Webhooks in Label Studio let you set up integrations that subscribe to certain events that occur inside Label Studio. When an event is triggered, Label Studio sends an HTTP POST request to the configured webhook URL.
|
|
30
|
+
|
|
31
|
+
For more information, see [Set up webhooks in Label Studio](https://labelstud.io/guide/webhooks).
|
|
32
|
+
|
|
33
|
+
Parameters
|
|
34
|
+
----------
|
|
35
|
+
project : typing.Optional[str]
|
|
36
|
+
Project ID
|
|
37
|
+
|
|
38
|
+
request_options : typing.Optional[RequestOptions]
|
|
39
|
+
Request-specific configuration.
|
|
40
|
+
|
|
41
|
+
Returns
|
|
42
|
+
-------
|
|
43
|
+
typing.List[Webhook]
|
|
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.webhooks.list()
|
|
54
|
+
"""
|
|
55
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
56
|
+
"api/webhooks/", 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[Webhook], _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(self, *, request: Webhook, request_options: typing.Optional[RequestOptions] = None) -> Webhook:
|
|
67
|
+
"""
|
|
68
|
+
Create a webhook.
|
|
69
|
+
Label Studio provides several out-of-the box webhook events, which you can find listed here: [Available Label Studio webhooks](https://labelstud.io/guide/webhooks#Available-Label-Studio-webhooks).
|
|
70
|
+
|
|
71
|
+
If you want to create your own custom webhook, refer to [Create custom events for webhooks in Label Studio](https://labelstud.io/guide/webhook_create).
|
|
72
|
+
|
|
73
|
+
<Note>Label Studio makes two main types of events available to integrate with webhooks: project-level task events and organization events. If you want to use organization-level webhook events, you will need to set `LABEL_STUDIO_ALLOW_ORGANIZATION_WEBHOOKS=true`. </Note>
|
|
74
|
+
|
|
75
|
+
Parameters
|
|
76
|
+
----------
|
|
77
|
+
request : Webhook
|
|
78
|
+
|
|
79
|
+
request_options : typing.Optional[RequestOptions]
|
|
80
|
+
Request-specific configuration.
|
|
81
|
+
|
|
82
|
+
Returns
|
|
83
|
+
-------
|
|
84
|
+
Webhook
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
Examples
|
|
88
|
+
--------
|
|
89
|
+
from label_studio_sdk import Webhook
|
|
90
|
+
from label_studio_sdk.client import LabelStudio
|
|
91
|
+
|
|
92
|
+
client = LabelStudio(
|
|
93
|
+
api_key="YOUR_API_KEY",
|
|
94
|
+
)
|
|
95
|
+
client.webhooks.create(
|
|
96
|
+
request=Webhook(
|
|
97
|
+
url="url",
|
|
98
|
+
),
|
|
99
|
+
)
|
|
100
|
+
"""
|
|
101
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
102
|
+
"api/webhooks/", method="POST", json=request, request_options=request_options, omit=OMIT
|
|
103
|
+
)
|
|
104
|
+
if 200 <= _response.status_code < 300:
|
|
105
|
+
return pydantic_v1.parse_obj_as(Webhook, _response.json()) # type: ignore
|
|
106
|
+
try:
|
|
107
|
+
_response_json = _response.json()
|
|
108
|
+
except JSONDecodeError:
|
|
109
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
110
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
111
|
+
|
|
112
|
+
def info(
|
|
113
|
+
self,
|
|
114
|
+
*,
|
|
115
|
+
organization_only: typing.Optional[bool] = None,
|
|
116
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
117
|
+
) -> None:
|
|
118
|
+
"""
|
|
119
|
+
Get descriptions of all available webhook actions to set up webhooks. For more information, see the [Webhook event reference](https://labelstud.io/guide/webhook_reference).
|
|
120
|
+
|
|
121
|
+
Parameters
|
|
122
|
+
----------
|
|
123
|
+
organization_only : typing.Optional[bool]
|
|
124
|
+
organization-only or not
|
|
125
|
+
|
|
126
|
+
request_options : typing.Optional[RequestOptions]
|
|
127
|
+
Request-specific configuration.
|
|
128
|
+
|
|
129
|
+
Returns
|
|
130
|
+
-------
|
|
131
|
+
None
|
|
132
|
+
|
|
133
|
+
Examples
|
|
134
|
+
--------
|
|
135
|
+
from label_studio_sdk.client import LabelStudio
|
|
136
|
+
|
|
137
|
+
client = LabelStudio(
|
|
138
|
+
api_key="YOUR_API_KEY",
|
|
139
|
+
)
|
|
140
|
+
client.webhooks.info()
|
|
141
|
+
"""
|
|
142
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
143
|
+
"api/webhooks/info/",
|
|
144
|
+
method="GET",
|
|
145
|
+
params={"organization-only": organization_only},
|
|
146
|
+
request_options=request_options,
|
|
147
|
+
)
|
|
148
|
+
if 200 <= _response.status_code < 300:
|
|
149
|
+
return
|
|
150
|
+
try:
|
|
151
|
+
_response_json = _response.json()
|
|
152
|
+
except JSONDecodeError:
|
|
153
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
154
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
155
|
+
|
|
156
|
+
def get(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> Webhook:
|
|
157
|
+
"""
|
|
158
|
+
Get information about a specific webhook. You will need to provide the webhook ID. You can get this from [List all webhooks](list).
|
|
159
|
+
|
|
160
|
+
For more information about webhooks, see [Set up webhooks in Label Studio](https://labelstud.io/guide/webhooks) and the [Webhook event reference](https://labelstud.io/guide/webhook_reference).
|
|
161
|
+
|
|
162
|
+
Parameters
|
|
163
|
+
----------
|
|
164
|
+
id : int
|
|
165
|
+
A unique integer value identifying this webhook.
|
|
166
|
+
|
|
167
|
+
request_options : typing.Optional[RequestOptions]
|
|
168
|
+
Request-specific configuration.
|
|
169
|
+
|
|
170
|
+
Returns
|
|
171
|
+
-------
|
|
172
|
+
Webhook
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
Examples
|
|
176
|
+
--------
|
|
177
|
+
from label_studio_sdk.client import LabelStudio
|
|
178
|
+
|
|
179
|
+
client = LabelStudio(
|
|
180
|
+
api_key="YOUR_API_KEY",
|
|
181
|
+
)
|
|
182
|
+
client.webhooks.get(
|
|
183
|
+
id=1,
|
|
184
|
+
)
|
|
185
|
+
"""
|
|
186
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
187
|
+
f"api/webhooks/{jsonable_encoder(id)}/", method="GET", request_options=request_options
|
|
188
|
+
)
|
|
189
|
+
if 200 <= _response.status_code < 300:
|
|
190
|
+
return pydantic_v1.parse_obj_as(Webhook, _response.json()) # type: ignore
|
|
191
|
+
try:
|
|
192
|
+
_response_json = _response.json()
|
|
193
|
+
except JSONDecodeError:
|
|
194
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
195
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
196
|
+
|
|
197
|
+
def delete(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> None:
|
|
198
|
+
"""
|
|
199
|
+
Delete a webhook. You will need to provide the webhook ID. You can get this from [List all webhooks](list).
|
|
200
|
+
|
|
201
|
+
For more information about webhooks, see [Set up webhooks in Label Studio](https://labelstud.io/guide/webhooks) and the [Webhook event reference](https://labelstud.io/guide/webhook_reference).
|
|
202
|
+
|
|
203
|
+
Parameters
|
|
204
|
+
----------
|
|
205
|
+
id : int
|
|
206
|
+
A unique integer value identifying this webhook.
|
|
207
|
+
|
|
208
|
+
request_options : typing.Optional[RequestOptions]
|
|
209
|
+
Request-specific configuration.
|
|
210
|
+
|
|
211
|
+
Returns
|
|
212
|
+
-------
|
|
213
|
+
None
|
|
214
|
+
|
|
215
|
+
Examples
|
|
216
|
+
--------
|
|
217
|
+
from label_studio_sdk.client import LabelStudio
|
|
218
|
+
|
|
219
|
+
client = LabelStudio(
|
|
220
|
+
api_key="YOUR_API_KEY",
|
|
221
|
+
)
|
|
222
|
+
client.webhooks.delete(
|
|
223
|
+
id=1,
|
|
224
|
+
)
|
|
225
|
+
"""
|
|
226
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
227
|
+
f"api/webhooks/{jsonable_encoder(id)}/", method="DELETE", request_options=request_options
|
|
228
|
+
)
|
|
229
|
+
if 200 <= _response.status_code < 300:
|
|
230
|
+
return
|
|
231
|
+
try:
|
|
232
|
+
_response_json = _response.json()
|
|
233
|
+
except JSONDecodeError:
|
|
234
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
235
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
236
|
+
|
|
237
|
+
def update(
|
|
238
|
+
self,
|
|
239
|
+
id: int,
|
|
240
|
+
*,
|
|
241
|
+
url: str,
|
|
242
|
+
request: WebhookSerializerForUpdate,
|
|
243
|
+
send_payload: typing.Optional[bool] = None,
|
|
244
|
+
send_for_all_actions: typing.Optional[bool] = None,
|
|
245
|
+
headers: typing.Optional[str] = None,
|
|
246
|
+
is_active: typing.Optional[bool] = None,
|
|
247
|
+
actions: typing.Optional[
|
|
248
|
+
typing.Union[WebhooksUpdateRequestActionsItem, typing.Sequence[WebhooksUpdateRequestActionsItem]]
|
|
249
|
+
] = None,
|
|
250
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
251
|
+
) -> WebhookSerializerForUpdate:
|
|
252
|
+
"""
|
|
253
|
+
Update a webhook. You will need to provide the webhook ID. You can get this from [List all webhooks](list).
|
|
254
|
+
|
|
255
|
+
For more information about webhooks, see [Set up webhooks in Label Studio](https://labelstud.io/guide/webhooks) and the [Webhook event reference](https://labelstud.io/guide/webhook_reference).
|
|
256
|
+
|
|
257
|
+
Parameters
|
|
258
|
+
----------
|
|
259
|
+
id : int
|
|
260
|
+
A unique integer value identifying this webhook.
|
|
261
|
+
|
|
262
|
+
url : str
|
|
263
|
+
URL of webhook
|
|
264
|
+
|
|
265
|
+
request : WebhookSerializerForUpdate
|
|
266
|
+
|
|
267
|
+
send_payload : typing.Optional[bool]
|
|
268
|
+
If value is False send only action
|
|
269
|
+
|
|
270
|
+
send_for_all_actions : typing.Optional[bool]
|
|
271
|
+
If value is False - used only for actions from WebhookAction
|
|
272
|
+
|
|
273
|
+
headers : typing.Optional[str]
|
|
274
|
+
Key Value Json of headers
|
|
275
|
+
|
|
276
|
+
is_active : typing.Optional[bool]
|
|
277
|
+
If value is False the webhook is disabled
|
|
278
|
+
|
|
279
|
+
actions : typing.Optional[typing.Union[WebhooksUpdateRequestActionsItem, typing.Sequence[WebhooksUpdateRequestActionsItem]]]
|
|
280
|
+
|
|
281
|
+
request_options : typing.Optional[RequestOptions]
|
|
282
|
+
Request-specific configuration.
|
|
283
|
+
|
|
284
|
+
Returns
|
|
285
|
+
-------
|
|
286
|
+
WebhookSerializerForUpdate
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
Examples
|
|
290
|
+
--------
|
|
291
|
+
from label_studio_sdk import WebhookSerializerForUpdate
|
|
292
|
+
from label_studio_sdk.client import LabelStudio
|
|
293
|
+
|
|
294
|
+
client = LabelStudio(
|
|
295
|
+
api_key="YOUR_API_KEY",
|
|
296
|
+
)
|
|
297
|
+
client.webhooks.update(
|
|
298
|
+
id=1,
|
|
299
|
+
url="url",
|
|
300
|
+
request=WebhookSerializerForUpdate(
|
|
301
|
+
url="url",
|
|
302
|
+
),
|
|
303
|
+
)
|
|
304
|
+
"""
|
|
305
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
306
|
+
f"api/webhooks/{jsonable_encoder(id)}/",
|
|
307
|
+
method="PATCH",
|
|
308
|
+
params={
|
|
309
|
+
"url": url,
|
|
310
|
+
"send_payload": send_payload,
|
|
311
|
+
"send_for_all_actions": send_for_all_actions,
|
|
312
|
+
"headers": headers,
|
|
313
|
+
"is_active": is_active,
|
|
314
|
+
"actions": actions,
|
|
315
|
+
},
|
|
316
|
+
json=request,
|
|
317
|
+
request_options=request_options,
|
|
318
|
+
omit=OMIT,
|
|
319
|
+
)
|
|
320
|
+
if 200 <= _response.status_code < 300:
|
|
321
|
+
return pydantic_v1.parse_obj_as(WebhookSerializerForUpdate, _response.json()) # type: ignore
|
|
322
|
+
try:
|
|
323
|
+
_response_json = _response.json()
|
|
324
|
+
except JSONDecodeError:
|
|
325
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
326
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
class AsyncWebhooksClient:
|
|
330
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
331
|
+
self._client_wrapper = client_wrapper
|
|
332
|
+
|
|
333
|
+
async def list(
|
|
334
|
+
self, *, project: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None
|
|
335
|
+
) -> typing.List[Webhook]:
|
|
336
|
+
"""
|
|
337
|
+
List all webhooks set up for your organization.
|
|
338
|
+
|
|
339
|
+
Webhooks in Label Studio let you set up integrations that subscribe to certain events that occur inside Label Studio. When an event is triggered, Label Studio sends an HTTP POST request to the configured webhook URL.
|
|
340
|
+
|
|
341
|
+
For more information, see [Set up webhooks in Label Studio](https://labelstud.io/guide/webhooks).
|
|
342
|
+
|
|
343
|
+
Parameters
|
|
344
|
+
----------
|
|
345
|
+
project : typing.Optional[str]
|
|
346
|
+
Project ID
|
|
347
|
+
|
|
348
|
+
request_options : typing.Optional[RequestOptions]
|
|
349
|
+
Request-specific configuration.
|
|
350
|
+
|
|
351
|
+
Returns
|
|
352
|
+
-------
|
|
353
|
+
typing.List[Webhook]
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
Examples
|
|
357
|
+
--------
|
|
358
|
+
from label_studio_sdk.client import AsyncLabelStudio
|
|
359
|
+
|
|
360
|
+
client = AsyncLabelStudio(
|
|
361
|
+
api_key="YOUR_API_KEY",
|
|
362
|
+
)
|
|
363
|
+
await client.webhooks.list()
|
|
364
|
+
"""
|
|
365
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
366
|
+
"api/webhooks/", method="GET", params={"project": project}, request_options=request_options
|
|
367
|
+
)
|
|
368
|
+
if 200 <= _response.status_code < 300:
|
|
369
|
+
return pydantic_v1.parse_obj_as(typing.List[Webhook], _response.json()) # type: ignore
|
|
370
|
+
try:
|
|
371
|
+
_response_json = _response.json()
|
|
372
|
+
except JSONDecodeError:
|
|
373
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
374
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
375
|
+
|
|
376
|
+
async def create(self, *, request: Webhook, request_options: typing.Optional[RequestOptions] = None) -> Webhook:
|
|
377
|
+
"""
|
|
378
|
+
Create a webhook.
|
|
379
|
+
Label Studio provides several out-of-the box webhook events, which you can find listed here: [Available Label Studio webhooks](https://labelstud.io/guide/webhooks#Available-Label-Studio-webhooks).
|
|
380
|
+
|
|
381
|
+
If you want to create your own custom webhook, refer to [Create custom events for webhooks in Label Studio](https://labelstud.io/guide/webhook_create).
|
|
382
|
+
|
|
383
|
+
<Note>Label Studio makes two main types of events available to integrate with webhooks: project-level task events and organization events. If you want to use organization-level webhook events, you will need to set `LABEL_STUDIO_ALLOW_ORGANIZATION_WEBHOOKS=true`. </Note>
|
|
384
|
+
|
|
385
|
+
Parameters
|
|
386
|
+
----------
|
|
387
|
+
request : Webhook
|
|
388
|
+
|
|
389
|
+
request_options : typing.Optional[RequestOptions]
|
|
390
|
+
Request-specific configuration.
|
|
391
|
+
|
|
392
|
+
Returns
|
|
393
|
+
-------
|
|
394
|
+
Webhook
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
Examples
|
|
398
|
+
--------
|
|
399
|
+
from label_studio_sdk import Webhook
|
|
400
|
+
from label_studio_sdk.client import AsyncLabelStudio
|
|
401
|
+
|
|
402
|
+
client = AsyncLabelStudio(
|
|
403
|
+
api_key="YOUR_API_KEY",
|
|
404
|
+
)
|
|
405
|
+
await client.webhooks.create(
|
|
406
|
+
request=Webhook(
|
|
407
|
+
url="url",
|
|
408
|
+
),
|
|
409
|
+
)
|
|
410
|
+
"""
|
|
411
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
412
|
+
"api/webhooks/", method="POST", json=request, request_options=request_options, omit=OMIT
|
|
413
|
+
)
|
|
414
|
+
if 200 <= _response.status_code < 300:
|
|
415
|
+
return pydantic_v1.parse_obj_as(Webhook, _response.json()) # type: ignore
|
|
416
|
+
try:
|
|
417
|
+
_response_json = _response.json()
|
|
418
|
+
except JSONDecodeError:
|
|
419
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
420
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
421
|
+
|
|
422
|
+
async def info(
|
|
423
|
+
self,
|
|
424
|
+
*,
|
|
425
|
+
organization_only: typing.Optional[bool] = None,
|
|
426
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
427
|
+
) -> None:
|
|
428
|
+
"""
|
|
429
|
+
Get descriptions of all available webhook actions to set up webhooks. For more information, see the [Webhook event reference](https://labelstud.io/guide/webhook_reference).
|
|
430
|
+
|
|
431
|
+
Parameters
|
|
432
|
+
----------
|
|
433
|
+
organization_only : typing.Optional[bool]
|
|
434
|
+
organization-only or not
|
|
435
|
+
|
|
436
|
+
request_options : typing.Optional[RequestOptions]
|
|
437
|
+
Request-specific configuration.
|
|
438
|
+
|
|
439
|
+
Returns
|
|
440
|
+
-------
|
|
441
|
+
None
|
|
442
|
+
|
|
443
|
+
Examples
|
|
444
|
+
--------
|
|
445
|
+
from label_studio_sdk.client import AsyncLabelStudio
|
|
446
|
+
|
|
447
|
+
client = AsyncLabelStudio(
|
|
448
|
+
api_key="YOUR_API_KEY",
|
|
449
|
+
)
|
|
450
|
+
await client.webhooks.info()
|
|
451
|
+
"""
|
|
452
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
453
|
+
"api/webhooks/info/",
|
|
454
|
+
method="GET",
|
|
455
|
+
params={"organization-only": organization_only},
|
|
456
|
+
request_options=request_options,
|
|
457
|
+
)
|
|
458
|
+
if 200 <= _response.status_code < 300:
|
|
459
|
+
return
|
|
460
|
+
try:
|
|
461
|
+
_response_json = _response.json()
|
|
462
|
+
except JSONDecodeError:
|
|
463
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
464
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
465
|
+
|
|
466
|
+
async def get(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> Webhook:
|
|
467
|
+
"""
|
|
468
|
+
Get information about a specific webhook. You will need to provide the webhook ID. You can get this from [List all webhooks](list).
|
|
469
|
+
|
|
470
|
+
For more information about webhooks, see [Set up webhooks in Label Studio](https://labelstud.io/guide/webhooks) and the [Webhook event reference](https://labelstud.io/guide/webhook_reference).
|
|
471
|
+
|
|
472
|
+
Parameters
|
|
473
|
+
----------
|
|
474
|
+
id : int
|
|
475
|
+
A unique integer value identifying this webhook.
|
|
476
|
+
|
|
477
|
+
request_options : typing.Optional[RequestOptions]
|
|
478
|
+
Request-specific configuration.
|
|
479
|
+
|
|
480
|
+
Returns
|
|
481
|
+
-------
|
|
482
|
+
Webhook
|
|
483
|
+
|
|
484
|
+
|
|
485
|
+
Examples
|
|
486
|
+
--------
|
|
487
|
+
from label_studio_sdk.client import AsyncLabelStudio
|
|
488
|
+
|
|
489
|
+
client = AsyncLabelStudio(
|
|
490
|
+
api_key="YOUR_API_KEY",
|
|
491
|
+
)
|
|
492
|
+
await client.webhooks.get(
|
|
493
|
+
id=1,
|
|
494
|
+
)
|
|
495
|
+
"""
|
|
496
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
497
|
+
f"api/webhooks/{jsonable_encoder(id)}/", method="GET", request_options=request_options
|
|
498
|
+
)
|
|
499
|
+
if 200 <= _response.status_code < 300:
|
|
500
|
+
return pydantic_v1.parse_obj_as(Webhook, _response.json()) # type: ignore
|
|
501
|
+
try:
|
|
502
|
+
_response_json = _response.json()
|
|
503
|
+
except JSONDecodeError:
|
|
504
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
505
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
506
|
+
|
|
507
|
+
async def delete(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> None:
|
|
508
|
+
"""
|
|
509
|
+
Delete a webhook. You will need to provide the webhook ID. You can get this from [List all webhooks](list).
|
|
510
|
+
|
|
511
|
+
For more information about webhooks, see [Set up webhooks in Label Studio](https://labelstud.io/guide/webhooks) and the [Webhook event reference](https://labelstud.io/guide/webhook_reference).
|
|
512
|
+
|
|
513
|
+
Parameters
|
|
514
|
+
----------
|
|
515
|
+
id : int
|
|
516
|
+
A unique integer value identifying this webhook.
|
|
517
|
+
|
|
518
|
+
request_options : typing.Optional[RequestOptions]
|
|
519
|
+
Request-specific configuration.
|
|
520
|
+
|
|
521
|
+
Returns
|
|
522
|
+
-------
|
|
523
|
+
None
|
|
524
|
+
|
|
525
|
+
Examples
|
|
526
|
+
--------
|
|
527
|
+
from label_studio_sdk.client import AsyncLabelStudio
|
|
528
|
+
|
|
529
|
+
client = AsyncLabelStudio(
|
|
530
|
+
api_key="YOUR_API_KEY",
|
|
531
|
+
)
|
|
532
|
+
await client.webhooks.delete(
|
|
533
|
+
id=1,
|
|
534
|
+
)
|
|
535
|
+
"""
|
|
536
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
537
|
+
f"api/webhooks/{jsonable_encoder(id)}/", method="DELETE", request_options=request_options
|
|
538
|
+
)
|
|
539
|
+
if 200 <= _response.status_code < 300:
|
|
540
|
+
return
|
|
541
|
+
try:
|
|
542
|
+
_response_json = _response.json()
|
|
543
|
+
except JSONDecodeError:
|
|
544
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
545
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
546
|
+
|
|
547
|
+
async def update(
|
|
548
|
+
self,
|
|
549
|
+
id: int,
|
|
550
|
+
*,
|
|
551
|
+
url: str,
|
|
552
|
+
request: WebhookSerializerForUpdate,
|
|
553
|
+
send_payload: typing.Optional[bool] = None,
|
|
554
|
+
send_for_all_actions: typing.Optional[bool] = None,
|
|
555
|
+
headers: typing.Optional[str] = None,
|
|
556
|
+
is_active: typing.Optional[bool] = None,
|
|
557
|
+
actions: typing.Optional[
|
|
558
|
+
typing.Union[WebhooksUpdateRequestActionsItem, typing.Sequence[WebhooksUpdateRequestActionsItem]]
|
|
559
|
+
] = None,
|
|
560
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
561
|
+
) -> WebhookSerializerForUpdate:
|
|
562
|
+
"""
|
|
563
|
+
Update a webhook. You will need to provide the webhook ID. You can get this from [List all webhooks](list).
|
|
564
|
+
|
|
565
|
+
For more information about webhooks, see [Set up webhooks in Label Studio](https://labelstud.io/guide/webhooks) and the [Webhook event reference](https://labelstud.io/guide/webhook_reference).
|
|
566
|
+
|
|
567
|
+
Parameters
|
|
568
|
+
----------
|
|
569
|
+
id : int
|
|
570
|
+
A unique integer value identifying this webhook.
|
|
571
|
+
|
|
572
|
+
url : str
|
|
573
|
+
URL of webhook
|
|
574
|
+
|
|
575
|
+
request : WebhookSerializerForUpdate
|
|
576
|
+
|
|
577
|
+
send_payload : typing.Optional[bool]
|
|
578
|
+
If value is False send only action
|
|
579
|
+
|
|
580
|
+
send_for_all_actions : typing.Optional[bool]
|
|
581
|
+
If value is False - used only for actions from WebhookAction
|
|
582
|
+
|
|
583
|
+
headers : typing.Optional[str]
|
|
584
|
+
Key Value Json of headers
|
|
585
|
+
|
|
586
|
+
is_active : typing.Optional[bool]
|
|
587
|
+
If value is False the webhook is disabled
|
|
588
|
+
|
|
589
|
+
actions : typing.Optional[typing.Union[WebhooksUpdateRequestActionsItem, typing.Sequence[WebhooksUpdateRequestActionsItem]]]
|
|
590
|
+
|
|
591
|
+
request_options : typing.Optional[RequestOptions]
|
|
592
|
+
Request-specific configuration.
|
|
593
|
+
|
|
594
|
+
Returns
|
|
595
|
+
-------
|
|
596
|
+
WebhookSerializerForUpdate
|
|
597
|
+
|
|
598
|
+
|
|
599
|
+
Examples
|
|
600
|
+
--------
|
|
601
|
+
from label_studio_sdk import WebhookSerializerForUpdate
|
|
602
|
+
from label_studio_sdk.client import AsyncLabelStudio
|
|
603
|
+
|
|
604
|
+
client = AsyncLabelStudio(
|
|
605
|
+
api_key="YOUR_API_KEY",
|
|
606
|
+
)
|
|
607
|
+
await client.webhooks.update(
|
|
608
|
+
id=1,
|
|
609
|
+
url="url",
|
|
610
|
+
request=WebhookSerializerForUpdate(
|
|
611
|
+
url="url",
|
|
612
|
+
),
|
|
613
|
+
)
|
|
614
|
+
"""
|
|
615
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
616
|
+
f"api/webhooks/{jsonable_encoder(id)}/",
|
|
617
|
+
method="PATCH",
|
|
618
|
+
params={
|
|
619
|
+
"url": url,
|
|
620
|
+
"send_payload": send_payload,
|
|
621
|
+
"send_for_all_actions": send_for_all_actions,
|
|
622
|
+
"headers": headers,
|
|
623
|
+
"is_active": is_active,
|
|
624
|
+
"actions": actions,
|
|
625
|
+
},
|
|
626
|
+
json=request,
|
|
627
|
+
request_options=request_options,
|
|
628
|
+
omit=OMIT,
|
|
629
|
+
)
|
|
630
|
+
if 200 <= _response.status_code < 300:
|
|
631
|
+
return pydantic_v1.parse_obj_as(WebhookSerializerForUpdate, _response.json()) # type: ignore
|
|
632
|
+
try:
|
|
633
|
+
_response_json = _response.json()
|
|
634
|
+
except JSONDecodeError:
|
|
635
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
636
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
WebhooksUpdateRequestActionsItem = typing.Union[
|
|
6
|
+
typing.Literal[
|
|
7
|
+
"PROJECT_CREATED",
|
|
8
|
+
"PROJECT_UPDATED",
|
|
9
|
+
"PROJECT_DELETED",
|
|
10
|
+
"TASKS_CREATED",
|
|
11
|
+
"TASKS_DELETED",
|
|
12
|
+
"ANNOTATION_CREATED",
|
|
13
|
+
"ANNOTATIONS_CREATED",
|
|
14
|
+
"ANNOTATION_UPDATED",
|
|
15
|
+
"ANNOTATIONS_DELETED",
|
|
16
|
+
"LABEL_LINK_CREATED",
|
|
17
|
+
"LABEL_LINK_UPDATED",
|
|
18
|
+
"LABEL_LINK_DELETED",
|
|
19
|
+
],
|
|
20
|
+
typing.Any,
|
|
21
|
+
]
|