nodes: 0, module; 1, function_definition; 2, function_name:apply_config; 3, parameters; 4, block; 5, identifier:self; 6, identifier:config; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, expression_statement; 14, expression_statement; 15, comment:"""
          Takes a given validated config dictionary and sets an instance
          attribute for each one.
  
          For check definitions, a Check instance is is created and a `checks`
          attribute set to a dictionary keyed off of the checks' names.  If
          the Check instance has some sort of error while being created an error
          is logged and the check skipped.
          """; 16, assignment; 17, assignment; 18, assignment; 19, assignment; 20, call; 21, assignment; 22, call; 23, attribute; 24, call; 25, attribute; 26, call; 27, attribute; 28, subscript; 29, attribute; 30, call; 31, attribute; 32, argument_list; 33, attribute; 34, subscript; 35, attribute; 36, argument_list; 37, identifier:self; 38, identifier:host; 39, attribute; 40, argument_list; 41, identifier:self; 42, identifier:configured_ports; 43, attribute; 44, argument_list; 45, identifier:self; 46, identifier:discovery; 47, identifier:config; 48, string:"discovery"; 49, identifier:self; 50, identifier:metadata; 51, attribute; 52, argument_list; 53, identifier:self; 54, identifier:update_ports; 55, identifier:self; 56, identifier:check_interval; 57, subscript; 58, string:"interval"; 59, identifier:self; 60, identifier:update_checks; 61, subscript; 62, identifier:config; 63, identifier:get; 64, string:"host"; 65, string:"127.0.0.1"; 66, identifier:config; 67, identifier:get; 68, string:"ports"; 69, list; 70, identifier:config; 71, identifier:get; 72, string:"metadata"; 73, dictionary; 74, identifier:config; 75, string:"checks"; 76, identifier:config; 77, string:"checks"; 78, call; 79, attribute; 80, argument_list; 81, identifier:config; 82, identifier:get; 83, string:"port"
code: def apply_config(self, config):
          """
          Takes a given validated config dictionary and sets an instance
          attribute for each one.
  
          For check definitions, a Check instance is is created and a `checks`
          attribute set to a dictionary keyed off of the checks' names.  If
          the Check instance has some sort of error while being created an error
          is logged and the check skipped.
          """
          self.host = config.get("host", "127.0.0.1")
  
          self.configured_ports = config.get("ports", [config.get("port")])
  
          self.discovery = config["discovery"]
  
          self.metadata = config.get("metadata", {})
  
          self.update_ports()
  
          self.check_interval = config["checks"]["interval"]
  
          self.update_checks(config["checks"])