class_docstr: Abstract Parser class to be inherited by all StreamAlert Parsers
class_docstr_tok: ["Abstract","Parser","class","to","be","inherited","by","all","StreamAlert","Parsers"]
docstr: Convert a parsed payload's values into their declared types.
  
  If the schema is incorrectly defined for a particular field,
  this function will return False which will make the payload
  invalid.
  
  Args:
      record (dict): Parsed record value
      schema (dict): Schema for the data being parsed. This could be parsing
          a nested value, so it should be passed in as an argument.
      optionals (set=None): Set of optional keys in the passed in schema that
          should be excluded from type conversion if not present in the record.
  
  Returns:
      bool: True if type conversion was successful, False otherwise
docstr_tok: ["Convert","a","parsed","payload","'s","values","into","their","declared","types",".","If","the","schema","is","incorrectly","defined","for","a","particular","field",",","this","function","will","return","False","which","will","make","the","payload","invalid",".","Args",":","record","(","dict",")",":","Parsed","record","value","schema","(","dict",")",":","Schema","for","the","data","being","parsed",".","This","could","be","parsing","a","nested","value",",","so","it","should","be","passed","in","as","an","argument",".","optionals","(","set=None",")",":","Set","of","optional","keys","in","the","passed","in","schema","that","should","be","excluded","from","type","conversion","if","not","present","in","the","record",".","Returns",":","bool",":","True","if","type","conversion","was","successful",",","False","otherwise"]
code: def _convert_type(cls, record, schema, optionals=None):
      """Convert a parsed payload's values into their declared types.
  
      If the schema is incorrectly defined for a particular field,
      this function will return False which will make the payload
      invalid.
  
      Args:
          record (dict): Parsed record value
          schema (dict): Schema for the data being parsed. This could be parsing
              a nested value, so it should be passed in as an argument.
          optionals (set=None): Set of optional keys in the passed in schema that
              should be excluded from type conversion if not present in the record.
  
      Returns:
          bool: True if type conversion was successful, False otherwise
      """
      for key, value in schema.items():
          key = str(key)
  
          # No need to type an optional key if it's value is not in the
          # record since this is a value we will insert
          if optionals and key in optionals and key not in record:
              LOGGER.debug(
                  "Skipping optional key not found in record: %s", key
              )
              continue
  
          if not record[key]:
              LOGGER.debug(
                  "Skipping NoneType value in record for key: %s", key
              )
              continue
  
          # if the schema value is declared as string
          if value == "string":
              try:
                  record[key] = str(record[key])
              except UnicodeEncodeError:
                  record[key] = str(record[key])
  
          # if the schema value is declared as integer
          elif value == "integer":
              try:
                  record[key] = int(record[key])
              except (ValueError, TypeError):
                  LOGGER.error(
                      "Invalid schema. Value for key [%s] is not an int: %s",
                      key,
                      record[key],
                  )
                  return False
  
          elif value == "float":
              try:
                  record[key] = float(record[key])
              except (ValueError, TypeError):
                  LOGGER.error(
                      "Invalid schema. Value for key [%s] is not a float: %s",
                      key,
                      record[key],
                  )
                  return False
  
          elif value == "boolean":
              record[key] = str(record[key]).lower() == "true"
  
          elif isinstance(value, dict):
              # Convert nested types
              if not cls._convert_type(record[key], value):
                  return False
  
          elif isinstance(value, list):
              # Ensure a list is actually a list, but do not check list value types
              # since we do not currently support type checking list elements
              if not isinstance(record[key], list):
                  LOGGER.error(
                      "Invalid schema. Value for key [%s] is not a list: %s",
                      key,
                      record[key],
                  )
                  return False
  
          else:
              LOGGER.error(
                  "Unsupported value type in schema for key '%s': %s",
                  key,
                  value,
              )
              return False
  
      return True
  
imports: from abc import ABCMeta, abstractmethod
  from copy import deepcopy
  import csv
  from fnmatch import fnmatch
  import json
  import logging
  import re
  import io
  import jmespath
  from streamalert.shared.logger import get_logger
label_desc: Use image node_id 21 for calling the ParserBase obj's underlying member method code with example usage: obj._convert_type(cls, record, schema, optionals) and returns: True, False, False, False, False, False