(self, search_id)
Initialize the search object from a saved search.

        Args:
            search_id: integer value for the saved
                search (primary key).
Initialize the search object from a saved search.
Initialize the search object from a saved search .
def from_saved(self, search_id):  # pylint: disable=arguments-differ
        """Initialize the search object from a saved search.

        Args:
            search_id: integer value for the saved
                search (primary key).
        """
        resource_uri = f'sketches/{self._sketch.id}/views/{search_id}/'
        resource_data = self.api.fetch_resource_data(resource_uri)

        data = resource_data.get('objects', [None])[0]
        if not data:
            logger.error('Unable to get any data back from a saved search.')
            return

        label_string = data.get('label_string', '')
        if label_string:
            self._labels = json.loads(label_string)
        else:
            self._labels = []

        self._aggregations = data.get('aggregation', 0)
        self._created_at = data.get('created_at', '')
        self._description = data.get('description', '')
        self._name = data.get('name', '')
        self.query_dsl = data.get('query_dsl', '')
        query_filter = data.get('query_filter', '')
        if query_filter:
            filter_dict = json.loads(query_filter)
            if 'fields' in filter_dict:
                fields = filter_dict.pop('fields')
                return_fields = [x.get('field') for x in fields]
                self.return_fields = ','.join(return_fields)

            self.query_filter = filter_dict
        self._query_string = data.get('query_string', '')
        self._resource_id = search_id
        self._searchtemplate = data.get('searchtemplate', 0)
        self._updated_at = data.get('updated_at', '')
        self._username = data.get('user', {}).get('username', 'System')

        self.resource_data = data
def from_saved ( self , search_id ) : # pylint: disable=arguments-differ resource_uri = f'sketches/{self._sketch.id}/views/{search_id}/' resource_data = self . api . fetch_resource_data ( resource_uri ) data = resource_data . get ( 'objects' , [ None ] ) [ 0 ] if not data : logger . error ( 'Unable to get any data back from a saved search.' ) return label_string = data . get ( 'label_string' , '' ) if label_string : self . _labels = json . loads ( label_string ) else : self . _labels = [ ] self . _aggregations = data . get ( 'aggregation' , 0 ) self . _created_at = data . get ( 'created_at' , '' ) self . _description = data . get ( 'description' , '' ) self . _name = data . get ( 'name' , '' ) self . query_dsl = data . get ( 'query_dsl' , '' ) query_filter = data . get ( 'query_filter' , '' ) if query_filter : filter_dict = json . loads ( query_filter ) if 'fields' in filter_dict : fields = filter_dict . pop ( 'fields' ) return_fields = [ x . get ( 'field' ) for x in fields ] self . return_fields = ',' . join ( return_fields ) self . query_filter = filter_dict self . _query_string = data . get ( 'query_string' , '' ) self . _resource_id = search_id self . _searchtemplate = data . get ( 'searchtemplate' , 0 ) self . _updated_at = data . get ( 'updated_at' , '' ) self . _username = data . get ( 'user' , { } ) . get ( 'username' , 'System' ) self . resource_data = data