@@ -2970,3 +2970,33 @@ def get_usage_report_for_repository(self, subject, repo, from_date=None, to_date
29702970 response = self ._requester .post (url , json = json_data )
29712971 self ._logger .info ("Search successfully" )
29722972 return response
2973+
2974+ def get_usage_report_for_package (self , subject , repo , package = None , start_pos = 50 ,
2975+ from_date = None , to_date = None ):
2976+ """ Get current storage usage report. Report can be requested for the specified repository,
2977+ optionally for a specific package.
2978+
2979+ Security: Authenticated user with 'admin' permission for repo, or 'publish' permission
2980+ for specific package.
2981+
2982+ :param subject: repository owner
2983+ :param repo: repository name
2984+ :param package: package name
2985+ :param start_pos: index position
2986+ :param from_date: initial date range ISO8601 (yyyy-MM-dd'T'HH:mm:ss.SSSZ)
2987+ :param to_date: end date range ISO8601 (yyyy-MM-dd'T'HH:mm:ss.SSSZ)
2988+ :return: download details
2989+ """
2990+ url = "{}/usage/package_usage/{}/{}" .format (Bintray .BINTRAY_URL , subject , repo )
2991+ if package :
2992+ url += "/{}" .format (package )
2993+ params = {"start_pos" : start_pos }
2994+ json_data = {}
2995+ if from_date :
2996+ json_data ["from" ] = from_date
2997+ if to_date :
2998+ json_data ["to" ] = to_date
2999+
3000+ response = self ._requester .post (url , json = json_data , params = params )
3001+ self ._logger .info ("Search successfully" )
3002+ return response
0 commit comments