def add()

in curator/actions/alias.py [0:0]


    def add(self, ilo, warn_if_no_indices=False):
        """
        Create ``add`` statements for each index in ``ilo`` for :py:attr:`name`, then
        append them to :py:attr:`actions`.  Add any :py:attr:`extra_settings` that
        may be there.

        :param ilo: An IndexList Object
        :type ilo: :py:class:`~.curator.indexlist.IndexList`
        """
        verify_index_list(ilo)
        self.loggit.debug('ADD -> ILO = %s', ilo.indices)
        if not self.client:
            self.client = ilo.client
        self.name = parse_datemath(self.client, self.name)
        try:
            ilo.empty_list_check()
        except NoIndices as exc:
            # Add a warning if there are no indices to add, if so set in options
            if warn_if_no_indices:
                self.warn_if_no_indices = True
                self.loggit.warning(
                    'No indices found after processing filters. Nothing to add to %s',
                    self.name,
                )
                return
            # Re-raise the exceptions.NoIndices so it will behave as before
            raise NoIndices('No indices to add to alias') from exc
        for index in ilo.working_list():
            self.loggit.debug(
                'Adding index %s to alias %s with extra settings %s',
                index,
                self.name,
                self.extra_settings,
            )
            add_dict = {'add': {'index': index, 'alias': self.name}}
            add_dict['add'].update(self.extra_settings)
            self.actions.append(add_dict)