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
|
|
|
from enarksh.message.MessageController import MessageController |
|
|
|
|
10
|
|
|
|
11
|
|
|
|
12
|
|
|
class RequestPossibleNodeActionsMessage(Message): |
13
|
|
|
""" |
14
|
|
|
Message type for requesting all possible node actions for a run node. |
15
|
|
|
""" |
16
|
|
|
MESSAGE_TYPE = 'controller:RequestPossibleNodeActionsMessage' |
17
|
|
|
""" |
18
|
|
|
The message type. |
19
|
|
|
|
20
|
|
|
:type: str |
21
|
|
|
""" |
22
|
|
|
|
23
|
|
|
# ------------------------------------------------------------------------------------------------------------------ |
24
|
|
|
def __init__(self, sch_id, rnd_id): |
25
|
|
|
""" |
26
|
|
|
Object constructor. |
27
|
|
|
|
28
|
|
|
:param int sch_id: The ID of the schedule. |
29
|
|
|
:param int rnd_id: The ID of the run node. |
30
|
|
|
""" |
31
|
|
|
Message.__init__(self, RequestPossibleNodeActionsMessage.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
|
|
|
# ------------------------------------------------------------------------------------------------------------------ |
48
|
|
|
@staticmethod |
49
|
|
|
def create_from_json(message): |
50
|
|
|
""" |
51
|
|
|
Object constructor using JSON encoded message. |
52
|
|
|
|
53
|
|
|
:param * message: The message. |
54
|
|
|
|
55
|
|
|
:rtype: enarksh.controller.message.RequestPossibleNodeActionsMessage.RequestPossibleNodeActionsMessage |
56
|
|
|
""" |
57
|
|
|
return RequestPossibleNodeActionsMessage(int(message['sch_id']), int(message['rnd_id'])) |
58
|
|
|
|
59
|
|
|
# ------------------------------------------------------------------------------------------------------------------ |
60
|
|
|
def send_message(self, end_point): |
61
|
|
|
""" |
62
|
|
|
Sends the message to an end point. |
63
|
|
|
|
64
|
|
|
:param str end_point: The end point. |
65
|
|
|
|
66
|
|
|
:rtype: None |
67
|
|
|
""" |
68
|
|
|
self.message_controller.send_message(end_point, self) |
|
|
|
|
69
|
|
|
|
70
|
|
|
# ---------------------------------------------------------------------------------------------------------------------- |
71
|
|
|
MessageController.register_json_message_creator(RequestPossibleNodeActionsMessage.MESSAGE_TYPE, |
72
|
|
|
RequestPossibleNodeActionsMessage.create_from_json) |
73
|
|
|
|