deeprails 0.3.2__py3-none-any.whl → 1.0.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.
Potentially problematic release.
This version of deeprails might be problematic. Click here for more details.
- deeprails/__init__.py +104 -1
- deeprails/_base_client.py +1995 -0
- deeprails/_client.py +478 -0
- deeprails/_compat.py +219 -0
- deeprails/_constants.py +14 -0
- deeprails/_exceptions.py +108 -0
- deeprails/_files.py +123 -0
- deeprails/_models.py +835 -0
- deeprails/_qs.py +150 -0
- deeprails/_resource.py +43 -0
- deeprails/_response.py +830 -0
- deeprails/_streaming.py +333 -0
- deeprails/_types.py +260 -0
- deeprails/_utils/__init__.py +64 -0
- deeprails/_utils/_compat.py +45 -0
- deeprails/_utils/_datetime_parse.py +136 -0
- deeprails/_utils/_logs.py +25 -0
- deeprails/_utils/_proxy.py +65 -0
- deeprails/_utils/_reflection.py +42 -0
- deeprails/_utils/_resources_proxy.py +24 -0
- deeprails/_utils/_streams.py +12 -0
- deeprails/_utils/_sync.py +86 -0
- deeprails/_utils/_transform.py +457 -0
- deeprails/_utils/_typing.py +156 -0
- deeprails/_utils/_utils.py +421 -0
- deeprails/_version.py +4 -0
- deeprails/lib/.keep +4 -0
- deeprails/py.typed +0 -0
- deeprails/resources/__init__.py +47 -0
- deeprails/resources/defend/__init__.py +33 -0
- deeprails/resources/defend/defend.py +480 -0
- deeprails/resources/defend/events.py +311 -0
- deeprails/resources/evaluate.py +334 -0
- deeprails/resources/monitor.py +566 -0
- deeprails/types/__init__.py +16 -0
- deeprails/types/api_response.py +50 -0
- deeprails/types/defend/__init__.py +6 -0
- deeprails/types/defend/event_submit_event_params.py +44 -0
- deeprails/types/defend/workflow_event_response.py +33 -0
- deeprails/types/defend_create_workflow_params.py +56 -0
- deeprails/types/defend_response.py +50 -0
- deeprails/types/defend_update_workflow_params.py +18 -0
- deeprails/types/evaluate_create_params.py +60 -0
- deeprails/types/evaluation.py +113 -0
- deeprails/types/monitor_create_params.py +15 -0
- deeprails/types/monitor_retrieve_params.py +12 -0
- deeprails/types/monitor_retrieve_response.py +81 -0
- deeprails/types/monitor_submit_event_params.py +63 -0
- deeprails/types/monitor_submit_event_response.py +36 -0
- deeprails/types/monitor_update_params.py +22 -0
- deeprails-1.0.0.dist-info/METADATA +550 -0
- deeprails-1.0.0.dist-info/RECORD +54 -0
- {deeprails-0.3.2.dist-info → deeprails-1.0.0.dist-info}/WHEEL +1 -1
- deeprails-1.0.0.dist-info/licenses/LICENSE +201 -0
- deeprails/client.py +0 -285
- deeprails/exceptions.py +0 -10
- deeprails/schemas.py +0 -92
- deeprails-0.3.2.dist-info/METADATA +0 -235
- deeprails-0.3.2.dist-info/RECORD +0 -8
- deeprails-0.3.2.dist-info/licenses/LICENSE +0 -11
|
@@ -0,0 +1,480 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Dict, Optional
|
|
6
|
+
from typing_extensions import Literal
|
|
7
|
+
|
|
8
|
+
import httpx
|
|
9
|
+
|
|
10
|
+
from .events import (
|
|
11
|
+
EventsResource,
|
|
12
|
+
AsyncEventsResource,
|
|
13
|
+
EventsResourceWithRawResponse,
|
|
14
|
+
AsyncEventsResourceWithRawResponse,
|
|
15
|
+
EventsResourceWithStreamingResponse,
|
|
16
|
+
AsyncEventsResourceWithStreamingResponse,
|
|
17
|
+
)
|
|
18
|
+
from ...types import defend_create_workflow_params, defend_update_workflow_params
|
|
19
|
+
from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
|
|
20
|
+
from ..._utils import maybe_transform, async_maybe_transform
|
|
21
|
+
from ..._compat import cached_property
|
|
22
|
+
from ..._resource import SyncAPIResource, AsyncAPIResource
|
|
23
|
+
from ..._response import (
|
|
24
|
+
to_raw_response_wrapper,
|
|
25
|
+
to_streamed_response_wrapper,
|
|
26
|
+
async_to_raw_response_wrapper,
|
|
27
|
+
async_to_streamed_response_wrapper,
|
|
28
|
+
)
|
|
29
|
+
from ..._base_client import make_request_options
|
|
30
|
+
from ...types.defend_response import DefendResponse
|
|
31
|
+
|
|
32
|
+
__all__ = ["DefendResource", "AsyncDefendResource"]
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class DefendResource(SyncAPIResource):
|
|
36
|
+
@cached_property
|
|
37
|
+
def events(self) -> EventsResource:
|
|
38
|
+
return EventsResource(self._client)
|
|
39
|
+
|
|
40
|
+
@cached_property
|
|
41
|
+
def with_raw_response(self) -> DefendResourceWithRawResponse:
|
|
42
|
+
"""
|
|
43
|
+
This property can be used as a prefix for any HTTP method call to return
|
|
44
|
+
the raw response object instead of the parsed content.
|
|
45
|
+
|
|
46
|
+
For more information, see https://www.github.com/deeprails/deeprails-python-sdk#accessing-raw-response-data-eg-headers
|
|
47
|
+
"""
|
|
48
|
+
return DefendResourceWithRawResponse(self)
|
|
49
|
+
|
|
50
|
+
@cached_property
|
|
51
|
+
def with_streaming_response(self) -> DefendResourceWithStreamingResponse:
|
|
52
|
+
"""
|
|
53
|
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
|
54
|
+
|
|
55
|
+
For more information, see https://www.github.com/deeprails/deeprails-python-sdk#with_streaming_response
|
|
56
|
+
"""
|
|
57
|
+
return DefendResourceWithStreamingResponse(self)
|
|
58
|
+
|
|
59
|
+
def create_workflow(
|
|
60
|
+
self,
|
|
61
|
+
*,
|
|
62
|
+
improvement_action: Optional[Literal["regenerate", "fixit"]],
|
|
63
|
+
metrics: Dict[str, float],
|
|
64
|
+
name: str,
|
|
65
|
+
type: Literal["automatic", "custom"],
|
|
66
|
+
automatic_tolerance: Literal["low", "medium", "high"] | Omit = omit,
|
|
67
|
+
description: str | Omit = omit,
|
|
68
|
+
max_retries: int | Omit = omit,
|
|
69
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
70
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
71
|
+
extra_headers: Headers | None = None,
|
|
72
|
+
extra_query: Query | None = None,
|
|
73
|
+
extra_body: Body | None = None,
|
|
74
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
75
|
+
) -> DefendResponse:
|
|
76
|
+
"""
|
|
77
|
+
Create a new guardrail workflow with optional guardrail thresholds and
|
|
78
|
+
improvement actions.
|
|
79
|
+
|
|
80
|
+
Args:
|
|
81
|
+
improvement_action: The action used to improve outputs that fail one or guardrail metrics for the
|
|
82
|
+
workflow events. May be `regenerate`, `fixit`, or null which represents “do
|
|
83
|
+
nothing”. ReGen runs the user's exact input prompt with minor induced variance.
|
|
84
|
+
Fixit attempts to directly address the shortcomings of the output using the
|
|
85
|
+
guardrail failure rationale. Do nothing does not attempt any improvement.
|
|
86
|
+
|
|
87
|
+
metrics: Mapping of guardrail metrics to floating point threshold values. If the workflow
|
|
88
|
+
type is automatic, only the metric names are used (`automatic_tolerance`
|
|
89
|
+
determines thresholds). Possible metrics are `correctness`, `completeness`,
|
|
90
|
+
`instruction_adherence`, `context_adherence`, `ground_truth_adherence`, or
|
|
91
|
+
`comprehensive_safety`.
|
|
92
|
+
|
|
93
|
+
name: Name of the workflow.
|
|
94
|
+
|
|
95
|
+
type: Type of thresholds to use for the workflow, either `automatic` or `custom`.
|
|
96
|
+
Automatic thresholds are assigned internally after the user specifies a
|
|
97
|
+
qualitative tolerance for the metrics, whereas custom metrics allow the user to
|
|
98
|
+
set the threshold for each metric as a floating point number between 0.0 and
|
|
99
|
+
1.0.
|
|
100
|
+
|
|
101
|
+
automatic_tolerance: Hallucination tolerance for automatic workflows; may be `low`, `medium`, or
|
|
102
|
+
`high`. Ignored if `type` is `custom`.
|
|
103
|
+
|
|
104
|
+
description: Description for the workflow.
|
|
105
|
+
|
|
106
|
+
max_retries: Max. number of improvement action retries until a given event passes the
|
|
107
|
+
guardrails. Defaults to 10.
|
|
108
|
+
|
|
109
|
+
extra_headers: Send extra headers
|
|
110
|
+
|
|
111
|
+
extra_query: Add additional query parameters to the request
|
|
112
|
+
|
|
113
|
+
extra_body: Add additional JSON properties to the request
|
|
114
|
+
|
|
115
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
116
|
+
"""
|
|
117
|
+
return self._post(
|
|
118
|
+
"/defend",
|
|
119
|
+
body=maybe_transform(
|
|
120
|
+
{
|
|
121
|
+
"improvement_action": improvement_action,
|
|
122
|
+
"metrics": metrics,
|
|
123
|
+
"name": name,
|
|
124
|
+
"type": type,
|
|
125
|
+
"automatic_tolerance": automatic_tolerance,
|
|
126
|
+
"description": description,
|
|
127
|
+
"max_retries": max_retries,
|
|
128
|
+
},
|
|
129
|
+
defend_create_workflow_params.DefendCreateWorkflowParams,
|
|
130
|
+
),
|
|
131
|
+
options=make_request_options(
|
|
132
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
133
|
+
),
|
|
134
|
+
cast_to=DefendResponse,
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
def retrieve_workflow(
|
|
138
|
+
self,
|
|
139
|
+
workflow_id: str,
|
|
140
|
+
*,
|
|
141
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
142
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
143
|
+
extra_headers: Headers | None = None,
|
|
144
|
+
extra_query: Query | None = None,
|
|
145
|
+
extra_body: Body | None = None,
|
|
146
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
147
|
+
) -> DefendResponse:
|
|
148
|
+
"""
|
|
149
|
+
Retrieve the details for a specific guardrail workflow.
|
|
150
|
+
|
|
151
|
+
Args:
|
|
152
|
+
extra_headers: Send extra headers
|
|
153
|
+
|
|
154
|
+
extra_query: Add additional query parameters to the request
|
|
155
|
+
|
|
156
|
+
extra_body: Add additional JSON properties to the request
|
|
157
|
+
|
|
158
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
159
|
+
"""
|
|
160
|
+
if not workflow_id:
|
|
161
|
+
raise ValueError(f"Expected a non-empty value for `workflow_id` but received {workflow_id!r}")
|
|
162
|
+
return self._get(
|
|
163
|
+
f"/defend/{workflow_id}",
|
|
164
|
+
options=make_request_options(
|
|
165
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
166
|
+
),
|
|
167
|
+
cast_to=DefendResponse,
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
def update_workflow(
|
|
171
|
+
self,
|
|
172
|
+
workflow_id: str,
|
|
173
|
+
*,
|
|
174
|
+
description: str | Omit = omit,
|
|
175
|
+
name: str | Omit = omit,
|
|
176
|
+
type: Literal["automatic", "custom"] | Omit = omit,
|
|
177
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
178
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
179
|
+
extra_headers: Headers | None = None,
|
|
180
|
+
extra_query: Query | None = None,
|
|
181
|
+
extra_body: Body | None = None,
|
|
182
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
183
|
+
) -> DefendResponse:
|
|
184
|
+
"""
|
|
185
|
+
Update an existing guardrail workflow.
|
|
186
|
+
|
|
187
|
+
Args:
|
|
188
|
+
description: Description for the workflow.
|
|
189
|
+
|
|
190
|
+
name: Name of the workflow.
|
|
191
|
+
|
|
192
|
+
type: Type of thresholds to use for the workflow, either `automatic` or `custom`.
|
|
193
|
+
|
|
194
|
+
extra_headers: Send extra headers
|
|
195
|
+
|
|
196
|
+
extra_query: Add additional query parameters to the request
|
|
197
|
+
|
|
198
|
+
extra_body: Add additional JSON properties to the request
|
|
199
|
+
|
|
200
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
201
|
+
"""
|
|
202
|
+
if not workflow_id:
|
|
203
|
+
raise ValueError(f"Expected a non-empty value for `workflow_id` but received {workflow_id!r}")
|
|
204
|
+
return self._put(
|
|
205
|
+
f"/defend/{workflow_id}",
|
|
206
|
+
body=maybe_transform(
|
|
207
|
+
{
|
|
208
|
+
"description": description,
|
|
209
|
+
"name": name,
|
|
210
|
+
"type": type,
|
|
211
|
+
},
|
|
212
|
+
defend_update_workflow_params.DefendUpdateWorkflowParams,
|
|
213
|
+
),
|
|
214
|
+
options=make_request_options(
|
|
215
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
216
|
+
),
|
|
217
|
+
cast_to=DefendResponse,
|
|
218
|
+
)
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
class AsyncDefendResource(AsyncAPIResource):
|
|
222
|
+
@cached_property
|
|
223
|
+
def events(self) -> AsyncEventsResource:
|
|
224
|
+
return AsyncEventsResource(self._client)
|
|
225
|
+
|
|
226
|
+
@cached_property
|
|
227
|
+
def with_raw_response(self) -> AsyncDefendResourceWithRawResponse:
|
|
228
|
+
"""
|
|
229
|
+
This property can be used as a prefix for any HTTP method call to return
|
|
230
|
+
the raw response object instead of the parsed content.
|
|
231
|
+
|
|
232
|
+
For more information, see https://www.github.com/deeprails/deeprails-python-sdk#accessing-raw-response-data-eg-headers
|
|
233
|
+
"""
|
|
234
|
+
return AsyncDefendResourceWithRawResponse(self)
|
|
235
|
+
|
|
236
|
+
@cached_property
|
|
237
|
+
def with_streaming_response(self) -> AsyncDefendResourceWithStreamingResponse:
|
|
238
|
+
"""
|
|
239
|
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
|
240
|
+
|
|
241
|
+
For more information, see https://www.github.com/deeprails/deeprails-python-sdk#with_streaming_response
|
|
242
|
+
"""
|
|
243
|
+
return AsyncDefendResourceWithStreamingResponse(self)
|
|
244
|
+
|
|
245
|
+
async def create_workflow(
|
|
246
|
+
self,
|
|
247
|
+
*,
|
|
248
|
+
improvement_action: Optional[Literal["regenerate", "fixit"]],
|
|
249
|
+
metrics: Dict[str, float],
|
|
250
|
+
name: str,
|
|
251
|
+
type: Literal["automatic", "custom"],
|
|
252
|
+
automatic_tolerance: Literal["low", "medium", "high"] | Omit = omit,
|
|
253
|
+
description: str | Omit = omit,
|
|
254
|
+
max_retries: int | Omit = omit,
|
|
255
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
256
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
257
|
+
extra_headers: Headers | None = None,
|
|
258
|
+
extra_query: Query | None = None,
|
|
259
|
+
extra_body: Body | None = None,
|
|
260
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
261
|
+
) -> DefendResponse:
|
|
262
|
+
"""
|
|
263
|
+
Create a new guardrail workflow with optional guardrail thresholds and
|
|
264
|
+
improvement actions.
|
|
265
|
+
|
|
266
|
+
Args:
|
|
267
|
+
improvement_action: The action used to improve outputs that fail one or guardrail metrics for the
|
|
268
|
+
workflow events. May be `regenerate`, `fixit`, or null which represents “do
|
|
269
|
+
nothing”. ReGen runs the user's exact input prompt with minor induced variance.
|
|
270
|
+
Fixit attempts to directly address the shortcomings of the output using the
|
|
271
|
+
guardrail failure rationale. Do nothing does not attempt any improvement.
|
|
272
|
+
|
|
273
|
+
metrics: Mapping of guardrail metrics to floating point threshold values. If the workflow
|
|
274
|
+
type is automatic, only the metric names are used (`automatic_tolerance`
|
|
275
|
+
determines thresholds). Possible metrics are `correctness`, `completeness`,
|
|
276
|
+
`instruction_adherence`, `context_adherence`, `ground_truth_adherence`, or
|
|
277
|
+
`comprehensive_safety`.
|
|
278
|
+
|
|
279
|
+
name: Name of the workflow.
|
|
280
|
+
|
|
281
|
+
type: Type of thresholds to use for the workflow, either `automatic` or `custom`.
|
|
282
|
+
Automatic thresholds are assigned internally after the user specifies a
|
|
283
|
+
qualitative tolerance for the metrics, whereas custom metrics allow the user to
|
|
284
|
+
set the threshold for each metric as a floating point number between 0.0 and
|
|
285
|
+
1.0.
|
|
286
|
+
|
|
287
|
+
automatic_tolerance: Hallucination tolerance for automatic workflows; may be `low`, `medium`, or
|
|
288
|
+
`high`. Ignored if `type` is `custom`.
|
|
289
|
+
|
|
290
|
+
description: Description for the workflow.
|
|
291
|
+
|
|
292
|
+
max_retries: Max. number of improvement action retries until a given event passes the
|
|
293
|
+
guardrails. Defaults to 10.
|
|
294
|
+
|
|
295
|
+
extra_headers: Send extra headers
|
|
296
|
+
|
|
297
|
+
extra_query: Add additional query parameters to the request
|
|
298
|
+
|
|
299
|
+
extra_body: Add additional JSON properties to the request
|
|
300
|
+
|
|
301
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
302
|
+
"""
|
|
303
|
+
return await self._post(
|
|
304
|
+
"/defend",
|
|
305
|
+
body=await async_maybe_transform(
|
|
306
|
+
{
|
|
307
|
+
"improvement_action": improvement_action,
|
|
308
|
+
"metrics": metrics,
|
|
309
|
+
"name": name,
|
|
310
|
+
"type": type,
|
|
311
|
+
"automatic_tolerance": automatic_tolerance,
|
|
312
|
+
"description": description,
|
|
313
|
+
"max_retries": max_retries,
|
|
314
|
+
},
|
|
315
|
+
defend_create_workflow_params.DefendCreateWorkflowParams,
|
|
316
|
+
),
|
|
317
|
+
options=make_request_options(
|
|
318
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
319
|
+
),
|
|
320
|
+
cast_to=DefendResponse,
|
|
321
|
+
)
|
|
322
|
+
|
|
323
|
+
async def retrieve_workflow(
|
|
324
|
+
self,
|
|
325
|
+
workflow_id: str,
|
|
326
|
+
*,
|
|
327
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
328
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
329
|
+
extra_headers: Headers | None = None,
|
|
330
|
+
extra_query: Query | None = None,
|
|
331
|
+
extra_body: Body | None = None,
|
|
332
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
333
|
+
) -> DefendResponse:
|
|
334
|
+
"""
|
|
335
|
+
Retrieve the details for a specific guardrail workflow.
|
|
336
|
+
|
|
337
|
+
Args:
|
|
338
|
+
extra_headers: Send extra headers
|
|
339
|
+
|
|
340
|
+
extra_query: Add additional query parameters to the request
|
|
341
|
+
|
|
342
|
+
extra_body: Add additional JSON properties to the request
|
|
343
|
+
|
|
344
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
345
|
+
"""
|
|
346
|
+
if not workflow_id:
|
|
347
|
+
raise ValueError(f"Expected a non-empty value for `workflow_id` but received {workflow_id!r}")
|
|
348
|
+
return await self._get(
|
|
349
|
+
f"/defend/{workflow_id}",
|
|
350
|
+
options=make_request_options(
|
|
351
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
352
|
+
),
|
|
353
|
+
cast_to=DefendResponse,
|
|
354
|
+
)
|
|
355
|
+
|
|
356
|
+
async def update_workflow(
|
|
357
|
+
self,
|
|
358
|
+
workflow_id: str,
|
|
359
|
+
*,
|
|
360
|
+
description: str | Omit = omit,
|
|
361
|
+
name: str | Omit = omit,
|
|
362
|
+
type: Literal["automatic", "custom"] | Omit = omit,
|
|
363
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
364
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
365
|
+
extra_headers: Headers | None = None,
|
|
366
|
+
extra_query: Query | None = None,
|
|
367
|
+
extra_body: Body | None = None,
|
|
368
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
369
|
+
) -> DefendResponse:
|
|
370
|
+
"""
|
|
371
|
+
Update an existing guardrail workflow.
|
|
372
|
+
|
|
373
|
+
Args:
|
|
374
|
+
description: Description for the workflow.
|
|
375
|
+
|
|
376
|
+
name: Name of the workflow.
|
|
377
|
+
|
|
378
|
+
type: Type of thresholds to use for the workflow, either `automatic` or `custom`.
|
|
379
|
+
|
|
380
|
+
extra_headers: Send extra headers
|
|
381
|
+
|
|
382
|
+
extra_query: Add additional query parameters to the request
|
|
383
|
+
|
|
384
|
+
extra_body: Add additional JSON properties to the request
|
|
385
|
+
|
|
386
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
387
|
+
"""
|
|
388
|
+
if not workflow_id:
|
|
389
|
+
raise ValueError(f"Expected a non-empty value for `workflow_id` but received {workflow_id!r}")
|
|
390
|
+
return await self._put(
|
|
391
|
+
f"/defend/{workflow_id}",
|
|
392
|
+
body=await async_maybe_transform(
|
|
393
|
+
{
|
|
394
|
+
"description": description,
|
|
395
|
+
"name": name,
|
|
396
|
+
"type": type,
|
|
397
|
+
},
|
|
398
|
+
defend_update_workflow_params.DefendUpdateWorkflowParams,
|
|
399
|
+
),
|
|
400
|
+
options=make_request_options(
|
|
401
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
402
|
+
),
|
|
403
|
+
cast_to=DefendResponse,
|
|
404
|
+
)
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
class DefendResourceWithRawResponse:
|
|
408
|
+
def __init__(self, defend: DefendResource) -> None:
|
|
409
|
+
self._defend = defend
|
|
410
|
+
|
|
411
|
+
self.create_workflow = to_raw_response_wrapper(
|
|
412
|
+
defend.create_workflow,
|
|
413
|
+
)
|
|
414
|
+
self.retrieve_workflow = to_raw_response_wrapper(
|
|
415
|
+
defend.retrieve_workflow,
|
|
416
|
+
)
|
|
417
|
+
self.update_workflow = to_raw_response_wrapper(
|
|
418
|
+
defend.update_workflow,
|
|
419
|
+
)
|
|
420
|
+
|
|
421
|
+
@cached_property
|
|
422
|
+
def events(self) -> EventsResourceWithRawResponse:
|
|
423
|
+
return EventsResourceWithRawResponse(self._defend.events)
|
|
424
|
+
|
|
425
|
+
|
|
426
|
+
class AsyncDefendResourceWithRawResponse:
|
|
427
|
+
def __init__(self, defend: AsyncDefendResource) -> None:
|
|
428
|
+
self._defend = defend
|
|
429
|
+
|
|
430
|
+
self.create_workflow = async_to_raw_response_wrapper(
|
|
431
|
+
defend.create_workflow,
|
|
432
|
+
)
|
|
433
|
+
self.retrieve_workflow = async_to_raw_response_wrapper(
|
|
434
|
+
defend.retrieve_workflow,
|
|
435
|
+
)
|
|
436
|
+
self.update_workflow = async_to_raw_response_wrapper(
|
|
437
|
+
defend.update_workflow,
|
|
438
|
+
)
|
|
439
|
+
|
|
440
|
+
@cached_property
|
|
441
|
+
def events(self) -> AsyncEventsResourceWithRawResponse:
|
|
442
|
+
return AsyncEventsResourceWithRawResponse(self._defend.events)
|
|
443
|
+
|
|
444
|
+
|
|
445
|
+
class DefendResourceWithStreamingResponse:
|
|
446
|
+
def __init__(self, defend: DefendResource) -> None:
|
|
447
|
+
self._defend = defend
|
|
448
|
+
|
|
449
|
+
self.create_workflow = to_streamed_response_wrapper(
|
|
450
|
+
defend.create_workflow,
|
|
451
|
+
)
|
|
452
|
+
self.retrieve_workflow = to_streamed_response_wrapper(
|
|
453
|
+
defend.retrieve_workflow,
|
|
454
|
+
)
|
|
455
|
+
self.update_workflow = to_streamed_response_wrapper(
|
|
456
|
+
defend.update_workflow,
|
|
457
|
+
)
|
|
458
|
+
|
|
459
|
+
@cached_property
|
|
460
|
+
def events(self) -> EventsResourceWithStreamingResponse:
|
|
461
|
+
return EventsResourceWithStreamingResponse(self._defend.events)
|
|
462
|
+
|
|
463
|
+
|
|
464
|
+
class AsyncDefendResourceWithStreamingResponse:
|
|
465
|
+
def __init__(self, defend: AsyncDefendResource) -> None:
|
|
466
|
+
self._defend = defend
|
|
467
|
+
|
|
468
|
+
self.create_workflow = async_to_streamed_response_wrapper(
|
|
469
|
+
defend.create_workflow,
|
|
470
|
+
)
|
|
471
|
+
self.retrieve_workflow = async_to_streamed_response_wrapper(
|
|
472
|
+
defend.retrieve_workflow,
|
|
473
|
+
)
|
|
474
|
+
self.update_workflow = async_to_streamed_response_wrapper(
|
|
475
|
+
defend.update_workflow,
|
|
476
|
+
)
|
|
477
|
+
|
|
478
|
+
@cached_property
|
|
479
|
+
def events(self) -> AsyncEventsResourceWithStreamingResponse:
|
|
480
|
+
return AsyncEventsResourceWithStreamingResponse(self._defend.events)
|