Implement "package unpublish" CLI

This commit is contained in:
Ivan Kravets
2020-05-27 01:10:35 +03:00
parent 8346b9822d
commit deb12972fb
4 changed files with 108 additions and 6 deletions

View File

@@ -41,3 +41,22 @@ class RegistryClient(RESTClient):
data=fp,
)
return response
def unpublish_package(self, name, owner=None, version=None, undo=False):
account = AccountClient()
if not owner:
owner = (
account.get_account_info(offline=True).get("profile").get("username")
)
path = "/v3/package/%s/%s" % (owner, name)
if version:
path = path + "/version/" + version
response = self.send_request(
"delete",
path,
params={"undo": 1 if undo else 0},
headers={
"Authorization": "Bearer %s" % account.fetch_authentication_token()
},
)
return response