Skip to content
This repository has been archived by the owner on Feb 27, 2023. It is now read-only.

Commit

Permalink
#5 Delete IP Restrictions
Browse files Browse the repository at this point in the history
Signed-off-by: Uilian Ries <uilianries@gmail.com>
  • Loading branch information
uilianries committed Jul 13, 2019
1 parent 5ef8e1e commit 5b81a26
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
13 changes: 13 additions & 0 deletions bintray/bintray.py
Original file line number Diff line number Diff line change
Expand Up @@ -1020,3 +1020,16 @@ def update_ip_restrictions(self, subject, repo, add_white_cidrs=None, rm_white_c
response = self._requester.patch(url, json=json_data)
self._logger.info("Update successfully")
return response

def delete_ip_restrictions(self, subject, repo):
""" Removes all restrictions, black and white.
:param subject: repository owner
:param repo: repository name
:return: request response
"""
url = "{}/repos/{}/{}/ip_restrictions".format(Bintray.BINTRAY_URL, subject, repo)

response = self._requester.delete(url)
self._logger.info("Update successfully")
return response
11 changes: 11 additions & 0 deletions tests/test_repositories.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,3 +214,14 @@ def test_update_ip_restrictions():
except Exception as error:
error_message = str(error)
assert "At lease one parameter must be filled." == error_message


def test_delete_ip_restrictions():
bintray = Bintray()
error_message = ""
try:
bintray.delete_ip_restrictions("uilianries", "generic")
except Exception as error:
error_message = str(error)
assert "Could not DELETE (403): 403 Client Error: Forbidden for url: " \
"https://api.bintray.com/repos/uilianries/generic/ip_restrictions" == error_message

0 comments on commit 5b81a26

Please sign in to comment.