-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpayloadModel.py
37 lines (31 loc) · 1.17 KB
/
payloadModel.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import json
import os
import datetime
class PingResult:
def __init__(self, svr_ip_ip_address, svr_ip_status, ping_date_time):
self.SvrIpIpAddress = svr_ip_ip_address
self.SvrIpStatus = svr_ip_status
self.PingDateTime = ping_date_time
class ServerData:
def __init__(self, hostname, ram_total, drive_space, cpu, ram_free):
self.Hostname = hostname
self.RamTotal = ram_total
self.DriveSpace = drive_space
self.Cpu = cpu
self.RamFree = ram_free
class DataToPost:
def __init__(self, license_key, org_id, server_data, ping_result):
self.licenceKey = license_key
self.OrgID = org_id
self.Serverdata = server_data
self.Pingresult = ping_result
class ServerDataEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, ServerData):
return obj.__dict__ # Convert ServerData object to a dictionary
return super().default(obj)
class DataToPostEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, DataToPost):
return obj.__dict__ # Convert DataToPost object to a dictionary
return super().default(obj)