@@ -5501,6 +5501,94 @@ def import_project(
5501
5501
"/projects/import" , post_data = data , files = files , ** kwargs
5502
5502
)
5503
5503
5504
+ def import_bitbucket_server (
5505
+ self ,
5506
+ bitbucket_server_url ,
5507
+ bitbucket_server_username ,
5508
+ personal_access_token ,
5509
+ bitbucket_server_project ,
5510
+ bitbucket_server_repo ,
5511
+ new_name = None ,
5512
+ target_namespace = None ,
5513
+ ** kwargs
5514
+ ):
5515
+ """Import a project from BitBucket Server to Gitlab (schedule the import)
5516
+
5517
+ This method will return when an import operation has been safely queued,
5518
+ or an error has occurred. After triggering an import, check the
5519
+ `import_status` of the newly created project to detect when the import
5520
+ operation has completed.
5521
+
5522
+ NOTE: this request may take longer than most other API requests.
5523
+ So this method will specify a 60 second default timeout if none is specified.
5524
+ A timeout can be specified via kwargs to override this functionality.
5525
+
5526
+ Args:
5527
+ bitbucket_server_url (str): Bitbucket Server URL
5528
+ bitbucket_server_username (str): Bitbucket Server Username
5529
+ personal_access_token (str): Bitbucket Server personal access
5530
+ token/password
5531
+ bitbucket_server_project (str): Bitbucket Project Key
5532
+ bitbucket_server_repo (str): Bitbucket Repository Name
5533
+ new_name (str): New repository name (Optional)
5534
+ target_namespace (str): Namespace to import repository into.
5535
+ Supports subgroups like /namespace/subgroup (Optional)
5536
+ **kwargs: Extra options to send to the server (e.g. sudo)
5537
+
5538
+ Raises:
5539
+ GitlabAuthenticationError: If authentication is not correct
5540
+ GitlabListError: If the server failed to perform the request
5541
+
5542
+ Returns:
5543
+ dict: A representation of the import status.
5544
+
5545
+ Example:
5546
+ ```
5547
+ gl = gitlab.Gitlab_from_config()
5548
+ print("Triggering import")
5549
+ result = gl.projects.import_bitbucket_server(
5550
+ bitbucket_server_url="https://some.server.url",
5551
+ bitbucket_server_username="some_bitbucket_user",
5552
+ personal_access_token="my_password_or_access_token",
5553
+ bitbucket_server_project="my_project",
5554
+ bitbucket_server_repo="my_repo",
5555
+ new_name="gl_project_name",
5556
+ target_namespace="gl_project_path"
5557
+ )
5558
+ project = gl.projects.get(ret['id'])
5559
+ print("Waiting for import to complete")
5560
+ while project.import_status == u'started':
5561
+ time.sleep(1.0)
5562
+ project = gl.projects.get(project.id)
5563
+ print("BitBucket import complete")
5564
+ ```
5565
+ """
5566
+ data = {
5567
+ "bitbucket_server_url" : bitbucket_server_url ,
5568
+ "bitbucket_server_username" : bitbucket_server_username ,
5569
+ "personal_access_token" : personal_access_token ,
5570
+ "bitbucket_server_project" : bitbucket_server_project ,
5571
+ "bitbucket_server_repo" : bitbucket_server_repo ,
5572
+ }
5573
+ if new_name :
5574
+ data ["new_name" ] = new_name
5575
+ if target_namespace :
5576
+ data ["target_namespace" ] = target_namespace
5577
+ if (
5578
+ "timeout" not in kwargs
5579
+ or self .gitlab .timeout is None
5580
+ or self .gitlab .timeout < 60.0
5581
+ ):
5582
+ # Ensure that this HTTP request has a longer-than-usual default timeout
5583
+ # The base gitlab object tends to have a default that is <10 seconds,
5584
+ # and this is too short for this API command, typically.
5585
+ # On the order of 24 seconds has been measured on a typical gitlab instance.
5586
+ kwargs ["timeout" ] = 60.0
5587
+ result = self .gitlab .http_post (
5588
+ "/import/bitbucket_server" , post_data = data , ** kwargs
5589
+ )
5590
+ return result
5591
+
5504
5592
def import_github (
5505
5593
self , personal_access_token , repo_id , target_namespace , new_name = None , ** kwargs
5506
5594
):
@@ -5532,16 +5620,16 @@ def import_github(
5532
5620
Example:
5533
5621
```
5534
5622
gl = gitlab.Gitlab_from_config()
5535
- print "Triggering import"
5623
+ print( "Triggering import")
5536
5624
result = gl.projects.import_github(ACCESS_TOKEN,
5537
5625
123456,
5538
5626
"my-group/my-subgroup")
5539
5627
project = gl.projects.get(ret['id'])
5540
- print "Waiting for import to complete"
5628
+ print( "Waiting for import to complete")
5541
5629
while project.import_status == u'started':
5542
5630
time.sleep(1.0)
5543
5631
project = gl.projects.get(project.id)
5544
- print "Github import complete"
5632
+ print( "Github import complete")
5545
5633
```
5546
5634
"""
5547
5635
data = {
0 commit comments