Fix the link to get the next share replica

The url to get the next share replica is broken when performing
pagination. The new API uses underscore to represent resource.
This fix resolves the broken link for share replicas by using alias.

Closes-bug: #2023754
Change-Id: I31e32c0bcfb60b53121da9a96df3b44ad2b3ac67
This commit is contained in:
Okeke Christian 2024-03-07 14:03:13 +01:00
parent a5532c3080
commit c8236141f8
3 changed files with 25 additions and 3 deletions

View File

@ -302,6 +302,7 @@ class ViewBuilder(object):
"""Model API responses as dictionaries."""
_collection_name = None
_collection_route_name = None
_detail_version_modifiers = []
def _get_project_id(self, request):
@ -325,20 +326,30 @@ class ViewBuilder(object):
"""Return href string with proper limit and marker params."""
params = request.params.copy()
params["marker"] = identifier
url = ""
collection_route_name = (
self._collection_route_name
or self._collection_name
)
prefix = self._update_link_prefix(request.application_url,
CONF.osapi_share_base_URL)
url = os.path.join(prefix,
self._get_project_id(request),
self._collection_name)
collection_route_name)
return "%s?%s" % (url, dict_to_query_str(params))
def _get_href_link(self, request, identifier):
"""Return an href string pointing to this object."""
collection_route_name = (
self._collection_route_name
or self._collection_name
)
prefix = self._update_link_prefix(request.application_url,
CONF.osapi_share_base_URL)
return os.path.join(prefix,
self._get_project_id(request),
self._collection_name,
collection_route_name,
str(identifier))
def _get_bookmark_link(self, request, identifier):
@ -346,9 +357,13 @@ class ViewBuilder(object):
base_url = remove_version_from_href(request.application_url)
base_url = self._update_link_prefix(base_url,
CONF.osapi_share_base_URL)
collection_route_name = (
self._collection_route_name
or self._collection_name
)
return os.path.join(base_url,
self._get_project_id(request),
self._collection_name,
collection_route_name,
str(identifier))
def _get_collection_links(self, request, items, id_key="uuid"):

View File

@ -20,6 +20,7 @@ class ReplicationViewBuilder(common.ViewBuilder):
"""Model a server API response as a python dictionary."""
_collection_name = 'share_replicas'
_collection_route_name = "share-replicas"
_collection_links = 'share_replica_links'
_detail_version_modifiers = [

View File

@ -0,0 +1,6 @@
---
fixes:
- |
Launchpad `bug 2023754 <https://bugs.launchpad.net/manila/+bug/2023754>`_
has been fixed for "next links" broken for limited share replicas api.