apicrud.ServiceConfig

class apicrud.ServiceConfig(file=None, models=None, reset=False, **kwargs)

Service configration - have it your way!

Flask and application configuration global default values are defined in service_config.yaml here in the source directory. Overrides of these values can be specified in a few ways and are evaluated in this order:

  • Environment variables set by parent process

  • Values defined in a file in yaml format

  • Values passed as a keyword arg at first class invocation

For runtime security, the config singleton is stored as an immutable namedtuple: to change values, update settings and restart the container running the service.

An endpoint /config/v1/config provides read-only access to these values except those of type password. Always override those secret values before deploying your service.

Attribute keys specified as env vars are UPPERCASE, and attribute keys stored in the config object are also uppercase. Use lowercase to specify attribute keys in kwargs or the yaml input file.

Parameters
  • file (str) – path of a YAML file defining override values

  • models (obj) – sqlalchemy db models

  • reset (boolean) – reset cached values (for unit tests)

  • **kwargs – key=value pair arguments to override values

Raises

AttributeError if unrecognized or invalid schema

__init__(file=None, models=None, reset=False, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__([file, models, reset])

Initialize self.

get()