Skip to main content

A simple Firebase Remote Config binding for Pydantic

Project description

Firebase Remote config validator for Pydantic

PyPI - Version Pydantic v2

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

pydantic_firebase_remoteconfig-0.3.0.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file pydantic_firebase_remoteconfig-0.3.0.tar.gz.

File metadata

File hashes

Hashes for pydantic_firebase_remoteconfig-0.3.0.tar.gz
Algorithm Hash digest
SHA256 736b85e59dcaf5f64521289d792889c56f8237a97722056fc2e9996a4affed07
MD5 f17bab3e2ac7a0d34e5180ed3fe51186
BLAKE2b-256 88c0338c2185ee8c8280d28033613ca00fc93f5a4a260219791acb9b6f3ca256

See more details on using hashes here.

File details

Details for the file pydantic_firebase_remoteconfig-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pydantic_firebase_remoteconfig-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 57a430e27422bc0ff97b1dcc27225e1568ebc732960310a2cabbf3c8154920c8
MD5 312818fa3e0d82bcabab97542760207d
BLAKE2b-256 0e24fbcc511d13eadd9298155ad87d372b833c633799a54608bfd1cbd756d995

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page