def apply(self):
    self.logger.info('Applying preprocessor')
    envvar = 'FOLIANT_ELASTICSEARCH'
    if ((not self.options['require_env']) or (getenv(envvar) is not None)):
        self.logger.debug((f"Allowed targets: {self.options['targets']}, " + f"current target: {self.context['target']}"))
        if ((not self.options['targets']) or (self.context['target'] in self.options['targets'])):
            actions = self.options['actions']
            if (not isinstance(self.options['actions'], list)):
                actions = [actions]
            for action in actions:
                self.logger.debug(f'Applying action: {action}')
                if (action == 'create'):
                    self._create_index(self.options['index_name'])
                elif (action == 'delete'):
                    self._delete_index(self.options['index_name'])
                elif (action == 'copy'):
                    self._copy_index(self.options['index_name'], self.options['index_copy_name'])
                else:
                    self.logger.debug('Unknown action, skipping')
    else:
        self.logger.debug(f'Environment variable {envvar} is not set, skipping')
    self.logger.info('Preprocessor applied')
def apply(self):
    self.logger.info('Applying preprocessor')
    envvar = 'FOLIANT_ELASTICSEARCH'
    if ((not self.options['require_env']) or (getenv(envvar) is not None)):
        self.logger.debug((f"Allowed targets: {self.options['targets']}, " + f"current target: {self.context['target']}"))
        if ((not self.options['targets']) or (self.context['target'] in self.options['targets'])):
            actions = self.options['actions']
            if (not isinstance(self.options['actions'], list)):
                actions = [actions]
            for action in actions:
                self.logger.debug(f'Applying action: {action}')
                if (action == 'create'):
                    self._create_index(self.options['index_name'])
                elif (action == 'delete'):
                    self._delete_index(self.options['index_name'])
                elif (action == 'copy'):
                    self._copy_index(self.options['index_name'], self.options['index_copy_name'])
                else:
                    self.logger.debug('Unknown action, skipping')
    else:
        self.logger.debug(f'Environment variable {envvar} is not set, skipping')
    self.logger.info('Preprocessor applied')