A simple Firebase Remote Config binding for Pydantic
Project description
Firebase Remote config validator for Pydantic
A simple Firebase Remote Config binding for Pydantic, using remote server configuration only.
Installation
Package is publicly available on PyPi and can be install using any supported package manager:
pip install pydantic-firebase-remoteconfig
Usage
You simply need to implement your BaseRemoteConfigModel class
and use the appropriate async validation class method. Let's imagine
you have a server remote configuration with a foo variable with bar
value:
from pydantic_firebase_remoteconfig import BaseRemoteConfigModel
class MyRemoteConfigModel(BaseRemoteConfigModel):
foo: str
config = await MyRemoteConfigModel.model_validate_remoteconfig()
print(config.foo)
# bar
With custom model configuration
A custom model configuration dict is also available.
Key prefix
from pydantic_firebase_remoteconfig import RemoteConfigConfigDict
class MyRemoteConfigModel(BaseRemoteConfigModel):
model_config = RemoteConfigConfigDict(
# This would evaluate remote configuration
# variable `myprefix_foo`.
rc_prefix="myprefix_",
)
foo: str
Parameter group selection
from pydantic_firebase_remoteconfig import RemoteConfigConfigDict
class MyRemoteConfigModel(BaseRemoteConfigModel):
model_config = RemoteConfigConfigDict(
# This would evaluate remote configuration
# variable `foo` under group `my_group`.
rc_group="my_group",
)
foo: str
Complex model using nested delimiter
Using the same pattern than pydantic_settings, nested configuration can be evaluated, based on either:
- A submodel is designed as a JSON parameter on RemoteConfig.
- A submodel is designed as combinaison of flat value with delimiter.
from pydantic import BaseModel
from pydantic_firebase_remoteconfig import RemoteConfigConfigDict
class MyNestedConfig(BaseModel):
foo: str
class MyRemoteConfigModel(BaseRemoteConfigModel):
model_config = RemoteConfigConfigDict(
# This would evaluate remote configuration
# variable `nested_config__foo`.
rc_nested_delimiter="__",
)
nested_config: MyNestedConfig
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pydantic_firebase_remoteconfig-0.2.2.tar.gz.
File metadata
- Download URL: pydantic_firebase_remoteconfig-0.2.2.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.8.24
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1119d3ee01251a97b1db79365d5b4736785d6f286b4e142e57dd3fa8f898f0f9
|
|
| MD5 |
eeb2754cb95ba2de31ec3bb6e724cd4f
|
|
| BLAKE2b-256 |
5a5940cc932ab6e3150237d23b3ac485099455875992c13d8f0b981118e5f007
|
File details
Details for the file pydantic_firebase_remoteconfig-0.2.2-py3-none-any.whl.
File metadata
- Download URL: pydantic_firebase_remoteconfig-0.2.2-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.8.24
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
94a3c480477936d6edf88be5deb0c25a44a0ee2f7804f7d5c4672f9f13e1cd07
|
|
| MD5 |
8f96c64178d085d73aec3524655915da
|
|
| BLAKE2b-256 |
4db979db580e56746946579fa3559d252d7ddbd1bb51fc66e2b323ed04d35409
|