worqhat 3.10.0__py3-none-any.whl → 4.1.0__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.
- worqhat/__init__.py +8 -89
- worqhat/client.py +62 -0
- worqhat/exceptions.py +43 -0
- worqhat/http_client.py +171 -0
- worqhat/py.typed +1 -0
- worqhat/resources/__init__.py +5 -59
- worqhat/resources/database.py +293 -0
- worqhat/resources/flows.py +61 -409
- worqhat/resources/storage.py +41 -431
- worqhat-4.1.0.dist-info/METADATA +538 -0
- worqhat-4.1.0.dist-info/RECORD +13 -0
- {worqhat-3.10.0.dist-info → worqhat-4.1.0.dist-info}/WHEEL +2 -1
- worqhat-4.1.0.dist-info/top_level.txt +1 -0
- worqhat/_base_client.py +0 -1995
- worqhat/_client.py +0 -484
- worqhat/_compat.py +0 -219
- worqhat/_constants.py +0 -14
- worqhat/_exceptions.py +0 -108
- worqhat/_files.py +0 -123
- worqhat/_models.py +0 -835
- worqhat/_qs.py +0 -150
- worqhat/_resource.py +0 -43
- worqhat/_response.py +0 -830
- worqhat/_streaming.py +0 -333
- worqhat/_types.py +0 -260
- worqhat/_utils/__init__.py +0 -64
- worqhat/_utils/_compat.py +0 -45
- worqhat/_utils/_datetime_parse.py +0 -136
- worqhat/_utils/_logs.py +0 -25
- worqhat/_utils/_proxy.py +0 -65
- worqhat/_utils/_reflection.py +0 -42
- worqhat/_utils/_resources_proxy.py +0 -24
- worqhat/_utils/_streams.py +0 -12
- worqhat/_utils/_sync.py +0 -86
- worqhat/_utils/_transform.py +0 -457
- worqhat/_utils/_typing.py +0 -156
- worqhat/_utils/_utils.py +0 -421
- worqhat/_version.py +0 -4
- worqhat/lib/.keep +0 -4
- worqhat/resources/db/__init__.py +0 -33
- worqhat/resources/db/db.py +0 -1650
- worqhat/resources/db/tables.py +0 -389
- worqhat/resources/health.py +0 -143
- worqhat/types/__init__.py +0 -44
- worqhat/types/db/__init__.py +0 -10
- worqhat/types/db/table_get_row_count_params.py +0 -12
- worqhat/types/db/table_get_row_count_response.py +0 -15
- worqhat/types/db/table_list_params.py +0 -15
- worqhat/types/db/table_list_response.py +0 -26
- worqhat/types/db/table_retrieve_schema_params.py +0 -12
- worqhat/types/db/table_retrieve_schema_response.py +0 -29
- worqhat/types/db_cluster_params.py +0 -27
- worqhat/types/db_cluster_response.py +0 -44
- worqhat/types/db_delete_records_params.py +0 -19
- worqhat/types/db_delete_records_response.py +0 -18
- worqhat/types/db_detect_anomalies_params.py +0 -24
- worqhat/types/db_detect_anomalies_response.py +0 -50
- worqhat/types/db_execute_batch_params.py +0 -36
- worqhat/types/db_execute_batch_response.py +0 -27
- worqhat/types/db_execute_query_params.py +0 -24
- worqhat/types/db_execute_query_response.py +0 -21
- worqhat/types/db_find_similar_params.py +0 -31
- worqhat/types/db_find_similar_response.py +0 -30
- worqhat/types/db_hybrid_search_params.py +0 -32
- worqhat/types/db_hybrid_search_response.py +0 -48
- worqhat/types/db_insert_record_params.py +0 -19
- worqhat/types/db_insert_record_response.py +0 -15
- worqhat/types/db_process_nl_query_params.py +0 -19
- worqhat/types/db_process_nl_query_response.py +0 -18
- worqhat/types/db_recommend_params.py +0 -33
- worqhat/types/db_recommend_response.py +0 -36
- worqhat/types/db_semantic_search_params.py +0 -33
- worqhat/types/db_semantic_search_response.py +0 -36
- worqhat/types/db_update_records_params.py +0 -22
- worqhat/types/db_update_records_response.py +0 -18
- worqhat/types/flow_get_metrics_params.py +0 -25
- worqhat/types/flow_get_metrics_response.py +0 -55
- worqhat/types/flow_trigger_with_file_params.py +0 -17
- worqhat/types/flow_trigger_with_file_response.py +0 -18
- worqhat/types/flow_trigger_with_payload_params.py +0 -13
- worqhat/types/flow_trigger_with_payload_response.py +0 -20
- worqhat/types/get_server_info_response.py +0 -15
- worqhat/types/health_check_response.py +0 -33
- worqhat/types/storage_delete_file_by_id_response.py +0 -18
- worqhat/types/storage_retrieve_file_by_id_response.py +0 -33
- worqhat/types/storage_retrieve_file_by_path_params.py +0 -12
- worqhat/types/storage_retrieve_file_by_path_response.py +0 -33
- worqhat/types/storage_upload_file_params.py +0 -17
- worqhat/types/storage_upload_file_response.py +0 -33
- worqhat-3.10.0.dist-info/METADATA +0 -432
- worqhat-3.10.0.dist-info/RECORD +0 -85
- worqhat-3.10.0.dist-info/licenses/LICENSE +0 -201
worqhat/resources/flows.py
CHANGED
|
@@ -1,443 +1,95 @@
|
|
|
1
|
-
|
|
1
|
+
"""Flows resource for Worqhat SDK."""
|
|
2
2
|
|
|
3
|
-
from
|
|
3
|
+
from typing import TYPE_CHECKING, Optional, Dict, Any, BinaryIO, Union
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
from
|
|
7
|
-
from typing_extensions import Literal
|
|
5
|
+
if TYPE_CHECKING:
|
|
6
|
+
from ..http_client import HTTPClient
|
|
8
7
|
|
|
9
|
-
import httpx
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
from .._utils import extract_files, maybe_transform, deepcopy_minimal, async_maybe_transform
|
|
14
|
-
from .._compat import cached_property
|
|
15
|
-
from .._resource import SyncAPIResource, AsyncAPIResource
|
|
16
|
-
from .._response import (
|
|
17
|
-
to_raw_response_wrapper,
|
|
18
|
-
to_streamed_response_wrapper,
|
|
19
|
-
async_to_raw_response_wrapper,
|
|
20
|
-
async_to_streamed_response_wrapper,
|
|
21
|
-
)
|
|
22
|
-
from .._base_client import make_request_options
|
|
23
|
-
from ..types.flow_get_metrics_response import FlowGetMetricsResponse
|
|
24
|
-
from ..types.flow_trigger_with_file_response import FlowTriggerWithFileResponse
|
|
25
|
-
from ..types.flow_trigger_with_payload_response import FlowTriggerWithPayloadResponse
|
|
9
|
+
class FlowsResource:
|
|
10
|
+
"""Workflow operations resource."""
|
|
26
11
|
|
|
27
|
-
|
|
12
|
+
def __init__(self, client: "HTTPClient"):
|
|
13
|
+
"""Initialize the flows resource."""
|
|
14
|
+
self._client = client
|
|
28
15
|
|
|
29
|
-
|
|
30
|
-
class FlowsResource(SyncAPIResource):
|
|
31
|
-
@cached_property
|
|
32
|
-
def with_raw_response(self) -> FlowsResourceWithRawResponse:
|
|
33
|
-
"""
|
|
34
|
-
This property can be used as a prefix for any HTTP method call to return
|
|
35
|
-
the raw response object instead of the parsed content.
|
|
36
|
-
|
|
37
|
-
For more information, see https://www.github.com/WorqHat/worqhat-python-sdk#accessing-raw-response-data-eg-headers
|
|
38
|
-
"""
|
|
39
|
-
return FlowsResourceWithRawResponse(self)
|
|
40
|
-
|
|
41
|
-
@cached_property
|
|
42
|
-
def with_streaming_response(self) -> FlowsResourceWithStreamingResponse:
|
|
16
|
+
def trigger(self, flow_id: str, input_data: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
|
|
43
17
|
"""
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
For more information, see https://www.github.com/WorqHat/worqhat-python-sdk#with_streaming_response
|
|
47
|
-
"""
|
|
48
|
-
return FlowsResourceWithStreamingResponse(self)
|
|
49
|
-
|
|
50
|
-
def get_metrics(
|
|
51
|
-
self,
|
|
52
|
-
*,
|
|
53
|
-
end_date: Union[str, date] | Omit = omit,
|
|
54
|
-
start_date: Union[str, date] | Omit = omit,
|
|
55
|
-
status: Literal["completed", "failed", "in_progress"] | Omit = omit,
|
|
56
|
-
user_id: str | Omit = omit,
|
|
57
|
-
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
58
|
-
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
59
|
-
extra_headers: Headers | None = None,
|
|
60
|
-
extra_query: Query | None = None,
|
|
61
|
-
extra_body: Body | None = None,
|
|
62
|
-
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
63
|
-
) -> FlowGetMetricsResponse:
|
|
64
|
-
"""Get metrics for workflows within a specified date range.
|
|
65
|
-
|
|
66
|
-
This endpoint provides
|
|
67
|
-
aggregated statistics about workflow execution and detailed information about
|
|
68
|
-
individual workflows.
|
|
69
|
-
|
|
70
|
-
The response includes metrics aggregated by user and a list of all workflows
|
|
71
|
-
matching the specified criteria.
|
|
18
|
+
Trigger a workflow by ID.
|
|
72
19
|
|
|
73
20
|
Args:
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
start_date: Start date for filtering (YYYY-MM-DD format)
|
|
77
|
-
|
|
78
|
-
status: Filter by workflow status
|
|
79
|
-
|
|
80
|
-
user_id: Filter by specific user ID
|
|
21
|
+
flow_id: Workflow ID.
|
|
22
|
+
input_data: Input data for the workflow.
|
|
81
23
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
extra_query: Add additional query parameters to the request
|
|
85
|
-
|
|
86
|
-
extra_body: Add additional JSON properties to the request
|
|
87
|
-
|
|
88
|
-
timeout: Override the client-level default timeout for this request, in seconds
|
|
24
|
+
Returns:
|
|
25
|
+
Workflow response.
|
|
89
26
|
"""
|
|
90
|
-
return self.
|
|
91
|
-
"/flows/metrics",
|
|
92
|
-
options=make_request_options(
|
|
93
|
-
extra_headers=extra_headers,
|
|
94
|
-
extra_query=extra_query,
|
|
95
|
-
extra_body=extra_body,
|
|
96
|
-
timeout=timeout,
|
|
97
|
-
query=maybe_transform(
|
|
98
|
-
{
|
|
99
|
-
"end_date": end_date,
|
|
100
|
-
"start_date": start_date,
|
|
101
|
-
"status": status,
|
|
102
|
-
"user_id": user_id,
|
|
103
|
-
},
|
|
104
|
-
flow_get_metrics_params.FlowGetMetricsParams,
|
|
105
|
-
),
|
|
106
|
-
),
|
|
107
|
-
cast_to=FlowGetMetricsResponse,
|
|
108
|
-
)
|
|
27
|
+
return self._client.post(f"/api/flows/trigger/{flow_id}", json=input_data or {})
|
|
109
28
|
|
|
110
29
|
def trigger_with_file(
|
|
111
30
|
self,
|
|
112
31
|
flow_id: str,
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
extra_headers: Headers | None = None,
|
|
119
|
-
extra_query: Query | None = None,
|
|
120
|
-
extra_body: Body | None = None,
|
|
121
|
-
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
122
|
-
) -> FlowTriggerWithFileResponse:
|
|
123
|
-
"""Trigger a workflow by its ID with either a file upload or a URL to a file.
|
|
124
|
-
|
|
125
|
-
This
|
|
126
|
-
endpoint accepts multipart/form-data with either a file field or a URL field.
|
|
127
|
-
When a URL is provided, the server will download the file and process it as if
|
|
128
|
-
it were directly uploaded. The workflow ID must be specified in the URL path.
|
|
129
|
-
|
|
130
|
-
Args:
|
|
131
|
-
file: File to upload and process
|
|
132
|
-
|
|
133
|
-
url: URL to a file to download and process
|
|
134
|
-
|
|
135
|
-
extra_headers: Send extra headers
|
|
136
|
-
|
|
137
|
-
extra_query: Add additional query parameters to the request
|
|
138
|
-
|
|
139
|
-
extra_body: Add additional JSON properties to the request
|
|
140
|
-
|
|
141
|
-
timeout: Override the client-level default timeout for this request, in seconds
|
|
32
|
+
file: Optional[Union[BinaryIO, bytes]] = None,
|
|
33
|
+
url: Optional[str] = None,
|
|
34
|
+
data: Optional[Dict[str, Any]] = None,
|
|
35
|
+
**kwargs: Any,
|
|
36
|
+
) -> Dict[str, Any]:
|
|
142
37
|
"""
|
|
143
|
-
|
|
144
|
-
raise ValueError(f"Expected a non-empty value for `flow_id` but received {flow_id!r}")
|
|
145
|
-
body = deepcopy_minimal(
|
|
146
|
-
{
|
|
147
|
-
"file": file,
|
|
148
|
-
"url": url,
|
|
149
|
-
}
|
|
150
|
-
)
|
|
151
|
-
files = extract_files(cast(Mapping[str, object], body), paths=[["file"]])
|
|
152
|
-
# It should be noted that the actual Content-Type header that will be
|
|
153
|
-
# sent to the server will contain a `boundary` parameter, e.g.
|
|
154
|
-
# multipart/form-data; boundary=---abc--
|
|
155
|
-
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
|
|
156
|
-
return self._post(
|
|
157
|
-
f"/flows/file/{flow_id}",
|
|
158
|
-
body=maybe_transform(body, flow_trigger_with_file_params.FlowTriggerWithFileParams),
|
|
159
|
-
files=files,
|
|
160
|
-
options=make_request_options(
|
|
161
|
-
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
162
|
-
),
|
|
163
|
-
cast_to=FlowTriggerWithFileResponse,
|
|
164
|
-
)
|
|
165
|
-
|
|
166
|
-
def trigger_with_payload(
|
|
167
|
-
self,
|
|
168
|
-
flow_id: str,
|
|
169
|
-
*,
|
|
170
|
-
data: Dict[str, object] | Omit = omit,
|
|
171
|
-
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
172
|
-
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
173
|
-
extra_headers: Headers | None = None,
|
|
174
|
-
extra_query: Query | None = None,
|
|
175
|
-
extra_body: Body | None = None,
|
|
176
|
-
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
177
|
-
) -> FlowTriggerWithPayloadResponse:
|
|
178
|
-
"""Trigger a workflow by its ID with a JSON payload.
|
|
179
|
-
|
|
180
|
-
This endpoint accepts any
|
|
181
|
-
valid JSON object as the request body and forwards it to the workflow. The
|
|
182
|
-
workflow ID must be specified in the URL path.
|
|
38
|
+
Trigger a workflow with a file upload or URL.
|
|
183
39
|
|
|
184
40
|
Args:
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
timeout: Override the client-level default timeout for this request, in seconds
|
|
194
|
-
"""
|
|
195
|
-
if not flow_id:
|
|
196
|
-
raise ValueError(f"Expected a non-empty value for `flow_id` but received {flow_id!r}")
|
|
197
|
-
return self._post(
|
|
198
|
-
f"/flows/trigger/{flow_id}",
|
|
199
|
-
body=maybe_transform({"data": data}, flow_trigger_with_payload_params.FlowTriggerWithPayloadParams),
|
|
200
|
-
options=make_request_options(
|
|
201
|
-
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
202
|
-
),
|
|
203
|
-
cast_to=FlowTriggerWithPayloadResponse,
|
|
204
|
-
)
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
class AsyncFlowsResource(AsyncAPIResource):
|
|
208
|
-
@cached_property
|
|
209
|
-
def with_raw_response(self) -> AsyncFlowsResourceWithRawResponse:
|
|
210
|
-
"""
|
|
211
|
-
This property can be used as a prefix for any HTTP method call to return
|
|
212
|
-
the raw response object instead of the parsed content.
|
|
213
|
-
|
|
214
|
-
For more information, see https://www.github.com/WorqHat/worqhat-python-sdk#accessing-raw-response-data-eg-headers
|
|
41
|
+
flow_id: Workflow ID.
|
|
42
|
+
file: File object or bytes to upload.
|
|
43
|
+
url: URL to download file from.
|
|
44
|
+
data: Additional data for the workflow.
|
|
45
|
+
**kwargs: Additional form fields.
|
|
46
|
+
|
|
47
|
+
Returns:
|
|
48
|
+
Workflow response.
|
|
215
49
|
"""
|
|
216
|
-
|
|
50
|
+
files = {}
|
|
51
|
+
form_data: Dict[str, Any] = {}
|
|
217
52
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
"""
|
|
221
|
-
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
|
222
|
-
|
|
223
|
-
For more information, see https://www.github.com/WorqHat/worqhat-python-sdk#with_streaming_response
|
|
224
|
-
"""
|
|
225
|
-
return AsyncFlowsResourceWithStreamingResponse(self)
|
|
226
|
-
|
|
227
|
-
async def get_metrics(
|
|
228
|
-
self,
|
|
229
|
-
*,
|
|
230
|
-
end_date: Union[str, date] | Omit = omit,
|
|
231
|
-
start_date: Union[str, date] | Omit = omit,
|
|
232
|
-
status: Literal["completed", "failed", "in_progress"] | Omit = omit,
|
|
233
|
-
user_id: str | Omit = omit,
|
|
234
|
-
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
235
|
-
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
236
|
-
extra_headers: Headers | None = None,
|
|
237
|
-
extra_query: Query | None = None,
|
|
238
|
-
extra_body: Body | None = None,
|
|
239
|
-
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
240
|
-
) -> FlowGetMetricsResponse:
|
|
241
|
-
"""Get metrics for workflows within a specified date range.
|
|
242
|
-
|
|
243
|
-
This endpoint provides
|
|
244
|
-
aggregated statistics about workflow execution and detailed information about
|
|
245
|
-
individual workflows.
|
|
246
|
-
|
|
247
|
-
The response includes metrics aggregated by user and a list of all workflows
|
|
248
|
-
matching the specified criteria.
|
|
249
|
-
|
|
250
|
-
Args:
|
|
251
|
-
end_date: End date for filtering (YYYY-MM-DD format)
|
|
252
|
-
|
|
253
|
-
start_date: Start date for filtering (YYYY-MM-DD format)
|
|
53
|
+
if file:
|
|
54
|
+
files["file"] = file
|
|
254
55
|
|
|
255
|
-
|
|
56
|
+
if url:
|
|
57
|
+
form_data["url"] = url
|
|
256
58
|
|
|
257
|
-
|
|
59
|
+
if data:
|
|
60
|
+
import json
|
|
258
61
|
|
|
259
|
-
|
|
62
|
+
form_data["data"] = json.dumps(data)
|
|
260
63
|
|
|
261
|
-
|
|
64
|
+
# Add any additional fields
|
|
65
|
+
form_data.update(kwargs)
|
|
262
66
|
|
|
263
|
-
|
|
67
|
+
return self._client.post(f"/api/flows/file/{flow_id}", data=form_data, files=files or None)
|
|
264
68
|
|
|
265
|
-
|
|
266
|
-
"""
|
|
267
|
-
return await self._get(
|
|
268
|
-
"/flows/metrics",
|
|
269
|
-
options=make_request_options(
|
|
270
|
-
extra_headers=extra_headers,
|
|
271
|
-
extra_query=extra_query,
|
|
272
|
-
extra_body=extra_body,
|
|
273
|
-
timeout=timeout,
|
|
274
|
-
query=await async_maybe_transform(
|
|
275
|
-
{
|
|
276
|
-
"end_date": end_date,
|
|
277
|
-
"start_date": start_date,
|
|
278
|
-
"status": status,
|
|
279
|
-
"user_id": user_id,
|
|
280
|
-
},
|
|
281
|
-
flow_get_metrics_params.FlowGetMetricsParams,
|
|
282
|
-
),
|
|
283
|
-
),
|
|
284
|
-
cast_to=FlowGetMetricsResponse,
|
|
285
|
-
)
|
|
286
|
-
|
|
287
|
-
async def trigger_with_file(
|
|
69
|
+
def get_metrics(
|
|
288
70
|
self,
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
294
|
-
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
295
|
-
extra_headers: Headers | None = None,
|
|
296
|
-
extra_query: Query | None = None,
|
|
297
|
-
extra_body: Body | None = None,
|
|
298
|
-
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
299
|
-
) -> FlowTriggerWithFileResponse:
|
|
300
|
-
"""Trigger a workflow by its ID with either a file upload or a URL to a file.
|
|
301
|
-
|
|
302
|
-
This
|
|
303
|
-
endpoint accepts multipart/form-data with either a file field or a URL field.
|
|
304
|
-
When a URL is provided, the server will download the file and process it as if
|
|
305
|
-
it were directly uploaded. The workflow ID must be specified in the URL path.
|
|
306
|
-
|
|
307
|
-
Args:
|
|
308
|
-
file: File to upload and process
|
|
309
|
-
|
|
310
|
-
url: URL to a file to download and process
|
|
311
|
-
|
|
312
|
-
extra_headers: Send extra headers
|
|
313
|
-
|
|
314
|
-
extra_query: Add additional query parameters to the request
|
|
315
|
-
|
|
316
|
-
extra_body: Add additional JSON properties to the request
|
|
317
|
-
|
|
318
|
-
timeout: Override the client-level default timeout for this request, in seconds
|
|
71
|
+
start_date: Optional[str] = None,
|
|
72
|
+
end_date: Optional[str] = None,
|
|
73
|
+
status: Optional[str] = None,
|
|
74
|
+
) -> Dict[str, Any]:
|
|
319
75
|
"""
|
|
320
|
-
|
|
321
|
-
raise ValueError(f"Expected a non-empty value for `flow_id` but received {flow_id!r}")
|
|
322
|
-
body = deepcopy_minimal(
|
|
323
|
-
{
|
|
324
|
-
"file": file,
|
|
325
|
-
"url": url,
|
|
326
|
-
}
|
|
327
|
-
)
|
|
328
|
-
files = extract_files(cast(Mapping[str, object], body), paths=[["file"]])
|
|
329
|
-
# It should be noted that the actual Content-Type header that will be
|
|
330
|
-
# sent to the server will contain a `boundary` parameter, e.g.
|
|
331
|
-
# multipart/form-data; boundary=---abc--
|
|
332
|
-
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
|
|
333
|
-
return await self._post(
|
|
334
|
-
f"/flows/file/{flow_id}",
|
|
335
|
-
body=await async_maybe_transform(body, flow_trigger_with_file_params.FlowTriggerWithFileParams),
|
|
336
|
-
files=files,
|
|
337
|
-
options=make_request_options(
|
|
338
|
-
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
339
|
-
),
|
|
340
|
-
cast_to=FlowTriggerWithFileResponse,
|
|
341
|
-
)
|
|
342
|
-
|
|
343
|
-
async def trigger_with_payload(
|
|
344
|
-
self,
|
|
345
|
-
flow_id: str,
|
|
346
|
-
*,
|
|
347
|
-
data: Dict[str, object] | Omit = omit,
|
|
348
|
-
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
349
|
-
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
350
|
-
extra_headers: Headers | None = None,
|
|
351
|
-
extra_query: Query | None = None,
|
|
352
|
-
extra_body: Body | None = None,
|
|
353
|
-
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
354
|
-
) -> FlowTriggerWithPayloadResponse:
|
|
355
|
-
"""Trigger a workflow by its ID with a JSON payload.
|
|
356
|
-
|
|
357
|
-
This endpoint accepts any
|
|
358
|
-
valid JSON object as the request body and forwards it to the workflow. The
|
|
359
|
-
workflow ID must be specified in the URL path.
|
|
76
|
+
Retrieve workflow metrics from analytics.
|
|
360
77
|
|
|
361
78
|
Args:
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
extra_query: Add additional query parameters to the request
|
|
79
|
+
start_date: Start date (YYYY-MM-DD).
|
|
80
|
+
end_date: End date (YYYY-MM-DD).
|
|
81
|
+
status: Filter by status ('completed', 'failed', 'in_progress').
|
|
367
82
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
timeout: Override the client-level default timeout for this request, in seconds
|
|
83
|
+
Returns:
|
|
84
|
+
Workflow metrics and analytics.
|
|
371
85
|
"""
|
|
372
|
-
|
|
373
|
-
raise ValueError(f"Expected a non-empty value for `flow_id` but received {flow_id!r}")
|
|
374
|
-
return await self._post(
|
|
375
|
-
f"/flows/trigger/{flow_id}",
|
|
376
|
-
body=await async_maybe_transform(
|
|
377
|
-
{"data": data}, flow_trigger_with_payload_params.FlowTriggerWithPayloadParams
|
|
378
|
-
),
|
|
379
|
-
options=make_request_options(
|
|
380
|
-
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
381
|
-
),
|
|
382
|
-
cast_to=FlowTriggerWithPayloadResponse,
|
|
383
|
-
)
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
class FlowsResourceWithRawResponse:
|
|
387
|
-
def __init__(self, flows: FlowsResource) -> None:
|
|
388
|
-
self._flows = flows
|
|
389
|
-
|
|
390
|
-
self.get_metrics = to_raw_response_wrapper(
|
|
391
|
-
flows.get_metrics,
|
|
392
|
-
)
|
|
393
|
-
self.trigger_with_file = to_raw_response_wrapper(
|
|
394
|
-
flows.trigger_with_file,
|
|
395
|
-
)
|
|
396
|
-
self.trigger_with_payload = to_raw_response_wrapper(
|
|
397
|
-
flows.trigger_with_payload,
|
|
398
|
-
)
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
class AsyncFlowsResourceWithRawResponse:
|
|
402
|
-
def __init__(self, flows: AsyncFlowsResource) -> None:
|
|
403
|
-
self._flows = flows
|
|
404
|
-
|
|
405
|
-
self.get_metrics = async_to_raw_response_wrapper(
|
|
406
|
-
flows.get_metrics,
|
|
407
|
-
)
|
|
408
|
-
self.trigger_with_file = async_to_raw_response_wrapper(
|
|
409
|
-
flows.trigger_with_file,
|
|
410
|
-
)
|
|
411
|
-
self.trigger_with_payload = async_to_raw_response_wrapper(
|
|
412
|
-
flows.trigger_with_payload,
|
|
413
|
-
)
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
class FlowsResourceWithStreamingResponse:
|
|
417
|
-
def __init__(self, flows: FlowsResource) -> None:
|
|
418
|
-
self._flows = flows
|
|
419
|
-
|
|
420
|
-
self.get_metrics = to_streamed_response_wrapper(
|
|
421
|
-
flows.get_metrics,
|
|
422
|
-
)
|
|
423
|
-
self.trigger_with_file = to_streamed_response_wrapper(
|
|
424
|
-
flows.trigger_with_file,
|
|
425
|
-
)
|
|
426
|
-
self.trigger_with_payload = to_streamed_response_wrapper(
|
|
427
|
-
flows.trigger_with_payload,
|
|
428
|
-
)
|
|
429
|
-
|
|
86
|
+
params: Dict[str, str] = {}
|
|
430
87
|
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
88
|
+
if start_date:
|
|
89
|
+
params["start_date"] = start_date
|
|
90
|
+
if end_date:
|
|
91
|
+
params["end_date"] = end_date
|
|
92
|
+
if status:
|
|
93
|
+
params["status"] = status
|
|
434
94
|
|
|
435
|
-
self.
|
|
436
|
-
flows.get_metrics,
|
|
437
|
-
)
|
|
438
|
-
self.trigger_with_file = async_to_streamed_response_wrapper(
|
|
439
|
-
flows.trigger_with_file,
|
|
440
|
-
)
|
|
441
|
-
self.trigger_with_payload = async_to_streamed_response_wrapper(
|
|
442
|
-
flows.trigger_with_payload,
|
|
443
|
-
)
|
|
95
|
+
return self._client.get("/api/flows/metrics", params=params or None)
|