(self, sketch)
return HTTP_STATUS_CODE_OK
Unarchives a sketch by opening up all indices and removing labels.

        Args:
            sketch: Instance of timesketch.models.sketch.Sketch
Unarchives a sketch by opening up all indices and removing labels.
Unarchives a sketch by opening up all indices and removing labels .
def _archive_sketch(self, sketch):
        """Unarchives a sketch by opening up all indices and removing labels.

        Args:
            sketch: Instance of timesketch.models.sketch.Sketch
        """
        if sketch.get_status.status == 'archived':
            abort(
                HTTP_STATUS_CODE_BAD_REQUEST,
                'Unable to archive a sketch that was already archived '
                '(sketch: {0:d})'.format(sketch.id))

        labels_to_prevent_deletion = current_app.config.get(
            'LABELS_TO_PREVENT_DELETION', [])

        for label in labels_to_prevent_deletion:
            if sketch.has_label(label):
                abort(
                    HTTP_STATUS_CODE_FORBIDDEN,
                    'A sketch with the label {0:s} cannot be '
                    'archived.'.format(label))

        sketch.set_status(status='archived')

        # Go through all timelines in a sketch.
        #    Each timeline has only a single search index, however
        #    each search index can be part of multiple timelines.
        #    Only archive a search index if all of it's timelines
        #    are archived.
        indexes_to_close = []
        for timeline in sketch.timelines:
            if timeline.get_status.status != 'ready':
                continue
            timeline.set_status(status='archived')
            search_index = timeline.searchindex

            if not all([
                    x.get_status.status == 'archived'
                    for x in search_index.timelines]):
                continue
            search_index.set_status(status='archived')
            indexes_to_close.append(search_index.index_name)

        # TODO (kiddi): Move this to lib/datastores/opensearch.py.
        if indexes_to_close:
            try:
                self.datastore.client.indices.close(','.join(indexes_to_close))
            except opensearchpy.NotFoundError:
                logger.error(
                    'Unable to close indices, not found: {0:s}'.format(
                        ','.join(indexes_to_close)))
        return HTTP_STATUS_CODE_OK
def _archive_sketch ( self , sketch ) : if sketch . get_status . status == 'archived' : abort ( HTTP_STATUS_CODE_BAD_REQUEST , 'Unable to archive a sketch that was already archived ' '(sketch: {0:d})' . format ( sketch . id ) ) labels_to_prevent_deletion = current_app . config . get ( 'LABELS_TO_PREVENT_DELETION' , [ ] ) for label in labels_to_prevent_deletion : if sketch . has_label ( label ) : abort ( HTTP_STATUS_CODE_FORBIDDEN , 'A sketch with the label {0:s} cannot be ' 'archived.' . format ( label ) ) sketch . set_status ( status = 'archived' ) # Go through all timelines in a sketch. #    Each timeline has only a single search index, however #    each search index can be part of multiple timelines. #    Only archive a search index if all of it's timelines #    are archived. indexes_to_close = [ ] for timeline in sketch . timelines : if timeline . get_status . status != 'ready' : continue timeline . set_status ( status = 'archived' ) search_index = timeline . searchindex if not all ( [ x . get_status . status == 'archived' for x in search_index . timelines ] ) : continue search_index . set_status ( status = 'archived' ) indexes_to_close . append ( search_index . index_name ) # TODO (kiddi): Move this to lib/datastores/opensearch.py. if indexes_to_close : try : self . datastore . client . indices . close ( ',' . join ( indexes_to_close ) ) except opensearchpy . NotFoundError : logger . error ( 'Unable to close indices, not found: {0:s}' . format ( ',' . join ( indexes_to_close ) ) ) return HTTP_STATUS_CODE_OK