def retrieve_configuration(_storage, _category_name, _default, _category_description): """Retrieves the configuration from the Category Manager for a category name Args: _storage: Reference to the Storage Client to be used _category_name: Category name to be retrieved _default: default values for the category _category_description: category description Returns: _config_from_manager: Retrieved configuration as a Dictionary Raises: """ _event_loop = asyncio.get_event_loop() cfg_manager = ConfigurationManager(_storage) _event_loop.run_until_complete( cfg_manager.create_category(_category_name, _default, _category_description)) _config_from_manager = _event_loop.run_until_complete( cfg_manager.get_category_all_items(_category_name)) return _config_from_manager
def set_configuration(self): """" set the default configuration for purge :return: Configuration information that was set for purge process """ cfg_manager = ConfigurationManager(self._storage) self.loop.run_until_complete( cfg_manager.create_category(self._CONFIG_CATEGORY_NAME, self._DEFAULT_PURGE_CONFIG, self._CONFIG_CATEGORY_DESCRIPTION)) return self.loop.run_until_complete( cfg_manager.get_category_all_items(self._CONFIG_CATEGORY_NAME))
def _fetch_configuration(self, cat_name=None, cat_desc=None, cat_config=None, cat_keep_original=False): """ Retrieves the configuration from the Configuration Manager""" SendingProcess._logger.debug("{0} - ".format("_fetch_configuration")) cfg_manager = ConfigurationManager(self._storage) try: self._event_loop.run_until_complete(cfg_manager.create_category(cat_name, cat_config, cat_desc, cat_keep_original)) _config_from_manager = self._event_loop.run_until_complete(cfg_manager.get_category_all_items(cat_name)) return _config_from_manager except Exception: _message = _MESSAGES_LIST["e000003"] SendingProcess._logger.error(_message) raise
def _update_configuration(cls, age='72', retain_unsent='False') -> dict: """"Update the configuration table with the appropriate information regarding "PURE_READ" using pre-existing configuration_manager tools args: age: corresponds to the `age` value used for purging retainUnsent: corresponds to the `retainUnsent` value used for purging :return: The corresponding values set in the configuration for the purge process """ event_loop = asyncio.get_event_loop() cfg_manager = ConfigurationManager(cls._storage_client) event_loop.run_until_complete(cfg_manager.set_category_item_value_entry( cls._CONFIG_CATEGORY_NAME, 'age', age)) event_loop.run_until_complete(cfg_manager.set_category_item_value_entry( cls._CONFIG_CATEGORY_NAME, 'retainUnsent', retain_unsent)) return event_loop.run_until_complete(cfg_manager.get_category_all_items(cls._CONFIG_CATEGORY_NAME))
def _retrieve_configuration_from_manager(self): """" Retrieves the configuration from the configuration manager Args: Returns: Raises: """ _event_loop = asyncio.get_event_loop() cfg_manager = ConfigurationManager(self._storage) _event_loop.run_until_complete( cfg_manager.create_category(self._CONFIG_CATEGORY_NAME, self._CONFIG_DEFAULT, self._CONFIG_CATEGORY_DESCRIPTION)) self._config_from_manager = _event_loop.run_until_complete( cfg_manager.get_category_all_items(self._CONFIG_CATEGORY_NAME)) self._decode_configuration_from_manager(self._config_from_manager)