def convert(self):
     if self.has_index(self.metadata):
         self.metadata['index'] = Config.new_index_pattern
     if self.has_references(self.data):
         for ref in self.data['references']:
             if ref['id'] == Config.old_index_pattern:
                 ref['id'] = Config.new_index_pattern
     for item in self.metadata['filter']:
         if self.has_meta(item):
             models.Meta(item['meta']).convert()
         if self.has_exists(item):
             replace_value('field', item['exists'])
         if self.has_wildcard(item):
             replace_keys(item['wildcard'])
         if self.has_bool(item):
             models.BoolQuery(item['bool']).convert()
         if self.has_query(item):
             models.Query(item['query']).convert()
     if self.has_query(self.metadata):
         models.QueryString(self.metadata['query']).convert()
     if self.has_panelsjson:
         for item in self.source['panelsJSON']:
             if self.has_columns(item):
                 replace_values(item['columns'])
             if self.has_embeddable_config(item):
                 models.EmbeddableConfig(item['embeddableConfig']).convert()
     return self
 def convert(self):
     if self.has_index(self.metadata):
         self.metadata['index'] = Config.new_index_pattern
     if self.has_references(self.data):
         for ref in self.data['references']:
             if ref['id'] == Config.old_index_pattern:
                 ref['id'] = Config.new_index_pattern
     for o in self.metadata['filter']:
         if self.has_meta(o):
             models.Meta(o['meta']).convert()
         if self.has_exists(o):
             replace_value('field', o['exists'])
         if self.has_wildcard(o):
             replace_keys(o['wildcard'])
         if self.has_bool(o):
             models.BoolQuery(o['bool']).convert()
         if self.has_query(o):
             models.Query(o['query']).convert()
     if self.has_query(self.metadata):  # Kibana 7
         if self.has_query(self.metadata['query']):
             models.QueryString(self.metadata['query']).convert()
         else:
             models.Query(self.metadata['query']).convert()
     if self.has_visState:
         if self.has_aggs(self.source['visState']):
             for agg in self.source['visState']['aggs']:
                 models.Agg(agg).convert()
     return self
 def validate(self):
     for item in self.metadata['filter']:
         if self.has_meta(item):
             self.invalid_fields += models.Meta(item['meta'])\
                 .validate().get_invalid_fields()
         if self.has_exists(item):
             self.invalid_fields += get_invalid_fields(
                 item['exists']['field'])
         if self.has_wildcard(item):
             self.invalid_fields += get_invalid_fields(
                 item['wildcard'].keys())
         if self.has_bool(item):
             self.invalid_fields += models.BoolQuery(item['bool'])\
                 .validate().get_invalid_fields()
         if self.has_query(item):
             self.invalid_fields += models.Query(item['query'])\
                 .validate().get_invalid_fields()
     if self.has_query(self.metadata
                       ):  # Kibana 7 'query' at this level is a QueryString
         self.invalid_fields += models.QueryString(self.metadata['query'])\
             .validate().get_invalid_fields()
     if self.has_panelsjson:
         for item in self.source['panelsJSON']:
             if self.has_columns(item):
                 self.invalid_fields += get_invalid_fields(item['columns'])
             if self.has_embeddable_config(item):
                 self.invalid_fields += models.EmbeddableConfig(item['embeddableConfig'])\
                     .validate().get_invalid_fields()
     return self
示例#4
0
 def convert(self):
     if self.is_match_all:
         return self  # match_all queries have no parameters
     if self.is_term:
         replace_keys(self.data['term'])
     if self.is_terms:
         replace_keys(self.data['terms'])
     if self.is_terms_set:
         replace_keys(self.data['terms_set'])
     if self.is_fuzzy:
         replace_keys(self.data['fuzzy'])
     if self.is_prefix:
         replace_keys(self.data['prefix'])
     if self.is_range:
         replace_keys(self.data['range'])
     if self.is_regexp:
         replace_keys(self.data['regexp'])
     if self.is_wildcard:
         replace_keys(self.data['wildcard'])
     if self.is_match:
         replace_keys(self.data['match'])
     if self.is_match_phrase:
         replace_keys(self.data['match_phrase'])
     if self.is_bool:
         models.BoolQuery(self.data['bool']).convert()
     if self.is_query_string:
         models.QueryString(self.data['query_string']).convert()
     if self.has_query:
         Query(self.data['query']).convert()
     return self
示例#5
0
 def convert(self):
     for filt in self.data:
         if filt.get('input') is not None:
             if filt['input'].get('query') is not None:
                 if isinstance(filt['input']['query'], str):
                     models.QueryString(filt['input']).convert()
                 else:
                     models.Query(filt['input']).convert()
         if filt.get('bool') is not None:
             models.BoolQuery(filt['bool']).convert()
     return self
示例#6
0
 def validate(self):
     for filt in self.data:
         if filt.get('input') is not None:
             if filt['input'].get('query') is not None:
                 if isinstance(filt['input']['query'], str):
                     self.invalid_fields += models.QueryString(filt['input'])\
                         .validate().get_invalid_fields()
                 else:
                     self.invalid_fields += models.Query(filt['input'])\
                         .validate().get_invalid_fields()
         if filt.get('bool') is not None:
             self.invalid_fields += models.BoolQuery(filt['bool'])\
                 .validate().get_invalid_fields()
     return self
示例#7
0
 def validate(self):
     if self.is_match_all:
         return self  # match_all queries have no parameters
     if self.is_term:
         self.invalid_fields += get_invalid_fields(self.data['term'].keys())
     if self.is_terms:
         self.invalid_fields += get_invalid_fields(
             self.data['terms'].keys())
     if self.is_terms_set:
         self.invalid_fields += get_invalid_fields(
             self.data['terms_set'].keys())
     if self.is_fuzzy:
         self.invalid_fields += get_invalid_fields(
             self.data['fuzzy'].keys())
     if self.is_prefix:
         self.invalid_fields += get_invalid_fields(
             self.data['prefix'].keys())
     if self.is_range:
         self.invalid_fields += get_invalid_fields(
             self.data['range'].keys())
     if self.is_regexp:
         self.invalid_fields += get_invalid_fields(
             self.data['regexp'].keys())
     if self.is_wildcard:
         self.invalid_fields += get_invalid_fields(
             self.data['wildcard'].keys())
     if self.is_match:
         self.invalid_fields += get_invalid_fields(
             self.data['match'].keys())
     if self.is_match_phrase:
         self.invalid_fields += get_invalid_fields(
             self.data['match_phrase'].keys())
     if self.is_bool:
         self.invalid_fields += models.BoolQuery(self.data['bool'])\
             .validate().get_invalid_fields()
     if self.is_query_string:
         self.invalid_fields += models.QueryString(self.data['query_string'])\
             .validate().get_invalid_fields()
     if self.has_query:
         self.invalid_fields += Query(
             self.data['query']).validate().get_invalid_fields()
     return self
示例#8
0
 def convert(self):
     if self.has_index(self.metadata):
         self.metadata['index'] = Config.new_index_pattern
     if self.has_references(self.data):
         for ref in self.data['references']:
             if ref['id'] == Config.old_index_pattern:
                 ref['id'] = Config.new_index_pattern
     for o in self.metadata['filter']:
         if self.has_meta(o):
             models.Meta(o['meta']).convert()
         if self.has_exists(o):
             replace_value('field', o['exists'])
         if self.has_wildcard(o):
             replace_keys(o['wildcard'])
         if self.has_bool(o):
             models.BoolQuery(o['bool']).convert()
         if self.has_query(o):
             models.Query(o['query']).convert()
     if self.has_query(self.metadata):
         models.Query(self.metadata['query']).convert()
     if self.has_columns:
         replace_values(self.source['columns'])
     return self
 def validate(self):
     for item in self.metadata['filter']:
         if self.has_meta(item):
             self.invalid_fields += models.Meta(item['meta'])\
                 .validate().get_invalid_fields()
         if self.has_exists(item):
             self.invalid_fields += get_invalid_fields(item['exists']['field'])
         if self.has_wildcard(item):
             self.invalid_fields += get_invalid_fields(item['wildcard'].keys())
         if self.has_bool(item):
             self.invalid_fields += models.BoolQuery(item['bool'])\
                 .validate().get_invalid_fields()
         if self.has_query(item):
             self.invalid_fields += models.Query(item['query'])\
                 .validate().get_invalid_fields()
     if self.has_query(self.metadata):
         models.QueryString(self.metadata['query'])\
             .validate().get_invalid_fields()
     if self.has_visState:
         if self.has_aggs(self.source['visState']):
             for agg in self.source['visState']['aggs']:
                 self.invalid_fields += models.Agg(agg)\
                     .validate().get_invalid_fields()
     return self