Skip to content

Commit

Permalink
Merge pull request #6033 from jolange/feature-6020-allow_deny_reason
Browse files Browse the repository at this point in the history
Clients: allow reason parameter for denying; Fix #6020
  • Loading branch information
bari12 committed Jan 13, 2023
2 parents 8b03363 + 885c40e commit 2b23466
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/rucio/client/ruleclient.py
Expand Up @@ -203,15 +203,19 @@ def approve_replication_rule(self, rule_id: str):
exc_cls, exc_msg = self._get_exception(headers=r.headers, status_code=r.status_code, data=r.content)
raise exc_cls(exc_msg)

def deny_replication_rule(self, rule_id: str):
def deny_replication_rule(self, rule_id: str, reason: Optional[str] = None):
"""
:param rule_id: Rule to be denied.
:param reason: Reason for denying the rule.
:raises: RuleNotFound
"""

path = self.RULE_BASEURL + '/' + rule_id
url = build_url(choice(self.list_hosts), path=path)
data = dumps({'options': {'approve': False}})
options: Dict[str, Union[bool, str]] = {'approve': False}
if reason:
options['comment'] = reason
data = dumps({'options': options})
r = self._send_request(url, type_='PUT', data=data)
if r.status_code == codes.ok:
return True
Expand Down

0 comments on commit 2b23466

Please sign in to comment.