label-studio-sdk 1.0.5__py3-none-any.whl → 1.0.8__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 +76 -0
- label_studio_sdk/_extensions/eval/categorical.py +83 -0
- label_studio_sdk/_extensions/label_studio_tools/core/label_config.py +13 -4
- label_studio_sdk/_extensions/label_studio_tools/core/utils/io.py +35 -17
- label_studio_sdk/_extensions/label_studio_tools/core/utils/json_schema.py +86 -0
- label_studio_sdk/_legacy/schema/label_config_schema.json +42 -11
- label_studio_sdk/annotations/__init__.py +3 -0
- label_studio_sdk/annotations/client.py +109 -0
- label_studio_sdk/annotations/types/__init__.py +5 -0
- label_studio_sdk/annotations/types/annotations_create_bulk_response_item.py +29 -0
- label_studio_sdk/base_client.py +9 -0
- label_studio_sdk/comments/__init__.py +2 -0
- label_studio_sdk/comments/client.py +512 -0
- label_studio_sdk/converter/converter.py +11 -4
- label_studio_sdk/converter/imports/coco.py +14 -13
- label_studio_sdk/converter/utils.py +72 -3
- label_studio_sdk/core/client_wrapper.py +1 -1
- label_studio_sdk/files/client.py +26 -16
- label_studio_sdk/label_interface/control_tags.py +205 -10
- label_studio_sdk/label_interface/interface.py +117 -10
- label_studio_sdk/label_interface/region.py +1 -10
- label_studio_sdk/model_providers/__init__.py +2 -0
- label_studio_sdk/model_providers/client.py +708 -0
- label_studio_sdk/projects/client.py +32 -16
- label_studio_sdk/projects/exports/client.py +133 -40
- label_studio_sdk/prompts/__init__.py +21 -0
- label_studio_sdk/prompts/client.py +862 -0
- label_studio_sdk/prompts/indicators/__init__.py +2 -0
- label_studio_sdk/prompts/indicators/client.py +194 -0
- label_studio_sdk/prompts/runs/__init__.py +5 -0
- label_studio_sdk/prompts/runs/client.py +354 -0
- label_studio_sdk/prompts/runs/types/__init__.py +5 -0
- label_studio_sdk/prompts/runs/types/runs_list_request_project_subset.py +5 -0
- label_studio_sdk/prompts/types/__init__.py +15 -0
- label_studio_sdk/prompts/types/prompts_batch_failed_predictions_request_failed_predictions_item.py +42 -0
- label_studio_sdk/prompts/types/prompts_batch_failed_predictions_response.py +29 -0
- label_studio_sdk/prompts/types/prompts_batch_predictions_request_results_item.py +62 -0
- label_studio_sdk/prompts/types/prompts_batch_predictions_response.py +29 -0
- label_studio_sdk/prompts/versions/__init__.py +2 -0
- label_studio_sdk/prompts/versions/client.py +1046 -0
- label_studio_sdk/types/__init__.py +58 -0
- label_studio_sdk/types/comment.py +39 -0
- label_studio_sdk/types/comment_created_by.py +5 -0
- label_studio_sdk/types/inference_run.py +43 -0
- label_studio_sdk/types/inference_run_cost_estimate.py +57 -0
- label_studio_sdk/types/inference_run_created_by.py +5 -0
- label_studio_sdk/types/inference_run_organization.py +5 -0
- label_studio_sdk/types/inference_run_project_subset.py +5 -0
- label_studio_sdk/types/inference_run_status.py +7 -0
- label_studio_sdk/types/key_indicator_value.py +30 -0
- label_studio_sdk/types/key_indicators.py +7 -0
- label_studio_sdk/types/key_indicators_item.py +51 -0
- label_studio_sdk/types/key_indicators_item_additional_kpis_item.py +37 -0
- label_studio_sdk/types/key_indicators_item_extra_kpis_item.py +37 -0
- label_studio_sdk/types/model_provider_connection.py +71 -0
- label_studio_sdk/types/model_provider_connection_budget_reset_period.py +5 -0
- label_studio_sdk/types/model_provider_connection_created_by.py +5 -0
- label_studio_sdk/types/model_provider_connection_organization.py +5 -0
- label_studio_sdk/types/model_provider_connection_provider.py +5 -0
- label_studio_sdk/types/model_provider_connection_scope.py +5 -0
- label_studio_sdk/types/prompt.py +79 -0
- label_studio_sdk/types/prompt_created_by.py +5 -0
- label_studio_sdk/types/prompt_organization.py +5 -0
- label_studio_sdk/types/prompt_version.py +41 -0
- label_studio_sdk/types/prompt_version_created_by.py +5 -0
- label_studio_sdk/types/prompt_version_organization.py +5 -0
- label_studio_sdk/types/prompt_version_provider.py +5 -0
- label_studio_sdk/types/refined_prompt_response.py +64 -0
- label_studio_sdk/types/refined_prompt_response_refinement_status.py +7 -0
- label_studio_sdk/types/task.py +3 -2
- label_studio_sdk/types/task_comment_authors_item.py +5 -0
- label_studio_sdk/webhooks/client.py +245 -36
- label_studio_sdk/workspaces/client.py +20 -20
- label_studio_sdk-1.0.8.dist-info/LICENSE +201 -0
- {label_studio_sdk-1.0.5.dist-info → label_studio_sdk-1.0.8.dist-info}/METADATA +19 -3
- {label_studio_sdk-1.0.5.dist-info → label_studio_sdk-1.0.8.dist-info}/RECORD +77 -24
- {label_studio_sdk-1.0.5.dist-info → label_studio_sdk-1.0.8.dist-info}/WHEEL +1 -1
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import datetime as dt
|
|
4
|
+
import typing
|
|
5
|
+
|
|
6
|
+
from ..core.datetime_utils import serialize_datetime
|
|
7
|
+
from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1
|
|
8
|
+
from .prompt_version_created_by import PromptVersionCreatedBy
|
|
9
|
+
from .prompt_version_organization import PromptVersionOrganization
|
|
10
|
+
from .prompt_version_provider import PromptVersionProvider
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class PromptVersion(pydantic_v1.BaseModel):
|
|
14
|
+
title: typing.Optional[str] = None
|
|
15
|
+
parent_model: typing.Optional[int] = None
|
|
16
|
+
model_provider_connection: typing.Optional[int] = None
|
|
17
|
+
prompt: typing.Optional[str] = None
|
|
18
|
+
provider: typing.Optional[PromptVersionProvider] = None
|
|
19
|
+
provider_model_id: typing.Optional[str] = None
|
|
20
|
+
created_by: typing.Optional[PromptVersionCreatedBy] = None
|
|
21
|
+
created_at: typing.Optional[dt.datetime] = None
|
|
22
|
+
updated_at: typing.Optional[dt.datetime] = None
|
|
23
|
+
organization: typing.Optional[PromptVersionOrganization] = None
|
|
24
|
+
|
|
25
|
+
def json(self, **kwargs: typing.Any) -> str:
|
|
26
|
+
kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
|
|
27
|
+
return super().json(**kwargs_with_defaults)
|
|
28
|
+
|
|
29
|
+
def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
|
|
30
|
+
kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
|
|
31
|
+
kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs}
|
|
32
|
+
|
|
33
|
+
return deep_union_pydantic_dicts(
|
|
34
|
+
super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none)
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
class Config:
|
|
38
|
+
frozen = True
|
|
39
|
+
smart_union = True
|
|
40
|
+
extra = pydantic_v1.Extra.allow
|
|
41
|
+
json_encoders = {dt.datetime: serialize_datetime}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import datetime as dt
|
|
4
|
+
import typing
|
|
5
|
+
|
|
6
|
+
from ..core.datetime_utils import serialize_datetime
|
|
7
|
+
from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1
|
|
8
|
+
from .prompt_version import PromptVersion
|
|
9
|
+
from .refined_prompt_response_refinement_status import RefinedPromptResponseRefinementStatus
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class RefinedPromptResponse(pydantic_v1.BaseModel):
|
|
13
|
+
title: typing.Optional[str] = pydantic_v1.Field(default=None)
|
|
14
|
+
"""
|
|
15
|
+
Title of the refined prompt
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
reasoning: typing.Optional[str] = pydantic_v1.Field(default=None)
|
|
19
|
+
"""
|
|
20
|
+
Reasoning behind the refinement
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
prompt: str = pydantic_v1.Field()
|
|
24
|
+
"""
|
|
25
|
+
The refined prompt text
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
refinement_job_id: typing.Optional[str] = pydantic_v1.Field(default=None)
|
|
29
|
+
"""
|
|
30
|
+
Unique identifier for the refinement job
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
refinement_status: typing.Optional[RefinedPromptResponseRefinementStatus] = pydantic_v1.Field(default=None)
|
|
34
|
+
"""
|
|
35
|
+
Status of the refinement job
|
|
36
|
+
"""
|
|
37
|
+
|
|
38
|
+
total_cost: typing.Optional[str] = pydantic_v1.Field(default=None)
|
|
39
|
+
"""
|
|
40
|
+
Total cost of the refinement job (in USD)
|
|
41
|
+
"""
|
|
42
|
+
|
|
43
|
+
previous_version: typing.Optional[PromptVersion] = pydantic_v1.Field(default=None)
|
|
44
|
+
"""
|
|
45
|
+
Previous version of the prompt
|
|
46
|
+
"""
|
|
47
|
+
|
|
48
|
+
def json(self, **kwargs: typing.Any) -> str:
|
|
49
|
+
kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
|
|
50
|
+
return super().json(**kwargs_with_defaults)
|
|
51
|
+
|
|
52
|
+
def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
|
|
53
|
+
kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
|
|
54
|
+
kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs}
|
|
55
|
+
|
|
56
|
+
return deep_union_pydantic_dicts(
|
|
57
|
+
super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none)
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
class Config:
|
|
61
|
+
frozen = True
|
|
62
|
+
smart_union = True
|
|
63
|
+
extra = pydantic_v1.Extra.allow
|
|
64
|
+
json_encoders = {dt.datetime: serialize_datetime}
|
label_studio_sdk/types/task.py
CHANGED
|
@@ -6,6 +6,7 @@ import typing
|
|
|
6
6
|
from ..core.datetime_utils import serialize_datetime
|
|
7
7
|
from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1
|
|
8
8
|
from .task_annotators_item import TaskAnnotatorsItem
|
|
9
|
+
from .task_comment_authors_item import TaskCommentAuthorsItem
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
class Task(pydantic_v1.BaseModel):
|
|
@@ -134,9 +135,9 @@ class Task(pydantic_v1.BaseModel):
|
|
|
134
135
|
Project ID for this task
|
|
135
136
|
"""
|
|
136
137
|
|
|
137
|
-
comment_authors: typing.Optional[typing.List[
|
|
138
|
+
comment_authors: typing.Optional[typing.List[TaskCommentAuthorsItem]] = pydantic_v1.Field(default=None)
|
|
138
139
|
"""
|
|
139
|
-
List of comment authors
|
|
140
|
+
List of comment authors for this task
|
|
140
141
|
"""
|
|
141
142
|
|
|
142
143
|
def json(self, **kwargs: typing.Any) -> str:
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
|
2
2
|
|
|
3
|
+
import datetime as dt
|
|
3
4
|
import typing
|
|
4
5
|
from json.decoder import JSONDecodeError
|
|
5
6
|
|
|
@@ -9,7 +10,9 @@ from ..core.jsonable_encoder import jsonable_encoder
|
|
|
9
10
|
from ..core.pydantic_utilities import pydantic_v1
|
|
10
11
|
from ..core.request_options import RequestOptions
|
|
11
12
|
from ..types.webhook import Webhook
|
|
13
|
+
from ..types.webhook_actions_item import WebhookActionsItem
|
|
12
14
|
from ..types.webhook_serializer_for_update import WebhookSerializerForUpdate
|
|
15
|
+
from ..types.webhook_serializer_for_update_actions_item import WebhookSerializerForUpdateActionsItem
|
|
13
16
|
from .types.webhooks_update_request_actions_item import WebhooksUpdateRequestActionsItem
|
|
14
17
|
|
|
15
18
|
# this is used as the default value for optional parameters
|
|
@@ -63,7 +66,22 @@ class WebhooksClient:
|
|
|
63
66
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
64
67
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
65
68
|
|
|
66
|
-
def create(
|
|
69
|
+
def create(
|
|
70
|
+
self,
|
|
71
|
+
*,
|
|
72
|
+
url: str,
|
|
73
|
+
id: typing.Optional[int] = OMIT,
|
|
74
|
+
organization: typing.Optional[int] = OMIT,
|
|
75
|
+
project: typing.Optional[int] = OMIT,
|
|
76
|
+
send_payload: typing.Optional[bool] = OMIT,
|
|
77
|
+
send_for_all_actions: typing.Optional[bool] = OMIT,
|
|
78
|
+
headers: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
|
|
79
|
+
is_active: typing.Optional[bool] = OMIT,
|
|
80
|
+
actions: typing.Optional[typing.Sequence[WebhookActionsItem]] = OMIT,
|
|
81
|
+
created_at: typing.Optional[dt.datetime] = OMIT,
|
|
82
|
+
updated_at: typing.Optional[dt.datetime] = OMIT,
|
|
83
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
84
|
+
) -> Webhook:
|
|
67
85
|
"""
|
|
68
86
|
Create a webhook.
|
|
69
87
|
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).
|
|
@@ -74,7 +92,34 @@ class WebhooksClient:
|
|
|
74
92
|
|
|
75
93
|
Parameters
|
|
76
94
|
----------
|
|
77
|
-
|
|
95
|
+
url : str
|
|
96
|
+
URL of webhook
|
|
97
|
+
|
|
98
|
+
id : typing.Optional[int]
|
|
99
|
+
|
|
100
|
+
organization : typing.Optional[int]
|
|
101
|
+
|
|
102
|
+
project : typing.Optional[int]
|
|
103
|
+
|
|
104
|
+
send_payload : typing.Optional[bool]
|
|
105
|
+
If value is False send only action
|
|
106
|
+
|
|
107
|
+
send_for_all_actions : typing.Optional[bool]
|
|
108
|
+
If value is False - used only for actions from WebhookAction
|
|
109
|
+
|
|
110
|
+
headers : typing.Optional[typing.Dict[str, typing.Any]]
|
|
111
|
+
Key Value Json of headers
|
|
112
|
+
|
|
113
|
+
is_active : typing.Optional[bool]
|
|
114
|
+
If value is False the webhook is disabled
|
|
115
|
+
|
|
116
|
+
actions : typing.Optional[typing.Sequence[WebhookActionsItem]]
|
|
117
|
+
|
|
118
|
+
created_at : typing.Optional[dt.datetime]
|
|
119
|
+
Creation time
|
|
120
|
+
|
|
121
|
+
updated_at : typing.Optional[dt.datetime]
|
|
122
|
+
Last update time
|
|
78
123
|
|
|
79
124
|
request_options : typing.Optional[RequestOptions]
|
|
80
125
|
Request-specific configuration.
|
|
@@ -86,20 +131,33 @@ class WebhooksClient:
|
|
|
86
131
|
|
|
87
132
|
Examples
|
|
88
133
|
--------
|
|
89
|
-
from label_studio_sdk import Webhook
|
|
90
134
|
from label_studio_sdk.client import LabelStudio
|
|
91
135
|
|
|
92
136
|
client = LabelStudio(
|
|
93
137
|
api_key="YOUR_API_KEY",
|
|
94
138
|
)
|
|
95
139
|
client.webhooks.create(
|
|
96
|
-
|
|
97
|
-
url="url",
|
|
98
|
-
),
|
|
140
|
+
url="url",
|
|
99
141
|
)
|
|
100
142
|
"""
|
|
101
143
|
_response = self._client_wrapper.httpx_client.request(
|
|
102
|
-
"api/webhooks/",
|
|
144
|
+
"api/webhooks/",
|
|
145
|
+
method="POST",
|
|
146
|
+
json={
|
|
147
|
+
"id": id,
|
|
148
|
+
"organization": organization,
|
|
149
|
+
"project": project,
|
|
150
|
+
"url": url,
|
|
151
|
+
"send_payload": send_payload,
|
|
152
|
+
"send_for_all_actions": send_for_all_actions,
|
|
153
|
+
"headers": headers,
|
|
154
|
+
"is_active": is_active,
|
|
155
|
+
"actions": actions,
|
|
156
|
+
"created_at": created_at,
|
|
157
|
+
"updated_at": updated_at,
|
|
158
|
+
},
|
|
159
|
+
request_options=request_options,
|
|
160
|
+
omit=OMIT,
|
|
103
161
|
)
|
|
104
162
|
try:
|
|
105
163
|
if 200 <= _response.status_code < 300:
|
|
@@ -236,10 +294,10 @@ class WebhooksClient:
|
|
|
236
294
|
|
|
237
295
|
def update(
|
|
238
296
|
self,
|
|
239
|
-
|
|
297
|
+
id_: int,
|
|
240
298
|
*,
|
|
241
299
|
url: str,
|
|
242
|
-
|
|
300
|
+
webhook_serializer_for_update_url: str,
|
|
243
301
|
send_payload: typing.Optional[bool] = None,
|
|
244
302
|
send_for_all_actions: typing.Optional[bool] = None,
|
|
245
303
|
headers: typing.Optional[str] = None,
|
|
@@ -247,6 +305,18 @@ class WebhooksClient:
|
|
|
247
305
|
actions: typing.Optional[
|
|
248
306
|
typing.Union[WebhooksUpdateRequestActionsItem, typing.Sequence[WebhooksUpdateRequestActionsItem]]
|
|
249
307
|
] = None,
|
|
308
|
+
id: typing.Optional[int] = OMIT,
|
|
309
|
+
organization: typing.Optional[int] = OMIT,
|
|
310
|
+
project: typing.Optional[int] = OMIT,
|
|
311
|
+
webhook_serializer_for_update_send_payload: typing.Optional[bool] = OMIT,
|
|
312
|
+
webhook_serializer_for_update_send_for_all_actions: typing.Optional[bool] = OMIT,
|
|
313
|
+
webhook_serializer_for_update_headers: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
|
|
314
|
+
webhook_serializer_for_update_is_active: typing.Optional[bool] = OMIT,
|
|
315
|
+
webhook_serializer_for_update_actions: typing.Optional[
|
|
316
|
+
typing.Sequence[WebhookSerializerForUpdateActionsItem]
|
|
317
|
+
] = OMIT,
|
|
318
|
+
created_at: typing.Optional[dt.datetime] = OMIT,
|
|
319
|
+
updated_at: typing.Optional[dt.datetime] = OMIT,
|
|
250
320
|
request_options: typing.Optional[RequestOptions] = None,
|
|
251
321
|
) -> WebhookSerializerForUpdate:
|
|
252
322
|
"""
|
|
@@ -256,13 +326,14 @@ class WebhooksClient:
|
|
|
256
326
|
|
|
257
327
|
Parameters
|
|
258
328
|
----------
|
|
259
|
-
|
|
329
|
+
id_ : int
|
|
260
330
|
A unique integer value identifying this webhook.
|
|
261
331
|
|
|
262
332
|
url : str
|
|
263
333
|
URL of webhook
|
|
264
334
|
|
|
265
|
-
|
|
335
|
+
webhook_serializer_for_update_url : str
|
|
336
|
+
URL of webhook
|
|
266
337
|
|
|
267
338
|
send_payload : typing.Optional[bool]
|
|
268
339
|
If value is False send only action
|
|
@@ -278,6 +349,32 @@ class WebhooksClient:
|
|
|
278
349
|
|
|
279
350
|
actions : typing.Optional[typing.Union[WebhooksUpdateRequestActionsItem, typing.Sequence[WebhooksUpdateRequestActionsItem]]]
|
|
280
351
|
|
|
352
|
+
id : typing.Optional[int]
|
|
353
|
+
|
|
354
|
+
organization : typing.Optional[int]
|
|
355
|
+
|
|
356
|
+
project : typing.Optional[int]
|
|
357
|
+
|
|
358
|
+
webhook_serializer_for_update_send_payload : typing.Optional[bool]
|
|
359
|
+
If value is False send only action
|
|
360
|
+
|
|
361
|
+
webhook_serializer_for_update_send_for_all_actions : typing.Optional[bool]
|
|
362
|
+
If value is False - used only for actions from WebhookAction
|
|
363
|
+
|
|
364
|
+
webhook_serializer_for_update_headers : typing.Optional[typing.Dict[str, typing.Any]]
|
|
365
|
+
Key Value Json of headers
|
|
366
|
+
|
|
367
|
+
webhook_serializer_for_update_is_active : typing.Optional[bool]
|
|
368
|
+
If value is False the webhook is disabled
|
|
369
|
+
|
|
370
|
+
webhook_serializer_for_update_actions : typing.Optional[typing.Sequence[WebhookSerializerForUpdateActionsItem]]
|
|
371
|
+
|
|
372
|
+
created_at : typing.Optional[dt.datetime]
|
|
373
|
+
Creation time
|
|
374
|
+
|
|
375
|
+
updated_at : typing.Optional[dt.datetime]
|
|
376
|
+
Last update time
|
|
377
|
+
|
|
281
378
|
request_options : typing.Optional[RequestOptions]
|
|
282
379
|
Request-specific configuration.
|
|
283
380
|
|
|
@@ -288,22 +385,19 @@ class WebhooksClient:
|
|
|
288
385
|
|
|
289
386
|
Examples
|
|
290
387
|
--------
|
|
291
|
-
from label_studio_sdk import WebhookSerializerForUpdate
|
|
292
388
|
from label_studio_sdk.client import LabelStudio
|
|
293
389
|
|
|
294
390
|
client = LabelStudio(
|
|
295
391
|
api_key="YOUR_API_KEY",
|
|
296
392
|
)
|
|
297
393
|
client.webhooks.update(
|
|
298
|
-
|
|
394
|
+
id_=1,
|
|
299
395
|
url="url",
|
|
300
|
-
|
|
301
|
-
url="url",
|
|
302
|
-
),
|
|
396
|
+
webhook_serializer_for_update_url="url",
|
|
303
397
|
)
|
|
304
398
|
"""
|
|
305
399
|
_response = self._client_wrapper.httpx_client.request(
|
|
306
|
-
f"api/webhooks/{jsonable_encoder(
|
|
400
|
+
f"api/webhooks/{jsonable_encoder(id_)}/",
|
|
307
401
|
method="PATCH",
|
|
308
402
|
params={
|
|
309
403
|
"url": url,
|
|
@@ -313,7 +407,19 @@ class WebhooksClient:
|
|
|
313
407
|
"is_active": is_active,
|
|
314
408
|
"actions": actions,
|
|
315
409
|
},
|
|
316
|
-
json=
|
|
410
|
+
json={
|
|
411
|
+
"id": id,
|
|
412
|
+
"organization": organization,
|
|
413
|
+
"project": project,
|
|
414
|
+
"url": url,
|
|
415
|
+
"send_payload": send_payload,
|
|
416
|
+
"send_for_all_actions": send_for_all_actions,
|
|
417
|
+
"headers": headers,
|
|
418
|
+
"is_active": is_active,
|
|
419
|
+
"actions": actions,
|
|
420
|
+
"created_at": created_at,
|
|
421
|
+
"updated_at": updated_at,
|
|
422
|
+
},
|
|
317
423
|
request_options=request_options,
|
|
318
424
|
omit=OMIT,
|
|
319
425
|
)
|
|
@@ -373,7 +479,22 @@ class AsyncWebhooksClient:
|
|
|
373
479
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
374
480
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
375
481
|
|
|
376
|
-
async def create(
|
|
482
|
+
async def create(
|
|
483
|
+
self,
|
|
484
|
+
*,
|
|
485
|
+
url: str,
|
|
486
|
+
id: typing.Optional[int] = OMIT,
|
|
487
|
+
organization: typing.Optional[int] = OMIT,
|
|
488
|
+
project: typing.Optional[int] = OMIT,
|
|
489
|
+
send_payload: typing.Optional[bool] = OMIT,
|
|
490
|
+
send_for_all_actions: typing.Optional[bool] = OMIT,
|
|
491
|
+
headers: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
|
|
492
|
+
is_active: typing.Optional[bool] = OMIT,
|
|
493
|
+
actions: typing.Optional[typing.Sequence[WebhookActionsItem]] = OMIT,
|
|
494
|
+
created_at: typing.Optional[dt.datetime] = OMIT,
|
|
495
|
+
updated_at: typing.Optional[dt.datetime] = OMIT,
|
|
496
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
497
|
+
) -> Webhook:
|
|
377
498
|
"""
|
|
378
499
|
Create a webhook.
|
|
379
500
|
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).
|
|
@@ -384,7 +505,34 @@ class AsyncWebhooksClient:
|
|
|
384
505
|
|
|
385
506
|
Parameters
|
|
386
507
|
----------
|
|
387
|
-
|
|
508
|
+
url : str
|
|
509
|
+
URL of webhook
|
|
510
|
+
|
|
511
|
+
id : typing.Optional[int]
|
|
512
|
+
|
|
513
|
+
organization : typing.Optional[int]
|
|
514
|
+
|
|
515
|
+
project : typing.Optional[int]
|
|
516
|
+
|
|
517
|
+
send_payload : typing.Optional[bool]
|
|
518
|
+
If value is False send only action
|
|
519
|
+
|
|
520
|
+
send_for_all_actions : typing.Optional[bool]
|
|
521
|
+
If value is False - used only for actions from WebhookAction
|
|
522
|
+
|
|
523
|
+
headers : typing.Optional[typing.Dict[str, typing.Any]]
|
|
524
|
+
Key Value Json of headers
|
|
525
|
+
|
|
526
|
+
is_active : typing.Optional[bool]
|
|
527
|
+
If value is False the webhook is disabled
|
|
528
|
+
|
|
529
|
+
actions : typing.Optional[typing.Sequence[WebhookActionsItem]]
|
|
530
|
+
|
|
531
|
+
created_at : typing.Optional[dt.datetime]
|
|
532
|
+
Creation time
|
|
533
|
+
|
|
534
|
+
updated_at : typing.Optional[dt.datetime]
|
|
535
|
+
Last update time
|
|
388
536
|
|
|
389
537
|
request_options : typing.Optional[RequestOptions]
|
|
390
538
|
Request-specific configuration.
|
|
@@ -396,20 +544,33 @@ class AsyncWebhooksClient:
|
|
|
396
544
|
|
|
397
545
|
Examples
|
|
398
546
|
--------
|
|
399
|
-
from label_studio_sdk import Webhook
|
|
400
547
|
from label_studio_sdk.client import AsyncLabelStudio
|
|
401
548
|
|
|
402
549
|
client = AsyncLabelStudio(
|
|
403
550
|
api_key="YOUR_API_KEY",
|
|
404
551
|
)
|
|
405
552
|
await client.webhooks.create(
|
|
406
|
-
|
|
407
|
-
url="url",
|
|
408
|
-
),
|
|
553
|
+
url="url",
|
|
409
554
|
)
|
|
410
555
|
"""
|
|
411
556
|
_response = await self._client_wrapper.httpx_client.request(
|
|
412
|
-
"api/webhooks/",
|
|
557
|
+
"api/webhooks/",
|
|
558
|
+
method="POST",
|
|
559
|
+
json={
|
|
560
|
+
"id": id,
|
|
561
|
+
"organization": organization,
|
|
562
|
+
"project": project,
|
|
563
|
+
"url": url,
|
|
564
|
+
"send_payload": send_payload,
|
|
565
|
+
"send_for_all_actions": send_for_all_actions,
|
|
566
|
+
"headers": headers,
|
|
567
|
+
"is_active": is_active,
|
|
568
|
+
"actions": actions,
|
|
569
|
+
"created_at": created_at,
|
|
570
|
+
"updated_at": updated_at,
|
|
571
|
+
},
|
|
572
|
+
request_options=request_options,
|
|
573
|
+
omit=OMIT,
|
|
413
574
|
)
|
|
414
575
|
try:
|
|
415
576
|
if 200 <= _response.status_code < 300:
|
|
@@ -546,10 +707,10 @@ class AsyncWebhooksClient:
|
|
|
546
707
|
|
|
547
708
|
async def update(
|
|
548
709
|
self,
|
|
549
|
-
|
|
710
|
+
id_: int,
|
|
550
711
|
*,
|
|
551
712
|
url: str,
|
|
552
|
-
|
|
713
|
+
webhook_serializer_for_update_url: str,
|
|
553
714
|
send_payload: typing.Optional[bool] = None,
|
|
554
715
|
send_for_all_actions: typing.Optional[bool] = None,
|
|
555
716
|
headers: typing.Optional[str] = None,
|
|
@@ -557,6 +718,18 @@ class AsyncWebhooksClient:
|
|
|
557
718
|
actions: typing.Optional[
|
|
558
719
|
typing.Union[WebhooksUpdateRequestActionsItem, typing.Sequence[WebhooksUpdateRequestActionsItem]]
|
|
559
720
|
] = None,
|
|
721
|
+
id: typing.Optional[int] = OMIT,
|
|
722
|
+
organization: typing.Optional[int] = OMIT,
|
|
723
|
+
project: typing.Optional[int] = OMIT,
|
|
724
|
+
webhook_serializer_for_update_send_payload: typing.Optional[bool] = OMIT,
|
|
725
|
+
webhook_serializer_for_update_send_for_all_actions: typing.Optional[bool] = OMIT,
|
|
726
|
+
webhook_serializer_for_update_headers: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
|
|
727
|
+
webhook_serializer_for_update_is_active: typing.Optional[bool] = OMIT,
|
|
728
|
+
webhook_serializer_for_update_actions: typing.Optional[
|
|
729
|
+
typing.Sequence[WebhookSerializerForUpdateActionsItem]
|
|
730
|
+
] = OMIT,
|
|
731
|
+
created_at: typing.Optional[dt.datetime] = OMIT,
|
|
732
|
+
updated_at: typing.Optional[dt.datetime] = OMIT,
|
|
560
733
|
request_options: typing.Optional[RequestOptions] = None,
|
|
561
734
|
) -> WebhookSerializerForUpdate:
|
|
562
735
|
"""
|
|
@@ -566,13 +739,14 @@ class AsyncWebhooksClient:
|
|
|
566
739
|
|
|
567
740
|
Parameters
|
|
568
741
|
----------
|
|
569
|
-
|
|
742
|
+
id_ : int
|
|
570
743
|
A unique integer value identifying this webhook.
|
|
571
744
|
|
|
572
745
|
url : str
|
|
573
746
|
URL of webhook
|
|
574
747
|
|
|
575
|
-
|
|
748
|
+
webhook_serializer_for_update_url : str
|
|
749
|
+
URL of webhook
|
|
576
750
|
|
|
577
751
|
send_payload : typing.Optional[bool]
|
|
578
752
|
If value is False send only action
|
|
@@ -588,6 +762,32 @@ class AsyncWebhooksClient:
|
|
|
588
762
|
|
|
589
763
|
actions : typing.Optional[typing.Union[WebhooksUpdateRequestActionsItem, typing.Sequence[WebhooksUpdateRequestActionsItem]]]
|
|
590
764
|
|
|
765
|
+
id : typing.Optional[int]
|
|
766
|
+
|
|
767
|
+
organization : typing.Optional[int]
|
|
768
|
+
|
|
769
|
+
project : typing.Optional[int]
|
|
770
|
+
|
|
771
|
+
webhook_serializer_for_update_send_payload : typing.Optional[bool]
|
|
772
|
+
If value is False send only action
|
|
773
|
+
|
|
774
|
+
webhook_serializer_for_update_send_for_all_actions : typing.Optional[bool]
|
|
775
|
+
If value is False - used only for actions from WebhookAction
|
|
776
|
+
|
|
777
|
+
webhook_serializer_for_update_headers : typing.Optional[typing.Dict[str, typing.Any]]
|
|
778
|
+
Key Value Json of headers
|
|
779
|
+
|
|
780
|
+
webhook_serializer_for_update_is_active : typing.Optional[bool]
|
|
781
|
+
If value is False the webhook is disabled
|
|
782
|
+
|
|
783
|
+
webhook_serializer_for_update_actions : typing.Optional[typing.Sequence[WebhookSerializerForUpdateActionsItem]]
|
|
784
|
+
|
|
785
|
+
created_at : typing.Optional[dt.datetime]
|
|
786
|
+
Creation time
|
|
787
|
+
|
|
788
|
+
updated_at : typing.Optional[dt.datetime]
|
|
789
|
+
Last update time
|
|
790
|
+
|
|
591
791
|
request_options : typing.Optional[RequestOptions]
|
|
592
792
|
Request-specific configuration.
|
|
593
793
|
|
|
@@ -598,22 +798,19 @@ class AsyncWebhooksClient:
|
|
|
598
798
|
|
|
599
799
|
Examples
|
|
600
800
|
--------
|
|
601
|
-
from label_studio_sdk import WebhookSerializerForUpdate
|
|
602
801
|
from label_studio_sdk.client import AsyncLabelStudio
|
|
603
802
|
|
|
604
803
|
client = AsyncLabelStudio(
|
|
605
804
|
api_key="YOUR_API_KEY",
|
|
606
805
|
)
|
|
607
806
|
await client.webhooks.update(
|
|
608
|
-
|
|
807
|
+
id_=1,
|
|
609
808
|
url="url",
|
|
610
|
-
|
|
611
|
-
url="url",
|
|
612
|
-
),
|
|
809
|
+
webhook_serializer_for_update_url="url",
|
|
613
810
|
)
|
|
614
811
|
"""
|
|
615
812
|
_response = await self._client_wrapper.httpx_client.request(
|
|
616
|
-
f"api/webhooks/{jsonable_encoder(
|
|
813
|
+
f"api/webhooks/{jsonable_encoder(id_)}/",
|
|
617
814
|
method="PATCH",
|
|
618
815
|
params={
|
|
619
816
|
"url": url,
|
|
@@ -623,7 +820,19 @@ class AsyncWebhooksClient:
|
|
|
623
820
|
"is_active": is_active,
|
|
624
821
|
"actions": actions,
|
|
625
822
|
},
|
|
626
|
-
json=
|
|
823
|
+
json={
|
|
824
|
+
"id": id,
|
|
825
|
+
"organization": organization,
|
|
826
|
+
"project": project,
|
|
827
|
+
"url": url,
|
|
828
|
+
"send_payload": send_payload,
|
|
829
|
+
"send_for_all_actions": send_for_all_actions,
|
|
830
|
+
"headers": headers,
|
|
831
|
+
"is_active": is_active,
|
|
832
|
+
"actions": actions,
|
|
833
|
+
"created_at": created_at,
|
|
834
|
+
"updated_at": updated_at,
|
|
835
|
+
},
|
|
627
836
|
request_options=request_options,
|
|
628
837
|
omit=OMIT,
|
|
629
838
|
)
|