forked from bestdpf/pyodl
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStaticRouteAPI.py
More file actions
40 lines (33 loc) · 1.6 KB
/
Copy pathStaticRouteAPI.py
File metadata and controls
40 lines (33 loc) · 1.6 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
"""
"""
from BasicAPI import *
from RequestData import *
class StaticRouteAPI(BasicAPI):
def __init__(self, format):
BasicAPI.__init__(self, format, app='staticroute')
def retrieve_all_static_routes(self, container):
self.uri = '/' + self.app + '/' + container + '/routes'
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_static_route_by_name(self, route, container):
self.uri = '/' + self.app + '/' + container + '/route/' + route
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 add_static_route(self, staticRoute, container):
self.uri = '/' + self.app + '/' + container + '/route/' + staticRoute['name']
self.method = 'PUT'
self.data = staticRoute
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)
def del_static_route(self, route, container):
self.uri = '/' + self.app + '/' + container + '/route/' + route
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)