This repository has been archived by the owner on Dec 7, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
holo-proxy-service-delete.py
63 lines (54 loc) · 1.9 KB
/
holo-proxy-service-delete.py
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
60
61
62
63
from zato.server.service import Service
from json import dumps
import httplib
class HoloProxyServiceDelete(Service):
def checkKey(self, d, key):
return key in d
def handle(self):
# miscellaneous logging
self.logger.info(self.request.raw_request)
self.logger.info('cid:[{}]'.format(self.cid))
# prep data
data = self.request.bunchified()
self.logger.info(data)
# exit if missing incoming data
if not self.checkKey(data, 'name'):
response = {"error": "request must contain a service name"}
self.response.status_code = httplib.BAD_REQUEST
self.response.payload = dumps(response)
return
# else
# Obtains a connection object
conn = self.outgoing.plain_http['holo-proxy-service-delete'].conn
# payload
name = data.name
payload = {"service_name":name}
# Invoke the resource providing all the information on input
try:
response = conn.delete(self.cid, payload)
except:
response = {"error": "something broke"}
self.response.status_code = httplib.BAD_GATEWAY # 502
self.response.payload = dumps(response)
return
else:
# if no response
"""
if not response:
response = {"error": "no response"}
self.response.status_code = httplib.BAD_GATEWAY # 502
self.response.payload = dumps(response)
return
"""
# else
# Kong's reesponse to DELETE is a 204 No Content always
# therefore we can't return anything at this time
# self.response.payload = dumps(response.json())
return
"""
uses the following server objects
outconn:holo-proxy-service-delete:
http://localhost:8001
/services/
Kong proxy
"""