Skip to content

Commit 1d5b520

Browse files
committed
Add client method for subscribing to a package
Signed-off-by: Keshav Priyadarshi <git@keshav.space>
1 parent 789b002 commit 1d5b520

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

aboutcode/federatedcode/client/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import os
1111
from typing import Union
12+
from urllib.parse import quote
1213
from urllib.parse import urljoin
1314

1415
import requests
@@ -60,3 +61,10 @@ def get_package_scan(purl: Union[PackageURL, str]):
6061
if response.status_code == 404:
6162
raise ScanNotAvailableError(f"No scan available for {purl!s}")
6263
raise err
64+
65+
66+
def subscribe_package(federatedcode_host, remote_username, purl):
67+
"""Subscribe package for their metadata update from FederatedCode."""
68+
69+
url_path = f"api/v0/users/@{remote_username}/subscribe/?purl={quote(purl)}"
70+
return requests.get(urljoin(federatedcode_host, url_path))

0 commit comments

Comments
 (0)