(self, searchindex_id)
return HTTP_STATUS_CODE_OK
Handles DELETE request to the resource.
Handles DELETE request to the resource.
Handles DELETE request to the resource .
def delete(self, searchindex_id):
        """Handles DELETE request to the resource."""
        searchindex = SearchIndex.query.get_with_acl(searchindex_id)
        if not searchindex:
            abort(
                HTTP_STATUS_CODE_NOT_FOUND,
                'No searchindex found with this ID.')

        if not searchindex.has_permission(current_user, 'delete'):
            abort(
                HTTP_STATUS_CODE_FORBIDDEN, (
                    'User does not have sufficient access rights to '
                    'delete the search index.'))

        if searchindex.get_status.status == 'deleted':
            abort(
                HTTP_STATUS_CODE_BAD_REQUEST, 'Search index already deleted.')

        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:
            error_strings = ['WARNING: This timeline is in use by:']
            for sketch in sketches:
                error_strings.append(' * {0:s}'.format(sketch.name))
            abort(
                HTTP_STATUS_CODE_FORBIDDEN,
                '\n'.join(error_strings))

        searchindex.set_status(status='deleted')
        db_session.commit()

        other_indexes = SearchIndex.query.filter_by(
            index_name=searchindex.index_name).all()
        if len(other_indexes) > 1:
            logger.warning(
                'Search index: {0:s} belongs to more than one '
                'db entry.'.format(searchindex.index_name))
            return HTTP_STATUS_CODE_OK

        try:
            self.datastore.client.indices.close(index=searchindex.index_name)
        except opensearchpy.NotFoundError:
            logger.warning(
                'Unable to close index: {0:s}, the index wasn\'t '
                'found.'.format(searchindex.index_name))

        return HTTP_STATUS_CODE_OK
def delete ( self , searchindex_id ) : searchindex = SearchIndex . query . get_with_acl ( searchindex_id ) if not searchindex : abort ( HTTP_STATUS_CODE_NOT_FOUND , 'No searchindex found with this ID.' ) if not searchindex . has_permission ( current_user , 'delete' ) : abort ( HTTP_STATUS_CODE_FORBIDDEN , ( 'User does not have sufficient access rights to ' 'delete the search index.' ) ) if searchindex . get_status . status == 'deleted' : abort ( HTTP_STATUS_CODE_BAD_REQUEST , 'Search index already deleted.' ) 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 : error_strings = [ 'WARNING: This timeline is in use by:' ] for sketch in sketches : error_strings . append ( ' * {0:s}' . format ( sketch . name ) ) abort ( HTTP_STATUS_CODE_FORBIDDEN , '\n' . join ( error_strings ) ) searchindex . set_status ( status = 'deleted' ) db_session . commit ( ) other_indexes = SearchIndex . query . filter_by ( index_name = searchindex . index_name ) . all ( ) if len ( other_indexes ) > 1 : logger . warning ( 'Search index: {0:s} belongs to more than one ' 'db entry.' . format ( searchindex . index_name ) ) return HTTP_STATUS_CODE_OK try : self . datastore . client . indices . close ( index = searchindex . index_name ) except opensearchpy . NotFoundError : logger . warning ( 'Unable to close index: {0:s}, the index wasn\'t ' 'found.' . format ( searchindex . index_name ) ) return HTTP_STATUS_CODE_OK