Config¶
Module defining configuration of the whole library and implementing the means of collecting the user config.
Configuration for each component is defined in separate class.
-
class
config.
ComponentConfig
(**kwargs)¶ Base class for each component config.
Implements all abstract methods of the
collections.abc.Mapping
abstract class, so it can be used in following manner:>>> class Conf(ComponentConfig): ... some_value = StringAttribute() >>> conf = Conf() >>> conf.some_value Traceback (most recent call last): ... dsw_sdk.common.attributes.AttributeNotSetError: ... >>> conf.some_value = 'foo' # Check if the value is set >>> 'some_value' in conf True # Get the item >>> conf.some_value 'foo' >>> conf['some_value'] 'foo' # Get number of configured values >>> len(conf) 1 # Iterate over the config as dict >>> for value in conf.values(): pass >>> for key in conf.keys(): pass >>> for key, value in conf.items(): pass # Deconstruct the config to pass it as kwargs >>> def foo(**kwargs): ... return kwargs['some_value'] >>> foo(**conf) 'foo'
- Parameters
kwargs – All the attributes you want to set on this instance. Note that the attribute must be defined on the class, otherwise it won’t get assigned. Attributes passed as a dict in
_update_attrs
keyword argument skip validation of read_only and immutable flags.
-
class
config.
HttpClientConfig
(**kwargs)¶ Config for the HTTP client.
- Parameters
kwargs – All the attributes you want to set on this instance. Note that the attribute must be defined on the class, otherwise it won’t get assigned. Attributes passed as a dict in
_update_attrs
keyword argument skip validation of read_only and immutable flags.
-
api_url
: str¶
-
email
: str¶
-
password
: str¶
-
enable_ssl
: bool¶
-
auth_endpoint
: str¶
-
class
config.
LoggerConfig
(**kwargs)¶ Config for the Logger.
- Parameters
kwargs – All the attributes you want to set on this instance. Note that the attribute must be defined on the class, otherwise it won’t get assigned. Attributes passed as a dict in
_update_attrs
keyword argument skip validation of read_only and immutable flags.
-
logger_name
: str¶
-
logger_level
: str¶ Class representing one attribute on the
AttributesMixin
classes.It’s defined as a data descriptor, responsible for validating values when the assignment takes place.
For example usage, see
AttributesMixin
, as these two can’t be really used separately.
-
logger_format
: str¶
-
class
config.
Config
(**obj_config)¶ This class serves 2 purposes.
It contains all the other “partial” configs. E.g. config objects for HTTP client or logger.
It also collects user-defined configuration from env variables (prefixed by
DSW_SDK
) and from file (YAML containingdsw_sdk
section) passed inconf_file
keyword argument. Then it merges these with all other values passed as keyword arguments, in following order (first takes precedence over the others):keyword arguments
environment variables
file config
Example file config:
dsw_sdk: enable_ssl: false auth_endpoint: '/auth' headers: 'X-CUSTOM-HEADER': 'Custom value' default_timeout: - 6 - 120
- Parameters
obj_config – arbitrary config values passed as keyword arguments; if path is passed in
conf_file
, it tries to load the config values from a file
-
config.
Timeout
¶ The central part of internal API.
This represents a generic version of type ‘origin’ with type arguments ‘params’. There are two kind of these aliases: user defined and special. The special ones are wrappers around builtin collections and ABCs in collections.abc. These must have ‘name’ always set. If ‘inst’ is False, then the alias can’t be instantiated, this is used by e.g. typing.List and typing.Dict.
alias of Union[None, int, float, Tuple[Union[int, float], Union[int, float]]]
-
config.
Headers
¶ The central part of internal API.
This represents a generic version of type ‘origin’ with type arguments ‘params’. There are two kind of these aliases: user defined and special. The special ones are wrappers around builtin collections and ABCs in collections.abc. These must have ‘name’ always set. If ‘inst’ is False, then the alias can’t be instantiated, this is used by e.g. typing.List and typing.Dict.
alias of Dict[str, str]