diff --git a/artifactory.py b/artifactory.py index ba44a89..4e0a96a 100755 --- a/artifactory.py +++ b/artifactory.py @@ -474,6 +474,24 @@ def get_stat_json(self, pathobj): return json.loads(text) + def get_downloads_stat_json(self, pathobj): + """ + Request remote file/directory download info only + Returns a json object as specified by Artifactory REST API + """ + url = '/'.join([pathobj.drive, + 'api/storage', + str(pathobj.relative_to(pathobj.drive)).strip('/'), '?stats']) + + text, code = self.rest_get(url, auth=pathobj.auth, verify=pathobj.verify, + cert=pathobj.cert) + if code == 404 and "Unable to find item" in text: + raise OSError(2, "No such file or directory: '%s'" % url) + if code != 200: + raise RuntimeError(text) + + return json.loads(text) + def stat(self, pathobj): """ Request remote file/directory status info