1
1
import logging
2
2
from atlassian import AtlassianRestAPI
3
3
4
-
5
4
log = logging .getLogger ('atlassian.stash' )
6
5
7
6
8
- class Stash (AtlassianRestAPI ):
7
+ class Bamboo (AtlassianRestAPI ):
8
+
9
+ def base_list_call (self , resource , expand , favourite , cloverEnabled , start_index , max_results , ** kwargs ):
10
+ flags = []
11
+ params = {'start-index' : start_index , 'max-results' : max_results }
12
+ if expand :
13
+ params ['expand' ] = expand
14
+ if favourite :
15
+ flags .append ('favourite' )
16
+ if cloverEnabled :
17
+ flags .append ('cloverEnabled' )
18
+ params .update (kwargs )
19
+ return self .get (self .resource_url (resource ), flags = flags , params = params )
20
+
21
+ def projects (self , expand = None , favourite = False , cloverEnabled = False , start_index = 0 , max_results = 25 ):
22
+ return self .base_list_call ('project' , expand , favourite , cloverEnabled , start_index , max_results )
23
+
24
+ def plans (self , expand = None , favourite = False , cloverEnabled = False , start_index = 0 , max_results = 25 ):
25
+ return self .base_list_call ("plan" , expand , favourite , cloverEnabled , start_index , max_results )
26
+
27
+ def results (self , project_key = None , plan_key = None , build_number = None , expand = None , favourite = False ,
28
+ cloverEnabled = False , label = None , issueKey = None , start_index = 0 , max_results = 25 ):
29
+ resource = "result"
30
+ if project_key and plan_key and build_number :
31
+ resource += "/{}-{}/{}" .format (project_key , plan_key , build_number )
32
+ elif project_key and plan_key :
33
+ resource += "/{}-{}" .format (project_key , plan_key )
34
+ elif project_key :
35
+ resource += '/' + project_key
36
+
37
+ params = {}
38
+ if issueKey :
39
+ params ['issueKey' ] = issueKey
40
+ return self .base_list_call (resource , expand , favourite , cloverEnabled , start_index , max_results , ** params )
41
+
42
+ def latest_results (self , expand = None , favourite = False , cloverEnabled = False , label = None , issueKey = None ,
43
+ start_index = 0 , max_results = 25 ):
44
+ return self .results (expand = expand , favourite = favourite , cloverEnabled = cloverEnabled ,
45
+ label = label , issueKey = issueKey , start_index = start_index , max_results = max_results )
46
+
47
+ def project_latest_results (self , project_key , expand = None , favourite = False , cloverEnabled = False , label = None , issueKey = None ,
48
+ start_index = 0 , max_results = 25 ):
49
+ return self .results (project_key , expand = expand , favourite = favourite , cloverEnabled = cloverEnabled ,
50
+ label = label , issueKey = issueKey , start_index = start_index , max_results = max_results )
9
51
10
- def projects_list (self , expand = None , favourite = False , cloverEnabled = False , start = 0 , limit = 25 ):
11
- args = ()
12
- kwargs = {}
13
- return self . get ( self . resource_url ( 'project' ), args = args , kwargs = kwargs )
52
+ def plan_results (self , project_key , plan_key , expand = None , favourite = False , cloverEnabled = False , label = None , issueKey = None ,
53
+ start_index = 0 , max_results = 25 ):
54
+ return self . results ( project_key , plan_key , expand = expand , favourite = favourite , cloverEnabled = cloverEnabled ,
55
+ label = label , issueKey = issueKey , start_index = start_index , max_results = max_results )
14
56
15
- def plans_list (self , expand = None , favourite = False , cloverEnabled = False , start = 0 , limit = 25 ):
16
- pass
57
+ def build_result (self , project_key , plan_key , build_key , expand = None , favourite = False , cloverEnabled = False , label = None , issueKey = None ,
58
+ start_index = 0 , max_results = 25 ):
59
+ return self .results (project_key , plan_key , expand = expand , favourite = favourite , cloverEnabled = cloverEnabled ,
60
+ label = label , issueKey = issueKey , start_index = start_index , max_results = max_results )
17
61
18
- def result_list (self , project_key = None , plan_key = None , build_number = None ,
19
- expand = None , favourite = False , cloverEnabled = False , label = None ,
20
- start = 0 , limit = 25 ) :
21
- pass
62
+ def reports (self , expand = None , start_index = 0 , max_results = 25 ):
63
+ params = { 'start-index' : start_index , 'max-results' : max_results }
64
+ if expand :
65
+ params [ 'expand' ] = expand
22
66
23
- def get_project_latest_results (self , project , expand = None , favourite = False , cloverEnabled = False , label = None ,
24
- start = 0 , limit = 25 ):
25
- return self .result_list (project_key , expand = expand , favourite = favourite , cloverEnabled = cloverEnabled ,
26
- label = label , start = start , limit = limit )
67
+ return self .get (self .resource_url ('chart/reports' ), params = params )
27
68
28
- def get_plan_results (self , project_key , plan_key , expand = None , favourite = False , cloverEnabled = False , label = None ,
29
- start = 0 , limit = 25 ):
30
- return self .result_list (project_key , plan_key , expand = expand , favourite = favourite , cloverEnabled = cloverEnabled ,
31
- label = label , start = start , limit = limit )
69
+ def chart (self , reportKey , buildKeys , groupByPeriod , dateFilter = None , dateFrom = None , dateTo = None ,
70
+ width = None , height = None , start_index = 9 , max_results = 25 ):
71
+ params = {'reportKey' : reportKey , 'buildKeys' : buildKeys , 'groupByPeriod' : groupByPeriod ,
72
+ 'start-index' : start_index , 'max-results' : max_results }
73
+ if dateFilter :
74
+ params ['dateFilter' ] = dateFilter
75
+ if dateFilter == 'RANGE' :
76
+ params ['dateFrom' ] = dateFrom
77
+ params ['dateTo' ] = dateTo
78
+ if width :
79
+ params ['width' ] = width
80
+ if height :
81
+ params ['height' ] = height
82
+ return self .get (self .resource_url ('chart' ), params = params )
32
83
33
- def get_result (self , project_key , plan_key , build_key , expand = None , favourite = False , cloverEnabled = False , label = None ,
34
- start = 0 , limit = 25 ):
35
- return self . result_list ( project_key , plan_key , expand = expand , favourite = favourite , cloverEnabled = cloverEnabled ,
36
- label = label , start = start , limit = limit )
84
+ def comments (self , project_key , plan_key , build_number , start_index = 0 , max_results = 25 ):
85
+ resource = "result/{}-{}-{}/comment" . format ( project_key , plan_key , build_number )
86
+ params = { 'start-index' : start_index , 'max-results' : max_results }
87
+ return self . get ( self . resource_url ( resource ), params = params )
37
88
38
- def chart_list (self , reportKey , buildKeys , groupByPeriod , dateFrom = None , dateTo = None ,
39
- width = None , height = None ):
40
- return self .result_list ()
89
+ def create_comment (self , project_key , plan_key , build_number , comment , author = None ):
90
+ resource = "result/{}-{}-{}/comment" .format (project_key , plan_key , build_number )
91
+ comment_data = {'author' : author if author else self .username , 'content' : comment }
92
+ return self .post (self .resource_url (resource ), data = comment_data )
41
93
42
- def reports_list (self , expand = None , start = 0 , limit = 25 ):
43
- pass
94
+ def labels (self , project_key , plan_key , build_number , start_index = 0 , max_results = 25 ):
95
+ resource = "result/{}-{}-{}/label" .format (project_key , plan_key , build_number )
96
+ params = {'start-index' : start_index , 'max-results' : max_results }
97
+ return self .get (self .resource_url (resource ), params = params )
44
98
45
- def get_comments (self , project_key , plan_key , build_number ):
46
- pass
99
+ def create_label (self , project_key , plan_key , build_number , label ):
100
+ resource = "result/{}-{}-{}/label" .format (project_key , plan_key , build_number )
101
+ return self .post (self .resource_url (resource ), data = {'name' : label })
47
102
48
- def get_labels (self , project_key , plan_key , build_number ):
49
- pass
103
+ def delete_label (self , project_key , plan_key , build_number , label ):
104
+ resource = "result/{}-{}-{}/label/{}" .format (project_key , plan_key , build_number , label )
105
+ return self .delete (self .resource_url (resource ))
50
106
51
- def get_server_info (self ):
52
- pass
107
+ def server_info (self ):
108
+ return self . get ( self . resource_url ( 'info' ))
0 commit comments