diff --git a/bintray/bintray.py b/bintray/bintray.py index d21f781..5cca2f3 100644 --- a/bintray/bintray.py +++ b/bintray/bintray.py @@ -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 diff --git a/tests/test_entitlements.py b/tests/test_entitlements.py index a4f6e46..1136c62 100644 --- a/tests/test_entitlements.py +++ b/tests/test_entitlements.py @@ -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