Skip to content

Commit 958009f

Browse files
committed
Complete Agent module!
1 parent 835e77f commit 958009f

File tree

2 files changed

+143
-6
lines changed

2 files changed

+143
-6
lines changed

dongtai_sdk/DongTai.py

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
Date: 2021-12-23 15:10:01
44
version:
55
LastEditors: 饕餮
6-
LastEditTime: 2021-12-24 12:52:57
6+
LastEditTime: 2021-12-24 14:56:01
77
Description: Main
88
'''
99
from .base.DongTaiProject import DongTaiProject,DongTaiProjectVersion
10+
from .base.DongTaiAgent import DongTaiAgent
1011
from .DongTaiApi import DongTaiApi
1112
from .base.BaseObejct import DongTaiError
1213

@@ -90,10 +91,36 @@ def StopAgent(self,agentId):
9091
return errorObject
9192

9293
def ModifiedAgentAlias(self,agentId,alias):
93-
pass
94+
repData = self.dongTaiApi.ModifiedAgentAlias(agentId,alias)
95+
if repData["status"] == 201:
96+
return True
97+
else:
98+
errorMsg = {"status":repData["status"],"msg":repData["msg"]}
99+
errorObject = DongTaiError(errorMsg)
100+
return errorObject
101+
102+
def GetAgentDetail(self,agentId):
103+
repData = self.dongTaiApi.GetAgentDetail(agentId)
104+
if repData["status"] == 201:
105+
agentObject = DongTaiAgent(repData["data"]["agent"])
106+
return agentObject
107+
else:
108+
errorMsg = {"status":repData["status"],"msg":repData["msg"]}
109+
errorObject = DongTaiError(errorMsg)
110+
return errorObject
94111

95112
def GetAgentList(self,page=1,pageSize=50,projectName=None,state=None,token=None):
96-
pass
113+
returnData = []
114+
repData = self.dongTaiApi.GetAgentList(page,pageSize,projectName,state,token)
115+
if repData["status"] == 201:
116+
tmpDataList = repData["data"]
117+
for tmpData in tmpDataList:
118+
tmpObject = DongTaiAgent(tmpData)
119+
returnData.append(tmpObject)
120+
return returnData
121+
else:
122+
errorMsg = {"status":repData["status"],"msg":repData["msg"]}
123+
errorObject = DongTaiError(errorMsg)
124+
return errorObject
97125

98-
def GetAgentDetail(self,agentId):
99-
pass
126+

dongtai_sdk/base/DongTaiAgent.py

Lines changed: 111 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,116 @@
33
Date: 2021-12-24 10:56:26
44
version:
55
LastEditors: 饕餮
6-
LastEditTime: 2021-12-24 10:56:26
6+
LastEditTime: 2021-12-24 14:48:42
77
Description: Agent Object
88
'''
9+
import json
10+
from .BaseObejct import BaseObject
11+
12+
class DongTaiAgent(BaseObject):
13+
def __init__(self,jsonData):
14+
self.ObjectData = jsonData
15+
16+
@property
17+
def Id(self):
18+
return self.TryGetValue("id")
19+
20+
@property
21+
def Token(self):
22+
return self.TryGetValue("token")
23+
24+
@property
25+
def Alias(self):
26+
return self.TryGetValue("alias")
27+
28+
@property
29+
def StartUpTime(self):
30+
return self.TryGetValue("startup_time")
31+
32+
@property
33+
def RegisterTime(self):
34+
return self.TryGetValue("register_time")
35+
36+
@property
37+
def User(self):
38+
return self.TryGetValue("user")
39+
40+
@property
41+
def Server(self):
42+
return self.TryGetValue("server")
43+
44+
@property
45+
def IsRunning(self):
46+
return self.TryGetValue("is_running")
47+
48+
@property
49+
def IsCoreRunning(self):
50+
return self.TryGetValue("is_core_running")
51+
52+
@property
53+
def Control(self):
54+
return self.TryGetValue("control")
55+
56+
@property
57+
def IsControl(self):
58+
return self.TryGetValue("is_control")
59+
60+
@property
61+
def BindProjectId(self):
62+
return self.TryGetValue("bind_project_id")
63+
64+
@property
65+
def ProjectName(self):
66+
return self.TryGetValue("project_name")
67+
68+
@property
69+
def Online(self):
70+
return self.TryGetValue("online")
71+
72+
@property
73+
def ProjectVersionId(self):
74+
return self.TryGetValue("project_version_id")
75+
76+
@property
77+
def Language(self):
78+
return self.TryGetValue("language")
79+
80+
@property
81+
def RunningStatus(self):
82+
return self.TryGetValue("running_status")
83+
84+
@property
85+
def SystemLoad(self):
86+
tmpData = self.TryGetValue("system_load")
87+
if tmpData is not None:
88+
return json.dumps(tmpData)
89+
else:
90+
return {}
91+
92+
@property
93+
def Owner(self):
94+
return self.TryGetValue("owner")
95+
96+
@property
97+
def LastestName(self):
98+
return self.TryGetValue("latest_time")
99+
100+
@property
101+
def Flow(self):
102+
return self.TryGetValue("flow")
103+
104+
@property
105+
def ReportQueue(self):
106+
return self.TryGetValue("report_queue")
107+
108+
@property
109+
def MethodQueue(self):
110+
return self.TryGetValue("method_queue")
111+
112+
@property
113+
def ReplayQueue(self):
114+
return self.TryGetValue("replay_queue")
115+
116+
117+
118+

0 commit comments

Comments
 (0)