Commit b1e92198 authored by Łukasz Nowak's avatar Łukasz Nowak

Change the way of fetching API root.

API is not an object, so generate virtual URLs.
parent 53cefc00
...@@ -176,7 +176,7 @@ def responseSupport(anonymous=False): ...@@ -176,7 +176,7 @@ def responseSupport(anonymous=False):
# force login # force login
self.REQUEST.response.setStatus(401) self.REQUEST.response.setStatus(401)
self.REQUEST.response.setHeader('WWW-Authenticate', 'Bearer realm="%s"'% self.REQUEST.response.setHeader('WWW-Authenticate', 'Bearer realm="%s"'%
self.absolute_url()) self.getAPIRoot())
self.REQUEST.response.setHeader('Location', self.getPortalObject()\ self.REQUEST.response.setHeader('Location', self.getPortalObject()\
.portal_preferences.getPreferredRestApiTokenServerUrl()) .portal_preferences.getPreferredRestApiTokenServerUrl())
return self.REQUEST.response return self.REQUEST.response
...@@ -374,8 +374,8 @@ class InstancePublisher(GenericPublisher): ...@@ -374,8 +374,8 @@ class InstancePublisher(GenericPublisher):
"connection": software_instance.getConnectionXmlAsDict(), "connection": software_instance.getConnectionXmlAsDict(),
"parameter": software_instance.getInstanceXmlAsDict(), "parameter": software_instance.getInstanceXmlAsDict(),
"sla": software_instance.getSlaXmlAsDict(), "sla": software_instance.getSlaXmlAsDict(),
"children_list": [q.absolute_url() for q in \ "children_list": [self.getAPIRoot() + '/' + q.getRelativeUrl() \
software_instance.getPredecessorValueList()], for q in software_instance.getPredecessorValueList()],
"partition": { # not ready yet "partition": { # not ready yet
"public_ip": [], "public_ip": [],
"private_ip": [], "private_ip": [],
...@@ -410,7 +410,7 @@ class InstancePublisher(GenericPublisher): ...@@ -410,7 +410,7 @@ class InstancePublisher(GenericPublisher):
d = {"list": []} d = {"list": []}
a = d['list'].append a = d['list'].append
for si in self.getPortalObject().portal_catalog(**kw): for si in self.getPortalObject().portal_catalog(**kw):
a('/'.join([self.absolute_url(), 'instance', si.getRelativeUrl()])) a('/'.join([self.getAPIRoot(), 'instance', si.getRelativeUrl()]))
try: try:
d['list'][0] d['list'][0]
except IndexError: except IndexError:
...@@ -504,6 +504,12 @@ class VifibRestAPIV1(Implicit): ...@@ -504,6 +504,12 @@ class VifibRestAPIV1(Implicit):
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
security.declarePublic('instance') security.declarePublic('instance')
security.declarePublic('getAPIRoot')
def getAPIRoot(self):
"""Returns the root of API"""
return self.absolute_url() + '/v1'
@ComputedAttribute @ComputedAttribute
def instance(self): def instance(self):
"""Instance publisher""" """Instance publisher"""
......
11 12
\ No newline at end of file \ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment