-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathSubnetsAPI.py
More file actions
49 lines (41 loc) · 2.03 KB
/
Copy pathSubnetsAPI.py
File metadata and controls
49 lines (41 loc) · 2.03 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
"""
"""
from BasicAPI import *
from RequestData import *
class SubnetsAPI(BasicAPI):
def __init__(self, format):
BasicAPI.__init__(self, format, app='subnetservice')
def retrieve_all_subnets(self, container):
self.uri = '/' + self.app + '/' + container + '/subnets'
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_subnet_by_name(self, subnetName, container):
self.uri = '/' + self.app + '/' + container + '/subnet/' + subnetName
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_subnet(self, subnetName, subnetConfig, container):
self.uri = '/' + self.app + '/' + container + '/subnet/' + subnetName
self.method = 'PUT'
self.data = subnetConfig
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_subnet(self, subnetName, container):
self.uri = '/' + self.app + '/' + container + '/subnet/' + subnetName
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 modify_subnet(self, subnetName, subnetConfig, container):
self.uri = '/' + self.app + '/' + container + '/subnet/' + subnetName
self.method = 'POST'
self.data = subnetConfig
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)