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

Commit

Permalink
#19 Search entitlement by tag
Browse files Browse the repository at this point in the history
Signed-off-by: Uilian Ries <[email protected]>
  • Loading branch information
uilianries committed Jul 21, 2019
1 parent 24dc4f9 commit 7d052fd
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
31 changes: 31 additions & 0 deletions bintray/bintray.py
Original file line number Diff line number Diff line change
Expand Up @@ -3728,3 +3728,34 @@ def search_entitlement_by_access_key(self, access_key=None, scope=None, product=
response = self._requester.get(url, params=params)
self._logger.info("Get successfully")
return response

def search_entitlement_by_tag(self, tag=None, scope=None, product=None, deep=False):
""" Search for entitlements for a specific tag in the specified scope.
The minimal scope is a subject.
You can optionally add a sub-scope of product, repo, package and version.
If deep equals true (default is false), will return all entitlements under the given
scope, for example, if scope is repository, existing package and version entitlements
under the given repository will be returned.
Security: Authenticated user with 'admin' permission.
:param tag: specific tag to be searched
:param scope: specified scope to be used in the search
:param product: products name associated to the access key
:param deep: return all entitlements under the given scope
:return: entitlement found
"""
url = "{}/search/entitlements".format(Bintray.BINTRAY_URL)
params = {"deep": bool_to_number(deep)}
if tag:
params["tag"] = tag
if scope:
params["scope"] = scope
if product:
params["product"] = product

response = self._requester.get(url, params=params)
self._logger.info("Get successfully")
return response
11 changes: 11 additions & 0 deletions tests/test_entitlements.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,14 @@ def test_search_entitlement_by_access_key():
error_message = str(error)

assert "Could not GET (403): Forbidden" == error_message


def test_search_entitlement_by_tag():
bintray = Bintray()
error_message = ""
try:
bintray.search_entitlement_by_tag("tag1", "jfrog/test-repo")
except Exception as error:
error_message = str(error)

assert "Could not GET (403): Forbidden" == error_message

0 comments on commit 7d052fd

Please sign in to comment.