@@ -104,6 +104,14 @@ def projects(
104
104
clover_enabled = False ,
105
105
max_results = 25 ,
106
106
):
107
+ """
108
+ Get all Projects
109
+ :param expand:
110
+ :param favourite:
111
+ :param clover_enabled:
112
+ :param max_results:
113
+ :return:
114
+ """
107
115
return self .base_list_call (
108
116
"project" ,
109
117
expand = expand ,
@@ -115,6 +123,14 @@ def projects(
115
123
)
116
124
117
125
def project (self , project_key , expand = None , favourite = False , clover_enabled = False ):
126
+ """
127
+ Get a single project by the key
128
+ :param project_key:
129
+ :param expand:
130
+ :param favourite:
131
+ :param clover_enabled:
132
+ :return:
133
+ """
118
134
resource = "project/{}" .format (project_key )
119
135
return self .base_list_call (
120
136
resource = resource ,
@@ -125,8 +141,21 @@ def project(self, project_key, expand=None, favourite=False, clover_enabled=Fals
125
141
max_results = 25 ,
126
142
)
127
143
144
+ def get_project (self , project_key ):
145
+ """Method used to retrieve information for project specified as project key.
146
+ Possible expand parameters: plans, list of plans for project. plans.plan, list of plans with plan details
147
+ (only plans visible - READ permission for user)"""
148
+ resource = "project/{}?showEmpty" .format (project_key )
149
+ return self .get (self .resource_url (resource ))
150
+
151
+ def delete_project (self , project_key ):
152
+ """Marks project for deletion. Project will be deleted by a batch job."""
153
+ resource = "project/{}" .format (project_key )
154
+ return self .delete (self .resource_url (resource ))
155
+
128
156
def project_plans (self , project_key , start_index = 0 , max_results = 25 ):
129
157
"""
158
+ Get all build plans in a project
130
159
Returns a generator with the plans in a given project.
131
160
:param project_key: project key
132
161
:param start_index:
@@ -153,6 +182,15 @@ def plans(
153
182
start_index = 0 ,
154
183
max_results = 25 ,
155
184
):
185
+ """
186
+ Get all build plans
187
+ :param expand:
188
+ :param favourite:
189
+ :param clover_enabled:
190
+ :param start_index:
191
+ :param max_results:
192
+ :return:
193
+ """
156
194
return self .base_list_call (
157
195
"plan" ,
158
196
expand = expand ,
@@ -234,6 +272,14 @@ def enable_plan(self, plan_key):
234
272
""" Branches """
235
273
236
274
def search_branches (self , plan_key , include_default_branch = True , max_results = 25 , start = 0 ):
275
+ """
276
+ Search Branches
277
+ :param plan_key:
278
+ :param include_default_branch:
279
+ :param max_results:
280
+ :param start:
281
+ :return:
282
+ """
237
283
params = {
238
284
"max-result" : max_results ,
239
285
"start-index" : start ,
@@ -256,7 +302,16 @@ def plan_branches(
256
302
clover_enabled = False ,
257
303
max_results = 25 ,
258
304
):
259
- """api/1.0/plan/{projectKey}-{buildKey}/branch"""
305
+ """
306
+ Get all plan Branches
307
+ api/1.0/plan/{projectKey}-{buildKey}/branch
308
+ :param plan_key:
309
+ :param expand:
310
+ :param favourite:
311
+ :param clover_enabled:
312
+ :param max_results:
313
+ :return:
314
+ """
260
315
resource = "plan/{}/branch" .format (plan_key )
261
316
return self .base_list_call (
262
317
resource ,
@@ -617,14 +672,30 @@ def comments(
617
672
start_index = 0 ,
618
673
max_results = 25 ,
619
674
):
675
+ """
676
+ Get comments for a specific build
677
+ :param project_key:
678
+ :param plan_key:
679
+ :param build_number:
680
+ :param start_index:
681
+ :param max_results:
682
+ :return:
683
+ """
620
684
resource = "result/{}-{}-{}/comment" .format (project_key , plan_key , build_number )
621
685
params = {"start-index" : start_index , "max-results" : max_results }
622
686
return self .get (self .resource_url (resource ), params = params )
623
687
624
- def create_comment (self , project_key , plan_key , build_number , comment , author = None ):
688
+ def create_comment (self , project_key , plan_key , build_number , comment ):
689
+ """
690
+ Create a comment for a specific build
691
+ :param project_key:
692
+ :param plan_key:
693
+ :param build_number:
694
+ :param comment:
695
+ :return:
696
+ """
625
697
resource = "result/{}-{}-{}/comment" .format (project_key , plan_key , build_number )
626
698
comment_data = {
627
- "author" : author if author else self .username ,
628
699
"content" : comment ,
629
700
}
630
701
return self .post (self .resource_url (resource ), data = comment_data )
@@ -637,15 +708,40 @@ def labels(
637
708
start_index = 0 ,
638
709
max_results = 25 ,
639
710
):
711
+ """
712
+ Get labels for a build
713
+ :param project_key:
714
+ :param plan_key:
715
+ :param build_number:
716
+ :param start_index:
717
+ :param max_results:
718
+ :return:
719
+ """
640
720
resource = "result/{}-{}-{}/label" .format (project_key , plan_key , build_number )
641
721
params = {"start-index" : start_index , "max-results" : max_results }
642
722
return self .get (self .resource_url (resource ), params = params )
643
723
644
724
def create_label (self , project_key , plan_key , build_number , label ):
725
+ """
726
+ Create a label for a specific build
727
+ :param project_key:
728
+ :param plan_key:
729
+ :param build_number:
730
+ :param label:
731
+ :return:
732
+ """
645
733
resource = "result/{}-{}-{}/label" .format (project_key , plan_key , build_number )
646
734
return self .post (self .resource_url (resource ), data = {"name" : label })
647
735
648
736
def delete_label (self , project_key , plan_key , build_number , label ):
737
+ """
738
+ Delete a label for a specific build
739
+ :param project_key:
740
+ :param plan_key:
741
+ :param build_number:
742
+ :param label:
743
+ :return:
744
+ """
649
745
resource = "result/{}-{}-{}/label/{}" .format (project_key , plan_key , build_number , label )
650
746
return self .delete (self .resource_url (resource ))
651
747
@@ -671,34 +767,43 @@ def get_projects(self):
671
767
for project in r ["projects" ]["project" ]:
672
768
yield project
673
769
674
- def get_project (self , project_key ):
675
- """Method used to retrieve information for project specified as project key.
676
- Possible expand parameters: plans, list of plans for project. plans.plan, list of plans with plan details
677
- (only plans visible - READ permission for user)"""
678
- resource = "project/{}?showEmpty" .format (project_key )
679
- return self .get (self .resource_url (resource ))
680
-
681
- def delete_project (self , project_key ):
682
- """Marks project for deletion. Project will be deleted by a batch job."""
683
- resource = "project/{}" .format (project_key )
684
- return self .delete (self .resource_url (resource ))
685
-
686
770
""" Deployments """
687
771
688
772
def deployment_projects (self ):
773
+ """
774
+ Returns all deployment projects.
775
+ :return:
776
+ """
689
777
resource = "deploy/project/all"
690
778
for project in self .get (self .resource_url (resource )):
691
779
yield project
692
780
693
781
def deployment_project (self , project_id ):
782
+ """
783
+ Returns a deployment project.
784
+ :param project_id:
785
+ :return:
786
+ """
694
787
resource = "deploy/project/{}" .format (project_id )
695
788
return self .get (self .resource_url (resource ))
696
789
697
790
def delete_deployment_project (self , project_id ):
791
+ """
792
+ Deletes a deployment project.
793
+ :param project_id:
794
+ :return:
795
+ """
698
796
resource = "deploy/project/{}" .format (project_id )
699
797
return self .delete (self .resource_url (resource ))
700
798
701
799
def deployment_environment_results (self , env_id , expand = None , max_results = 25 ):
800
+ """
801
+ Get deployment environment results
802
+ :param env_id:
803
+ :param expand:
804
+ :param max_results:
805
+ :return:
806
+ """
702
807
resource = "deploy/environment/{environmentId}/results" .format (environmentId = env_id )
703
808
params = {"max-result" : max_results , "start-index" : 0 }
704
809
size = 1
@@ -844,23 +949,6 @@ def get_users_not_in_group(self, group_name, filter_users="", start=0, limit=25)
844
949
url = "rest/api/latest/admin/groups/{}/more-non-members" .format (group_name )
845
950
return self .get (url , params = params )
846
951
847
- def get_build_queue (self , expand = "queuedBuilds" ):
848
- """
849
- Lists all the builds waiting in the build queue, adds or removes a build from the build queue.
850
- May be used also to resume build on manual stage or rerun failed jobs.
851
- :return:
852
- """
853
- params = {"expand" : expand }
854
- return self .get ("rest/api/latest/queue" , params = params )
855
-
856
- def get_deployment_queue (self , expand = "queuedDeployments" ):
857
- """
858
- Provide list of deployment results scheduled for execution and waiting in queue.
859
- :return:
860
- """
861
- params = {"expand" : expand }
862
- return self .get ("rest/api/latest/queue/deployment" , params = params )
863
-
864
952
def get_deployment_users (self , deployment_id , filter_name = None , start = 0 , limit = 25 ):
865
953
"""
866
954
Retrieve a list of users with their explicit permissions to given resource.
@@ -1022,6 +1110,23 @@ def grant_group_to_environment(self, environment_id, group, permissions):
1022
1110
def server_info (self ):
1023
1111
return self .get (self .resource_url ("info" ))
1024
1112
1113
+ def get_build_queue (self , expand = "queuedBuilds" ):
1114
+ """
1115
+ Lists all the builds waiting in the build queue, adds or removes a build from the build queue.
1116
+ May be used also to resume build on manual stage or rerun failed jobs.
1117
+ :return:
1118
+ """
1119
+ params = {"expand" : expand }
1120
+ return self .get ("rest/api/latest/queue" , params = params )
1121
+
1122
+ def get_deployment_queue (self , expand = "queuedDeployments" ):
1123
+ """
1124
+ Provide list of deployment results scheduled for execution and waiting in queue.
1125
+ :return:
1126
+ """
1127
+ params = {"expand" : expand }
1128
+ return self .get ("rest/api/latest/queue/deployment" , params = params )
1129
+
1025
1130
def agent_status (self , online = False ):
1026
1131
"""
1027
1132
Provides a list of all agents.
@@ -1128,6 +1233,20 @@ def chart(
1128
1233
start_index = 9 ,
1129
1234
max_results = 25 ,
1130
1235
):
1236
+ """
1237
+ Get chart data
1238
+ :param report_key:
1239
+ :param build_keys:
1240
+ :param group_by_period:
1241
+ :param date_filter:
1242
+ :param date_from:
1243
+ :param date_to:
1244
+ :param width:
1245
+ :param height:
1246
+ :param start_index:
1247
+ :param max_results:
1248
+ :return:
1249
+ """
1131
1250
params = {
1132
1251
"reportKey" : report_key ,
1133
1252
"buildKeys" : build_keys ,
@@ -1173,6 +1292,8 @@ def health_check(self):
1173
1292
response = self .get ("rest/supportHealthCheck/1.0/check/" )
1174
1293
return response
1175
1294
1295
+ """Elastic Bamboo"""
1296
+
1176
1297
def get_elastic_instance_logs (self , instance_id ):
1177
1298
"""
1178
1299
Get logs from an EC2 instance
@@ -1201,7 +1322,7 @@ def create_elastic_configuration(self, json):
1201
1322
1202
1323
def get_elastic_configuration (self , configuration_id ):
1203
1324
"""
1204
- Get informatin of an elastic configuration
1325
+ Get information of an elastic configuration
1205
1326
:param configuration_id:
1206
1327
:return:
1207
1328
"""
@@ -1264,7 +1385,7 @@ def get_plugin_info(self, plugin_key):
1264
1385
1265
1386
def get_plugin_license_info (self , plugin_key ):
1266
1387
"""
1267
- Provide plugin license info
1388
+ Provide plugin license information
1268
1389
:return a json specific License query
1269
1390
"""
1270
1391
url = "rest/plugins/1.0/{plugin_key}-key/license" .format (plugin_key = plugin_key )
@@ -1286,6 +1407,34 @@ def upload_plugin(self, plugin_path):
1286
1407
url = "rest/plugins/1.0/?token={upm_token}" .format (upm_token = upm_token )
1287
1408
return self .post (url , files = files , headers = self .no_check_headers )
1288
1409
1410
+ def disable_plugin (self , plugin_key ):
1411
+ """
1412
+ Disable a plugin
1413
+ :param plugin_key:
1414
+ :return:
1415
+ """
1416
+ app_headers = {
1417
+ "X-Atlassian-Token" : "nocheck" ,
1418
+ "Content-Type" : "application/vnd.atl.plugins+json" ,
1419
+ }
1420
+ url = "rest/plugins/1.0/{plugin_key}-key" .format (plugin_key = plugin_key )
1421
+ data = {"status" : "disabled" }
1422
+ return self .put (url , data = data , headers = app_headers )
1423
+
1424
+ def enable_plugin (self , plugin_key ):
1425
+ """
1426
+ Enable a plugin
1427
+ :param plugin_key:
1428
+ :return:
1429
+ """
1430
+ app_headers = {
1431
+ "X-Atlassian-Token" : "nocheck" ,
1432
+ "Content-Type" : "application/vnd.atl.plugins+json" ,
1433
+ }
1434
+ url = "rest/plugins/1.0/{plugin_key}-key" .format (plugin_key = plugin_key )
1435
+ data = {"status" : "enabled" }
1436
+ return self .put (url , data = data , headers = app_headers )
1437
+
1289
1438
def delete_plugin (self , plugin_key ):
1290
1439
"""
1291
1440
Delete plugin
@@ -1296,6 +1445,10 @@ def delete_plugin(self, plugin_key):
1296
1445
return self .delete (url )
1297
1446
1298
1447
def check_plugin_manager_status (self ):
1448
+ """
1449
+ Check plugin manager status
1450
+ :return:
1451
+ """
1299
1452
url = "rest/plugins/latest/safe-mode"
1300
1453
return self .request (method = "GET" , path = url , headers = self .safe_mode_headers )
1301
1454
0 commit comments