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

Commit 2bad30e

Browse files
committed
#21 Delete license
Signed-off-by: Uilian Ries <uilianries@gmail.com>
1 parent bdb3111 commit 2bad30e

2 files changed

Lines changed: 33 additions & 0 deletions

File tree

bintray/bintray.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,27 @@ def update_user_proprietary_license(self, user, custom_license_name, license):
169169
url = "{}/users/{}/licenses/{}".format(Bintray.BINTRAY_URL, user, custom_license_name)
170170
return self._requester.patch(url, json=license)
171171

172+
def delete_org_proprietary_license(self, org, custom_license_name):
173+
""" Delete a license associated with an organization.
174+
For organization, caller must be an admin of the organization.
175+
176+
:param org: Organization name
177+
:param custom_license_name: License name to be deleted
178+
:return: request answer
179+
"""
180+
url = "{}/orgs/{}/licenses/{}".format(Bintray.BINTRAY_URL, org, custom_license_name)
181+
return self._requester.delete(url)
182+
183+
def delete_user_proprietary_license(self, user, custom_license_name):
184+
""" Delete a license associated with an user.
185+
186+
:param user: User name
187+
:param custom_license_name: License to be deleted
188+
:return: request answer
189+
"""
190+
url = "{}/users/{}/licenses/{}".format(Bintray.BINTRAY_URL, user, custom_license_name)
191+
return self._requester.patch(url)
192+
172193
def get_oss_licenses(self):
173194
""" Returns a list of all the OSS licenses.
174195

bintray/requester.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,15 @@ def patch(self, url, json=None, params=None):
104104
if not response.ok:
105105
self._raise_error("Could not PATCH", response)
106106
return self._add_status_code(response)
107+
108+
def delete(self, url, params=None):
109+
""" Forward DELETE method
110+
111+
:param url: URL address
112+
:param params: URL parameters
113+
:return: Request response
114+
"""
115+
response = requests.delete(url, auth=self._get_authentication(), params=params)
116+
if not response.ok:
117+
self._raise_error("Could not DELETE", response)
118+
return self._add_status_code(response)

0 commit comments

Comments
 (0)