(self, index_name)
Delete timeline in both Timesketch and OpenSearch.

        Args:
            index_name: The name of the index in OpenSearch
Delete timeline in both Timesketch and OpenSearch.
Delete timeline in both Timesketch and OpenSearch .
def run(self, index_name):
        """Delete timeline in both Timesketch and OpenSearch.

        Args:
            index_name: The name of the index in OpenSearch
        """
        if not isinstance(index_name, six.text_type):
            index_name = codecs.decode(index_name, 'utf-8')

        searchindex = SearchIndex.query.filter_by(
            index_name=index_name).first()

        if not searchindex:
            sys.stdout.write('No such index\n')
            sys.exit()

        datastore = OpenSearchDataStore(
            host=current_app.config['OPENSEARCH_HOST'],
            port=current_app.config['OPENSEARCH_PORT'])

        timelines = Timeline.query.filter_by(searchindex=searchindex).all()
        sketches = [
            t.sketch for t in timelines
            if t.sketch and t.sketch.get_status.status != 'deleted'
        ]
        if sketches:
            sys.stdout.write('WARNING: This timeline is in use by:\n')
            for sketch in sketches:
                sys.stdout.write(' * {0:s}\n'.format(sketch.name))
                sys.stdout.flush()
        really_delete = prompt_bool(
            'Are you sure you want to delete this timeline?')
        if really_delete:
            for timeline in timelines:
                db_session.delete(timeline)
            db_session.delete(searchindex)
            db_session.commit()
            datastore.client.indices.delete(index=index_name)
def run ( self , index_name ) : if not isinstance ( index_name , six . text_type ) : index_name = codecs . decode ( index_name , 'utf-8' ) searchindex = SearchIndex . query . filter_by ( index_name = index_name ) . first ( ) if not searchindex : sys . stdout . write ( 'No such index\n' ) sys . exit ( ) datastore = OpenSearchDataStore ( host = current_app . config [ 'OPENSEARCH_HOST' ] , port = current_app . config [ 'OPENSEARCH_PORT' ] ) timelines = Timeline . query . filter_by ( searchindex = searchindex ) . all ( ) sketches = [ t . sketch for t in timelines if t . sketch and t . sketch . get_status . status != 'deleted' ] if sketches : sys . stdout . write ( 'WARNING: This timeline is in use by:\n' ) for sketch in sketches : sys . stdout . write ( ' * {0:s}\n' . format ( sketch . name ) ) sys . stdout . flush ( ) really_delete = prompt_bool ( 'Are you sure you want to delete this timeline?' ) if really_delete : for timeline in timelines : db_session . delete ( timeline ) db_session . delete ( searchindex ) db_session . commit ( ) datastore . client . indices . delete ( index = index_name )