Return HTTP response for delete_access_rule.

In the original code, when ignore_missing parameter is set to False,
no information is reported when either the share or the access is
not found. However, after applying this patch, the HTTP response
is returned to users, allowing them to verify whether the request
completed successfully or not. If there are serious issues with
the request clients, an exception will be raised to handle those
situations appropriately.

Change-Id: I925d943a00b4de198013336f5043753552255247
This commit is contained in:
René Ribaud 2023-07-24 17:35:52 +02:00
parent 56804e9889
commit c0758f1462
2 changed files with 8 additions and 5 deletions

View File

@ -816,10 +816,11 @@ class Proxy(proxy.Proxy):
:param access_id: The id of the access rule to get
:param share_id: The ID of the share
:rtype: ``None``
:rtype: ``requests.models.Response`` HTTP response from internal
requests client
"""
res = self._get_resource(_share_access_rule.ShareAccessRule, access_id)
res.delete(self, share_id, ignore_missing=ignore_missing)
return res.delete(self, share_id, ignore_missing=ignore_missing)
def share_group_snapshots(self, details=True, **query):
"""Lists all share group snapshots.

View File

@ -61,7 +61,7 @@ class ShareAccessRule(resource.Resource):
if microversion is None:
microversion = self._get_microversion(session, action=action)
session.post(
return session.post(
url, json=body, headers=headers, microversion=microversion
)
@ -74,10 +74,12 @@ class ShareAccessRule(resource.Resource):
)
def delete(self, session, share_id, ignore_missing=True):
body = {'deny_access': {'access_id': self.id}}
url = utils.urljoin('/shares', share_id, 'action')
body = {"deny_access": {"access_id": self.id}}
url = utils.urljoin("/shares", share_id, "action")
response = self._action(session, body, url)
try:
response = self._action(session, body, url)
self._translate_response(response)
except exceptions.ResourceNotFound:
if not ignore_missing:
raise