/
endpointtemplates.py
74 lines (63 loc) · 3.08 KB
/
endpointtemplates.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
64
65
66
67
68
69
70
71
72
73
74
from keystone import utils
from keystone.common import wsgi
from keystone.logic.service import IdentityService
from keystone.logic.types.endpoint import EndpointTemplate
from . import get_marker_limit_and_url
class EndpointTemplatesController(wsgi.Controller):
"""Controller for EndpointTemplates related operations"""
def __init__(self, options):
self.options = options
@utils.wrap_error
def get_endpoint_templates(self, req):
marker, limit, url = get_marker_limit_and_url(req)
service_id = req.GET["serviceId"] if "serviceId" in req.GET else None
if service_id:
endpoint_templates = IdentityService.\
get_endpoint_templates_by_service(
utils.get_auth_token(req), service_id, marker, limit, url)
else:
endpoint_templates = IdentityService.get_endpoint_templates(
utils.get_auth_token(req), marker, limit, url)
return utils.send_result(200, req, endpoint_templates)
@utils.wrap_error
def add_endpoint_template(self, req):
endpoint_template = utils.get_normalized_request_content(
EndpointTemplate, req)
return utils.send_result(201, req,
IdentityService.add_endpoint_template(utils.get_auth_token(req),
endpoint_template))
@utils.wrap_error
def modify_endpoint_template(self, req, endpoint_template_id):
endpoint_template = utils.\
get_normalized_request_content(EndpointTemplate, req)
return utils.send_result(201, req,
IdentityService.modify_endpoint_template(\
utils.get_auth_token(req),
endpoint_template_id, endpoint_template))
@utils.wrap_error
def delete_endpoint_template(self, req, endpoint_template_id):
rval = IdentityService.delete_endpoint_template(
utils.get_auth_token(req), endpoint_template_id)
return utils.send_result(204, req, rval)
@utils.wrap_error
def get_endpoint_template(self, req, endpoint_template_id):
endpoint_template = IdentityService.get_endpoint_template(
utils.get_auth_token(req), endpoint_template_id)
return utils.send_result(200, req, endpoint_template)
@utils.wrap_error
def get_endpoints_for_tenant(self, req, tenant_id):
marker, limit, url = get_marker_limit_and_url(req)
endpoints = IdentityService.get_tenant_endpoints(
utils.get_auth_token(req), marker, limit, url, tenant_id)
return utils.send_result(200, req, endpoints)
@utils.wrap_error
def add_endpoint_to_tenant(self, req, tenant_id):
endpoint = utils.get_normalized_request_content(EndpointTemplate, req)
return utils.send_result(201, req,
IdentityService.create_endpoint_for_tenant(
utils.get_auth_token(req), tenant_id, endpoint))
@utils.wrap_error
def remove_endpoint_from_tenant(self, req, tenant_id, endpoint_id):
rval = IdentityService.delete_endpoint(utils.get_auth_token(req),
endpoint_id)
return utils.send_result(204, req, rval)