aries_cloudagent.config package

Submodules

aries_cloudagent.config.argparse module

aries_cloudagent.config.banner module

Module to contain logic to generate the banner for ACA-py.

class aries_cloudagent.config.banner.Banner(border: str, length: int)[source]

Bases: object

Management class to generate a banner for ACA-py.

lr_pad(content: str)[source]

Pad string content with defined border character.

Parameters:content – String content to pad
print_border()[source]

Print a full line using the border character.

print_list(items)[source]

Print a list of items, prepending a dash to each item.

print_spacer()[source]

Print an empty line with the border character only.

print_subtitle(title)[source]

Print a subtitle for a section.

print_title(title)[source]

Print the main title element.

print_version(version)[source]

Print the current version.

aries_cloudagent.config.base module

Configuration base classes.

class aries_cloudagent.config.base.BaseInjector[source]

Bases: abc.ABC

Base injector class.

copy() → aries_cloudagent.config.base.BaseInjector[source]

Produce a copy of the injector instance.

inject(base_cls: Type[InjectType], settings: Optional[Mapping[str, Any]] = None) → InjectType[source]

Get the provided instance of a given class identifier.

Parameters:
  • cls – The base class to retrieve an instance of
  • settings – An optional mapping providing configuration to the provider
Returns:

An instance of the base class, or None

inject_or(base_cls: Type[InjectType], settings: Optional[Mapping[str, Any]] = None, default: Optional[InjectType] = None) → Optional[InjectType][source]

Get the provided instance of a given class identifier or default if not found.

Parameters:
  • base_cls – The base class to retrieve an instance of
  • settings – An optional dict providing configuration to the provider
  • default – default return value if no instance is found
Returns:

An instance of the base class, or None

class aries_cloudagent.config.base.BaseProvider[source]

Bases: abc.ABC

Base provider class.

provide(settings: aries_cloudagent.config.base.BaseSettings, injector: aries_cloudagent.config.base.BaseInjector)[source]

Provide the object instance given a config and injector.

class aries_cloudagent.config.base.BaseSettings[source]

Bases: collections.abc.Mapping, typing.Generic

Base settings class.

copy() → aries_cloudagent.config.base.BaseSettings[source]

Produce a copy of the settings instance.

extend(other: Mapping[str, Any]) → aries_cloudagent.config.base.BaseSettings[source]

Merge another mapping to produce a new settings instance.

get_bool(*var_names, default: Optional[bool] = None) → Optional[bool][source]

Fetch a setting as a boolean value.

Parameters:
  • var_names – A list of variable name alternatives
  • default – The default value to return if none are defined
get_int(*var_names, default: Optional[int] = None) → Optional[int][source]

Fetch a setting as an integer value.

Parameters:
  • var_names – A list of variable name alternatives
  • default – The default value to return if none are defined
get_str(*var_names, default: Optional[str] = None) → Optional[str][source]

Fetch a setting as a string value.

Parameters:
  • var_names – A list of variable name alternatives
  • default – The default value to return if none are defined
get_value(*var_names, default: Optional[Any] = None) → Any[source]

Fetch a setting.

Parameters:
  • var_names – A list of variable name alternatives
  • default – The default value to return if none are defined
Returns:

The setting value, if defined, otherwise the default value

exception aries_cloudagent.config.base.ConfigError(*args, error_code: str = None, **kwargs)[source]

Bases: aries_cloudagent.core.error.BaseError

A base exception for all configuration errors.

exception aries_cloudagent.config.base.InjectionError(*args, error_code: str = None, **kwargs)[source]

Bases: aries_cloudagent.config.base.ConfigError

The base exception raised by Injector and Provider implementations.

exception aries_cloudagent.config.base.SettingsError(*args, error_code: str = None, **kwargs)[source]

Bases: aries_cloudagent.config.base.ConfigError

The base exception raised by BaseSettings implementations.

aries_cloudagent.config.base_context module

Base injection context builder classes.

class aries_cloudagent.config.base_context.ContextBuilder(settings: Optional[Mapping[str, Any]] = None)[source]

Bases: abc.ABC

Base injection context builder class.

build_context() → aries_cloudagent.config.injection_context.InjectionContext[source]

Build the base injection context.

update_settings(settings: Mapping[str, object])[source]

Update the context builder with additional settings.

aries_cloudagent.config.default_context module

aries_cloudagent.config.error module

Errors for config modules.

exception aries_cloudagent.config.error.ArgsParseError(*args, error_code: str = None, **kwargs)[source]

Bases: aries_cloudagent.config.base.ConfigError

Error raised when there is a problem parsing the command-line arguments.

aries_cloudagent.config.injection_context module

Injection context implementation.

class aries_cloudagent.config.injection_context.InjectionContext(*, settings: Mapping[str, object] = None, enforce_typing: bool = True)[source]

Bases: aries_cloudagent.config.base.BaseInjector

Manager for configuration settings and class providers.

ROOT_SCOPE = 'application'
copy() → aries_cloudagent.config.injection_context.InjectionContext[source]

Produce a copy of the injector instance.

inject(base_cls: Type[InjectType], settings: Mapping[str, object] = None) → InjectType[source]

Get the provided instance of a given class identifier.

Parameters:
  • cls – The base class to retrieve an instance of
  • settings – An optional mapping providing configuration to the provider
Returns:

An instance of the base class, or None

inject_or(base_cls: Type[InjectType], settings: Mapping[str, object] = None, default: Optional[InjectType] = None) → Optional[InjectType][source]

Get the provided instance of a given class identifier or default if not found.

Parameters:
  • base_cls – The base class to retrieve an instance of
  • settings – An optional dict providing configuration to the provider
  • default – default return value if no instance is found
Returns:

An instance of the base class, or None

injector

Accessor for scope-specific injector.

injector_for_scope(scope_name: str) → aries_cloudagent.config.injector.Injector[source]

Fetch the injector for a specific scope.

Parameters:scope_name – The unique scope identifier
scope_name

Accessor for the current scope name.

settings

Accessor for scope-specific settings.

start_scope(scope_name: str, settings: Mapping[str, object] = None) → aries_cloudagent.config.injection_context.InjectionContext[source]

Begin a new named scope.

Parameters:
  • scope_name – The unique name for the scope being entered
  • settings – An optional mapping of additional settings to apply
Returns:

A new injection context representing the scope

update_settings(settings: Mapping[str, object])[source]

Update the scope with additional settings.

exception aries_cloudagent.config.injection_context.InjectionContextError(*args, error_code: str = None, **kwargs)[source]

Bases: aries_cloudagent.config.base.InjectionError

Base class for issues in the injection context.

class aries_cloudagent.config.injection_context.Scope(name, injector)

Bases: tuple

injector

Alias for field number 1

name

Alias for field number 0

aries_cloudagent.config.injector module

Standard Injector implementation.

class aries_cloudagent.config.injector.Injector(settings: Mapping[str, object] = None, *, enforce_typing: bool = True)[source]

Bases: aries_cloudagent.config.base.BaseInjector

Injector implementation with static and dynamic bindings.

bind_instance(base_cls: Type[InjectType], instance: InjectType)[source]

Add a static instance as a class binding.

bind_provider(base_cls: Type[InjectType], provider: aries_cloudagent.config.base.BaseProvider, *, cache: bool = False)[source]

Add a dynamic instance resolver as a class binding.

clear_binding(base_cls: Type[InjectType])[source]

Remove a previously-added binding.

copy() → aries_cloudagent.config.base.BaseInjector[source]

Produce a copy of the injector instance.

get_provider(base_cls: Type[InjectType])[source]

Find the provider associated with a class binding.

inject(base_cls: Type[InjectType], settings: Mapping[str, object] = None) → InjectType[source]

Get the provided instance of a given class identifier.

Parameters:
  • cls – The base class to retrieve an instance of
  • params – An optional dict providing configuration to the provider
Returns:

An instance of the base class, or None

inject_or(base_cls: Type[InjectType], settings: Mapping[str, object] = None, default: Optional[InjectType] = None) → Optional[InjectType][source]

Get the provided instance of a given class identifier or default if not found.

Parameters:
  • base_cls – The base class to retrieve an instance of
  • settings – An optional dict providing configuration to the provider
  • default – default return value if no instance is found
Returns:

An instance of the base class, or None

settings

Accessor for scope-specific settings.

aries_cloudagent.config.ledger module

Ledger configuration.

aries_cloudagent.config.ledger.accept_taa(ledger: aries_cloudagent.ledger.base.BaseLedger, profile: aries_cloudagent.core.profile.Profile, taa_info, provision: bool = False) → bool[source]

Perform TAA acceptance.

aries_cloudagent.config.ledger.fetch_genesis_transactions(genesis_url: str) → str[source]

Get genesis transactions.

aries_cloudagent.config.ledger.get_genesis_transactions(settings: aries_cloudagent.config.settings.Settings) → str[source]

Fetch genesis transactions if necessary.

aries_cloudagent.config.ledger.ledger_config(profile: aries_cloudagent.core.profile.Profile, public_did: str, provision: bool = False) → bool[source]

Perform Indy ledger configuration.

aries_cloudagent.config.ledger.load_multiple_genesis_transactions_from_config(settings: aries_cloudagent.config.settings.Settings)[source]

Fetch genesis transactions for multiple ledger configuration.

aries_cloudagent.config.ledger.select_aml_tty(taa_info, provision: bool = False) → Optional[str][source]

Select acceptance mechanism from AML.

aries_cloudagent.config.logging module

Utilities related to logging.

class aries_cloudagent.config.logging.LoggingConfigurator[source]

Bases: object

Utility class used to configure logging and print an informative start banner.

classmethod configure(logging_config_path: str = None, log_level: str = None, log_file: str = None)[source]

Configure logger.

Parameters:
  • logging_config_path – str: (Default value = None) Optional path to custom logging config
  • log_level – str: (Default value = None)
classmethod print_banner(agent_label, inbound_transports, outbound_transports, public_did, admin_server=None, banner_length=40, border_character=':')[source]

Print a startup banner describing the configuration.

Parameters:
  • agent_label – Agent Label
  • inbound_transports – Configured inbound transports
  • outbound_transports – Configured outbound transports
  • admin_server – Admin server info
  • public_did – Public DID
  • banner_length – (Default value = 40) Length of the banner
  • border_character – (Default value = “:”) Character to use in banner
  • border
class aries_cloudagent.config.logging.TimedRotatingFileMultiProcessHandler(filename, when='h', interval=1, backupCount=1, encoding=None, delay=False, utc=False, atTime=None)[source]

Bases: logging.handlers.BaseRotatingHandler

Handler for logging to a file.

Rotating the log file at certain timed with file lock unlock mechanism to support multi-process writing to log file.

acquire()[source]

Acquire thread and file locks.

close()[source]

Close log stream and stream_lock.

compute_next_rollover_time()[source]

Return next rollover time.

doRollover()[source]

Perform rollover.

get_log_files_to_delete()[source]

Delete backup files on rotation based on backupCount.

get_next_rollover_time()[source]

Get next rollover time stamp from lock file.

release()[source]

Release file and thread locks.

save_next_rollover_time()[source]

Save the nextRolloverTimestamp to lock file.

shouldRollover(record)[source]

Determine if rollover should occur.

aries_cloudagent.config.logging.clear_prev_handlers(logger: logging.Logger) → logging.Logger[source]

Remove all handler classes associated with logger instance.

aries_cloudagent.config.logging.get_did_ident(profile: aries_cloudagent.core.profile.Profile) → Optional[str][source]

Get public did identifier for logging, if applicable.

aries_cloudagent.config.logging.get_logger_inst(profile: aries_cloudagent.core.profile.Profile, logger_name) → logging.Logger[source]

Return a logger instance with provided name and handlers.

aries_cloudagent.config.logging.get_logger_with_handlers(settings: aries_cloudagent.config.base.BaseSettings, logger: logging.Logger, at_when: str = None, interval: int = None, backup_count: int = None, did_ident: str = None) → logging.Logger[source]

Return logger instance with necessary handlers if required.

aries_cloudagent.config.logging.load_resource(path: str, encoding: str = None) → TextIO[source]

Open a resource file located in a python package or the local filesystem.

Parameters:path – The resource path in the form of dir/file or package:dir/file
Returns:A file-like object representing the resource

aries_cloudagent.config.plugin_settings module

Settings implementation for plugins.

class aries_cloudagent.config.plugin_settings.PluginSettings(values: Optional[Mapping[str, Any]] = None)[source]

Bases: aries_cloudagent.config.base.BaseSettings

Retrieve immutable settings for plugins.

Plugin settings should be retrieved by calling:

PluginSettings.for_plugin(settings, “my_plugin”, {“default”: “values”})

This will extract the PLUGIN_CONFIG_KEY in “settings” and return a new PluginSettings instance.

copy() → aries_cloudagent.config.base.BaseSettings[source]

Produce a copy of the settings instance.

extend(other: Mapping[str, Any]) → aries_cloudagent.config.base.BaseSettings[source]

Merge another settings instance to produce a new instance.

classmethod for_plugin(settings: aries_cloudagent.config.base.BaseSettings, plugin: str, default: Optional[Mapping[str, Any]] = None) → aries_cloudagent.config.plugin_settings.PluginSettings[source]

Construct a PluginSettings object from another settings object.

PLUGIN_CONFIG_KEY is read from settings.

get_value(*var_names, default: Any = None)[source]

Fetch a setting.

Parameters:
  • var_names – A list of variable name alternatives
  • default – The default value to return if none are defined

aries_cloudagent.config.provider module

Service provider implementations.

class aries_cloudagent.config.provider.CachedProvider(provider: aries_cloudagent.config.base.BaseProvider, unique_settings_keys: tuple = ())[source]

Bases: aries_cloudagent.config.base.BaseProvider

Cache the result of another provider.

provide(config: aries_cloudagent.config.base.BaseSettings, injector: aries_cloudagent.config.base.BaseInjector)[source]

Provide the object instance given a config and injector.

Instances are cached keyed on a SHA256 digest of the relevant subset of settings.

class aries_cloudagent.config.provider.ClassProvider(instance_cls: Union[str, type], *ctor_args, init_method: str = None, **ctor_kwargs)[source]

Bases: aries_cloudagent.config.base.BaseProvider

Provider for a particular class.

class Inject(base_cls: type)[source]

Bases: object

A class for passing injected arguments to the constructor.

provide(config: aries_cloudagent.config.base.BaseSettings, injector: aries_cloudagent.config.base.BaseInjector)[source]

Provide the object instance given a config and injector.

class aries_cloudagent.config.provider.InstanceProvider(instance)[source]

Bases: aries_cloudagent.config.base.BaseProvider

Provider for a previously-created instance.

provide(config: aries_cloudagent.config.base.BaseSettings, injector: aries_cloudagent.config.base.BaseInjector)[source]

Provide the object instance given a config and injector.

class aries_cloudagent.config.provider.StatsProvider(provider: aries_cloudagent.config.base.BaseProvider, methods: Sequence[str], *, ignore_missing: bool = True)[source]

Bases: aries_cloudagent.config.base.BaseProvider

Add statistics to the results of another provider.

provide(config: aries_cloudagent.config.base.BaseSettings, injector: aries_cloudagent.config.base.BaseInjector)[source]

Provide the object instance given a config and injector.

aries_cloudagent.config.settings module

Settings implementation.

class aries_cloudagent.config.settings.Settings(values: Optional[Mapping[str, Any]] = None)[source]

Bases: aries_cloudagent.config.base.BaseSettings, collections.abc.MutableMapping, typing.Generic

Mutable settings implementation.

clear_value(var_name: str)[source]

Remove a setting.

Parameters:var_name – The name of the setting
copy() → aries_cloudagent.config.base.BaseSettings[source]

Produce a copy of the settings instance.

extend(other: Mapping[str, Any]) → aries_cloudagent.config.base.BaseSettings[source]

Merge another settings instance to produce a new instance.

for_plugin(plugin: str, default: Optional[Mapping[str, Any]] = None)[source]

Retrieve settings for plugin.

get_value(*var_names, default=None)[source]

Fetch a setting.

Parameters:
  • var_names – A list of variable name alternatives
  • default – The default value to return if none are defined
set_default(var_name: str, value)[source]

Add a setting if not currently defined.

Parameters:
  • var_name – The name of the setting
  • value – The value to assign
set_value(var_name: str, value)[source]

Add a setting.

Parameters:
  • var_name – The name of the setting
  • value – The value to assign
update(other: Mapping[str, Any])[source]

Update the settings in place.

aries_cloudagent.config.util module

Entrypoint.

class aries_cloudagent.config.util.BoundedInt(min: int = None, max: int = None)[source]

Bases: object

Argument value parser for a bounded integer.

class aries_cloudagent.config.util.ByteSize(min: int = 0, max: int = None)[source]

Bases: object

Argument value parser for byte sizes.

aries_cloudagent.config.util.common_config(settings: Mapping[str, Any])[source]

Perform common app configuration.

aries_cloudagent.config.wallet module

Wallet configuration.

aries_cloudagent.config.wallet.add_or_update_version_to_storage(session: aries_cloudagent.core.profile.ProfileSession)[source]

Add or update ACA-Py version StorageRecord.

aries_cloudagent.config.wallet.wallet_config(context: aries_cloudagent.config.injection_context.InjectionContext, provision: bool = False) → Tuple[aries_cloudagent.core.profile.Profile, aries_cloudagent.wallet.did_info.DIDInfo][source]

Initialize the root profile.