@@ -165,8 +165,7 @@ def file_in_download_list(self, subject, repo, file_path, add_or_remove):
165165
166166 def upload_content (self , subject , repo , package , version , remote_file_path , local_file_path ,
167167 publish = True , override = False , explode = False ):
168- """
169- Upload content to the specified repository path, with package and version information (both required).
168+ """ Upload content to the specified repository path, with package and version information.
170169
171170 :param subject: username or organization
172171 :param repo: repository name
@@ -177,7 +176,7 @@ def upload_content(self, subject, repo, package, version, remote_file_path, loca
177176 :param publish: publish after uploading
178177 :param override: override remote file
179178 :param explode: explode remote file
180- :return:
179+ :return: Request response
181180 """
182181 url = "{}/content/{}/{}/{}/{}/{}" .format (Bintray .BINTRAY_URL , subject , repo , package ,
183182 version , remote_file_path )
@@ -191,6 +190,161 @@ def upload_content(self, subject, repo, package, version, remote_file_path, loca
191190 self ._logger .info ("Upload successfully: {}" .format (url ))
192191 return response
193192
193+ def maven_upload (self , subject , repo , package , remote_file_path , local_file_path , publish = True ,
194+ passphrase = None ):
195+ """ Upload Maven artifacts to the specified repository path, with package information.
196+
197+ Version information is resolved from the path, which is expected to follow the Maven
198+ layout.
199+
200+ You may supply a passphrase for signing uploaded files using the X-GPG-PASSPHRASE header
201+
202+ :param subject: username or organization
203+ :param repo: repository name
204+ :param package: package name
205+ :param remote_file_path: file name to be used on Bintray
206+ :param local_file_path: file path to be uploaded
207+ :param publish: publish after uploading
208+ :param passphrase: GPG passphrase
209+ :return: Request response
210+ """
211+ url = "{}/maven/{}/{}/{}/{}" .format (Bintray .BINTRAY_URL , subject , repo , package ,
212+ remote_file_path )
213+ parameters = {"publish" : bool_to_number (publish )}
214+ headers = {"X-GPG-PASSPHRASE" : passphrase } if passphrase else None
215+
216+ with open (local_file_path , 'rb' ) as file_content :
217+ response = self ._requester .put (url , params = parameters , data = file_content ,
218+ headers = headers )
219+
220+ self ._logger .info ("Upload successfully: {}" .format (url ))
221+ return response
222+
223+ def debian_upload (self , subject , repo , package , version , remote_file_path , local_file_path ,
224+ deb_distribution , deb_component , deb_architecture , publish = True ,
225+ override = False , passphrase = None ):
226+ """ Upload Debian artifacts to the specified repository path, with package information.
227+
228+ When artifacts are uploaded to a Debian repository using the Automatic index layout,
229+ the Debian distribution information is required and must be specified.
230+
231+ :param subject: username or organization
232+ :param repo: repository name
233+ :param package: package name
234+ :param version: package version
235+ :param remote_file_path: file name to be used on Bintray
236+ :param local_file_path: file path to be uploaded
237+ :param deb_distribution: Debian package distribution e.g. wheezy
238+ :param deb_component: Debian package component e.g. main
239+ :param deb_architecture: Debian package architecture e.g. i386,amd64
240+ :param publish: publish after uploading
241+ :param override: override remote file
242+ :param passphrase: GPG passphrase
243+ :return: Request response
244+ """
245+ url = "{}/content/{}/{}/{}/{}/{}" .format (Bintray .BINTRAY_URL , subject , repo , package ,
246+ version , remote_file_path )
247+ parameters = {"publish" : bool_to_number (publish ),
248+ "override" : bool_to_number (override )}
249+ headers = {
250+ "X-Bintray-Debian-Distribution" : deb_distribution ,
251+ "X-Bintray-Debian-Component" : deb_component ,
252+ "X-Bintray-Debian-Architecture" : deb_architecture
253+ }
254+ if passphrase :
255+ headers ["X-GPG-PASSPHRASE" ] = passphrase
256+
257+ with open (local_file_path , 'rb' ) as file_content :
258+ response = self ._requester .put (url , params = parameters , data = file_content ,
259+ headers = headers )
260+
261+ self ._logger .info ("Upload successfully: {}" .format (url ))
262+ return response
263+
264+ def _publish_discard_uploaded_content (self , subject , repo , package , version , discard = False ,
265+ publish_wait_for_secs = - 1 , passphrase = None ):
266+ """ Asynchronously publishes all unpublished content for a user’s package version. Returns
267+ the number of to-be-published files.
268+
269+ In order to wait for publishing to finish and run this call synchronously, specify a
270+ "publish_wait_for_secs" timeout in seconds. To wait for the maximum timeout allowed by
271+ Bintray use a wait value of -1 . A wait value of 0 is the default and is the same as
272+ running this call asynchronously without waiting.
273+
274+ Optionally, pass in a "discard" flag to discard any unpublished content, instead of
275+ publishing.
276+
277+ Automatic Signing for Repository Metadata
278+
279+ For repositories that support automatic calculation of repository metadata (such as
280+ Debian and YUM), you may supply signing required information.
281+
282+ :param subject: username or organization
283+ :param repo: repository name
284+ :param package: package name
285+ :param version: package version
286+ :param discard: Discard package
287+ :param publish_wait_for_secs: Publishing timeout
288+ :param passphrase: GPG passphrase
289+ :return: Request response
290+ """
291+ url = "{}/content/{}/{}/{}/{}/publish" .format (Bintray .BINTRAY_URL , subject , repo , package ,
292+ version )
293+ body = {'discard' : discard ,
294+ 'publish_wait_for_secs' : publish_wait_for_secs }
295+ headers = {"X-GPG-PASSPHRASE" : passphrase } if passphrase else None
296+
297+ response = self ._requester .post (url , json = body , headers = headers )
298+
299+ self ._logger .info ("Publish/Discard successfully: {}" .format (url ))
300+ return response
301+
302+ def publish_uploaded_content (self , subject , repo , package , version , passphrase = None ):
303+ """ Asynchronously publishes all unpublished content for a user’s package version.
304+
305+ :param subject: username or organization
306+ :param repo: repository name
307+ :param package: package name
308+ :param version: package version
309+ :param passphrase: GPG passphrase
310+ :return: the number of to-be-published files.
311+ """
312+ return self ._publish_discard_uploaded_content (subject , repo , package , version ,
313+ discard = False , passphrase = passphrase )
314+
315+ def discard_uploaded_content (self , subject , repo , package , version , passphrase = None ):
316+ """ Asynchronously discard all unpublished content for a user’s package version.
317+
318+ :param subject: username or organization
319+ :param repo: repository name
320+ :param package: package name
321+ :param version: package version
322+ :param passphrase: GPG passphrase
323+ :return: the number of discarded files.
324+ """
325+ return self ._publish_discard_uploaded_content (subject , repo , package , version ,
326+ discard = True , passphrase = passphrase )
327+
328+ def delete_content (self , subject , repo , file_path ):
329+ """ Delete content from the specified repository path,
330+
331+ Currently supports only deletion of files.
332+ For OSS, this action is limited for 180 days from the content’s publish date.
333+
334+ Security: Authenticated user with 'publish' permission, or read/write entitlement for a
335+ repository path
336+
337+ :param subject: username or organization
338+ :param repo: repository name
339+ :param file_path: file to be deleted
340+ :return: request response
341+ """
342+ url = "{}/content/{}/{}/{}" .format (Bintray .BINTRAY_URL , subject , repo , file_path )
343+ response = self ._requester .delete (url )
344+
345+ self ._logger .info ("Delete successfully: {}" .format (url ))
346+ return response
347+
194348 # Content Downloading
195349
196350 def download_content (self , subject , repo , remote_file_path , local_file_path ):
0 commit comments