hermers 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.
- hermers-0.1.0/LICENSE +21 -0
- hermers-0.1.0/PKG-INFO +154 -0
- hermers-0.1.0/README.md +124 -0
- hermers-0.1.0/pyproject.toml +47 -0
- hermers-0.1.0/setup.cfg +4 -0
- hermers-0.1.0/src/hermers/__init__.py +18 -0
- hermers-0.1.0/src/hermers/client.py +3 -0
- hermers-0.1.0/src/hermers/crypto.py +16 -0
- hermers-0.1.0/src/hermers/errors.py +70 -0
- hermers-0.1.0/src/hermers/generated/__init__.py +10 -0
- hermers-0.1.0/src/hermers/generated/contact_pb2.py +57 -0
- hermers-0.1.0/src/hermers/generated/contact_pb2_grpc.py +312 -0
- hermers-0.1.0/src/hermers/generated/feeds_pb2.py +56 -0
- hermers-0.1.0/src/hermers/generated/feeds_pb2_grpc.py +312 -0
- hermers-0.1.0/src/hermers/generated/mail_pb2.py +77 -0
- hermers-0.1.0/src/hermers/generated/mail_pb2_grpc.py +484 -0
- hermers-0.1.0/src/hermers/generated/security_pb2.py +48 -0
- hermers-0.1.0/src/hermers/generated/security_pb2_grpc.py +97 -0
- hermers-0.1.0/src/hermers/generated/session_pb2.py +65 -0
- hermers-0.1.0/src/hermers/generated/session_pb2_grpc.py +398 -0
- hermers-0.1.0/src/hermers/generated/spam_pb2.py +48 -0
- hermers-0.1.0/src/hermers/generated/spam_pb2_grpc.py +140 -0
- hermers-0.1.0/src/hermers/generated/storage_pb2.py +50 -0
- hermers-0.1.0/src/hermers/generated/storage_pb2_grpc.py +183 -0
- hermers-0.1.0/src/hermers/generated/sync_pb2.py +45 -0
- hermers-0.1.0/src/hermers/generated/sync_pb2_grpc.py +140 -0
- hermers-0.1.0/src/hermers/generated/tier_pb2.py +48 -0
- hermers-0.1.0/src/hermers/generated/tier_pb2_grpc.py +140 -0
- hermers-0.1.0/src/hermers/generated/usage_pb2.py +52 -0
- hermers-0.1.0/src/hermers/generated/usage_pb2_grpc.py +226 -0
- hermers-0.1.0/src/hermers/grpc/__init__.py +9 -0
- hermers-0.1.0/src/hermers/grpc/client.py +361 -0
- hermers-0.1.0/src/hermers/grpc/errors.py +3 -0
- hermers-0.1.0/src/hermers/rest/__init__.py +10 -0
- hermers-0.1.0/src/hermers/rest/calendar.py +34 -0
- hermers-0.1.0/src/hermers/rest/client.py +249 -0
- hermers-0.1.0/src/hermers/rest/contacts.py +44 -0
- hermers-0.1.0/src/hermers/rest/errors.py +3 -0
- hermers-0.1.0/src/hermers/rest/feeds.py +18 -0
- hermers-0.1.0/src/hermers/rest/keys.py +42 -0
- hermers-0.1.0/src/hermers/rest/mail.py +54 -0
- hermers-0.1.0/src/hermers/rest/scheduling.py +31 -0
- hermers-0.1.0/src/hermers/rest/tenant.py +92 -0
- hermers-0.1.0/src/hermers/rest/types.py +649 -0
- hermers-0.1.0/src/hermers/rest/user.py +29 -0
- hermers-0.1.0/src/hermers.egg-info/PKG-INFO +154 -0
- hermers-0.1.0/src/hermers.egg-info/SOURCES.txt +52 -0
- hermers-0.1.0/src/hermers.egg-info/dependency_links.txt +1 -0
- hermers-0.1.0/src/hermers.egg-info/requires.txt +5 -0
- hermers-0.1.0/src/hermers.egg-info/top_level.txt +1 -0
- hermers-0.1.0/tests/test_grpc.py +113 -0
- hermers-0.1.0/tests/test_live_grpc.py +47 -0
- hermers-0.1.0/tests/test_live_rest.py +55 -0
- hermers-0.1.0/tests/test_rest.py +98 -0
hermers-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 aduki, Inc
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
hermers-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: hermers
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Official Hermers SDK - REST + gRPC clients (API key auth)
|
|
5
|
+
Author: Aduki
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/aduki-org/hermers-py
|
|
8
|
+
Project-URL: Repository, https://github.com/aduki-org/hermers-py
|
|
9
|
+
Project-URL: Documentation, https://aduki-org.github.io/hermers-py
|
|
10
|
+
Project-URL: Issues, https://github.com/aduki-org/hermers-py/issues
|
|
11
|
+
Keywords: hermes,hermers,sdk,rest,grpc
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
20
|
+
Classifier: Topic :: Internet
|
|
21
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
|
+
Requires-Python: >=3.11
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Requires-Dist: grpcio
|
|
26
|
+
Requires-Dist: protobuf
|
|
27
|
+
Provides-Extra: dev
|
|
28
|
+
Requires-Dist: build>=1.2.2; extra == "dev"
|
|
29
|
+
Dynamic: license-file
|
|
30
|
+
|
|
31
|
+
# hermers
|
|
32
|
+
|
|
33
|
+
Open-source **Python** client for Hermers with REST and native gRPC in **one package**.
|
|
34
|
+
|
|
35
|
+
The Hermers **server is private / proprietary**. This repository is the public SDK only and does
|
|
36
|
+
not include or publish server source.
|
|
37
|
+
|
|
38
|
+
| Client | Import | Default endpoint |
|
|
39
|
+
| --- | --- | --- |
|
|
40
|
+
| `Hermes` | `hermers` | `https://hermers.aduki.pro/v1` |
|
|
41
|
+
| `HermesGrpc` | `hermers` | `grpc.aduki.pro:443` |
|
|
42
|
+
|
|
43
|
+
## Requirements
|
|
44
|
+
|
|
45
|
+
- Python **3.11+**
|
|
46
|
+
|
|
47
|
+
## Install
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
pip install hermers
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Quickstart (REST)
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
from hermers import Hermes
|
|
57
|
+
|
|
58
|
+
hermes = Hermes("hm_live_xxxxxxxxxxxxxxxxxxxxxxxx")
|
|
59
|
+
me = hermes.ready()
|
|
60
|
+
print(me.tenant, me.user)
|
|
61
|
+
|
|
62
|
+
contacts = hermes.contacts.list({"limit": 50})
|
|
63
|
+
print(contacts["total"])
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Quickstart (gRPC)
|
|
67
|
+
|
|
68
|
+
```python
|
|
69
|
+
from hermers import HermesGrpc
|
|
70
|
+
|
|
71
|
+
client = HermesGrpc("hm_live_xxxxxxxxxxxxxxxxxxxxxxxx")
|
|
72
|
+
client.ready()
|
|
73
|
+
print(client.me.tenant, client.me.user)
|
|
74
|
+
|
|
75
|
+
mailboxes = client.mail.list_mailboxes()
|
|
76
|
+
print(len(mailboxes.items))
|
|
77
|
+
client.close()
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
For resource-by-resource examples, see `docs/rest/README.md` and `docs/grpc/README.md`.
|
|
81
|
+
|
|
82
|
+
## Authentication
|
|
83
|
+
|
|
84
|
+
**API key only**:
|
|
85
|
+
|
|
86
|
+
- REST: `Authorization: Key <key>`
|
|
87
|
+
- gRPC metadata: `authorization: Key <key>`
|
|
88
|
+
|
|
89
|
+
The SDK does not expose login, password, or JWT refresh helpers. Prefer `ready()` before the first
|
|
90
|
+
resource call. Callers never pass tenant/user hex for scoped resource methods because both clients
|
|
91
|
+
cache `whoami`.
|
|
92
|
+
|
|
93
|
+
## Resources
|
|
94
|
+
|
|
95
|
+
REST properties:
|
|
96
|
+
|
|
97
|
+
- `contacts`
|
|
98
|
+
- `mail`
|
|
99
|
+
- `keys`
|
|
100
|
+
- `user`
|
|
101
|
+
- `tenant`
|
|
102
|
+
- `calendar`
|
|
103
|
+
- `events`
|
|
104
|
+
- `feeds`
|
|
105
|
+
- `scheduling`
|
|
106
|
+
|
|
107
|
+
gRPC properties:
|
|
108
|
+
|
|
109
|
+
- `contacts`
|
|
110
|
+
- `mail`
|
|
111
|
+
- `feeds`
|
|
112
|
+
- `storage`
|
|
113
|
+
- `sync`
|
|
114
|
+
- `security`
|
|
115
|
+
- `spam`
|
|
116
|
+
- `tier`
|
|
117
|
+
- `usage`
|
|
118
|
+
- `session`
|
|
119
|
+
|
|
120
|
+
The clean top-level API stays available via `hermers.Hermes` / `hermers.HermesGrpc`, while the
|
|
121
|
+
implementation is organized under `hermers.rest.*` and `hermers.grpc.*`.
|
|
122
|
+
|
|
123
|
+
## Testing
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
PYTHONPATH=src python3 -m unittest discover -s tests -v
|
|
127
|
+
# for live tests, set the API-key environment variable expected by the test suite
|
|
128
|
+
PYTHONPATH=src python3 -m unittest discover -s tests -v
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Without a live API key configured, the unit suites still run and the live REST/gRPC tests no-op.
|
|
132
|
+
Never commit secrets or local environment files.
|
|
133
|
+
|
|
134
|
+
## Docs
|
|
135
|
+
|
|
136
|
+
Developer docs live under `docs/` and publish with
|
|
137
|
+
**[mdBook](https://rust-lang.github.io/mdBook/)**.
|
|
138
|
+
|
|
139
|
+
The book source is assembled from `docs/` plus this repository `README.md` into `book/`, then
|
|
140
|
+
built into `site/` for GitHub Pages.
|
|
141
|
+
|
|
142
|
+
Requires `mdbook` on `PATH`.
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
make docs-prepare
|
|
146
|
+
make docs-build
|
|
147
|
+
make docs-check
|
|
148
|
+
make docs-serve
|
|
149
|
+
make docs
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## License
|
|
153
|
+
|
|
154
|
+
MIT
|
hermers-0.1.0/README.md
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# hermers
|
|
2
|
+
|
|
3
|
+
Open-source **Python** client for Hermers with REST and native gRPC in **one package**.
|
|
4
|
+
|
|
5
|
+
The Hermers **server is private / proprietary**. This repository is the public SDK only and does
|
|
6
|
+
not include or publish server source.
|
|
7
|
+
|
|
8
|
+
| Client | Import | Default endpoint |
|
|
9
|
+
| --- | --- | --- |
|
|
10
|
+
| `Hermes` | `hermers` | `https://hermers.aduki.pro/v1` |
|
|
11
|
+
| `HermesGrpc` | `hermers` | `grpc.aduki.pro:443` |
|
|
12
|
+
|
|
13
|
+
## Requirements
|
|
14
|
+
|
|
15
|
+
- Python **3.11+**
|
|
16
|
+
|
|
17
|
+
## Install
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pip install hermers
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Quickstart (REST)
|
|
24
|
+
|
|
25
|
+
```python
|
|
26
|
+
from hermers import Hermes
|
|
27
|
+
|
|
28
|
+
hermes = Hermes("hm_live_xxxxxxxxxxxxxxxxxxxxxxxx")
|
|
29
|
+
me = hermes.ready()
|
|
30
|
+
print(me.tenant, me.user)
|
|
31
|
+
|
|
32
|
+
contacts = hermes.contacts.list({"limit": 50})
|
|
33
|
+
print(contacts["total"])
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Quickstart (gRPC)
|
|
37
|
+
|
|
38
|
+
```python
|
|
39
|
+
from hermers import HermesGrpc
|
|
40
|
+
|
|
41
|
+
client = HermesGrpc("hm_live_xxxxxxxxxxxxxxxxxxxxxxxx")
|
|
42
|
+
client.ready()
|
|
43
|
+
print(client.me.tenant, client.me.user)
|
|
44
|
+
|
|
45
|
+
mailboxes = client.mail.list_mailboxes()
|
|
46
|
+
print(len(mailboxes.items))
|
|
47
|
+
client.close()
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
For resource-by-resource examples, see `docs/rest/README.md` and `docs/grpc/README.md`.
|
|
51
|
+
|
|
52
|
+
## Authentication
|
|
53
|
+
|
|
54
|
+
**API key only**:
|
|
55
|
+
|
|
56
|
+
- REST: `Authorization: Key <key>`
|
|
57
|
+
- gRPC metadata: `authorization: Key <key>`
|
|
58
|
+
|
|
59
|
+
The SDK does not expose login, password, or JWT refresh helpers. Prefer `ready()` before the first
|
|
60
|
+
resource call. Callers never pass tenant/user hex for scoped resource methods because both clients
|
|
61
|
+
cache `whoami`.
|
|
62
|
+
|
|
63
|
+
## Resources
|
|
64
|
+
|
|
65
|
+
REST properties:
|
|
66
|
+
|
|
67
|
+
- `contacts`
|
|
68
|
+
- `mail`
|
|
69
|
+
- `keys`
|
|
70
|
+
- `user`
|
|
71
|
+
- `tenant`
|
|
72
|
+
- `calendar`
|
|
73
|
+
- `events`
|
|
74
|
+
- `feeds`
|
|
75
|
+
- `scheduling`
|
|
76
|
+
|
|
77
|
+
gRPC properties:
|
|
78
|
+
|
|
79
|
+
- `contacts`
|
|
80
|
+
- `mail`
|
|
81
|
+
- `feeds`
|
|
82
|
+
- `storage`
|
|
83
|
+
- `sync`
|
|
84
|
+
- `security`
|
|
85
|
+
- `spam`
|
|
86
|
+
- `tier`
|
|
87
|
+
- `usage`
|
|
88
|
+
- `session`
|
|
89
|
+
|
|
90
|
+
The clean top-level API stays available via `hermers.Hermes` / `hermers.HermesGrpc`, while the
|
|
91
|
+
implementation is organized under `hermers.rest.*` and `hermers.grpc.*`.
|
|
92
|
+
|
|
93
|
+
## Testing
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
PYTHONPATH=src python3 -m unittest discover -s tests -v
|
|
97
|
+
# for live tests, set the API-key environment variable expected by the test suite
|
|
98
|
+
PYTHONPATH=src python3 -m unittest discover -s tests -v
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Without a live API key configured, the unit suites still run and the live REST/gRPC tests no-op.
|
|
102
|
+
Never commit secrets or local environment files.
|
|
103
|
+
|
|
104
|
+
## Docs
|
|
105
|
+
|
|
106
|
+
Developer docs live under `docs/` and publish with
|
|
107
|
+
**[mdBook](https://rust-lang.github.io/mdBook/)**.
|
|
108
|
+
|
|
109
|
+
The book source is assembled from `docs/` plus this repository `README.md` into `book/`, then
|
|
110
|
+
built into `site/` for GitHub Pages.
|
|
111
|
+
|
|
112
|
+
Requires `mdbook` on `PATH`.
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
make docs-prepare
|
|
116
|
+
make docs-build
|
|
117
|
+
make docs-check
|
|
118
|
+
make docs-serve
|
|
119
|
+
make docs
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## License
|
|
123
|
+
|
|
124
|
+
MIT
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=80"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "hermers"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Official Hermers SDK - REST + gRPC clients (API key auth)"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
authors = [{ name = "Aduki" }]
|
|
13
|
+
keywords = ["hermes", "hermers", "sdk", "rest", "grpc"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 3 - Alpha",
|
|
16
|
+
"Intended Audience :: Developers",
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
19
|
+
"Programming Language :: Python :: 3.11",
|
|
20
|
+
"Programming Language :: Python :: 3.12",
|
|
21
|
+
"Programming Language :: Python :: 3.13",
|
|
22
|
+
"Programming Language :: Python :: 3.14",
|
|
23
|
+
"Topic :: Internet",
|
|
24
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
25
|
+
]
|
|
26
|
+
dependencies = [
|
|
27
|
+
"grpcio",
|
|
28
|
+
"protobuf",
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
[project.urls]
|
|
32
|
+
Homepage = "https://github.com/aduki-org/hermers-py"
|
|
33
|
+
Repository = "https://github.com/aduki-org/hermers-py"
|
|
34
|
+
Documentation = "https://aduki-org.github.io/hermers-py"
|
|
35
|
+
Issues = "https://github.com/aduki-org/hermers-py/issues"
|
|
36
|
+
|
|
37
|
+
[project.optional-dependencies]
|
|
38
|
+
dev = [
|
|
39
|
+
"build>=1.2.2",
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
[tool.setuptools]
|
|
43
|
+
package-dir = { "" = "src" }
|
|
44
|
+
include-package-data = true
|
|
45
|
+
|
|
46
|
+
[tool.setuptools.packages.find]
|
|
47
|
+
where = ["src"]
|
hermers-0.1.0/setup.cfg
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from .client import BASE_URL, Hermes, HermesOptions, Identity, new
|
|
2
|
+
from .errors import HermesError, HermesGrpcError
|
|
3
|
+
from .grpc.client import BASE_ENDPOINT, GrpcIdentity, HermesGrpc, HermesGrpcOptions, connect
|
|
4
|
+
|
|
5
|
+
__all__ = [
|
|
6
|
+
"BASE_ENDPOINT",
|
|
7
|
+
"BASE_URL",
|
|
8
|
+
"GrpcIdentity",
|
|
9
|
+
"Hermes",
|
|
10
|
+
"HermesError",
|
|
11
|
+
"HermesGrpc",
|
|
12
|
+
"HermesGrpcError",
|
|
13
|
+
"HermesGrpcOptions",
|
|
14
|
+
"HermesOptions",
|
|
15
|
+
"Identity",
|
|
16
|
+
"connect",
|
|
17
|
+
"new",
|
|
18
|
+
]
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import hashlib
|
|
4
|
+
import secrets
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def generate_key() -> str:
|
|
8
|
+
return f"hm_live_{secrets.token_urlsafe(24)}"
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def hash_key(raw_key: str) -> str:
|
|
12
|
+
return hashlib.sha256(raw_key.encode("utf-8")).hexdigest()
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def prefix_key(raw_key: str, *, limit: int = 16) -> str:
|
|
16
|
+
return raw_key[:limit]
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
from typing import Any
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@dataclass(slots=True)
|
|
8
|
+
class ErrorPayload:
|
|
9
|
+
message: str
|
|
10
|
+
status: int = 0
|
|
11
|
+
code: str = "unknown_error"
|
|
12
|
+
field: str | None = None
|
|
13
|
+
request_id: str | None = None
|
|
14
|
+
body: Any = None
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class HermesError(Exception):
|
|
18
|
+
def __init__(
|
|
19
|
+
self,
|
|
20
|
+
message: str,
|
|
21
|
+
*,
|
|
22
|
+
status: int = 0,
|
|
23
|
+
code: str = "unknown_error",
|
|
24
|
+
field: str | None = None,
|
|
25
|
+
request_id: str | None = None,
|
|
26
|
+
body: Any = None,
|
|
27
|
+
) -> None:
|
|
28
|
+
super().__init__(message)
|
|
29
|
+
self.message = message
|
|
30
|
+
self.status = status
|
|
31
|
+
self.code = code
|
|
32
|
+
self.field = field
|
|
33
|
+
self.request_id = request_id
|
|
34
|
+
self.body = body
|
|
35
|
+
|
|
36
|
+
@classmethod
|
|
37
|
+
def from_http(cls, status: int, status_text: str, body: Any) -> "HermesError":
|
|
38
|
+
if isinstance(body, dict) and isinstance(body.get("error"), dict):
|
|
39
|
+
error = body["error"]
|
|
40
|
+
return cls(
|
|
41
|
+
str(error.get("message") or status_text or "Request failed"),
|
|
42
|
+
status=status,
|
|
43
|
+
code=str(error.get("code") or "request_failed"),
|
|
44
|
+
field=error.get("field"),
|
|
45
|
+
request_id=error.get("request_id"),
|
|
46
|
+
body=body,
|
|
47
|
+
)
|
|
48
|
+
return cls(status_text or "Request failed", status=status, code="request_failed", body=body)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class HermesGrpcError(Exception):
|
|
52
|
+
def __init__(
|
|
53
|
+
self,
|
|
54
|
+
message: str,
|
|
55
|
+
*,
|
|
56
|
+
code: str = "UNKNOWN",
|
|
57
|
+
details: str | None = None,
|
|
58
|
+
body: Any = None,
|
|
59
|
+
) -> None:
|
|
60
|
+
super().__init__(message)
|
|
61
|
+
self.message = message
|
|
62
|
+
self.code = code
|
|
63
|
+
self.details = details
|
|
64
|
+
self.body = body
|
|
65
|
+
|
|
66
|
+
@classmethod
|
|
67
|
+
def from_rpc_error(cls, err: Exception) -> "HermesGrpcError":
|
|
68
|
+
code = getattr(getattr(err, "code", lambda: None)(), "name", "UNKNOWN")
|
|
69
|
+
details = getattr(err, "details", lambda: None)()
|
|
70
|
+
return cls(details or str(err), code=code, details=details, body=err)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
# grpc_tools generates sibling imports like `import contact_pb2`.
|
|
7
|
+
# Put this package directory on sys.path so those imports resolve.
|
|
8
|
+
pkg_dir = str(Path(__file__).resolve().parent)
|
|
9
|
+
if pkg_dir not in sys.path:
|
|
10
|
+
sys.path.append(pkg_dir)
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
3
|
+
# NO CHECKED-IN PROTOBUF GENCODE
|
|
4
|
+
# source: contact.proto
|
|
5
|
+
# Protobuf Python Version: 7.35.1
|
|
6
|
+
"""Generated protocol buffer code."""
|
|
7
|
+
from google.protobuf import descriptor as _descriptor
|
|
8
|
+
from google.protobuf import descriptor_pool as _descriptor_pool
|
|
9
|
+
from google.protobuf import runtime_version as _runtime_version
|
|
10
|
+
from google.protobuf import symbol_database as _symbol_database
|
|
11
|
+
from google.protobuf.internal import builder as _builder
|
|
12
|
+
_runtime_version.ValidateProtobufRuntimeVersion(
|
|
13
|
+
_runtime_version.Domain.PUBLIC,
|
|
14
|
+
7,
|
|
15
|
+
35,
|
|
16
|
+
1,
|
|
17
|
+
'',
|
|
18
|
+
'contact.proto'
|
|
19
|
+
)
|
|
20
|
+
# @@protoc_insertion_point(imports)
|
|
21
|
+
|
|
22
|
+
_sym_db = _symbol_database.Default()
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
from google.protobuf import timestamp_pb2 as google_dot_protobuf_dot_timestamp__pb2
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\rcontact.proto\x12\x0ehermes.contact\x1a\x1fgoogle/protobuf/timestamp.proto\"\xac\x01\n\x07\x43ontact\x12\x0b\n\x03hex\x18\x01 \x01(\t\x12\x0e\n\x06tenant\x18\x02 \x01(\t\x12\r\n\x05owner\x18\x03 \x01(\t\x12\r\n\x05vcard\x18\x04 \x01(\t\x12\x0c\n\x04\x65tag\x18\x05 \x01(\t\x12+\n\x07\x63reated\x18\x06 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12+\n\x07updated\x18\x07 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\"8\n\x07ListReq\x12\x0e\n\x06tenant\x18\x01 \x01(\t\x12\x0e\n\x06\x63ursor\x18\x02 \x01(\t\x12\r\n\x05limit\x18\x03 \x01(\r\"@\n\x08ListResp\x12&\n\x05items\x18\x01 \x03(\x0b\x32\x17.hermes.contact.Contact\x12\x0c\n\x04next\x18\x02 \x01(\t\"\x15\n\x06GetReq\x12\x0b\n\x03hex\x18\x01 \x01(\t\"9\n\tCreateReq\x12\x0e\n\x06tenant\x18\x01 \x01(\t\x12\r\n\x05owner\x18\x02 \x01(\t\x12\r\n\x05vcard\x18\x03 \x01(\t\"5\n\tUpdateReq\x12\x0b\n\x03hex\x18\x01 \x01(\t\x12\r\n\x05vcard\x18\x02 \x01(\t\x12\x0c\n\x04\x65tag\x18\x03 \x01(\t\"\x18\n\tRemoveReq\x12\x0b\n\x03hex\x18\x01 \x01(\t\"\x0c\n\nRemoveResp\"D\n\x07SyncReq\x12\x0e\n\x06tenant\x18\x01 \x01(\t\x12)\n\x05since\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\"E\n\x08SyncResp\x12(\n\x07\x63hanged\x18\x01 \x03(\x0b\x32\x17.hermes.contact.Contact\x12\x0f\n\x07removed\x18\x02 \x03(\t2\xfb\x02\n\x0e\x43ontactService\x12\x39\n\x04List\x12\x17.hermes.contact.ListReq\x1a\x18.hermes.contact.ListResp\x12\x36\n\x03Get\x12\x16.hermes.contact.GetReq\x1a\x17.hermes.contact.Contact\x12<\n\x06\x43reate\x12\x19.hermes.contact.CreateReq\x1a\x17.hermes.contact.Contact\x12<\n\x06Update\x12\x19.hermes.contact.UpdateReq\x1a\x17.hermes.contact.Contact\x12?\n\x06Remove\x12\x19.hermes.contact.RemoveReq\x1a\x1a.hermes.contact.RemoveResp\x12\x39\n\x04Sync\x12\x17.hermes.contact.SyncReq\x1a\x18.hermes.contact.SyncRespb\x06proto3')
|
|
29
|
+
|
|
30
|
+
_globals = globals()
|
|
31
|
+
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
|
|
32
|
+
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'contact_pb2', _globals)
|
|
33
|
+
if not _descriptor._USE_C_DESCRIPTORS:
|
|
34
|
+
DESCRIPTOR._loaded_options = None
|
|
35
|
+
_globals['_CONTACT']._serialized_start=67
|
|
36
|
+
_globals['_CONTACT']._serialized_end=239
|
|
37
|
+
_globals['_LISTREQ']._serialized_start=241
|
|
38
|
+
_globals['_LISTREQ']._serialized_end=297
|
|
39
|
+
_globals['_LISTRESP']._serialized_start=299
|
|
40
|
+
_globals['_LISTRESP']._serialized_end=363
|
|
41
|
+
_globals['_GETREQ']._serialized_start=365
|
|
42
|
+
_globals['_GETREQ']._serialized_end=386
|
|
43
|
+
_globals['_CREATEREQ']._serialized_start=388
|
|
44
|
+
_globals['_CREATEREQ']._serialized_end=445
|
|
45
|
+
_globals['_UPDATEREQ']._serialized_start=447
|
|
46
|
+
_globals['_UPDATEREQ']._serialized_end=500
|
|
47
|
+
_globals['_REMOVEREQ']._serialized_start=502
|
|
48
|
+
_globals['_REMOVEREQ']._serialized_end=526
|
|
49
|
+
_globals['_REMOVERESP']._serialized_start=528
|
|
50
|
+
_globals['_REMOVERESP']._serialized_end=540
|
|
51
|
+
_globals['_SYNCREQ']._serialized_start=542
|
|
52
|
+
_globals['_SYNCREQ']._serialized_end=610
|
|
53
|
+
_globals['_SYNCRESP']._serialized_start=612
|
|
54
|
+
_globals['_SYNCRESP']._serialized_end=681
|
|
55
|
+
_globals['_CONTACTSERVICE']._serialized_start=684
|
|
56
|
+
_globals['_CONTACTSERVICE']._serialized_end=1063
|
|
57
|
+
# @@protoc_insertion_point(module_scope)
|