sendora 2.8.0__tar.gz → 2.9.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.
Files changed (40) hide show
  1. {sendora-2.8.0 → sendora-2.9.0}/CHANGELOG.md +7 -0
  2. {sendora-2.8.0 → sendora-2.9.0}/PKG-INFO +16 -14
  3. {sendora-2.8.0 → sendora-2.9.0}/README.md +16 -14
  4. {sendora-2.8.0 → sendora-2.9.0}/src/sendora/_version.py +1 -1
  5. {sendora-2.8.0 → sendora-2.9.0}/src/sendora/resources/tokens.py +34 -38
  6. {sendora-2.8.0 → sendora-2.9.0}/src/sendora/skills/sendora/SKILL.md +5 -1
  7. {sendora-2.8.0 → sendora-2.9.0}/.gitignore +0 -0
  8. {sendora-2.8.0 → sendora-2.9.0}/LICENSE +0 -0
  9. {sendora-2.8.0 → sendora-2.9.0}/pyproject.toml +0 -0
  10. {sendora-2.8.0 → sendora-2.9.0}/src/sendora/__init__.py +0 -0
  11. {sendora-2.8.0 → sendora-2.9.0}/src/sendora/_account.py +0 -0
  12. {sendora-2.8.0 → sendora-2.9.0}/src/sendora/_answers.py +0 -0
  13. {sendora-2.8.0 → sendora-2.9.0}/src/sendora/_client.py +0 -0
  14. {sendora-2.8.0 → sendora-2.9.0}/src/sendora/_errors.py +0 -0
  15. {sendora-2.8.0 → sendora-2.9.0}/src/sendora/_json.py +0 -0
  16. {sendora-2.8.0 → sendora-2.9.0}/src/sendora/_keys.py +0 -0
  17. {sendora-2.8.0 → sendora-2.9.0}/src/sendora/_model.py +0 -0
  18. {sendora-2.8.0 → sendora-2.9.0}/src/sendora/_options.py +0 -0
  19. {sendora-2.8.0 → sendora-2.9.0}/src/sendora/_pages.py +0 -0
  20. {sendora-2.8.0 → sendora-2.9.0}/src/sendora/_retry.py +0 -0
  21. {sendora-2.8.0 → sendora-2.9.0}/src/sendora/_transport.py +0 -0
  22. {sendora-2.8.0 → sendora-2.9.0}/src/sendora/_webhooks.py +0 -0
  23. {sendora-2.8.0 → sendora-2.9.0}/src/sendora/_wire.py +0 -0
  24. {sendora-2.8.0 → sendora-2.9.0}/src/sendora/py.typed +0 -0
  25. {sendora-2.8.0 → sendora-2.9.0}/src/sendora/resources/__init__.py +0 -0
  26. {sendora-2.8.0 → sendora-2.9.0}/src/sendora/resources/broadcasts.py +0 -0
  27. {sendora-2.8.0 → sendora-2.9.0}/src/sendora/resources/domains.py +0 -0
  28. {sendora-2.8.0 → sendora-2.9.0}/src/sendora/resources/email.py +0 -0
  29. {sendora-2.8.0 → sendora-2.9.0}/src/sendora/resources/erasures.py +0 -0
  30. {sendora-2.8.0 → sendora-2.9.0}/src/sendora/resources/inbound.py +0 -0
  31. {sendora-2.8.0 → sendora-2.9.0}/src/sendora/resources/inbound_domains.py +0 -0
  32. {sendora-2.8.0 → sendora-2.9.0}/src/sendora/resources/messages.py +0 -0
  33. {sendora-2.8.0 → sendora-2.9.0}/src/sendora/resources/server.py +0 -0
  34. {sendora-2.8.0 → sendora-2.9.0}/src/sendora/resources/servers.py +0 -0
  35. {sendora-2.8.0 → sendora-2.9.0}/src/sendora/resources/streams.py +0 -0
  36. {sendora-2.8.0 → sendora-2.9.0}/src/sendora/resources/suppressions.py +0 -0
  37. {sendora-2.8.0 → sendora-2.9.0}/src/sendora/resources/tracking_domains.py +0 -0
  38. {sendora-2.8.0 → sendora-2.9.0}/src/sendora/resources/tracking_opt_outs.py +0 -0
  39. {sendora-2.8.0 → sendora-2.9.0}/src/sendora/resources/webhooks.py +0 -0
  40. {sendora-2.8.0 → sendora-2.9.0}/src/sendora/types.py +0 -0
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.9.0
4
+
5
+ - `tokens.create` and `tokens.revoke` of `Sendora` and `AsyncSendora` are
6
+ deprecated, since no server key creates or revokes a key any more. The API
7
+ refuses both with `wrong_token_kind`, whatever the package's version. Use
8
+ `servers.tokens` of `SendoraAccount`, or the dashboard.
9
+
3
10
  ## 2.8.0
4
11
 
5
12
  - Two new error codes, each a `ConflictError` with `max`.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: sendora
3
- Version: 2.8.0
3
+ Version: 2.9.0
4
4
  Summary: The Python client for Sendora's email API.
5
5
  Project-URL: Homepage, https://sendora.se/docs
6
6
  License-Expression: MIT
@@ -287,20 +287,19 @@ sendora.tracking_opt_outs.add(address="anna@example.com")
287
287
 
288
288
  ## Tokens
289
289
 
290
- The server's own keys, from its own key. Every key of a server has the
291
- same rights; the value is shown once, when it is created; a server holds
292
- up to two live keys, and a third is `token_limit`. The account key
293
- manages the same keys under `account.servers.tokens`.
290
+ The server's own keys, read with any of them. Every key of a server has the
291
+ same rights. The account key creates and revokes them, under
292
+ `account.servers.tokens`. So does a person, in the dashboard.
294
293
 
295
- | Call | Answers |
296
- | --------------------------------- | --------------------------------------------------- |
297
- | `sendora.tokens.create(name=)` | `CreatedToken` with its `token` value, once |
298
- | `sendora.tokens.list()` | `TokenList` with `tokens`, revoked ones included |
299
- | `sendora.tokens.get(token_id)` | One token, without its value |
300
- | `sendora.tokens.revoke(token_id)` | `None`; the last live key is refused (`last_token`) |
294
+ | Call | Answers |
295
+ | ------------------------------ | ------------------------------------------------ |
296
+ | `sendora.tokens.list()` | `TokenList` with `tokens`, revoked ones included |
297
+ | `sendora.tokens.get(token_id)` | One token, without its value |
301
298
 
302
- A key's value is kept out of the answer's `repr`, so a logged answer does
303
- not print it; read it from `.token`.
299
+ `sendora.tokens.create(name=)` and `sendora.tokens.revoke(token_id)` are
300
+ deprecated, and go in the next major version. The API refuses both with
301
+ `wrong_token_kind`. A stolen server key can then neither make another key nor
302
+ revoke its owner's.
304
303
 
305
304
  ## The server
306
305
 
@@ -465,6 +464,9 @@ switch to it, revoke the old one.
465
464
  | `account.servers.tokens.get(server_id, token_id)` | One key, without its value |
466
465
  | `account.servers.tokens.revoke(server_id, token_id)` | `None`; the last live key is refused (`last_token`) |
467
466
 
467
+ A key's value is kept out of the answer's `repr`, so a logged answer does
468
+ not print it; read it from `.token`.
469
+
468
470
  Sending domains belong to the account, and every server sends from them.
469
471
  A domain sends once both DNS records are seen. A lookup that fails at the
470
472
  resolver (`dns_error`) changes nothing, and a verified domain whose record
@@ -649,7 +651,7 @@ Lost connections, timeouts, `rate_limited` (the edge's own included),
649
651
  twice by default, honouring `retry_after` when it fits within five
650
652
  seconds of waiting in all. A longer `retry_after` is raised at once for
651
653
  you to schedule. A call that creates something (`streams.create`,
652
- `tokens.create`, `webhooks.create`, `webhooks.create_secret`,
654
+ `webhooks.create`, `webhooks.create_secret`,
653
655
  `webhooks.replay`, `inbound_domains.create`, `servers.create`,
654
656
  `servers.tokens.create`, `domains.create`, `tracking_domains.create`) is repeated only after a
655
657
  `rate_limited` or `sending_disabled` answer, never after a lost connection
@@ -265,20 +265,19 @@ sendora.tracking_opt_outs.add(address="anna@example.com")
265
265
 
266
266
  ## Tokens
267
267
 
268
- The server's own keys, from its own key. Every key of a server has the
269
- same rights; the value is shown once, when it is created; a server holds
270
- up to two live keys, and a third is `token_limit`. The account key
271
- manages the same keys under `account.servers.tokens`.
272
-
273
- | Call | Answers |
274
- | --------------------------------- | --------------------------------------------------- |
275
- | `sendora.tokens.create(name=)` | `CreatedToken` with its `token` value, once |
276
- | `sendora.tokens.list()` | `TokenList` with `tokens`, revoked ones included |
277
- | `sendora.tokens.get(token_id)` | One token, without its value |
278
- | `sendora.tokens.revoke(token_id)` | `None`; the last live key is refused (`last_token`) |
268
+ The server's own keys, read with any of them. Every key of a server has the
269
+ same rights. The account key creates and revokes them, under
270
+ `account.servers.tokens`. So does a person, in the dashboard.
279
271
 
280
- A key's value is kept out of the answer's `repr`, so a logged answer does
281
- not print it; read it from `.token`.
272
+ | Call | Answers |
273
+ | ------------------------------ | ------------------------------------------------ |
274
+ | `sendora.tokens.list()` | `TokenList` with `tokens`, revoked ones included |
275
+ | `sendora.tokens.get(token_id)` | One token, without its value |
276
+
277
+ `sendora.tokens.create(name=)` and `sendora.tokens.revoke(token_id)` are
278
+ deprecated, and go in the next major version. The API refuses both with
279
+ `wrong_token_kind`. A stolen server key can then neither make another key nor
280
+ revoke its owner's.
282
281
 
283
282
  ## The server
284
283
 
@@ -443,6 +442,9 @@ switch to it, revoke the old one.
443
442
  | `account.servers.tokens.get(server_id, token_id)` | One key, without its value |
444
443
  | `account.servers.tokens.revoke(server_id, token_id)` | `None`; the last live key is refused (`last_token`) |
445
444
 
445
+ A key's value is kept out of the answer's `repr`, so a logged answer does
446
+ not print it; read it from `.token`.
447
+
446
448
  Sending domains belong to the account, and every server sends from them.
447
449
  A domain sends once both DNS records are seen. A lookup that fails at the
448
450
  resolver (`dns_error`) changes nothing, and a verified domain whose record
@@ -627,7 +629,7 @@ Lost connections, timeouts, `rate_limited` (the edge's own included),
627
629
  twice by default, honouring `retry_after` when it fits within five
628
630
  seconds of waiting in all. A longer `retry_after` is raised at once for
629
631
  you to schedule. A call that creates something (`streams.create`,
630
- `tokens.create`, `webhooks.create`, `webhooks.create_secret`,
632
+ `webhooks.create`, `webhooks.create_secret`,
631
633
  `webhooks.replay`, `inbound_domains.create`, `servers.create`,
632
634
  `servers.tokens.create`, `domains.create`, `tracking_domains.create`) is repeated only after a
633
635
  `rate_limited` or `sending_disabled` answer, never after a lost connection
@@ -1,3 +1,3 @@
1
1
  """The package's version: the build reads it, and every request names it."""
2
2
 
3
- __version__ = "2.8.0"
3
+ __version__ = "2.9.0"
@@ -1,5 +1,6 @@
1
1
  """The keys of the key's own server; every key of a server has the same rights."""
2
2
 
3
+ import warnings
3
4
  from urllib.parse import quote
4
5
 
5
6
  from sendora._transport import AsyncTransport, Call, SyncTransport
@@ -8,32 +9,28 @@ from sendora.types import CreatedToken, Token, TokenList
8
9
 
9
10
 
10
11
  class Tokens:
11
- """Creates, reads and revokes the server's keys."""
12
+ """Reads the server's keys."""
12
13
 
13
14
  def __init__(self, transport: SyncTransport) -> None:
14
15
  """Takes the client's transport."""
15
16
  self._transport = transport
16
17
 
17
18
  def create(self, *, name: str) -> CreatedToken:
18
- """Creates another key and answers its value, shown this once.
19
+ """Deprecated: the API refuses it, so a stolen key makes no other.
19
20
 
20
- A server holds at most two live keys; rotation is create, switch,
21
- revoke. A create is never repeated after a lost connection, which
22
- may have created the key.
21
+ Create a key with ``servers.tokens.create`` of ``SendoraAccount``, or in
22
+ the dashboard. The next major version does not have this method.
23
23
 
24
24
  Args:
25
25
  name: 1 to 100 characters, for people to tell keys apart.
26
26
 
27
27
  Returns:
28
- The key, with its value in ``token``.
28
+ Nothing: the API refuses every call.
29
29
 
30
30
  Raises:
31
- ConflictError: The server holds two live keys (``token_limit``).
32
-
33
- Example:
34
- >>> created = sendora.tokens.create(name="Fakturasystemet")
35
- >>> store_secret(created.token)
31
+ PermissionDeniedError: Always (``wrong_token_kind``).
36
32
  """
33
+ warnings.warn(_CREATE_DEPRECATED, DeprecationWarning, stacklevel=2)
37
34
  return decode(CreatedToken, self._transport.send(_create_call(name)))
38
35
 
39
36
  def list(self) -> TokenList:
@@ -66,51 +63,44 @@ class Tokens:
66
63
  return decode(Token, self._transport.send(_get_call(token_id)))
67
64
 
68
65
  def revoke(self, token_id: str) -> None:
69
- """The key stops working at once.
66
+ """Deprecated: the API refuses it, so a stolen key locks nobody out.
70
67
 
71
- The last live key of a server cannot be revoked, so a server is
72
- never locked out. A revoke repeated after a lost answer whose first
73
- attempt took effect raises ``not_found``.
68
+ Revoke a key with ``servers.tokens.revoke`` of ``SendoraAccount``, or in
69
+ the dashboard. The next major version does not have this method.
74
70
 
75
71
  Args:
76
72
  token_id: The key's id.
77
73
 
78
74
  Raises:
79
- ConflictError: It is the server's last live key (``last_token``).
80
-
81
- Example:
82
- >>> sendora.tokens.revoke(token_id)
75
+ PermissionDeniedError: Always (``wrong_token_kind``).
83
76
  """
77
+ warnings.warn(_REVOKE_DEPRECATED, DeprecationWarning, stacklevel=2)
84
78
  self._transport.send(_revoke_call(token_id))
85
79
 
86
80
 
87
81
  class AsyncTokens:
88
- """Creates, reads and revokes the server's keys."""
82
+ """Reads the server's keys."""
89
83
 
90
84
  def __init__(self, transport: AsyncTransport) -> None:
91
85
  """Takes the client's transport."""
92
86
  self._transport = transport
93
87
 
94
88
  async def create(self, *, name: str) -> CreatedToken:
95
- """Creates another key and answers its value, shown this once.
89
+ """Deprecated: the API refuses it, so a stolen key makes no other.
96
90
 
97
- A server holds at most two live keys; rotation is create, switch,
98
- revoke. A create is never repeated after a lost connection, which
99
- may have created the key.
91
+ Create a key with ``servers.tokens.create`` of ``SendoraAccount``, or in
92
+ the dashboard. The next major version does not have this method.
100
93
 
101
94
  Args:
102
95
  name: 1 to 100 characters, for people to tell keys apart.
103
96
 
104
97
  Returns:
105
- The key, with its value in ``token``.
98
+ Nothing: the API refuses every call.
106
99
 
107
100
  Raises:
108
- ConflictError: The server holds two live keys (``token_limit``).
109
-
110
- Example:
111
- >>> created = await sendora.tokens.create(name="Fakturasystemet")
112
- >>> store_secret(created.token)
101
+ PermissionDeniedError: Always (``wrong_token_kind``).
113
102
  """
103
+ warnings.warn(_CREATE_DEPRECATED, DeprecationWarning, stacklevel=2)
114
104
  return decode(CreatedToken, await self._transport.send(_create_call(name)))
115
105
 
116
106
  async def list(self) -> TokenList:
@@ -143,24 +133,30 @@ class AsyncTokens:
143
133
  return decode(Token, await self._transport.send(_get_call(token_id)))
144
134
 
145
135
  async def revoke(self, token_id: str) -> None:
146
- """The key stops working at once.
136
+ """Deprecated: the API refuses it, so a stolen key locks nobody out.
147
137
 
148
- The last live key of a server cannot be revoked, so a server is
149
- never locked out. A revoke repeated after a lost answer whose first
150
- attempt took effect raises ``not_found``.
138
+ Revoke a key with ``servers.tokens.revoke`` of ``SendoraAccount``, or in
139
+ the dashboard. The next major version does not have this method.
151
140
 
152
141
  Args:
153
142
  token_id: The key's id.
154
143
 
155
144
  Raises:
156
- ConflictError: It is the server's last live key (``last_token``).
157
-
158
- Example:
159
- >>> await sendora.tokens.revoke(token_id)
145
+ PermissionDeniedError: Always (``wrong_token_kind``).
160
146
  """
147
+ warnings.warn(_REVOKE_DEPRECATED, DeprecationWarning, stacklevel=2)
161
148
  await self._transport.send(_revoke_call(token_id))
162
149
 
163
150
 
151
+ _CREATE_DEPRECATED = (
152
+ "tokens.create is deprecated: the API refuses it. Create a key with "
153
+ "SendoraAccount's servers.tokens.create, or in the dashboard."
154
+ )
155
+ _REVOKE_DEPRECATED = (
156
+ "tokens.revoke is deprecated: the API refuses it. Revoke a key with "
157
+ "SendoraAccount's servers.tokens.revoke, or in the dashboard."
158
+ )
159
+
164
160
  _LIST = Call("GET", "/v1/tokens", idempotent=True)
165
161
 
166
162
 
@@ -30,7 +30,11 @@ and every event is in it.
30
30
  `account.servers.create(name=...)` answers `token.token` once, and
31
31
  `Sendora(token)` sends with it. A server or the account holds at most
32
32
  two live keys, so rotate by creating the new key, switching to it, then
33
- revoking the old one; the last live key can never be revoked.
33
+ revoking the old one; the last live key can never be revoked. The account
34
+ key creates and revokes a server's keys (`account.servers.tokens`). A
35
+ server key only reads them (`sendora.tokens.list()` and `.get()`); its
36
+ `tokens.create` and `tokens.revoke` are deprecated and refused
37
+ (`wrong_token_kind`).
34
38
  - For tests and CI, use a test server:
35
39
  `account.servers.create(name=..., mode="test")`. It accepts, logs and
36
40
  fires webhooks like a live one but delivers nothing; its keys start
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes