retab 0.0.35__py3-none-any.whl → 0.0.37__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.
- {uiform → retab}/_utils/ai_models.py +2 -2
- {uiform → retab}/_utils/benchmarking.py +15 -16
- {uiform → retab}/_utils/chat.py +9 -14
- {uiform → retab}/_utils/display.py +0 -3
- {uiform → retab}/_utils/json_schema.py +9 -14
- {uiform → retab}/_utils/mime.py +11 -14
- {uiform → retab}/_utils/responses.py +9 -3
- {uiform → retab}/_utils/stream_context_managers.py +1 -1
- {uiform → retab}/_utils/usage/usage.py +28 -28
- {uiform → retab}/client.py +32 -31
- {uiform → retab}/resources/consensus/client.py +17 -36
- {uiform → retab}/resources/consensus/completions.py +24 -47
- {uiform → retab}/resources/consensus/completions_stream.py +26 -38
- {uiform → retab}/resources/consensus/responses.py +31 -80
- {uiform → retab}/resources/consensus/responses_stream.py +31 -79
- {uiform → retab}/resources/documents/client.py +59 -45
- {uiform → retab}/resources/documents/extractions.py +181 -90
- {uiform → retab}/resources/evals.py +56 -43
- retab/resources/evaluations/__init__.py +3 -0
- retab/resources/evaluations/client.py +301 -0
- retab/resources/evaluations/documents.py +233 -0
- retab/resources/evaluations/iterations.py +452 -0
- {uiform → retab}/resources/files.py +2 -2
- {uiform → retab}/resources/jsonlUtils.py +220 -216
- retab/resources/models.py +73 -0
- retab/resources/processors/automations/client.py +244 -0
- {uiform → retab}/resources/processors/automations/endpoints.py +77 -118
- retab/resources/processors/automations/links.py +294 -0
- {uiform → retab}/resources/processors/automations/logs.py +30 -19
- {uiform → retab}/resources/processors/automations/mailboxes.py +136 -174
- retab/resources/processors/automations/outlook.py +337 -0
- {uiform → retab}/resources/processors/automations/tests.py +22 -25
- {uiform → retab}/resources/processors/client.py +179 -164
- {uiform → retab}/resources/schemas.py +78 -66
- {uiform → retab}/resources/secrets/external_api_keys.py +1 -5
- retab/resources/secrets/webhook.py +64 -0
- {uiform → retab}/resources/usage.py +39 -2
- {uiform → retab}/types/ai_models.py +13 -13
- {uiform → retab}/types/automations/cron.py +19 -12
- {uiform → retab}/types/automations/endpoints.py +7 -4
- {uiform → retab}/types/automations/links.py +7 -3
- {uiform → retab}/types/automations/mailboxes.py +9 -9
- {uiform → retab}/types/automations/outlook.py +15 -11
- retab/types/browser_canvas.py +3 -0
- {uiform → retab}/types/chat.py +2 -2
- {uiform → retab}/types/completions.py +9 -12
- retab/types/consensus.py +19 -0
- {uiform → retab}/types/db/annotations.py +3 -3
- {uiform → retab}/types/db/files.py +8 -6
- {uiform → retab}/types/documents/create_messages.py +18 -20
- {uiform → retab}/types/documents/extractions.py +69 -24
- {uiform → retab}/types/evals.py +5 -5
- retab/types/evaluations/__init__.py +31 -0
- retab/types/evaluations/documents.py +30 -0
- retab/types/evaluations/iterations.py +112 -0
- retab/types/evaluations/model.py +73 -0
- retab/types/events.py +79 -0
- {uiform → retab}/types/extractions.py +33 -10
- retab/types/inference_settings.py +15 -0
- retab/types/jobs/base.py +54 -0
- retab/types/jobs/batch_annotation.py +12 -0
- {uiform → retab}/types/jobs/evaluation.py +1 -2
- {uiform → retab}/types/logs.py +37 -34
- retab/types/metrics.py +32 -0
- {uiform → retab}/types/mime.py +22 -20
- {uiform → retab}/types/modalities.py +10 -10
- retab/types/predictions.py +19 -0
- {uiform → retab}/types/schemas/enhance.py +4 -2
- {uiform → retab}/types/schemas/evaluate.py +7 -4
- {uiform → retab}/types/schemas/generate.py +6 -3
- {uiform → retab}/types/schemas/layout.py +1 -1
- {uiform → retab}/types/schemas/object.py +13 -14
- {uiform → retab}/types/schemas/templates.py +1 -3
- {uiform → retab}/types/secrets/external_api_keys.py +0 -1
- {uiform → retab}/types/standards.py +18 -1
- {retab-0.0.35.dist-info → retab-0.0.37.dist-info}/METADATA +7 -6
- retab-0.0.37.dist-info/RECORD +107 -0
- retab-0.0.37.dist-info/top_level.txt +1 -0
- retab-0.0.35.dist-info/RECORD +0 -111
- retab-0.0.35.dist-info/top_level.txt +0 -1
- uiform/_utils/benchmarking copy.py +0 -588
- uiform/resources/deployments/__init__.py +0 -9
- uiform/resources/deployments/client.py +0 -78
- uiform/resources/deployments/endpoints.py +0 -322
- uiform/resources/deployments/links.py +0 -452
- uiform/resources/deployments/logs.py +0 -211
- uiform/resources/deployments/mailboxes.py +0 -496
- uiform/resources/deployments/outlook.py +0 -531
- uiform/resources/deployments/tests.py +0 -158
- uiform/resources/models.py +0 -45
- uiform/resources/processors/automations/client.py +0 -78
- uiform/resources/processors/automations/links.py +0 -356
- uiform/resources/processors/automations/outlook.py +0 -444
- uiform/resources/secrets/webhook.py +0 -62
- uiform/types/consensus.py +0 -10
- uiform/types/deployments/cron.py +0 -59
- uiform/types/deployments/endpoints.py +0 -28
- uiform/types/deployments/links.py +0 -36
- uiform/types/deployments/mailboxes.py +0 -67
- uiform/types/deployments/outlook.py +0 -76
- uiform/types/deployments/webhooks.py +0 -21
- uiform/types/events.py +0 -76
- uiform/types/jobs/base.py +0 -150
- uiform/types/jobs/batch_annotation.py +0 -22
- uiform/types/secrets/__init__.py +0 -0
- {uiform → retab}/__init__.py +0 -0
- {uiform → retab}/_resource.py +0 -0
- {uiform → retab}/_utils/__init__.py +0 -0
- {uiform → retab}/_utils/usage/__init__.py +0 -0
- {uiform → retab}/py.typed +0 -0
- {uiform → retab}/resources/__init__.py +0 -0
- {uiform → retab}/resources/consensus/__init__.py +0 -0
- {uiform → retab}/resources/documents/__init__.py +0 -0
- {uiform → retab}/resources/finetuning.py +0 -0
- {uiform → retab}/resources/openai_example.py +0 -0
- {uiform → retab}/resources/processors/__init__.py +0 -0
- {uiform → retab}/resources/processors/automations/__init__.py +0 -0
- {uiform → retab}/resources/prompt_optimization.py +0 -0
- {uiform → retab}/resources/secrets/__init__.py +0 -0
- {uiform → retab}/resources/secrets/client.py +0 -0
- {uiform → retab}/types/__init__.py +0 -0
- {uiform → retab}/types/automations/__init__.py +0 -0
- {uiform → retab}/types/automations/webhooks.py +0 -0
- {uiform → retab}/types/db/__init__.py +0 -0
- {uiform/types/deployments → retab/types/documents}/__init__.py +0 -0
- {uiform → retab}/types/documents/correct_orientation.py +0 -0
- {uiform/types/documents → retab/types/jobs}/__init__.py +0 -0
- {uiform → retab}/types/jobs/finetune.py +0 -0
- {uiform → retab}/types/jobs/prompt_optimization.py +0 -0
- {uiform → retab}/types/jobs/webcrawl.py +0 -0
- {uiform → retab}/types/pagination.py +0 -0
- {uiform/types/jobs → retab/types/schemas}/__init__.py +0 -0
- {uiform/types/schemas → retab/types/secrets}/__init__.py +0 -0
- {retab-0.0.35.dist-info → retab-0.0.37.dist-info}/WHEEL +0 -0
@@ -0,0 +1,337 @@
|
|
1
|
+
from typing import Any, Literal, List
|
2
|
+
|
3
|
+
from pydantic_core import PydanticUndefined
|
4
|
+
|
5
|
+
from ...._resource import AsyncAPIResource, SyncAPIResource
|
6
|
+
from ....types.automations.outlook import FetchParams, ListOutlooks, MatchParams, Outlook, UpdateOutlookRequest
|
7
|
+
from ....types.standards import PreparedRequest
|
8
|
+
|
9
|
+
|
10
|
+
class OutlooksMixin:
|
11
|
+
outlooks_base_url: str = "/v1/processors/automations/outlook"
|
12
|
+
|
13
|
+
def prepare_create(
|
14
|
+
self,
|
15
|
+
name: str,
|
16
|
+
processor_id: str,
|
17
|
+
webhook_url: str,
|
18
|
+
default_language: str = PydanticUndefined, # type: ignore[assignment]
|
19
|
+
webhook_headers: dict[str, str] = PydanticUndefined, # type: ignore[assignment]
|
20
|
+
need_validation: bool = PydanticUndefined, # type: ignore[assignment]
|
21
|
+
authorized_domains: list[str] = PydanticUndefined, # type: ignore[assignment]
|
22
|
+
authorized_emails: list[str] = PydanticUndefined, # type: ignore[assignment]
|
23
|
+
layout_schema: dict[str, Any] = PydanticUndefined, # type: ignore[assignment]
|
24
|
+
match_params: list[MatchParams] = PydanticUndefined, # type: ignore[assignment]
|
25
|
+
fetch_params: list[FetchParams] = PydanticUndefined, # type: ignore[assignment]
|
26
|
+
) -> PreparedRequest:
|
27
|
+
# Validate the data
|
28
|
+
outlook_data = Outlook(
|
29
|
+
processor_id=processor_id,
|
30
|
+
name=name,
|
31
|
+
default_language=default_language,
|
32
|
+
webhook_url=webhook_url,
|
33
|
+
webhook_headers=webhook_headers,
|
34
|
+
need_validation=need_validation,
|
35
|
+
authorized_domains=authorized_domains,
|
36
|
+
authorized_emails=authorized_emails,
|
37
|
+
layout_schema=layout_schema,
|
38
|
+
match_params=match_params,
|
39
|
+
fetch_params=fetch_params,
|
40
|
+
)
|
41
|
+
return PreparedRequest(method="POST", url=self.outlooks_base_url, data=outlook_data.model_dump(mode="json"))
|
42
|
+
|
43
|
+
def prepare_list(
|
44
|
+
self,
|
45
|
+
before: str | None = None,
|
46
|
+
after: str | None = None,
|
47
|
+
limit: int = 10,
|
48
|
+
order: Literal["asc", "desc"] | None = "desc",
|
49
|
+
name: str | None = None,
|
50
|
+
webhook_url: str | None = None,
|
51
|
+
) -> PreparedRequest:
|
52
|
+
params = {
|
53
|
+
"before": before,
|
54
|
+
"after": after,
|
55
|
+
"limit": limit,
|
56
|
+
"order": order,
|
57
|
+
"name": name,
|
58
|
+
"webhook_url": webhook_url,
|
59
|
+
}
|
60
|
+
# Remove None values
|
61
|
+
params = {k: v for k, v in params.items() if v is not None}
|
62
|
+
|
63
|
+
return PreparedRequest(method="GET", url=self.outlooks_base_url, params=params)
|
64
|
+
|
65
|
+
def prepare_get(self, outlook_id: str) -> PreparedRequest:
|
66
|
+
return PreparedRequest(method="GET", url=f"{self.outlooks_base_url}/{outlook_id}")
|
67
|
+
|
68
|
+
def prepare_update(
|
69
|
+
self,
|
70
|
+
outlook_id: str,
|
71
|
+
name: str = PydanticUndefined, # type: ignore[assignment]
|
72
|
+
default_language: str = PydanticUndefined, # type: ignore[assignment]
|
73
|
+
webhook_url: str = PydanticUndefined, # type: ignore[assignment]
|
74
|
+
webhook_headers: dict[str, str] = PydanticUndefined, # type: ignore[assignment]
|
75
|
+
need_validation: bool = PydanticUndefined, # type: ignore[assignment]
|
76
|
+
authorized_domains: list[str] = PydanticUndefined, # type: ignore[assignment]
|
77
|
+
authorized_emails: list[str] = PydanticUndefined, # type: ignore[assignment]
|
78
|
+
match_params: list[MatchParams] = PydanticUndefined, # type: ignore[assignment]
|
79
|
+
fetch_params: list[FetchParams] = PydanticUndefined, # type: ignore[assignment]
|
80
|
+
layout_schema: dict[str, Any] = PydanticUndefined, # type: ignore[assignment]
|
81
|
+
) -> PreparedRequest:
|
82
|
+
update_outlook_request = UpdateOutlookRequest(
|
83
|
+
name=name,
|
84
|
+
default_language=default_language,
|
85
|
+
webhook_url=webhook_url,
|
86
|
+
webhook_headers=webhook_headers,
|
87
|
+
need_validation=need_validation,
|
88
|
+
authorized_domains=authorized_domains,
|
89
|
+
authorized_emails=authorized_emails,
|
90
|
+
layout_schema=layout_schema,
|
91
|
+
match_params=match_params,
|
92
|
+
fetch_params=fetch_params,
|
93
|
+
)
|
94
|
+
|
95
|
+
return PreparedRequest(method="PUT", url=f"{self.outlooks_base_url}/{outlook_id}", data=update_outlook_request.model_dump(mode="json"))
|
96
|
+
|
97
|
+
def prepare_delete(self, outlook_id: str) -> PreparedRequest:
|
98
|
+
return PreparedRequest(method="DELETE", url=f"{self.outlooks_base_url}/{outlook_id}")
|
99
|
+
|
100
|
+
|
101
|
+
class Outlooks(SyncAPIResource, OutlooksMixin):
|
102
|
+
"""Outlook API wrapper for managing outlook automation configurations"""
|
103
|
+
|
104
|
+
def __init__(self, client: Any) -> None:
|
105
|
+
super().__init__(client=client)
|
106
|
+
|
107
|
+
def create(
|
108
|
+
self,
|
109
|
+
name: str,
|
110
|
+
processor_id: str,
|
111
|
+
webhook_url: str,
|
112
|
+
default_language: str = PydanticUndefined, # type: ignore[assignment]
|
113
|
+
webhook_headers: dict[str, str] = PydanticUndefined, # type: ignore[assignment]
|
114
|
+
need_validation: bool = PydanticUndefined, # type: ignore[assignment]
|
115
|
+
authorized_domains: list[str] = PydanticUndefined, # type: ignore[assignment]
|
116
|
+
authorized_emails: list[str] = PydanticUndefined, # type: ignore[assignment]
|
117
|
+
layout_schema: dict[str, Any] = PydanticUndefined, # type: ignore[assignment]
|
118
|
+
match_params: list[MatchParams] = PydanticUndefined, # type: ignore[assignment]
|
119
|
+
fetch_params: list[FetchParams] = PydanticUndefined, # type: ignore[assignment]
|
120
|
+
) -> Outlook:
|
121
|
+
"""Create a new outlook automation configuration.
|
122
|
+
|
123
|
+
Args:
|
124
|
+
name: Name of the outlook plugin
|
125
|
+
processor_id: ID of the processor to use for the automation
|
126
|
+
webhook_url: Webhook URL to receive processed data
|
127
|
+
webhook_headers: Webhook headers to send with processed data
|
128
|
+
authorized_domains: List of authorized domains
|
129
|
+
authorized_emails: List of authorized emails
|
130
|
+
layout_schema: Layout schema to display the data
|
131
|
+
match_params: List of match parameters for the outlook automation
|
132
|
+
fetch_params: List of fetch parameters for the outlook automation
|
133
|
+
Returns:
|
134
|
+
Outlook: The created outlook plugin configuration
|
135
|
+
"""
|
136
|
+
|
137
|
+
request = self.prepare_create(
|
138
|
+
name=name,
|
139
|
+
processor_id=processor_id,
|
140
|
+
webhook_url=webhook_url,
|
141
|
+
default_language=default_language,
|
142
|
+
webhook_headers=webhook_headers,
|
143
|
+
need_validation=need_validation,
|
144
|
+
authorized_domains=authorized_domains,
|
145
|
+
authorized_emails=authorized_emails,
|
146
|
+
layout_schema=layout_schema,
|
147
|
+
match_params=match_params,
|
148
|
+
fetch_params=fetch_params,
|
149
|
+
)
|
150
|
+
response = self._client._prepared_request(request)
|
151
|
+
|
152
|
+
print(f"Outlook automation created. Outlook available at https://www.uiform.com/dashboard/processors/{response['id']}")
|
153
|
+
|
154
|
+
return Outlook.model_validate(response)
|
155
|
+
|
156
|
+
def list(
|
157
|
+
self,
|
158
|
+
before: str | None = None,
|
159
|
+
after: str | None = None,
|
160
|
+
limit: int = 10,
|
161
|
+
order: Literal["asc", "desc"] | None = "desc",
|
162
|
+
name: str | None = None,
|
163
|
+
webhook_url: str | None = None,
|
164
|
+
) -> ListOutlooks:
|
165
|
+
"""List all outlook automation configurations.
|
166
|
+
|
167
|
+
Args:
|
168
|
+
before: Optional cursor for pagination - get results before this log ID
|
169
|
+
after: Optional cursor for pagination - get results after this log ID
|
170
|
+
limit: Maximum number of logs to return (1-100, default 10)
|
171
|
+
order: Sort order by creation time - "asc" or "desc" (default "desc")
|
172
|
+
name: Optional name filter
|
173
|
+
webhook_url: Optional webhook URL filter
|
174
|
+
Returns:
|
175
|
+
List[Outlook]: List of outlook plugin configurations
|
176
|
+
"""
|
177
|
+
request = self.prepare_list(before, after, limit, order, name, webhook_url)
|
178
|
+
response = self._client._prepared_request(request)
|
179
|
+
return ListOutlooks.model_validate(response)
|
180
|
+
|
181
|
+
def get(self, outlook_id: str) -> Outlook:
|
182
|
+
"""Get a specific outlook automation configuration.
|
183
|
+
|
184
|
+
Args:
|
185
|
+
id: ID of the outlook plugin
|
186
|
+
|
187
|
+
Returns:
|
188
|
+
Outlook: The outlook plugin configuration
|
189
|
+
"""
|
190
|
+
request = self.prepare_get(outlook_id)
|
191
|
+
response = self._client._prepared_request(request)
|
192
|
+
return Outlook.model_validate(response)
|
193
|
+
|
194
|
+
def update(
|
195
|
+
self,
|
196
|
+
outlook_id: str,
|
197
|
+
name: str = PydanticUndefined, # type: ignore[assignment]
|
198
|
+
default_language: str = PydanticUndefined, # type: ignore[assignment]
|
199
|
+
webhook_url: str = PydanticUndefined, # type: ignore[assignment]
|
200
|
+
webhook_headers: dict[str, str] = PydanticUndefined, # type: ignore[assignment]
|
201
|
+
need_validation: bool = PydanticUndefined, # type: ignore[assignment]
|
202
|
+
authorized_domains: List[str] = PydanticUndefined, # type: ignore[assignment]
|
203
|
+
authorized_emails: List[str] = PydanticUndefined, # type: ignore[assignment]
|
204
|
+
layout_schema: dict[str, Any] = PydanticUndefined, # type: ignore[assignment]
|
205
|
+
match_params: List[MatchParams] = PydanticUndefined, # type: ignore[assignment]
|
206
|
+
fetch_params: List[FetchParams] = PydanticUndefined, # type: ignore[assignment]
|
207
|
+
) -> Outlook:
|
208
|
+
"""Update an outlook automation configuration.
|
209
|
+
|
210
|
+
Args:
|
211
|
+
outlook_id: ID of the outlook plugin to update
|
212
|
+
name: New name for the outlook plugin
|
213
|
+
webhook_url: New webhook URL
|
214
|
+
webhook_headers: New webhook headers
|
215
|
+
authorized_domains: New authorized domains
|
216
|
+
authorized_emails: New authorized emails
|
217
|
+
match_params: New match parameters for the outlook automation
|
218
|
+
fetch_params: New fetch parameters for the outlook automation
|
219
|
+
layout_schema: New layout schema for the outlook automation
|
220
|
+
|
221
|
+
Returns:
|
222
|
+
Outlook: The updated outlook plugin configuration
|
223
|
+
"""
|
224
|
+
request = self.prepare_update(
|
225
|
+
outlook_id,
|
226
|
+
name=name,
|
227
|
+
default_language=default_language,
|
228
|
+
webhook_url=webhook_url,
|
229
|
+
webhook_headers=webhook_headers,
|
230
|
+
need_validation=need_validation,
|
231
|
+
authorized_domains=authorized_domains,
|
232
|
+
authorized_emails=authorized_emails,
|
233
|
+
layout_schema=layout_schema,
|
234
|
+
match_params=match_params,
|
235
|
+
fetch_params=fetch_params,
|
236
|
+
)
|
237
|
+
response = self._client._prepared_request(request)
|
238
|
+
return Outlook.model_validate(response)
|
239
|
+
|
240
|
+
def delete(self, outlook_id: str) -> None:
|
241
|
+
"""Delete an outlook automation configuration.
|
242
|
+
|
243
|
+
Args:
|
244
|
+
outlook_id: ID of the outlook plugin to delete
|
245
|
+
"""
|
246
|
+
request = self.prepare_delete(outlook_id)
|
247
|
+
self._client._prepared_request(request)
|
248
|
+
return None
|
249
|
+
|
250
|
+
|
251
|
+
class AsyncOutlooks(AsyncAPIResource, OutlooksMixin):
|
252
|
+
def __init__(self, client: Any) -> None:
|
253
|
+
super().__init__(client=client)
|
254
|
+
|
255
|
+
async def create(
|
256
|
+
self,
|
257
|
+
name: str,
|
258
|
+
processor_id: str,
|
259
|
+
webhook_url: str,
|
260
|
+
default_language: str = PydanticUndefined, # type: ignore[assignment]
|
261
|
+
webhook_headers: dict[str, str] = PydanticUndefined, # type: ignore[assignment]
|
262
|
+
need_validation: bool = PydanticUndefined, # type: ignore[assignment]
|
263
|
+
authorized_domains: list[str] = PydanticUndefined, # type: ignore[assignment]
|
264
|
+
authorized_emails: list[str] = PydanticUndefined, # type: ignore[assignment]
|
265
|
+
layout_schema: dict[str, Any] = PydanticUndefined, # type: ignore[assignment]
|
266
|
+
match_params: list[MatchParams] = PydanticUndefined, # type: ignore[assignment]
|
267
|
+
fetch_params: list[FetchParams] = PydanticUndefined, # type: ignore[assignment]
|
268
|
+
) -> Outlook:
|
269
|
+
request = self.prepare_create(
|
270
|
+
name=name,
|
271
|
+
processor_id=processor_id,
|
272
|
+
webhook_url=webhook_url,
|
273
|
+
default_language=default_language,
|
274
|
+
webhook_headers=webhook_headers,
|
275
|
+
need_validation=need_validation,
|
276
|
+
authorized_domains=authorized_domains,
|
277
|
+
authorized_emails=authorized_emails,
|
278
|
+
layout_schema=layout_schema,
|
279
|
+
match_params=match_params,
|
280
|
+
fetch_params=fetch_params,
|
281
|
+
)
|
282
|
+
response = await self._client._prepared_request(request)
|
283
|
+
print(f"Outlook automation created. Outlook available at https://www.uiform.com/dashboard/processors/{response['id']}")
|
284
|
+
return Outlook.model_validate(response)
|
285
|
+
|
286
|
+
async def list(
|
287
|
+
self,
|
288
|
+
before: str | None = None,
|
289
|
+
after: str | None = None,
|
290
|
+
limit: int = 10,
|
291
|
+
order: Literal["asc", "desc"] | None = "desc",
|
292
|
+
name: str | None = None,
|
293
|
+
webhook_url: str | None = None,
|
294
|
+
) -> ListOutlooks:
|
295
|
+
request = self.prepare_list(before, after, limit, order, name, webhook_url)
|
296
|
+
response = await self._client._prepared_request(request)
|
297
|
+
return ListOutlooks.model_validate(response)
|
298
|
+
|
299
|
+
async def get(self, outlook_id: str) -> Outlook:
|
300
|
+
request = self.prepare_get(outlook_id)
|
301
|
+
response = await self._client._prepared_request(request)
|
302
|
+
return Outlook.model_validate(response)
|
303
|
+
|
304
|
+
async def update(
|
305
|
+
self,
|
306
|
+
outlook_id: str,
|
307
|
+
name: str = PydanticUndefined, # type: ignore[assignment]
|
308
|
+
default_language: str = PydanticUndefined, # type: ignore[assignment]
|
309
|
+
webhook_url: str = PydanticUndefined, # type: ignore[assignment]
|
310
|
+
webhook_headers: dict[str, str] = PydanticUndefined, # type: ignore[assignment]
|
311
|
+
need_validation: bool = PydanticUndefined, # type: ignore[assignment]
|
312
|
+
authorized_domains: List[str] = PydanticUndefined, # type: ignore[assignment]
|
313
|
+
authorized_emails: List[str] = PydanticUndefined, # type: ignore[assignment]
|
314
|
+
layout_schema: dict[str, Any] = PydanticUndefined, # type: ignore[assignment]
|
315
|
+
match_params: List[MatchParams] = PydanticUndefined, # type: ignore[assignment]
|
316
|
+
fetch_params: List[FetchParams] = PydanticUndefined, # type: ignore[assignment]
|
317
|
+
) -> Outlook:
|
318
|
+
request = self.prepare_update(
|
319
|
+
outlook_id=outlook_id,
|
320
|
+
name=name,
|
321
|
+
default_language=default_language,
|
322
|
+
webhook_url=webhook_url,
|
323
|
+
webhook_headers=webhook_headers,
|
324
|
+
need_validation=need_validation,
|
325
|
+
authorized_domains=authorized_domains,
|
326
|
+
authorized_emails=authorized_emails,
|
327
|
+
layout_schema=layout_schema,
|
328
|
+
match_params=match_params,
|
329
|
+
fetch_params=fetch_params,
|
330
|
+
)
|
331
|
+
response = await self._client._prepared_request(request)
|
332
|
+
return Outlook.model_validate(response)
|
333
|
+
|
334
|
+
async def delete(self, outlook_id: str) -> None:
|
335
|
+
request = self.prepare_delete(outlook_id)
|
336
|
+
await self._client._prepared_request(request)
|
337
|
+
return None
|
@@ -1,32 +1,29 @@
|
|
1
|
-
import datetime
|
2
1
|
import json
|
3
2
|
from io import IOBase
|
4
3
|
from pathlib import Path
|
5
|
-
from typing import Any, Dict, Literal, Optional
|
6
4
|
|
7
|
-
import httpx
|
8
|
-
from pydantic import HttpUrl
|
9
5
|
from PIL.Image import Image
|
6
|
+
from pydantic import HttpUrl
|
10
7
|
|
11
8
|
from ...._resource import AsyncAPIResource, SyncAPIResource
|
12
9
|
from ...._utils.mime import prepare_mime_document
|
13
|
-
from ....types.mime import BaseMIMEData, MIMEData
|
14
10
|
from ....types.logs import AutomationLog
|
11
|
+
from ....types.mime import MIMEData
|
15
12
|
from ....types.standards import PreparedRequest
|
16
13
|
|
17
14
|
|
18
15
|
class TestsMixin:
|
19
16
|
def prepare_upload(self, automation_id: str, document: Path | str | IOBase | HttpUrl | Image | MIMEData) -> PreparedRequest:
|
20
17
|
mime_document = prepare_mime_document(document)
|
21
|
-
return PreparedRequest(method="POST", url=f"/v1/processors/automations/tests/upload/{automation_id}", data={"document": mime_document.model_dump(mode=
|
18
|
+
return PreparedRequest(method="POST", url=f"/v1/processors/automations/tests/upload/{automation_id}", data={"document": mime_document.model_dump(mode="json")})
|
22
19
|
|
23
20
|
def prepare_webhook(self, automation_id: str) -> PreparedRequest:
|
24
21
|
return PreparedRequest(method="POST", url=f"/v1/processors/automations/tests/webhook/{automation_id}", data=None)
|
25
22
|
|
26
23
|
def print_upload_verbose(self, log: AutomationLog) -> None:
|
27
24
|
if log.external_request_log:
|
28
|
-
print(
|
29
|
-
print(
|
25
|
+
print("\nTEST FILE UPLOAD RESULTS:")
|
26
|
+
print("\n#########################")
|
30
27
|
print(f"Status Code: {log.external_request_log.status_code}")
|
31
28
|
print(f"Duration: {log.external_request_log.duration_ms:.2f}ms")
|
32
29
|
|
@@ -38,7 +35,7 @@ class TestsMixin:
|
|
38
35
|
print("RESPONSE BODY:")
|
39
36
|
print("--------------")
|
40
37
|
print(json.dumps(log.external_request_log.response_body, indent=2))
|
41
|
-
|
38
|
+
|
42
39
|
if log.external_request_log.response_headers:
|
43
40
|
print("\n--------------")
|
44
41
|
print("RESPONSE HEADERS:")
|
@@ -47,8 +44,8 @@ class TestsMixin:
|
|
47
44
|
|
48
45
|
def print_webhook_verbose(self, log: AutomationLog) -> None:
|
49
46
|
if log.external_request_log:
|
50
|
-
print(
|
51
|
-
print(
|
47
|
+
print("\nTEST WEBHOOK RESULTS:")
|
48
|
+
print("\n#########################")
|
52
49
|
print(f"Status Code: {log.external_request_log.status_code}")
|
53
50
|
print(f"Duration: {log.external_request_log.duration_ms:.2f}ms")
|
54
51
|
|
@@ -60,7 +57,7 @@ class TestsMixin:
|
|
60
57
|
print("RESPONSE BODY:")
|
61
58
|
print("--------------")
|
62
59
|
print(json.dumps(log.external_request_log.response_body, indent=2))
|
63
|
-
|
60
|
+
|
64
61
|
if log.external_request_log.response_headers:
|
65
62
|
print("\n--------------")
|
66
63
|
print("RESPONSE HEADERS:")
|
@@ -84,18 +81,18 @@ class Tests(SyncAPIResource, TestsMixin):
|
|
84
81
|
"""
|
85
82
|
request = self.prepare_upload(automation_id, document)
|
86
83
|
response = self._client._prepared_request(request)
|
87
|
-
|
84
|
+
|
88
85
|
log = AutomationLog.model_validate(response)
|
89
|
-
|
86
|
+
|
90
87
|
if verbose:
|
91
88
|
self.print_upload_verbose(log)
|
92
|
-
|
89
|
+
|
93
90
|
return log
|
94
91
|
|
95
92
|
def webhook(self, automation_id: str, verbose: bool = True) -> AutomationLog:
|
96
93
|
"""Test endpoint that simulates the complete webhook process with sample data.
|
97
94
|
|
98
|
-
Args:
|
95
|
+
Args:
|
99
96
|
automation_id: ID of the automation to test
|
100
97
|
verbose: Whether to print verbose output
|
101
98
|
|
@@ -104,12 +101,12 @@ class Tests(SyncAPIResource, TestsMixin):
|
|
104
101
|
"""
|
105
102
|
request = self.prepare_webhook(automation_id)
|
106
103
|
response = self._client._prepared_request(request)
|
107
|
-
|
104
|
+
|
108
105
|
log = AutomationLog.model_validate(response)
|
109
|
-
|
106
|
+
|
110
107
|
if verbose:
|
111
108
|
self.print_webhook_verbose(log)
|
112
|
-
|
109
|
+
|
113
110
|
return log
|
114
111
|
|
115
112
|
|
@@ -129,12 +126,12 @@ class AsyncTests(AsyncAPIResource, TestsMixin):
|
|
129
126
|
"""
|
130
127
|
request = self.prepare_upload(automation_id, document)
|
131
128
|
response = await self._client._prepared_request(request)
|
132
|
-
|
129
|
+
|
133
130
|
log = AutomationLog.model_validate(response)
|
134
|
-
|
131
|
+
|
135
132
|
if verbose:
|
136
133
|
self.print_upload_verbose(log)
|
137
|
-
|
134
|
+
|
138
135
|
return log
|
139
136
|
|
140
137
|
async def webhook(self, automation_id: str, verbose: bool = True) -> AutomationLog:
|
@@ -149,10 +146,10 @@ class AsyncTests(AsyncAPIResource, TestsMixin):
|
|
149
146
|
"""
|
150
147
|
request = self.prepare_webhook(automation_id)
|
151
148
|
response = await self._client._prepared_request(request)
|
152
|
-
|
149
|
+
|
153
150
|
log = AutomationLog.model_validate(response)
|
154
|
-
|
151
|
+
|
155
152
|
if verbose:
|
156
153
|
self.print_webhook_verbose(log)
|
157
|
-
|
154
|
+
|
158
155
|
return log
|