-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathFlowProgrammerAPI.py
More file actions
59 lines (50 loc) · 2.61 KB
/
Copy pathFlowProgrammerAPI.py
File metadata and controls
59 lines (50 loc) · 2.61 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
"""
"""
from RequestData import *
from BasicAPI import *
class FlowProgrammerAPI(BasicAPI):
def __init__(self, format):
BasicAPI.__init__(self, format, app='flowprogrammer')
def retrieve_flows(self, container):
self.uri = '/' + self.app + '/' + container
self.method = 'GET'
self.data = None
self.headers = {'Accept': 'application/' + self.format}
return RequestData(uri=self.uri, method=self.method, data=self.data, headers=self.headers)
def retrieve_node_flows(self, nodeId, nodeType, container):
self.uri = '/' + self.app + '/' + container + \
'/node/' + nodeType + '/' + nodeId
self.method = 'GET'
self.data = None
self.headers = {'Accept': 'application/' + self.format}
return RequestData(uri=self.uri, method=self.method, data=self.data, headers=self.headers)
def retrieve_flow_by_name(self, nodeId, flowName, nodeType, container):
self.uri = '/' + self.app + '/' + container + '/node/' + \
nodeType + '/' + nodeId + '/staticFlow/' + flowName
self.method = 'GET'
self.data = None
self.headers = {'Accept': 'application/' + self.format}
return RequestData(uri=self.uri, method=self.method, data=self.data, headers=self.headers)
def del_flow_by_name(self, nodeId, flowName, nodeType, container):
self.uri = '/' + self.app + '/' + container + '/node/' + \
nodeType + '/' + nodeId + '/staticFlow/' + flowName
self.method = 'DELETE'
self.data = None
self.headers = {'Accept': 'application/' + self.format}
return RequestData(uri=self.uri, method=self.method, data=self.data, headers=self.headers)
def toggle_flow_by_name(self, nodeId, flowName, nodeType, container):
self.uri = '/' + self.app + '/' + container + '/node/' + \
nodeType + '/' + nodeId + '/staticFlow/' + flowName
self.method = 'POST'
self.data = None
self.headers = {'Accept': 'application/' + self.format}
return RequestData(uri=self.uri, method=self.method, data=self.data, headers=self.headers)
def add_or_modify_flow(self, flowConfig, container):
self.uri = '/' + self.app + '/' + container + '/node/' + \
flowConfig['node']['type'] + '/' + flowConfig['node']['id'] + '/staticFlow/' + flowConfig['name']
self.method = 'PUT'
self.data = flowConfig
self.headers = {'Accept': 'application/' + self.format,
'Content-type': 'application/' + self.format
}
return RequestData(uri=self.uri, method=self.method, data=self.data, headers=self.headers)