class_docstr: Encapsulates a single alert and handles serializing to Dynamo and merging.
class_docstr_tok: ["Encapsulates","a","single","alert","and","handles","serializing","to","Dynamo","and","merging","."]
docstr: Find values common to every record.
  
  Args:
      records (list): List of record dictionaries.
  
  Returns:
      dict: The greatest common subset of all records.
  
  Example:
      _compute_common([
          {'abc': 123, 'nested': {'A': 1, 'B': 2}},
          {'abc': 123, 'def': 456, 'nested': {'A': 1}}
      ])
      will return {'abc': 123, 'nested': {'A': 1}}
docstr_tok: ["Find","values","common","to","every","record",".","Args",":","records","(","list",")",":","List","of","record","dictionaries",".","Returns",":","dict",":","The","greatest","common","subset","of","all","records",".","Example",":","_compute_common","(","[","{","'abc","'",":","123",",","'nested","'",":","{","'","A","'",":","1",",","'","B","'",":","2","}","}",",","{","'abc","'",":","123",",","'def","'",":","456",",","'nested","'",":","{","'","A","'",":","1","}","}","]",")","will","return","{","'abc","'",":","123",",","'nested","'",":","{","'","A","'",":","1","}","}"]
code: def _compute_common(cls, records):
      """Find values common to every record.
  
      Args:
          records (list): List of record dictionaries.
  
      Returns:
          dict: The greatest common subset of all records.
  
      Example:
          _compute_common([
              {'abc': 123, 'nested': {'A': 1, 'B': 2}},
              {'abc': 123, 'def': 456, 'nested': {'A': 1}}
          ])
          will return {'abc': 123, 'nested': {'A': 1}}
      """
      if not records:
          return {}
      if len(records) == 1:
          return records[0]
  
      # Any common key must be in the first record, so just traverse the first record.
      other_records = records[1:]
      common = {}
      for key, val in records[0].items():
          if not all(key in r for r in other_records):
              # This key does not exist in all other records and so cannot be common.
              continue
  
          if all(r[key] == val for r in other_records):
              # Every other record has the same key:value pair - add it to the common results.
              # This also works for identical nested structures, avoiding unnecessary recursion.
              common[key] = val
              continue
  
          if isinstance(val, dict):
              # This nested dict is not completely common to all records, but maybe some of it is.
  
              if not all(
                  isinstance(r[key], dict) for r in other_records
              ):
                  # This key is not a dictionary in every record - no partial similarities exist.
                  continue
  
              nested_common = cls._compute_common(
                  [r[key] for r in records]
              )
              if nested_common:
                  common[key] = nested_common
  
      return common
  
imports: from datetime import datetime, timedelta
  import json
  import uuid
  from streamalert.shared import resources, utils
label_desc: Use image node_id 13 for calling the Alert obj's underlying member method code with example usage: obj._compute_common(cls, records) and returns: common, dict, records