|
1
|
|
|
""" |
|
2
|
|
|
Enarksh |
|
3
|
|
|
|
|
4
|
|
|
Copyright 2013-2016 Set Based IT Consultancy |
|
5
|
|
|
|
|
6
|
|
|
Licence MIT |
|
7
|
|
|
""" |
|
8
|
|
|
from enarksh.message.Message import Message |
|
9
|
|
|
|
|
10
|
|
|
|
|
11
|
|
|
class NodeActionWebMessage(Message): |
|
12
|
|
|
""" |
|
13
|
|
|
Message type for requesting a node action made through the web application. |
|
14
|
|
|
""" |
|
15
|
|
|
MESSAGE_TYPE = 'controller:NodeActionWebMessage' |
|
16
|
|
|
""" |
|
17
|
|
|
The message type. |
|
18
|
|
|
|
|
19
|
|
|
:type: str |
|
20
|
|
|
""" |
|
21
|
|
|
|
|
22
|
|
|
# ------------------------------------------------------------------------------------------------------------------ |
|
23
|
|
|
def __init__(self, sch_id, rnd_id, act_id): |
|
24
|
|
|
""" |
|
25
|
|
|
Object constructor. |
|
26
|
|
|
|
|
27
|
|
|
:param int sch_id: The ID of the schedule. |
|
28
|
|
|
:param int rnd_id: The ID of the run node. |
|
29
|
|
|
:param int act_id: The ID of the requested action. |
|
30
|
|
|
""" |
|
31
|
|
|
Message.__init__(self, NodeActionWebMessage.MESSAGE_TYPE) |
|
32
|
|
|
|
|
33
|
|
|
self.sch_id = sch_id |
|
34
|
|
|
""" |
|
35
|
|
|
The ID of the schedule. |
|
36
|
|
|
|
|
37
|
|
|
:type: int |
|
38
|
|
|
""" |
|
39
|
|
|
|
|
40
|
|
|
self.rnd_id = rnd_id |
|
41
|
|
|
""" |
|
42
|
|
|
The ID of the run node. |
|
43
|
|
|
|
|
44
|
|
|
:type: int |
|
45
|
|
|
""" |
|
46
|
|
|
|
|
47
|
|
|
self.act_id = act_id |
|
48
|
|
|
""" |
|
49
|
|
|
The ID of the requested action. |
|
50
|
|
|
|
|
51
|
|
|
:type: int |
|
52
|
|
|
""" |
|
53
|
|
|
|
|
54
|
|
|
# ------------------------------------------------------------------------------------------------------------------ |
|
55
|
|
|
@staticmethod |
|
56
|
|
|
def create_from_json(message): |
|
57
|
|
|
""" |
|
58
|
|
|
Object constructor using JSON encoded message. |
|
59
|
|
|
|
|
60
|
|
|
:param * message: The message. |
|
61
|
|
|
|
|
62
|
|
|
:rtype: enarksh.controller.message.PossibleNodeActionsWebMessage.PossibleNodeActionsWebMessage |
|
63
|
|
|
""" |
|
64
|
|
|
return NodeActionWebMessage(int(message['sch_id']), |
|
65
|
|
|
int(message['rnd_id']), |
|
66
|
|
|
int(message['act_id'])) |
|
67
|
|
|
|
|
68
|
|
|
# ------------------------------------------------------------------------------------------------------------------ |
|
69
|
|
|
def send_message(self, end_point): |
|
70
|
|
|
""" |
|
71
|
|
|
Sends the message to an end point. |
|
72
|
|
|
|
|
73
|
|
|
:param str end_point: The end point. |
|
74
|
|
|
|
|
75
|
|
|
:rtype: None |
|
76
|
|
|
""" |
|
77
|
|
|
self.message_controller.send_message(end_point, self) |
|
78
|
|
|
|
|
79
|
|
|
# ---------------------------------------------------------------------------------------------------------------------- |
|
80
|
|
|
|