daknode 0.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.
- daknode/__init__.py +8 -0
- daknode/api/__init__.py +1 -0
- daknode/api/block_rules/__init__.py +1 -0
- daknode/api/block_rules/create_block_rule.py +211 -0
- daknode/api/block_rules/create_inbox_block_rule.py +225 -0
- daknode/api/block_rules/delete_block_rule.py +192 -0
- daknode/api/block_rules/list_block_rules.py +214 -0
- daknode/api/block_rules/list_inbox_block_rules.py +228 -0
- daknode/api/consent/__init__.py +1 -0
- daknode/api/consent/create_consent.py +203 -0
- daknode/api/consent/revoke.py +195 -0
- daknode/api/control_plane/__init__.py +1 -0
- daknode/api/control_plane/close_workspace.py +184 -0
- daknode/api/control_plane/create_workspace.py +211 -0
- daknode/api/control_plane/list_workspaces.py +155 -0
- daknode/api/control_plane/read_workspace.py +176 -0
- daknode/api/control_plane/update_workspace.py +197 -0
- daknode/api/dead_letters/__init__.py +1 -0
- daknode/api/dead_letters/list_dead_letters.py +198 -0
- daknode/api/dead_letters/replay_dead_letter.py +216 -0
- daknode/api/inboxes/__init__.py +1 -0
- daknode/api/inboxes/create_inbox.py +183 -0
- daknode/api/inboxes/register_webhook.py +225 -0
- daknode/api/inboxes/rotate_webhook_secret.py +224 -0
- daknode/api/messages/__init__.py +1 -0
- daknode/api/messages/get_message.py +176 -0
- daknode/api/messages/get_thread.py +184 -0
- daknode/api/messages/list_messages.py +228 -0
- daknode/api/messages/list_threads.py +228 -0
- daknode/api/privacy/__init__.py +1 -0
- daknode/api/privacy/create_erasure_request.py +227 -0
- daknode/api/privacy/read_erasure_request.py +200 -0
- daknode/api/public/__init__.py +1 -0
- daknode/api/public/agent_signup.py +191 -0
- daknode/api/public/agent_verify.py +191 -0
- daknode/api/search/__init__.py +1 -0
- daknode/api/search/search.py +207 -0
- daknode/api/send/__init__.py +1 -0
- daknode/api/send/send.py +254 -0
- daknode/client.py +270 -0
- daknode/errors.py +14 -0
- daknode/models/__init__.py +79 -0
- daknode/models/block_rule_create.py +104 -0
- daknode/models/block_rule_out.py +160 -0
- daknode/models/block_rule_page.py +116 -0
- daknode/models/consent_request.py +104 -0
- daknode/models/consent_response.py +105 -0
- daknode/models/create_erasure_request_response_create_erasure_request.py +63 -0
- daknode/models/create_in.py +119 -0
- daknode/models/dead_letter_response.py +205 -0
- daknode/models/erasure_request_body.py +60 -0
- daknode/models/http_validation_error.py +97 -0
- daknode/models/inbox_create_request.py +120 -0
- daknode/models/inbox_response.py +148 -0
- daknode/models/message_out.py +309 -0
- daknode/models/message_page.py +116 -0
- daknode/models/read_erasure_request_response_read_erasure_request.py +63 -0
- daknode/models/replay_response.py +113 -0
- daknode/models/revoke_request.py +74 -0
- daknode/models/revoke_response_revoke.py +63 -0
- daknode/models/search_match.py +170 -0
- daknode/models/search_request.py +107 -0
- daknode/models/search_response.py +124 -0
- daknode/models/send_request.py +162 -0
- daknode/models/send_response_send.py +63 -0
- daknode/models/signup_in.py +63 -0
- daknode/models/signup_out.py +102 -0
- daknode/models/thread_detail_out.py +223 -0
- daknode/models/thread_out.py +163 -0
- daknode/models/thread_page.py +116 -0
- daknode/models/timeline_item_out.py +280 -0
- daknode/models/update_in.py +111 -0
- daknode/models/validation_error.py +141 -0
- daknode/models/validation_error_context.py +63 -0
- daknode/models/verify_in.py +67 -0
- daknode/models/verify_out.py +74 -0
- daknode/models/webhook_register_request.py +74 -0
- daknode/models/workspace_list_out.py +92 -0
- daknode/models/workspace_out.py +147 -0
- daknode/py.typed +1 -0
- daknode/types.py +53 -0
- daknode-0.1.0.dist-info/METADATA +143 -0
- daknode-0.1.0.dist-info/RECORD +84 -0
- daknode-0.1.0.dist-info/WHEEL +4 -0
daknode/client.py
ADDED
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import ssl
|
|
2
|
+
from typing import Any, Union, Optional
|
|
3
|
+
|
|
4
|
+
from attrs import define, field, evolve
|
|
5
|
+
import httpx
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@define
|
|
12
|
+
class Client:
|
|
13
|
+
"""A class for keeping track of data related to the API
|
|
14
|
+
|
|
15
|
+
The following are accepted as keyword arguments and will be used to construct httpx Clients internally:
|
|
16
|
+
|
|
17
|
+
``base_url``: The base URL for the API, all requests are made to a relative path to this URL
|
|
18
|
+
|
|
19
|
+
``cookies``: A dictionary of cookies to be sent with every request
|
|
20
|
+
|
|
21
|
+
``headers``: A dictionary of headers to be sent with every request
|
|
22
|
+
|
|
23
|
+
``timeout``: The maximum amount of a time a request can take. API functions will raise
|
|
24
|
+
httpx.TimeoutException if this is exceeded.
|
|
25
|
+
|
|
26
|
+
``verify_ssl``: Whether or not to verify the SSL certificate of the API server. This should be True in production,
|
|
27
|
+
but can be set to False for testing purposes.
|
|
28
|
+
|
|
29
|
+
``follow_redirects``: Whether or not to follow redirects. Default value is False.
|
|
30
|
+
|
|
31
|
+
``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx.Client`` and ``httpx.AsyncClient`` constructor.
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
Attributes:
|
|
35
|
+
raise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatus if the API returns a
|
|
36
|
+
status code that was not documented in the source OpenAPI document. Can also be provided as a keyword
|
|
37
|
+
argument to the constructor.
|
|
38
|
+
"""
|
|
39
|
+
raise_on_unexpected_status: bool = field(default=False, kw_only=True)
|
|
40
|
+
_base_url: str = field(alias="base_url")
|
|
41
|
+
_cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies")
|
|
42
|
+
_headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers")
|
|
43
|
+
_timeout: Optional[httpx.Timeout] = field(default=None, kw_only=True, alias="timeout")
|
|
44
|
+
_verify_ssl: Union[str, bool, ssl.SSLContext] = field(default=True, kw_only=True, alias="verify_ssl")
|
|
45
|
+
_follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects")
|
|
46
|
+
_httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args")
|
|
47
|
+
_client: Optional[httpx.Client] = field(default=None, init=False)
|
|
48
|
+
_async_client: Optional[httpx.AsyncClient] = field(default=None, init=False)
|
|
49
|
+
|
|
50
|
+
def with_headers(self, headers: dict[str, str]) -> "Client":
|
|
51
|
+
"""Get a new client matching this one with additional headers"""
|
|
52
|
+
if self._client is not None:
|
|
53
|
+
self._client.headers.update(headers)
|
|
54
|
+
if self._async_client is not None:
|
|
55
|
+
self._async_client.headers.update(headers)
|
|
56
|
+
return evolve(self, headers={**self._headers, **headers})
|
|
57
|
+
|
|
58
|
+
def with_cookies(self, cookies: dict[str, str]) -> "Client":
|
|
59
|
+
"""Get a new client matching this one with additional cookies"""
|
|
60
|
+
if self._client is not None:
|
|
61
|
+
self._client.cookies.update(cookies)
|
|
62
|
+
if self._async_client is not None:
|
|
63
|
+
self._async_client.cookies.update(cookies)
|
|
64
|
+
return evolve(self, cookies={**self._cookies, **cookies})
|
|
65
|
+
|
|
66
|
+
def with_timeout(self, timeout: httpx.Timeout) -> "Client":
|
|
67
|
+
"""Get a new client matching this one with a new timeout (in seconds)"""
|
|
68
|
+
if self._client is not None:
|
|
69
|
+
self._client.timeout = timeout
|
|
70
|
+
if self._async_client is not None:
|
|
71
|
+
self._async_client.timeout = timeout
|
|
72
|
+
return evolve(self, timeout=timeout)
|
|
73
|
+
|
|
74
|
+
def set_httpx_client(self, client: httpx.Client) -> "Client":
|
|
75
|
+
"""Manually set the underlying httpx.Client
|
|
76
|
+
|
|
77
|
+
**NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
|
|
78
|
+
"""
|
|
79
|
+
self._client = client
|
|
80
|
+
return self
|
|
81
|
+
|
|
82
|
+
def get_httpx_client(self) -> httpx.Client:
|
|
83
|
+
"""Get the underlying httpx.Client, constructing a new one if not previously set"""
|
|
84
|
+
if self._client is None:
|
|
85
|
+
self._client = httpx.Client(
|
|
86
|
+
base_url=self._base_url,
|
|
87
|
+
cookies=self._cookies,
|
|
88
|
+
headers=self._headers,
|
|
89
|
+
timeout=self._timeout,
|
|
90
|
+
verify=self._verify_ssl,
|
|
91
|
+
follow_redirects=self._follow_redirects,
|
|
92
|
+
**self._httpx_args,
|
|
93
|
+
)
|
|
94
|
+
return self._client
|
|
95
|
+
|
|
96
|
+
def __enter__(self) -> "Client":
|
|
97
|
+
"""Enter a context manager for self.client—you cannot enter twice (see httpx docs)"""
|
|
98
|
+
self.get_httpx_client().__enter__()
|
|
99
|
+
return self
|
|
100
|
+
|
|
101
|
+
def __exit__(self, *args: Any, **kwargs: Any) -> None:
|
|
102
|
+
"""Exit a context manager for internal httpx.Client (see httpx docs)"""
|
|
103
|
+
self.get_httpx_client().__exit__(*args, **kwargs)
|
|
104
|
+
|
|
105
|
+
def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "Client":
|
|
106
|
+
"""Manually the underlying httpx.AsyncClient
|
|
107
|
+
|
|
108
|
+
**NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
|
|
109
|
+
"""
|
|
110
|
+
self._async_client = async_client
|
|
111
|
+
return self
|
|
112
|
+
|
|
113
|
+
def get_async_httpx_client(self) -> httpx.AsyncClient:
|
|
114
|
+
"""Get the underlying httpx.AsyncClient, constructing a new one if not previously set"""
|
|
115
|
+
if self._async_client is None:
|
|
116
|
+
self._async_client = httpx.AsyncClient(
|
|
117
|
+
base_url=self._base_url,
|
|
118
|
+
cookies=self._cookies,
|
|
119
|
+
headers=self._headers,
|
|
120
|
+
timeout=self._timeout,
|
|
121
|
+
verify=self._verify_ssl,
|
|
122
|
+
follow_redirects=self._follow_redirects,
|
|
123
|
+
**self._httpx_args,
|
|
124
|
+
)
|
|
125
|
+
return self._async_client
|
|
126
|
+
|
|
127
|
+
async def __aenter__(self) -> "Client":
|
|
128
|
+
"""Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)"""
|
|
129
|
+
await self.get_async_httpx_client().__aenter__()
|
|
130
|
+
return self
|
|
131
|
+
|
|
132
|
+
async def __aexit__(self, *args: Any, **kwargs: Any) -> None:
|
|
133
|
+
"""Exit a context manager for underlying httpx.AsyncClient (see httpx docs)"""
|
|
134
|
+
await self.get_async_httpx_client().__aexit__(*args, **kwargs)
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
@define
|
|
138
|
+
class AuthenticatedClient:
|
|
139
|
+
"""A Client which has been authenticated for use on secured endpoints
|
|
140
|
+
|
|
141
|
+
The following are accepted as keyword arguments and will be used to construct httpx Clients internally:
|
|
142
|
+
|
|
143
|
+
``base_url``: The base URL for the API, all requests are made to a relative path to this URL
|
|
144
|
+
|
|
145
|
+
``cookies``: A dictionary of cookies to be sent with every request
|
|
146
|
+
|
|
147
|
+
``headers``: A dictionary of headers to be sent with every request
|
|
148
|
+
|
|
149
|
+
``timeout``: The maximum amount of a time a request can take. API functions will raise
|
|
150
|
+
httpx.TimeoutException if this is exceeded.
|
|
151
|
+
|
|
152
|
+
``verify_ssl``: Whether or not to verify the SSL certificate of the API server. This should be True in production,
|
|
153
|
+
but can be set to False for testing purposes.
|
|
154
|
+
|
|
155
|
+
``follow_redirects``: Whether or not to follow redirects. Default value is False.
|
|
156
|
+
|
|
157
|
+
``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx.Client`` and ``httpx.AsyncClient`` constructor.
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
Attributes:
|
|
161
|
+
raise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatus if the API returns a
|
|
162
|
+
status code that was not documented in the source OpenAPI document. Can also be provided as a keyword
|
|
163
|
+
argument to the constructor.
|
|
164
|
+
token: The token to use for authentication
|
|
165
|
+
prefix: The prefix to use for the Authorization header
|
|
166
|
+
auth_header_name: The name of the Authorization header
|
|
167
|
+
"""
|
|
168
|
+
|
|
169
|
+
raise_on_unexpected_status: bool = field(default=False, kw_only=True)
|
|
170
|
+
_base_url: str = field(alias="base_url")
|
|
171
|
+
_cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies")
|
|
172
|
+
_headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers")
|
|
173
|
+
_timeout: Optional[httpx.Timeout] = field(default=None, kw_only=True, alias="timeout")
|
|
174
|
+
_verify_ssl: Union[str, bool, ssl.SSLContext] = field(default=True, kw_only=True, alias="verify_ssl")
|
|
175
|
+
_follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects")
|
|
176
|
+
_httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args")
|
|
177
|
+
_client: Optional[httpx.Client] = field(default=None, init=False)
|
|
178
|
+
_async_client: Optional[httpx.AsyncClient] = field(default=None, init=False)
|
|
179
|
+
|
|
180
|
+
token: str
|
|
181
|
+
prefix: str = "Bearer"
|
|
182
|
+
auth_header_name: str = "Authorization"
|
|
183
|
+
|
|
184
|
+
def with_headers(self, headers: dict[str, str]) -> "AuthenticatedClient":
|
|
185
|
+
"""Get a new client matching this one with additional headers"""
|
|
186
|
+
if self._client is not None:
|
|
187
|
+
self._client.headers.update(headers)
|
|
188
|
+
if self._async_client is not None:
|
|
189
|
+
self._async_client.headers.update(headers)
|
|
190
|
+
return evolve(self, headers={**self._headers, **headers})
|
|
191
|
+
|
|
192
|
+
def with_cookies(self, cookies: dict[str, str]) -> "AuthenticatedClient":
|
|
193
|
+
"""Get a new client matching this one with additional cookies"""
|
|
194
|
+
if self._client is not None:
|
|
195
|
+
self._client.cookies.update(cookies)
|
|
196
|
+
if self._async_client is not None:
|
|
197
|
+
self._async_client.cookies.update(cookies)
|
|
198
|
+
return evolve(self, cookies={**self._cookies, **cookies})
|
|
199
|
+
|
|
200
|
+
def with_timeout(self, timeout: httpx.Timeout) -> "AuthenticatedClient":
|
|
201
|
+
"""Get a new client matching this one with a new timeout (in seconds)"""
|
|
202
|
+
if self._client is not None:
|
|
203
|
+
self._client.timeout = timeout
|
|
204
|
+
if self._async_client is not None:
|
|
205
|
+
self._async_client.timeout = timeout
|
|
206
|
+
return evolve(self, timeout=timeout)
|
|
207
|
+
|
|
208
|
+
def set_httpx_client(self, client: httpx.Client) -> "AuthenticatedClient":
|
|
209
|
+
"""Manually set the underlying httpx.Client
|
|
210
|
+
|
|
211
|
+
**NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
|
|
212
|
+
"""
|
|
213
|
+
self._client = client
|
|
214
|
+
return self
|
|
215
|
+
|
|
216
|
+
def get_httpx_client(self) -> httpx.Client:
|
|
217
|
+
"""Get the underlying httpx.Client, constructing a new one if not previously set"""
|
|
218
|
+
if self._client is None:
|
|
219
|
+
self._headers[self.auth_header_name] = f"{self.prefix} {self.token}" if self.prefix else self.token
|
|
220
|
+
self._client = httpx.Client(
|
|
221
|
+
base_url=self._base_url,
|
|
222
|
+
cookies=self._cookies,
|
|
223
|
+
headers=self._headers,
|
|
224
|
+
timeout=self._timeout,
|
|
225
|
+
verify=self._verify_ssl,
|
|
226
|
+
follow_redirects=self._follow_redirects,
|
|
227
|
+
**self._httpx_args,
|
|
228
|
+
)
|
|
229
|
+
return self._client
|
|
230
|
+
|
|
231
|
+
def __enter__(self) -> "AuthenticatedClient":
|
|
232
|
+
"""Enter a context manager for self.client—you cannot enter twice (see httpx docs)"""
|
|
233
|
+
self.get_httpx_client().__enter__()
|
|
234
|
+
return self
|
|
235
|
+
|
|
236
|
+
def __exit__(self, *args: Any, **kwargs: Any) -> None:
|
|
237
|
+
"""Exit a context manager for internal httpx.Client (see httpx docs)"""
|
|
238
|
+
self.get_httpx_client().__exit__(*args, **kwargs)
|
|
239
|
+
|
|
240
|
+
def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "AuthenticatedClient":
|
|
241
|
+
"""Manually the underlying httpx.AsyncClient
|
|
242
|
+
|
|
243
|
+
**NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
|
|
244
|
+
"""
|
|
245
|
+
self._async_client = async_client
|
|
246
|
+
return self
|
|
247
|
+
|
|
248
|
+
def get_async_httpx_client(self) -> httpx.AsyncClient:
|
|
249
|
+
"""Get the underlying httpx.AsyncClient, constructing a new one if not previously set"""
|
|
250
|
+
if self._async_client is None:
|
|
251
|
+
self._headers[self.auth_header_name] = f"{self.prefix} {self.token}" if self.prefix else self.token
|
|
252
|
+
self._async_client = httpx.AsyncClient(
|
|
253
|
+
base_url=self._base_url,
|
|
254
|
+
cookies=self._cookies,
|
|
255
|
+
headers=self._headers,
|
|
256
|
+
timeout=self._timeout,
|
|
257
|
+
verify=self._verify_ssl,
|
|
258
|
+
follow_redirects=self._follow_redirects,
|
|
259
|
+
**self._httpx_args,
|
|
260
|
+
)
|
|
261
|
+
return self._async_client
|
|
262
|
+
|
|
263
|
+
async def __aenter__(self) -> "AuthenticatedClient":
|
|
264
|
+
"""Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)"""
|
|
265
|
+
await self.get_async_httpx_client().__aenter__()
|
|
266
|
+
return self
|
|
267
|
+
|
|
268
|
+
async def __aexit__(self, *args: Any, **kwargs: Any) -> None:
|
|
269
|
+
"""Exit a context manager for underlying httpx.AsyncClient (see httpx docs)"""
|
|
270
|
+
await self.get_async_httpx_client().__aexit__(*args, **kwargs)
|
daknode/errors.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
""" Contains shared errors types that can be raised from API functions """
|
|
2
|
+
|
|
3
|
+
class UnexpectedStatus(Exception):
|
|
4
|
+
"""Raised by api functions when the response status an undocumented status and Client.raise_on_unexpected_status is True"""
|
|
5
|
+
|
|
6
|
+
def __init__(self, status_code: int, content: bytes):
|
|
7
|
+
self.status_code = status_code
|
|
8
|
+
self.content = content
|
|
9
|
+
|
|
10
|
+
super().__init__(
|
|
11
|
+
f"Unexpected status code: {status_code}\n\nResponse content:\n{content.decode(errors='ignore')}"
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
__all__ = ["UnexpectedStatus"]
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
""" Contains all the data models used in inputs/outputs """
|
|
2
|
+
|
|
3
|
+
from .block_rule_create import BlockRuleCreate
|
|
4
|
+
from .block_rule_out import BlockRuleOut
|
|
5
|
+
from .block_rule_page import BlockRulePage
|
|
6
|
+
from .consent_request import ConsentRequest
|
|
7
|
+
from .consent_response import ConsentResponse
|
|
8
|
+
from .create_erasure_request_response_create_erasure_request import CreateErasureRequestResponseCreateErasureRequest
|
|
9
|
+
from .create_in import CreateIn
|
|
10
|
+
from .dead_letter_response import DeadLetterResponse
|
|
11
|
+
from .erasure_request_body import ErasureRequestBody
|
|
12
|
+
from .http_validation_error import HTTPValidationError
|
|
13
|
+
from .inbox_create_request import InboxCreateRequest
|
|
14
|
+
from .inbox_response import InboxResponse
|
|
15
|
+
from .message_out import MessageOut
|
|
16
|
+
from .message_page import MessagePage
|
|
17
|
+
from .read_erasure_request_response_read_erasure_request import ReadErasureRequestResponseReadErasureRequest
|
|
18
|
+
from .replay_response import ReplayResponse
|
|
19
|
+
from .revoke_request import RevokeRequest
|
|
20
|
+
from .revoke_response_revoke import RevokeResponseRevoke
|
|
21
|
+
from .search_match import SearchMatch
|
|
22
|
+
from .search_request import SearchRequest
|
|
23
|
+
from .search_response import SearchResponse
|
|
24
|
+
from .send_request import SendRequest
|
|
25
|
+
from .send_response_send import SendResponseSend
|
|
26
|
+
from .signup_in import SignupIn
|
|
27
|
+
from .signup_out import SignupOut
|
|
28
|
+
from .thread_detail_out import ThreadDetailOut
|
|
29
|
+
from .thread_out import ThreadOut
|
|
30
|
+
from .thread_page import ThreadPage
|
|
31
|
+
from .timeline_item_out import TimelineItemOut
|
|
32
|
+
from .update_in import UpdateIn
|
|
33
|
+
from .validation_error import ValidationError
|
|
34
|
+
from .validation_error_context import ValidationErrorContext
|
|
35
|
+
from .verify_in import VerifyIn
|
|
36
|
+
from .verify_out import VerifyOut
|
|
37
|
+
from .webhook_register_request import WebhookRegisterRequest
|
|
38
|
+
from .workspace_list_out import WorkspaceListOut
|
|
39
|
+
from .workspace_out import WorkspaceOut
|
|
40
|
+
|
|
41
|
+
__all__ = (
|
|
42
|
+
"BlockRuleCreate",
|
|
43
|
+
"BlockRuleOut",
|
|
44
|
+
"BlockRulePage",
|
|
45
|
+
"ConsentRequest",
|
|
46
|
+
"ConsentResponse",
|
|
47
|
+
"CreateErasureRequestResponseCreateErasureRequest",
|
|
48
|
+
"CreateIn",
|
|
49
|
+
"DeadLetterResponse",
|
|
50
|
+
"ErasureRequestBody",
|
|
51
|
+
"HTTPValidationError",
|
|
52
|
+
"InboxCreateRequest",
|
|
53
|
+
"InboxResponse",
|
|
54
|
+
"MessageOut",
|
|
55
|
+
"MessagePage",
|
|
56
|
+
"ReadErasureRequestResponseReadErasureRequest",
|
|
57
|
+
"ReplayResponse",
|
|
58
|
+
"RevokeRequest",
|
|
59
|
+
"RevokeResponseRevoke",
|
|
60
|
+
"SearchMatch",
|
|
61
|
+
"SearchRequest",
|
|
62
|
+
"SearchResponse",
|
|
63
|
+
"SendRequest",
|
|
64
|
+
"SendResponseSend",
|
|
65
|
+
"SignupIn",
|
|
66
|
+
"SignupOut",
|
|
67
|
+
"ThreadDetailOut",
|
|
68
|
+
"ThreadOut",
|
|
69
|
+
"ThreadPage",
|
|
70
|
+
"TimelineItemOut",
|
|
71
|
+
"UpdateIn",
|
|
72
|
+
"ValidationError",
|
|
73
|
+
"ValidationErrorContext",
|
|
74
|
+
"VerifyIn",
|
|
75
|
+
"VerifyOut",
|
|
76
|
+
"WebhookRegisterRequest",
|
|
77
|
+
"WorkspaceListOut",
|
|
78
|
+
"WorkspaceOut",
|
|
79
|
+
)
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
from collections.abc import Mapping
|
|
2
|
+
from typing import Any, TypeVar, Optional, BinaryIO, TextIO, TYPE_CHECKING, Generator
|
|
3
|
+
|
|
4
|
+
from attrs import define as _attrs_define
|
|
5
|
+
from attrs import field as _attrs_field
|
|
6
|
+
|
|
7
|
+
from ..types import UNSET, Unset
|
|
8
|
+
|
|
9
|
+
from ..types import UNSET, Unset
|
|
10
|
+
from typing import cast, Union
|
|
11
|
+
from typing import Union
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
T = TypeVar("T", bound="BlockRuleCreate")
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@_attrs_define
|
|
23
|
+
class BlockRuleCreate:
|
|
24
|
+
""" `kind` is deliberately absent.
|
|
25
|
+
|
|
26
|
+
It is DERIVED from the pattern — presence of `@` decides address versus
|
|
27
|
+
domain. A client that could assert `kind` could mislabel a rule and make the
|
|
28
|
+
matcher silently wrong; not accepting the field means the conflict cannot
|
|
29
|
+
arise, rather than relying on the CHECK constraint to catch it later.
|
|
30
|
+
|
|
31
|
+
Attributes:
|
|
32
|
+
pattern (str):
|
|
33
|
+
reason (Union[None, Unset, str]):
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
pattern: str
|
|
37
|
+
reason: Union[None, Unset, str] = UNSET
|
|
38
|
+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def to_dict(self) -> dict[str, Any]:
|
|
45
|
+
pattern = self.pattern
|
|
46
|
+
|
|
47
|
+
reason: Union[None, Unset, str]
|
|
48
|
+
if isinstance(self.reason, Unset):
|
|
49
|
+
reason = UNSET
|
|
50
|
+
else:
|
|
51
|
+
reason = self.reason
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
field_dict: dict[str, Any] = {}
|
|
55
|
+
field_dict.update(self.additional_properties)
|
|
56
|
+
field_dict.update({
|
|
57
|
+
"pattern": pattern,
|
|
58
|
+
})
|
|
59
|
+
if reason is not UNSET:
|
|
60
|
+
field_dict["reason"] = reason
|
|
61
|
+
|
|
62
|
+
return field_dict
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
@classmethod
|
|
67
|
+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
68
|
+
d = dict(src_dict)
|
|
69
|
+
pattern = d.pop("pattern")
|
|
70
|
+
|
|
71
|
+
def _parse_reason(data: object) -> Union[None, Unset, str]:
|
|
72
|
+
if data is None:
|
|
73
|
+
return data
|
|
74
|
+
if isinstance(data, Unset):
|
|
75
|
+
return data
|
|
76
|
+
return cast(Union[None, Unset, str], data)
|
|
77
|
+
|
|
78
|
+
reason = _parse_reason(d.pop("reason", UNSET))
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
block_rule_create = cls(
|
|
82
|
+
pattern=pattern,
|
|
83
|
+
reason=reason,
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
block_rule_create.additional_properties = d
|
|
88
|
+
return block_rule_create
|
|
89
|
+
|
|
90
|
+
@property
|
|
91
|
+
def additional_keys(self) -> list[str]:
|
|
92
|
+
return list(self.additional_properties.keys())
|
|
93
|
+
|
|
94
|
+
def __getitem__(self, key: str) -> Any:
|
|
95
|
+
return self.additional_properties[key]
|
|
96
|
+
|
|
97
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
|
98
|
+
self.additional_properties[key] = value
|
|
99
|
+
|
|
100
|
+
def __delitem__(self, key: str) -> None:
|
|
101
|
+
del self.additional_properties[key]
|
|
102
|
+
|
|
103
|
+
def __contains__(self, key: str) -> bool:
|
|
104
|
+
return key in self.additional_properties
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
from collections.abc import Mapping
|
|
2
|
+
from typing import Any, TypeVar, Optional, BinaryIO, TextIO, TYPE_CHECKING, Generator
|
|
3
|
+
|
|
4
|
+
from attrs import define as _attrs_define
|
|
5
|
+
from attrs import field as _attrs_field
|
|
6
|
+
|
|
7
|
+
from ..types import UNSET, Unset
|
|
8
|
+
|
|
9
|
+
from dateutil.parser import isoparse
|
|
10
|
+
from typing import cast
|
|
11
|
+
from typing import cast, Union
|
|
12
|
+
from uuid import UUID
|
|
13
|
+
import datetime
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
T = TypeVar("T", bound="BlockRuleOut")
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@_attrs_define
|
|
25
|
+
class BlockRuleOut:
|
|
26
|
+
"""
|
|
27
|
+
Attributes:
|
|
28
|
+
created_at (datetime.datetime):
|
|
29
|
+
id (UUID):
|
|
30
|
+
inbox_id (Union[None, UUID]):
|
|
31
|
+
kind (str):
|
|
32
|
+
pattern (str):
|
|
33
|
+
reason (Union[None, str]):
|
|
34
|
+
scope (str):
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
created_at: datetime.datetime
|
|
38
|
+
id: UUID
|
|
39
|
+
inbox_id: Union[None, UUID]
|
|
40
|
+
kind: str
|
|
41
|
+
pattern: str
|
|
42
|
+
reason: Union[None, str]
|
|
43
|
+
scope: str
|
|
44
|
+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def to_dict(self) -> dict[str, Any]:
|
|
51
|
+
created_at = self.created_at.isoformat()
|
|
52
|
+
|
|
53
|
+
id = str(self.id)
|
|
54
|
+
|
|
55
|
+
inbox_id: Union[None, str]
|
|
56
|
+
if isinstance(self.inbox_id, UUID):
|
|
57
|
+
inbox_id = str(self.inbox_id)
|
|
58
|
+
else:
|
|
59
|
+
inbox_id = self.inbox_id
|
|
60
|
+
|
|
61
|
+
kind = self.kind
|
|
62
|
+
|
|
63
|
+
pattern = self.pattern
|
|
64
|
+
|
|
65
|
+
reason: Union[None, str]
|
|
66
|
+
reason = self.reason
|
|
67
|
+
|
|
68
|
+
scope = self.scope
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
field_dict: dict[str, Any] = {}
|
|
72
|
+
field_dict.update(self.additional_properties)
|
|
73
|
+
field_dict.update({
|
|
74
|
+
"created_at": created_at,
|
|
75
|
+
"id": id,
|
|
76
|
+
"inbox_id": inbox_id,
|
|
77
|
+
"kind": kind,
|
|
78
|
+
"pattern": pattern,
|
|
79
|
+
"reason": reason,
|
|
80
|
+
"scope": scope,
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
return field_dict
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
@classmethod
|
|
88
|
+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
89
|
+
d = dict(src_dict)
|
|
90
|
+
created_at = isoparse(d.pop("created_at"))
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
id = UUID(d.pop("id"))
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def _parse_inbox_id(data: object) -> Union[None, UUID]:
|
|
101
|
+
if data is None:
|
|
102
|
+
return data
|
|
103
|
+
try:
|
|
104
|
+
if not isinstance(data, str):
|
|
105
|
+
raise TypeError()
|
|
106
|
+
inbox_id_type_0 = UUID(data)
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
return inbox_id_type_0
|
|
111
|
+
except: # noqa: E722
|
|
112
|
+
pass
|
|
113
|
+
return cast(Union[None, UUID], data)
|
|
114
|
+
|
|
115
|
+
inbox_id = _parse_inbox_id(d.pop("inbox_id"))
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
kind = d.pop("kind")
|
|
119
|
+
|
|
120
|
+
pattern = d.pop("pattern")
|
|
121
|
+
|
|
122
|
+
def _parse_reason(data: object) -> Union[None, str]:
|
|
123
|
+
if data is None:
|
|
124
|
+
return data
|
|
125
|
+
return cast(Union[None, str], data)
|
|
126
|
+
|
|
127
|
+
reason = _parse_reason(d.pop("reason"))
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
scope = d.pop("scope")
|
|
131
|
+
|
|
132
|
+
block_rule_out = cls(
|
|
133
|
+
created_at=created_at,
|
|
134
|
+
id=id,
|
|
135
|
+
inbox_id=inbox_id,
|
|
136
|
+
kind=kind,
|
|
137
|
+
pattern=pattern,
|
|
138
|
+
reason=reason,
|
|
139
|
+
scope=scope,
|
|
140
|
+
)
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
block_rule_out.additional_properties = d
|
|
144
|
+
return block_rule_out
|
|
145
|
+
|
|
146
|
+
@property
|
|
147
|
+
def additional_keys(self) -> list[str]:
|
|
148
|
+
return list(self.additional_properties.keys())
|
|
149
|
+
|
|
150
|
+
def __getitem__(self, key: str) -> Any:
|
|
151
|
+
return self.additional_properties[key]
|
|
152
|
+
|
|
153
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
|
154
|
+
self.additional_properties[key] = value
|
|
155
|
+
|
|
156
|
+
def __delitem__(self, key: str) -> None:
|
|
157
|
+
del self.additional_properties[key]
|
|
158
|
+
|
|
159
|
+
def __contains__(self, key: str) -> bool:
|
|
160
|
+
return key in self.additional_properties
|