bella-baxter-fastapi 0.1.1rc12__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.
@@ -0,0 +1,19 @@
1
+ Metadata-Version: 2.4
2
+ Name: bella-baxter-fastapi
3
+ Version: 0.1.1rc12
4
+ Summary: FastAPI integration for the Bella Baxter secret management SDK
5
+ License: MIT
6
+ Project-URL: Homepage, https://bella-baxter.io
7
+ Project-URL: Repository, https://github.com/cosmic-chimps/bella-baxter-python
8
+ Project-URL: Documentation, https://docs.bella-baxter.io
9
+ Keywords: bella-baxter,fastapi,secrets,config
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Requires-Python: >=3.9
13
+ Description-Content-Type: text/markdown
14
+ Requires-Dist: bella-baxter>=0.1.0
15
+ Requires-Dist: fastapi>=0.100.0
16
+ Provides-Extra: dev
17
+ Requires-Dist: pytest>=7; extra == "dev"
18
+ Requires-Dist: pytest-asyncio>=0.21; extra == "dev"
19
+ Requires-Dist: httpx>=0.25.0; extra == "dev"
@@ -0,0 +1,31 @@
1
+ [build-system]
2
+ requires = ["setuptools>=65", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "bella-baxter-fastapi"
7
+ version = "0.1.1-preview.12"
8
+ description = "FastAPI integration for the Bella Baxter secret management SDK"
9
+ readme = "README.md"
10
+ license = { text = "MIT" }
11
+ requires-python = ">=3.9"
12
+ keywords = ["bella-baxter", "fastapi", "secrets", "config"]
13
+ classifiers = [
14
+ "Programming Language :: Python :: 3",
15
+ "License :: OSI Approved :: MIT License",
16
+ ]
17
+ dependencies = [
18
+ "bella-baxter>=0.1.0",
19
+ "fastapi>=0.100.0",
20
+ ]
21
+
22
+ [project.optional-dependencies]
23
+ dev = ["pytest>=7", "pytest-asyncio>=0.21", "httpx>=0.25.0"]
24
+
25
+ [project.urls]
26
+ Homepage = "https://bella-baxter.io"
27
+ Repository = "https://github.com/cosmic-chimps/bella-baxter-python"
28
+ Documentation = "https://docs.bella-baxter.io"
29
+
30
+ [tool.setuptools.packages.find]
31
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,97 @@
1
+ """
2
+ bella-baxter-fastapi — FastAPI integration for the Bella Baxter secret management SDK.
3
+
4
+ Usage::
5
+
6
+ from fastapi import FastAPI, Depends
7
+ from bella_baxter_fastapi import init_bella, BellaDepends
8
+
9
+ app = FastAPI()
10
+
11
+ # Call once at startup (e.g. in a lifespan handler)
12
+ init_bella(api_key='bax-...', baxter_url='https://api.bella-baxter.io')
13
+
14
+ @app.get('/health')
15
+ async def health(bella = BellaDepends):
16
+ secrets = await bella.get_all_secrets_async()
17
+ return {'database': secrets.secrets.get('DATABASE_URL')}
18
+
19
+ Or use the lifespan pattern::
20
+
21
+ from contextlib import asynccontextmanager
22
+ from bella_baxter_fastapi import init_bella, BellaDepends
23
+
24
+ @asynccontextmanager
25
+ async def lifespan(app: FastAPI):
26
+ init_bella(api_key=os.environ['BELLA_BAXTER_API_KEY'])
27
+ yield
28
+
29
+ app = FastAPI(lifespan=lifespan)
30
+ """
31
+
32
+ from __future__ import annotations
33
+
34
+ import threading
35
+ from typing import Annotated, TYPE_CHECKING
36
+
37
+ if TYPE_CHECKING:
38
+ from bella_baxter import BaxterClient
39
+
40
+ _lock = threading.Lock()
41
+ _client: "BaxterClient | None" = None
42
+
43
+
44
+ def init_bella(
45
+ api_key: str,
46
+ baxter_url: str = "https://api.bella-baxter.io",
47
+ ) -> "BaxterClient":
48
+ """
49
+ Initialise the shared BaxterClient. Call once at application startup.
50
+
51
+ Args:
52
+ api_key: Bella Baxter API key (``bax-...``).
53
+ baxter_url: Base URL of the Baxter API.
54
+
55
+ Returns:
56
+ The initialised BaxterClient instance.
57
+ """
58
+ global _client
59
+
60
+ with _lock:
61
+ from bella_baxter import BaxterClient, BaxterClientOptions
62
+
63
+ _client = BaxterClient(
64
+ BaxterClientOptions(baxter_url=baxter_url, api_key=api_key)
65
+ )
66
+
67
+ return _client
68
+
69
+
70
+ def _get_bella_client() -> "BaxterClient":
71
+ if _client is None:
72
+ raise RuntimeError(
73
+ "Bella Baxter client is not initialised. "
74
+ "Call `init_bella(api_key=...)` at application startup."
75
+ )
76
+ return _client
77
+
78
+
79
+ try:
80
+ from fastapi import Depends
81
+
82
+ BellaDepends = Annotated["BaxterClient", Depends(_get_bella_client)]
83
+ """
84
+ FastAPI dependency — inject a BaxterClient into a route handler.
85
+
86
+ Example::
87
+
88
+ @app.get('/secrets')
89
+ async def get_secrets(bella: BellaDepends):
90
+ resp = await bella.get_all_secrets_async()
91
+ return resp.secrets
92
+ """
93
+ except ImportError:
94
+ BellaDepends = None # type: ignore[assignment]
95
+
96
+
97
+ __all__ = ["init_bella", "BellaDepends"]
@@ -0,0 +1,19 @@
1
+ Metadata-Version: 2.4
2
+ Name: bella-baxter-fastapi
3
+ Version: 0.1.1rc12
4
+ Summary: FastAPI integration for the Bella Baxter secret management SDK
5
+ License: MIT
6
+ Project-URL: Homepage, https://bella-baxter.io
7
+ Project-URL: Repository, https://github.com/cosmic-chimps/bella-baxter-python
8
+ Project-URL: Documentation, https://docs.bella-baxter.io
9
+ Keywords: bella-baxter,fastapi,secrets,config
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Requires-Python: >=3.9
13
+ Description-Content-Type: text/markdown
14
+ Requires-Dist: bella-baxter>=0.1.0
15
+ Requires-Dist: fastapi>=0.100.0
16
+ Provides-Extra: dev
17
+ Requires-Dist: pytest>=7; extra == "dev"
18
+ Requires-Dist: pytest-asyncio>=0.21; extra == "dev"
19
+ Requires-Dist: httpx>=0.25.0; extra == "dev"
@@ -0,0 +1,7 @@
1
+ pyproject.toml
2
+ src/bella_baxter_fastapi/__init__.py
3
+ src/bella_baxter_fastapi.egg-info/PKG-INFO
4
+ src/bella_baxter_fastapi.egg-info/SOURCES.txt
5
+ src/bella_baxter_fastapi.egg-info/dependency_links.txt
6
+ src/bella_baxter_fastapi.egg-info/requires.txt
7
+ src/bella_baxter_fastapi.egg-info/top_level.txt
@@ -0,0 +1,7 @@
1
+ bella-baxter>=0.1.0
2
+ fastapi>=0.100.0
3
+
4
+ [dev]
5
+ pytest>=7
6
+ pytest-asyncio>=0.21
7
+ httpx>=0.25.0