Oct-29-2019, 11:40 AM
Thanks Craig. That is working perfectly now.
Here is the new code
<class 'dict'>: {'id': '116bd3bf-00b9-42b1-bf11-ffc6de819084', 'hostname': 'DC', 'health': {'overall': 'good'}, 'ipv4Addresses': ['192.168.220.22'], 'ProtectionEnabled': True, 'lastSeenAt': '2018-11-14T17:07:28.240Z', 'service_health': {'services': 'good'}, 'threats': {'threats': 'good'}}
Here is the new code
for all_computers in computers_json["items"]: # Make a temporary Dictionary to be added to the sub estate list computer_dictionary = {key:value for key, value in all_computers.items() if key in computer_keys} if 'health' in computer_dictionary.keys(): computer_dictionary['service_health'] = {'services': computer_dictionary['health']['services']['status']} computer_dictionary['threats'] = {'threats': computer_dictionary['health']['threats']['status']} computer_dictionary['health'] = {'overall': computer_dictionary['health']['overall']} computer_list.append(computer_dictionary)The only issue left is, I really only want the bad or good, but I get the below. Is there anyway to tidy this up?
<class 'dict'>: {'id': '116bd3bf-00b9-42b1-bf11-ffc6de819084', 'hostname': 'DC', 'health': {'overall': 'good'}, 'ipv4Addresses': ['192.168.220.22'], 'ProtectionEnabled': True, 'lastSeenAt': '2018-11-14T17:07:28.240Z', 'service_health': {'services': 'good'}, 'threats': {'threats': 'good'}}