summaryrefslogtreecommitdiff
path: root/designate/api
diff options
context:
space:
mode:
authorErik Olof Gunnar Andersson <eandersson@blizzard.com>2019-10-22 01:19:54 -0700
committerErik Olof Gunnar Andersson <eandersson@blizzard.com>2019-10-22 01:43:54 -0700
commit282392158262e1afd1a2e9f7f9d6b9d2bda0fb1c (patch)
treeeec5b6ee6ef16394d9ba7cc3e0009b1fa3099dd7 /designate/api
parent68d8d8f4e5b896ca4c7363972d0ba88a7c5d3d50 (diff)
downloaddesignate-282392158262e1afd1a2e9f7f9d6b9d2bda0fb1c.tar.gz
Fix api version not providing the full url
We are currently using host_url to build the version href which causes the /dns portion to get dropped. This patch changes host_url to url_root. We also enable enable_host_header by default. Finally we add a help url that points at the designate api reference. Change-Id: Ie8d815391b316d664b0c51099a08d8d32932c555
Diffstat (limited to 'designate/api')
-rw-r--r--designate/api/versions.py40
1 files changed, 16 insertions, 24 deletions
diff --git a/designate/api/versions.py b/designate/api/versions.py
index 520e08f6..56854eeb 100644
--- a/designate/api/versions.py
+++ b/designate/api/versions.py
@@ -22,36 +22,28 @@ cfg.CONF.import_opt('enable_host_header', 'designate.api', group='service:api')
def factory(global_config, **local_conf):
app = flask.Flask('designate.api.versions')
- versions = []
-
- base = cfg.CONF['service:api'].api_base_uri.rstrip('/')
-
- def _host_header_links():
- del versions[:]
- host_url = flask.request.host_url.rstrip('/')
- _version('v2', 'CURRENT', host_url)
-
- def _version(version, status, base_uri):
- versions.append({
- 'id': '%s' % version,
- 'status': status,
- 'links': [{
- 'href': base_uri + '/' + version,
- 'rel': 'self'
- }]
- })
-
- if cfg.CONF['service:api'].enable_api_v2:
- _version('v2', 'CURRENT', base)
-
@app.route('/', methods=['GET'])
def version_list():
if cfg.CONF['service:api'].enable_host_header:
- _host_header_links()
+ url_root = flask.request.url_root
+ else:
+ url_root = cfg.CONF['service:api'].api_base_uri
return flask.jsonify({
"versions": {
- "values": versions
+ "values": [{
+ 'id': 'v2',
+ 'status': 'CURRENT',
+ 'links': [
+ {
+ 'href': url_root.rstrip('/') + '/v2',
+ 'rel': 'self',
+ }, {
+ 'rel': 'help',
+ 'href': 'https://docs.openstack.org/api-ref/dns'
+ }
+ ]
+ }]
}
})