def remove()

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


    def remove(self, ilo, warn_if_no_indices=False):
        """
        Create ``remove`` statements for each index in ``ilo`` for :py:attr:`name`,
        then append them to :py:attr:`actions`.

        :param ilo: An IndexList Object
        :type ilo: :py:class:`~.curator.indexlist.IndexList`
        """
        verify_index_list(ilo)
        self.loggit.debug('REMOVE -> 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 remove from %s',
                    self.name,
                )
                return

            # Re-raise the exceptions.NoIndices so it will behave as before
            raise NoIndices('No indices to remove from alias') from exc
        aliases = self.client.indices.get_alias(expand_wildcards=['open', 'closed'])
        for index in ilo.working_list():
            if index in aliases:
                self.loggit.debug('Index %s in get_aliases output', index)
                # Only remove if the index is associated with the alias
                if self.name in aliases[index]['aliases']:
                    self.loggit.debug(
                        'Removing index %s from alias %s', index, self.name
                    )
                    self.actions.append(
                        {'remove': {'index': index, 'alias': self.name}}
                    )
                else:
                    self.loggit.debug(
                        'Can not remove: Index %s is not associated with alias %s',
                        index,
                        self.name,
                    )