patera-apiinterface 0.12.0__tar.gz → 0.13.1__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: patera-apiinterface
3
- Version: 0.12.0
3
+ Version: 0.13.1
4
4
  Summary: Declarative async HTTP clients for external APIs in Patera applications
5
5
  Keywords: patera,http,client,api
6
6
  Author: Marko Šterk
@@ -27,46 +27,52 @@ Project-URL: Issues, https://github.com/MarkoSterk/Patera/issues
27
27
  Project-URL: Changelog, https://github.com/MarkoSterk/Patera/blob/main/CHANGELOG.md
28
28
  Description-Content-Type: text/markdown
29
29
 
30
- # patera-apiinterface
31
-
32
- Declarative async HTTP clients for external APIs in Patera applications. Part of [Patera](https://github.com/MarkoSterk/Patera), a modular async-first Python web framework.
33
-
34
- ## Installation
35
-
36
- ```sh
37
- pip install patera-apiinterface
38
- # or, with uv
39
- uv add "patera[apiinterface]"
40
- ```
41
-
42
- Requires Python 3.13 or newer and `patera>=0.121`.
43
-
44
- ## Usage
45
-
46
- `patera-apiinterface` turns annotated methods into HTTP calls (with [HTTPX](https://www.python-httpx.org)):
47
-
48
- ```python
49
- from patera import HttpMethod
50
- from patera.apiinterface import ApiInterface, AuthType, auth, headers, method, resource, service, timeout
51
-
52
-
53
- @service("GITHUB_URL") # config key or literal URL
54
- @auth(AuthType.BEARER, token="GITHUB_TOKEN") # config key or literal value
55
- @headers({"X-Client": "my-app"})
56
- @timeout(10)
57
- class GithubApi(ApiInterface):
58
-
59
- @method(HttpMethod.GET)
60
- @resource("/repos/<repo_id>") # filled from the argument of the same name
61
- async def get_repo(self, repo_id: int) -> Repo: ... # Pydantic return types are validated
62
-
63
- @method(HttpMethod.POST)
64
- @resource("/repos")
65
- async def create_repo(self, name: str, private: bool) -> dict: ... # arguments become the JSON body
66
- ```
67
-
68
- See the [External APIs section of the Patera documentation](https://github.com/MarkoSterk/Patera#external-apis) for the full guide.
69
-
70
- ## License
71
-
72
- MIT. See [LICENSE](https://github.com/MarkoSterk/Patera/blob/main/LICENSE).
30
+ # patera-apiinterface
31
+
32
+ Declarative async HTTP clients for external APIs in Patera applications. Part of [Patera](https://github.com/MarkoSterk/Patera), a modular async-first Python web framework.
33
+
34
+ ## Installation
35
+
36
+ ```sh
37
+ pip install patera-apiinterface
38
+ # or, with uv
39
+ uv add "patera[apiinterface]"
40
+ ```
41
+
42
+ Requires Python 3.13 or newer and `patera>=0.121`.
43
+
44
+ ## Usage
45
+
46
+ Within an application lifespan, an interface reuses one HTTP client and closes
47
+ it at shutdown. Standalone and CLI endpoint calls use temporary clients closed
48
+ before the call returns, including failures. If you acquire `interface.client`
49
+ explicitly, call `await interface.aclose()` in that same event loop before it
50
+ closes. Access from another loop raises instead of discarding an unclosed client.
51
+
52
+ `patera-apiinterface` turns annotated methods into HTTP calls (with [HTTPX](https://www.python-httpx.org)):
53
+
54
+ ```python
55
+ from patera import HttpMethod
56
+ from patera.apiinterface import ApiInterface, AuthType, auth, headers, method, resource, service, timeout
57
+
58
+
59
+ @service("GITHUB_URL") # config key or literal URL
60
+ @auth(AuthType.BEARER, token="GITHUB_TOKEN") # config key or literal value
61
+ @headers({"X-Client": "my-app"})
62
+ @timeout(10)
63
+ class GithubApi(ApiInterface):
64
+
65
+ @method(HttpMethod.GET)
66
+ @resource("/repos/<repo_id>") # filled from the argument of the same name
67
+ async def get_repo(self, repo_id: int) -> Repo: ... # Pydantic return types are validated
68
+
69
+ @method(HttpMethod.POST)
70
+ @resource("/repos")
71
+ async def create_repo(self, name: str, private: bool) -> dict: ... # arguments become the JSON body
72
+ ```
73
+
74
+ See the [External APIs section of the Patera documentation](https://github.com/MarkoSterk/Patera#external-apis) for the full guide.
75
+
76
+ ## License
77
+
78
+ MIT. See [LICENSE](https://github.com/MarkoSterk/Patera/blob/main/LICENSE).
@@ -1,43 +1,49 @@
1
- # patera-apiinterface
2
-
3
- Declarative async HTTP clients for external APIs in Patera applications. Part of [Patera](https://github.com/MarkoSterk/Patera), a modular async-first Python web framework.
4
-
5
- ## Installation
6
-
7
- ```sh
8
- pip install patera-apiinterface
9
- # or, with uv
10
- uv add "patera[apiinterface]"
11
- ```
12
-
13
- Requires Python 3.13 or newer and `patera>=0.121`.
14
-
15
- ## Usage
16
-
17
- `patera-apiinterface` turns annotated methods into HTTP calls (with [HTTPX](https://www.python-httpx.org)):
18
-
19
- ```python
20
- from patera import HttpMethod
21
- from patera.apiinterface import ApiInterface, AuthType, auth, headers, method, resource, service, timeout
22
-
23
-
24
- @service("GITHUB_URL") # config key or literal URL
25
- @auth(AuthType.BEARER, token="GITHUB_TOKEN") # config key or literal value
26
- @headers({"X-Client": "my-app"})
27
- @timeout(10)
28
- class GithubApi(ApiInterface):
29
-
30
- @method(HttpMethod.GET)
31
- @resource("/repos/<repo_id>") # filled from the argument of the same name
32
- async def get_repo(self, repo_id: int) -> Repo: ... # Pydantic return types are validated
33
-
34
- @method(HttpMethod.POST)
35
- @resource("/repos")
36
- async def create_repo(self, name: str, private: bool) -> dict: ... # arguments become the JSON body
37
- ```
38
-
39
- See the [External APIs section of the Patera documentation](https://github.com/MarkoSterk/Patera#external-apis) for the full guide.
40
-
41
- ## License
42
-
43
- MIT. See [LICENSE](https://github.com/MarkoSterk/Patera/blob/main/LICENSE).
1
+ # patera-apiinterface
2
+
3
+ Declarative async HTTP clients for external APIs in Patera applications. Part of [Patera](https://github.com/MarkoSterk/Patera), a modular async-first Python web framework.
4
+
5
+ ## Installation
6
+
7
+ ```sh
8
+ pip install patera-apiinterface
9
+ # or, with uv
10
+ uv add "patera[apiinterface]"
11
+ ```
12
+
13
+ Requires Python 3.13 or newer and `patera>=0.121`.
14
+
15
+ ## Usage
16
+
17
+ Within an application lifespan, an interface reuses one HTTP client and closes
18
+ it at shutdown. Standalone and CLI endpoint calls use temporary clients closed
19
+ before the call returns, including failures. If you acquire `interface.client`
20
+ explicitly, call `await interface.aclose()` in that same event loop before it
21
+ closes. Access from another loop raises instead of discarding an unclosed client.
22
+
23
+ `patera-apiinterface` turns annotated methods into HTTP calls (with [HTTPX](https://www.python-httpx.org)):
24
+
25
+ ```python
26
+ from patera import HttpMethod
27
+ from patera.apiinterface import ApiInterface, AuthType, auth, headers, method, resource, service, timeout
28
+
29
+
30
+ @service("GITHUB_URL") # config key or literal URL
31
+ @auth(AuthType.BEARER, token="GITHUB_TOKEN") # config key or literal value
32
+ @headers({"X-Client": "my-app"})
33
+ @timeout(10)
34
+ class GithubApi(ApiInterface):
35
+
36
+ @method(HttpMethod.GET)
37
+ @resource("/repos/<repo_id>") # filled from the argument of the same name
38
+ async def get_repo(self, repo_id: int) -> Repo: ... # Pydantic return types are validated
39
+
40
+ @method(HttpMethod.POST)
41
+ @resource("/repos")
42
+ async def create_repo(self, name: str, private: bool) -> dict: ... # arguments become the JSON body
43
+ ```
44
+
45
+ See the [External APIs section of the Patera documentation](https://github.com/MarkoSterk/Patera#external-apis) for the full guide.
46
+
47
+ ## License
48
+
49
+ MIT. See [LICENSE](https://github.com/MarkoSterk/Patera/blob/main/LICENSE).
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "patera-apiinterface"
3
- version = "0.12.0"
3
+ version = "0.13.1"
4
4
  description = "Declarative async HTTP clients for external APIs in Patera applications"
5
5
  readme = "README.md"
6
6
  license = "MIT"