daknode 0.1.0__tar.gz
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-0.1.0/PKG-INFO +143 -0
- daknode-0.1.0/README.md +124 -0
- daknode-0.1.0/daknode/__init__.py +8 -0
- daknode-0.1.0/daknode/api/__init__.py +1 -0
- daknode-0.1.0/daknode/api/block_rules/__init__.py +1 -0
- daknode-0.1.0/daknode/api/block_rules/create_block_rule.py +211 -0
- daknode-0.1.0/daknode/api/block_rules/create_inbox_block_rule.py +225 -0
- daknode-0.1.0/daknode/api/block_rules/delete_block_rule.py +192 -0
- daknode-0.1.0/daknode/api/block_rules/list_block_rules.py +214 -0
- daknode-0.1.0/daknode/api/block_rules/list_inbox_block_rules.py +228 -0
- daknode-0.1.0/daknode/api/consent/__init__.py +1 -0
- daknode-0.1.0/daknode/api/consent/create_consent.py +203 -0
- daknode-0.1.0/daknode/api/consent/revoke.py +195 -0
- daknode-0.1.0/daknode/api/control_plane/__init__.py +1 -0
- daknode-0.1.0/daknode/api/control_plane/close_workspace.py +184 -0
- daknode-0.1.0/daknode/api/control_plane/create_workspace.py +211 -0
- daknode-0.1.0/daknode/api/control_plane/list_workspaces.py +155 -0
- daknode-0.1.0/daknode/api/control_plane/read_workspace.py +176 -0
- daknode-0.1.0/daknode/api/control_plane/update_workspace.py +197 -0
- daknode-0.1.0/daknode/api/dead_letters/__init__.py +1 -0
- daknode-0.1.0/daknode/api/dead_letters/list_dead_letters.py +198 -0
- daknode-0.1.0/daknode/api/dead_letters/replay_dead_letter.py +216 -0
- daknode-0.1.0/daknode/api/inboxes/__init__.py +1 -0
- daknode-0.1.0/daknode/api/inboxes/create_inbox.py +183 -0
- daknode-0.1.0/daknode/api/inboxes/register_webhook.py +225 -0
- daknode-0.1.0/daknode/api/inboxes/rotate_webhook_secret.py +224 -0
- daknode-0.1.0/daknode/api/messages/__init__.py +1 -0
- daknode-0.1.0/daknode/api/messages/get_message.py +176 -0
- daknode-0.1.0/daknode/api/messages/get_thread.py +184 -0
- daknode-0.1.0/daknode/api/messages/list_messages.py +228 -0
- daknode-0.1.0/daknode/api/messages/list_threads.py +228 -0
- daknode-0.1.0/daknode/api/privacy/__init__.py +1 -0
- daknode-0.1.0/daknode/api/privacy/create_erasure_request.py +227 -0
- daknode-0.1.0/daknode/api/privacy/read_erasure_request.py +200 -0
- daknode-0.1.0/daknode/api/public/__init__.py +1 -0
- daknode-0.1.0/daknode/api/public/agent_signup.py +191 -0
- daknode-0.1.0/daknode/api/public/agent_verify.py +191 -0
- daknode-0.1.0/daknode/api/search/__init__.py +1 -0
- daknode-0.1.0/daknode/api/search/search.py +207 -0
- daknode-0.1.0/daknode/api/send/__init__.py +1 -0
- daknode-0.1.0/daknode/api/send/send.py +254 -0
- daknode-0.1.0/daknode/client.py +270 -0
- daknode-0.1.0/daknode/errors.py +14 -0
- daknode-0.1.0/daknode/models/__init__.py +79 -0
- daknode-0.1.0/daknode/models/block_rule_create.py +104 -0
- daknode-0.1.0/daknode/models/block_rule_out.py +160 -0
- daknode-0.1.0/daknode/models/block_rule_page.py +116 -0
- daknode-0.1.0/daknode/models/consent_request.py +104 -0
- daknode-0.1.0/daknode/models/consent_response.py +105 -0
- daknode-0.1.0/daknode/models/create_erasure_request_response_create_erasure_request.py +63 -0
- daknode-0.1.0/daknode/models/create_in.py +119 -0
- daknode-0.1.0/daknode/models/dead_letter_response.py +205 -0
- daknode-0.1.0/daknode/models/erasure_request_body.py +60 -0
- daknode-0.1.0/daknode/models/http_validation_error.py +97 -0
- daknode-0.1.0/daknode/models/inbox_create_request.py +120 -0
- daknode-0.1.0/daknode/models/inbox_response.py +148 -0
- daknode-0.1.0/daknode/models/message_out.py +309 -0
- daknode-0.1.0/daknode/models/message_page.py +116 -0
- daknode-0.1.0/daknode/models/read_erasure_request_response_read_erasure_request.py +63 -0
- daknode-0.1.0/daknode/models/replay_response.py +113 -0
- daknode-0.1.0/daknode/models/revoke_request.py +74 -0
- daknode-0.1.0/daknode/models/revoke_response_revoke.py +63 -0
- daknode-0.1.0/daknode/models/search_match.py +170 -0
- daknode-0.1.0/daknode/models/search_request.py +107 -0
- daknode-0.1.0/daknode/models/search_response.py +124 -0
- daknode-0.1.0/daknode/models/send_request.py +162 -0
- daknode-0.1.0/daknode/models/send_response_send.py +63 -0
- daknode-0.1.0/daknode/models/signup_in.py +63 -0
- daknode-0.1.0/daknode/models/signup_out.py +102 -0
- daknode-0.1.0/daknode/models/thread_detail_out.py +223 -0
- daknode-0.1.0/daknode/models/thread_out.py +163 -0
- daknode-0.1.0/daknode/models/thread_page.py +116 -0
- daknode-0.1.0/daknode/models/timeline_item_out.py +280 -0
- daknode-0.1.0/daknode/models/update_in.py +111 -0
- daknode-0.1.0/daknode/models/validation_error.py +141 -0
- daknode-0.1.0/daknode/models/validation_error_context.py +63 -0
- daknode-0.1.0/daknode/models/verify_in.py +67 -0
- daknode-0.1.0/daknode/models/verify_out.py +74 -0
- daknode-0.1.0/daknode/models/webhook_register_request.py +74 -0
- daknode-0.1.0/daknode/models/workspace_list_out.py +92 -0
- daknode-0.1.0/daknode/models/workspace_out.py +147 -0
- daknode-0.1.0/daknode/py.typed +1 -0
- daknode-0.1.0/daknode/types.py +53 -0
- daknode-0.1.0/pyproject.toml +26 -0
daknode-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: daknode
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A client library for accessing DakNode
|
|
5
|
+
Requires-Python: >=3.9,<4.0
|
|
6
|
+
Classifier: Programming Language :: Python :: 3
|
|
7
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
8
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
14
|
+
Requires-Dist: attrs (>=22.2.0)
|
|
15
|
+
Requires-Dist: httpx (>=0.23.0,<0.29.0)
|
|
16
|
+
Requires-Dist: python-dateutil (>=2.8.0,<3.0.0)
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
|
|
19
|
+
# daknode
|
|
20
|
+
A client library for accessing DakNode
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
First, create a client:
|
|
24
|
+
|
|
25
|
+
```python
|
|
26
|
+
from daknode import Client
|
|
27
|
+
|
|
28
|
+
client = Client(base_url="https://api.example.com")
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
If the endpoints you're going to hit require authentication, use `AuthenticatedClient` instead:
|
|
32
|
+
|
|
33
|
+
```python
|
|
34
|
+
from daknode import AuthenticatedClient
|
|
35
|
+
|
|
36
|
+
client = AuthenticatedClient(base_url="https://api.example.com", token="SuperSecretToken")
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Now call your endpoint and use your models:
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
from daknode.models import MyDataModel
|
|
43
|
+
from daknode.api.my_tag import get_my_data_model
|
|
44
|
+
from daknode.types import Response
|
|
45
|
+
|
|
46
|
+
with client as client:
|
|
47
|
+
my_data: MyDataModel = get_my_data_model.sync(client=client)
|
|
48
|
+
# or if you need more info (e.g. status_code)
|
|
49
|
+
response: Response[MyDataModel] = get_my_data_model.sync_detailed(client=client)
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Or do the same thing with an async version:
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
from daknode.models import MyDataModel
|
|
56
|
+
from daknode.api.my_tag import get_my_data_model
|
|
57
|
+
from daknode.types import Response
|
|
58
|
+
|
|
59
|
+
async with client as client:
|
|
60
|
+
my_data: MyDataModel = await get_my_data_model.asyncio(client=client)
|
|
61
|
+
response: Response[MyDataModel] = await get_my_data_model.asyncio_detailed(client=client)
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
By default, when you're calling an HTTPS API it will attempt to verify that SSL is working correctly. Using certificate verification is highly recommended most of the time, but sometimes you may need to authenticate to a server (especially an internal server) using a custom certificate bundle.
|
|
65
|
+
|
|
66
|
+
```python
|
|
67
|
+
client = AuthenticatedClient(
|
|
68
|
+
base_url="https://internal_api.example.com",
|
|
69
|
+
token="SuperSecretToken",
|
|
70
|
+
verify_ssl="/path/to/certificate_bundle.pem",
|
|
71
|
+
)
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
You can also disable certificate validation altogether, but beware that **this is a security risk**.
|
|
75
|
+
|
|
76
|
+
```python
|
|
77
|
+
client = AuthenticatedClient(
|
|
78
|
+
base_url="https://internal_api.example.com",
|
|
79
|
+
token="SuperSecretToken",
|
|
80
|
+
verify_ssl=False
|
|
81
|
+
)
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Things to know:
|
|
85
|
+
1. Every path/method combo becomes a Python module with four functions:
|
|
86
|
+
1. `sync`: Blocking request that returns parsed data (if successful) or `None`
|
|
87
|
+
1. `sync_detailed`: Blocking request that always returns a `Request`, optionally with `parsed` set if the request was successful.
|
|
88
|
+
1. `asyncio`: Like `sync` but async instead of blocking
|
|
89
|
+
1. `asyncio_detailed`: Like `sync_detailed` but async instead of blocking
|
|
90
|
+
|
|
91
|
+
1. All path/query params, and bodies become method arguments.
|
|
92
|
+
1. If your endpoint had any tags on it, the first tag will be used as a module name for the function (my_tag above)
|
|
93
|
+
1. Any endpoint which did not have a tag will be in `daknode.api.default`
|
|
94
|
+
|
|
95
|
+
## Advanced customizations
|
|
96
|
+
|
|
97
|
+
There are more settings on the generated `Client` class which let you control more runtime behavior, check out the docstring on that class for more info. You can also customize the underlying `httpx.Client` or `httpx.AsyncClient` (depending on your use-case):
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
from daknode import Client
|
|
101
|
+
|
|
102
|
+
def log_request(request):
|
|
103
|
+
print(f"Request event hook: {request.method} {request.url} - Waiting for response")
|
|
104
|
+
|
|
105
|
+
def log_response(response):
|
|
106
|
+
request = response.request
|
|
107
|
+
print(f"Response event hook: {request.method} {request.url} - Status {response.status_code}")
|
|
108
|
+
|
|
109
|
+
client = Client(
|
|
110
|
+
base_url="https://api.example.com",
|
|
111
|
+
httpx_args={"event_hooks": {"request": [log_request], "response": [log_response]}},
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
# Or get the underlying httpx client to modify directly with client.get_httpx_client() or client.get_async_httpx_client()
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
You can even set the httpx client directly, but beware that this will override any existing settings (e.g., base_url):
|
|
118
|
+
|
|
119
|
+
```python
|
|
120
|
+
import httpx
|
|
121
|
+
from daknode import Client
|
|
122
|
+
|
|
123
|
+
client = Client(
|
|
124
|
+
base_url="https://api.example.com",
|
|
125
|
+
)
|
|
126
|
+
# Note that base_url needs to be re-set, as would any shared cookies, headers, etc.
|
|
127
|
+
client.set_httpx_client(httpx.Client(base_url="https://api.example.com", proxies="http://localhost:8030"))
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Building / publishing this package
|
|
131
|
+
This project uses [Poetry](https://python-poetry.org/) to manage dependencies and packaging. Here are the basics:
|
|
132
|
+
1. Update the metadata in pyproject.toml (e.g. authors, version)
|
|
133
|
+
1. If you're using a private repository, configure it with Poetry
|
|
134
|
+
1. `poetry config repositories.<your-repository-name> <url-to-your-repository>`
|
|
135
|
+
1. `poetry config http-basic.<your-repository-name> <username> <password>`
|
|
136
|
+
1. Publish the client with `poetry publish --build -r <your-repository-name>` or, if for public PyPI, just `poetry publish --build`
|
|
137
|
+
|
|
138
|
+
If you want to install this client into another project without publishing it (e.g. for development) then:
|
|
139
|
+
1. If that project **is using Poetry**, you can simply do `poetry add <path-to-this-client>` from that project
|
|
140
|
+
1. If that project is not using Poetry:
|
|
141
|
+
1. Build a wheel with `poetry build -f wheel`
|
|
142
|
+
1. Install that wheel from the other project `pip install <path-to-wheel>`
|
|
143
|
+
|
daknode-0.1.0/README.md
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# daknode
|
|
2
|
+
A client library for accessing DakNode
|
|
3
|
+
|
|
4
|
+
## Usage
|
|
5
|
+
First, create a client:
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
from daknode import Client
|
|
9
|
+
|
|
10
|
+
client = Client(base_url="https://api.example.com")
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
If the endpoints you're going to hit require authentication, use `AuthenticatedClient` instead:
|
|
14
|
+
|
|
15
|
+
```python
|
|
16
|
+
from daknode import AuthenticatedClient
|
|
17
|
+
|
|
18
|
+
client = AuthenticatedClient(base_url="https://api.example.com", token="SuperSecretToken")
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Now call your endpoint and use your models:
|
|
22
|
+
|
|
23
|
+
```python
|
|
24
|
+
from daknode.models import MyDataModel
|
|
25
|
+
from daknode.api.my_tag import get_my_data_model
|
|
26
|
+
from daknode.types import Response
|
|
27
|
+
|
|
28
|
+
with client as client:
|
|
29
|
+
my_data: MyDataModel = get_my_data_model.sync(client=client)
|
|
30
|
+
# or if you need more info (e.g. status_code)
|
|
31
|
+
response: Response[MyDataModel] = get_my_data_model.sync_detailed(client=client)
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Or do the same thing with an async version:
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
from daknode.models import MyDataModel
|
|
38
|
+
from daknode.api.my_tag import get_my_data_model
|
|
39
|
+
from daknode.types import Response
|
|
40
|
+
|
|
41
|
+
async with client as client:
|
|
42
|
+
my_data: MyDataModel = await get_my_data_model.asyncio(client=client)
|
|
43
|
+
response: Response[MyDataModel] = await get_my_data_model.asyncio_detailed(client=client)
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
By default, when you're calling an HTTPS API it will attempt to verify that SSL is working correctly. Using certificate verification is highly recommended most of the time, but sometimes you may need to authenticate to a server (especially an internal server) using a custom certificate bundle.
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
client = AuthenticatedClient(
|
|
50
|
+
base_url="https://internal_api.example.com",
|
|
51
|
+
token="SuperSecretToken",
|
|
52
|
+
verify_ssl="/path/to/certificate_bundle.pem",
|
|
53
|
+
)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
You can also disable certificate validation altogether, but beware that **this is a security risk**.
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
client = AuthenticatedClient(
|
|
60
|
+
base_url="https://internal_api.example.com",
|
|
61
|
+
token="SuperSecretToken",
|
|
62
|
+
verify_ssl=False
|
|
63
|
+
)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Things to know:
|
|
67
|
+
1. Every path/method combo becomes a Python module with four functions:
|
|
68
|
+
1. `sync`: Blocking request that returns parsed data (if successful) or `None`
|
|
69
|
+
1. `sync_detailed`: Blocking request that always returns a `Request`, optionally with `parsed` set if the request was successful.
|
|
70
|
+
1. `asyncio`: Like `sync` but async instead of blocking
|
|
71
|
+
1. `asyncio_detailed`: Like `sync_detailed` but async instead of blocking
|
|
72
|
+
|
|
73
|
+
1. All path/query params, and bodies become method arguments.
|
|
74
|
+
1. If your endpoint had any tags on it, the first tag will be used as a module name for the function (my_tag above)
|
|
75
|
+
1. Any endpoint which did not have a tag will be in `daknode.api.default`
|
|
76
|
+
|
|
77
|
+
## Advanced customizations
|
|
78
|
+
|
|
79
|
+
There are more settings on the generated `Client` class which let you control more runtime behavior, check out the docstring on that class for more info. You can also customize the underlying `httpx.Client` or `httpx.AsyncClient` (depending on your use-case):
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
from daknode import Client
|
|
83
|
+
|
|
84
|
+
def log_request(request):
|
|
85
|
+
print(f"Request event hook: {request.method} {request.url} - Waiting for response")
|
|
86
|
+
|
|
87
|
+
def log_response(response):
|
|
88
|
+
request = response.request
|
|
89
|
+
print(f"Response event hook: {request.method} {request.url} - Status {response.status_code}")
|
|
90
|
+
|
|
91
|
+
client = Client(
|
|
92
|
+
base_url="https://api.example.com",
|
|
93
|
+
httpx_args={"event_hooks": {"request": [log_request], "response": [log_response]}},
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
# Or get the underlying httpx client to modify directly with client.get_httpx_client() or client.get_async_httpx_client()
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
You can even set the httpx client directly, but beware that this will override any existing settings (e.g., base_url):
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
import httpx
|
|
103
|
+
from daknode import Client
|
|
104
|
+
|
|
105
|
+
client = Client(
|
|
106
|
+
base_url="https://api.example.com",
|
|
107
|
+
)
|
|
108
|
+
# Note that base_url needs to be re-set, as would any shared cookies, headers, etc.
|
|
109
|
+
client.set_httpx_client(httpx.Client(base_url="https://api.example.com", proxies="http://localhost:8030"))
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Building / publishing this package
|
|
113
|
+
This project uses [Poetry](https://python-poetry.org/) to manage dependencies and packaging. Here are the basics:
|
|
114
|
+
1. Update the metadata in pyproject.toml (e.g. authors, version)
|
|
115
|
+
1. If you're using a private repository, configure it with Poetry
|
|
116
|
+
1. `poetry config repositories.<your-repository-name> <url-to-your-repository>`
|
|
117
|
+
1. `poetry config http-basic.<your-repository-name> <username> <password>`
|
|
118
|
+
1. Publish the client with `poetry publish --build -r <your-repository-name>` or, if for public PyPI, just `poetry publish --build`
|
|
119
|
+
|
|
120
|
+
If you want to install this client into another project without publishing it (e.g. for development) then:
|
|
121
|
+
1. If that project **is using Poetry**, you can simply do `poetry add <path-to-this-client>` from that project
|
|
122
|
+
1. If that project is not using Poetry:
|
|
123
|
+
1. Build a wheel with `poetry build -f wheel`
|
|
124
|
+
1. Install that wheel from the other project `pip install <path-to-wheel>`
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
""" Contains methods for accessing the API """
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
""" Contains endpoint functions for accessing the API """
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
from http import HTTPStatus
|
|
2
|
+
from typing import Any, Optional, Union, cast
|
|
3
|
+
|
|
4
|
+
import httpx
|
|
5
|
+
|
|
6
|
+
from ...client import AuthenticatedClient, Client
|
|
7
|
+
from ...types import Response, UNSET
|
|
8
|
+
from ... import errors
|
|
9
|
+
|
|
10
|
+
from ...models.block_rule_create import BlockRuleCreate
|
|
11
|
+
from ...models.block_rule_out import BlockRuleOut
|
|
12
|
+
from ...models.http_validation_error import HTTPValidationError
|
|
13
|
+
from typing import cast
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def _get_kwargs(
|
|
18
|
+
*,
|
|
19
|
+
body: BlockRuleCreate,
|
|
20
|
+
|
|
21
|
+
) -> dict[str, Any]:
|
|
22
|
+
headers: dict[str, Any] = {}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
_kwargs: dict[str, Any] = {
|
|
30
|
+
"method": "post",
|
|
31
|
+
"url": "/v1/block-rules",
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
_kwargs["json"] = body.to_dict()
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
headers["Content-Type"] = "application/json"
|
|
38
|
+
|
|
39
|
+
_kwargs["headers"] = headers
|
|
40
|
+
return _kwargs
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Union[BlockRuleOut, HTTPValidationError]]:
|
|
44
|
+
if response.status_code == 201:
|
|
45
|
+
response_201 = BlockRuleOut.from_dict(response.json())
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
return response_201
|
|
50
|
+
if response.status_code == 422:
|
|
51
|
+
response_422 = HTTPValidationError.from_dict(response.json())
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
return response_422
|
|
56
|
+
if client.raise_on_unexpected_status:
|
|
57
|
+
raise errors.UnexpectedStatus(response.status_code, response.content)
|
|
58
|
+
else:
|
|
59
|
+
return None
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Union[BlockRuleOut, HTTPValidationError]]:
|
|
63
|
+
return Response(
|
|
64
|
+
status_code=HTTPStatus(response.status_code),
|
|
65
|
+
content=response.content,
|
|
66
|
+
headers=response.headers,
|
|
67
|
+
parsed=_parse_response(client=client, response=response),
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def sync_detailed(
|
|
72
|
+
*,
|
|
73
|
+
client: AuthenticatedClient,
|
|
74
|
+
body: BlockRuleCreate,
|
|
75
|
+
|
|
76
|
+
) -> Response[Union[BlockRuleOut, HTTPValidationError]]:
|
|
77
|
+
""" Create Block Rule
|
|
78
|
+
|
|
79
|
+
Refuse inbound mail from a sender across the whole Workspace.
|
|
80
|
+
|
|
81
|
+
Args:
|
|
82
|
+
body (BlockRuleCreate): `kind` is deliberately absent.
|
|
83
|
+
|
|
84
|
+
It is DERIVED from the pattern — presence of `@` decides address versus
|
|
85
|
+
domain. A client that could assert `kind` could mislabel a rule and make the
|
|
86
|
+
matcher silently wrong; not accepting the field means the conflict cannot
|
|
87
|
+
arise, rather than relying on the CHECK constraint to catch it later.
|
|
88
|
+
|
|
89
|
+
Raises:
|
|
90
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
91
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
92
|
+
|
|
93
|
+
Returns:
|
|
94
|
+
Response[Union[BlockRuleOut, HTTPValidationError]]
|
|
95
|
+
"""
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
kwargs = _get_kwargs(
|
|
99
|
+
body=body,
|
|
100
|
+
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
response = client.get_httpx_client().request(
|
|
104
|
+
**kwargs,
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
return _build_response(client=client, response=response)
|
|
108
|
+
|
|
109
|
+
def sync(
|
|
110
|
+
*,
|
|
111
|
+
client: AuthenticatedClient,
|
|
112
|
+
body: BlockRuleCreate,
|
|
113
|
+
|
|
114
|
+
) -> Optional[Union[BlockRuleOut, HTTPValidationError]]:
|
|
115
|
+
""" Create Block Rule
|
|
116
|
+
|
|
117
|
+
Refuse inbound mail from a sender across the whole Workspace.
|
|
118
|
+
|
|
119
|
+
Args:
|
|
120
|
+
body (BlockRuleCreate): `kind` is deliberately absent.
|
|
121
|
+
|
|
122
|
+
It is DERIVED from the pattern — presence of `@` decides address versus
|
|
123
|
+
domain. A client that could assert `kind` could mislabel a rule and make the
|
|
124
|
+
matcher silently wrong; not accepting the field means the conflict cannot
|
|
125
|
+
arise, rather than relying on the CHECK constraint to catch it later.
|
|
126
|
+
|
|
127
|
+
Raises:
|
|
128
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
129
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
130
|
+
|
|
131
|
+
Returns:
|
|
132
|
+
Union[BlockRuleOut, HTTPValidationError]
|
|
133
|
+
"""
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
return sync_detailed(
|
|
137
|
+
client=client,
|
|
138
|
+
body=body,
|
|
139
|
+
|
|
140
|
+
).parsed
|
|
141
|
+
|
|
142
|
+
async def asyncio_detailed(
|
|
143
|
+
*,
|
|
144
|
+
client: AuthenticatedClient,
|
|
145
|
+
body: BlockRuleCreate,
|
|
146
|
+
|
|
147
|
+
) -> Response[Union[BlockRuleOut, HTTPValidationError]]:
|
|
148
|
+
""" Create Block Rule
|
|
149
|
+
|
|
150
|
+
Refuse inbound mail from a sender across the whole Workspace.
|
|
151
|
+
|
|
152
|
+
Args:
|
|
153
|
+
body (BlockRuleCreate): `kind` is deliberately absent.
|
|
154
|
+
|
|
155
|
+
It is DERIVED from the pattern — presence of `@` decides address versus
|
|
156
|
+
domain. A client that could assert `kind` could mislabel a rule and make the
|
|
157
|
+
matcher silently wrong; not accepting the field means the conflict cannot
|
|
158
|
+
arise, rather than relying on the CHECK constraint to catch it later.
|
|
159
|
+
|
|
160
|
+
Raises:
|
|
161
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
162
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
163
|
+
|
|
164
|
+
Returns:
|
|
165
|
+
Response[Union[BlockRuleOut, HTTPValidationError]]
|
|
166
|
+
"""
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
kwargs = _get_kwargs(
|
|
170
|
+
body=body,
|
|
171
|
+
|
|
172
|
+
)
|
|
173
|
+
|
|
174
|
+
response = await client.get_async_httpx_client().request(
|
|
175
|
+
**kwargs
|
|
176
|
+
)
|
|
177
|
+
|
|
178
|
+
return _build_response(client=client, response=response)
|
|
179
|
+
|
|
180
|
+
async def asyncio(
|
|
181
|
+
*,
|
|
182
|
+
client: AuthenticatedClient,
|
|
183
|
+
body: BlockRuleCreate,
|
|
184
|
+
|
|
185
|
+
) -> Optional[Union[BlockRuleOut, HTTPValidationError]]:
|
|
186
|
+
""" Create Block Rule
|
|
187
|
+
|
|
188
|
+
Refuse inbound mail from a sender across the whole Workspace.
|
|
189
|
+
|
|
190
|
+
Args:
|
|
191
|
+
body (BlockRuleCreate): `kind` is deliberately absent.
|
|
192
|
+
|
|
193
|
+
It is DERIVED from the pattern — presence of `@` decides address versus
|
|
194
|
+
domain. A client that could assert `kind` could mislabel a rule and make the
|
|
195
|
+
matcher silently wrong; not accepting the field means the conflict cannot
|
|
196
|
+
arise, rather than relying on the CHECK constraint to catch it later.
|
|
197
|
+
|
|
198
|
+
Raises:
|
|
199
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
200
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
201
|
+
|
|
202
|
+
Returns:
|
|
203
|
+
Union[BlockRuleOut, HTTPValidationError]
|
|
204
|
+
"""
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
return (await asyncio_detailed(
|
|
208
|
+
client=client,
|
|
209
|
+
body=body,
|
|
210
|
+
|
|
211
|
+
)).parsed
|