11
11
12
12
13
13
class Jira (AtlassianRestAPI ):
14
-
15
14
"""
16
15
Provide permission information for the current user.
17
16
Reference: https://docs.atlassian.com/software/jira/docs/api/REST/8.5.0/#api/2
18
17
"""
19
18
20
19
def get_permissions (
21
- self , project_id = None , project_key = None , issue_id = None , issue_key = None
20
+ self , project_id = None , project_key = None , issue_id = None , issue_key = None
22
21
):
23
22
"""
24
23
Returns all permissions in the system and whether the currently logged in user has them.
@@ -201,7 +200,7 @@ def get_attachment_expand_raw(self, attachment_id):
201
200
"""
202
201
203
202
def get_audit_records (
204
- self , offset = None , limit = None , filter = None , from_date = None , to_date = None
203
+ self , offset = None , limit = None , filter = None , from_date = None , to_date = None
205
204
):
206
205
"""
207
206
Returns auditing records filtered using provided parameters
@@ -591,7 +590,7 @@ def remove_group(self, name, swap_group=None):
591
590
return self .delete (url , params = params )
592
591
593
592
def get_all_users_from_group (
594
- self , group , include_inactive_users = False , start = 0 , limit = 50
593
+ self , group , include_inactive_users = False , start = 0 , limit = 50
595
594
):
596
595
"""
597
596
Just wrapping method user group members
@@ -648,7 +647,7 @@ def issue(self, key, fields="*all"):
648
647
return self .get ("rest/api/2/issue/{0}?fields={1}" .format (key , fields ))
649
648
650
649
def get_issue (
651
- self , issue_id_or_key , fields = None , properties = None , update_history = True
650
+ self , issue_id_or_key , fields = None , properties = None , update_history = True
652
651
):
653
652
"""
654
653
Returns a full representation of the issue for the given issue key
@@ -1014,7 +1013,7 @@ def get_issue_remote_links(self, issue_key, global_id=None, internal_id=None):
1014
1013
return self .get (url , params = params )
1015
1014
1016
1015
def create_or_update_issue_remote_links (
1017
- self , issue_key , link_url , title , global_id = None , relationship = None
1016
+ self , issue_key , link_url , title , global_id = None , relationship = None
1018
1017
):
1019
1018
"""
1020
1019
Add Remote Link to Issue, update url if global_id is passed
@@ -1039,7 +1038,7 @@ def get_issue_remote_link_by_id(self, issue_key, link_id):
1039
1038
return self .get (url )
1040
1039
1041
1040
def update_issue_remote_link_by_id (
1042
- self , issue_key , link_id , url , title , global_id = None , relationship = None
1041
+ self , issue_key , link_id , url , title , global_id = None , relationship = None
1043
1042
):
1044
1043
"""
1045
1044
Update existing Remote Link on Issue
@@ -1081,7 +1080,7 @@ def get_issue_transitions(self, issue_key):
1081
1080
"to" : transition ["to" ]["name" ],
1082
1081
}
1083
1082
for transition in (
1084
- self .get_issue_transitions_full (issue_key ).json () or {}
1083
+ self .get_issue_transitions_full (issue_key ).json () or {}
1085
1084
).get ("transitions" )
1086
1085
]
1087
1086
else :
@@ -1092,7 +1091,7 @@ def get_issue_transitions(self, issue_key):
1092
1091
"to" : transition ["to" ]["name" ],
1093
1092
}
1094
1093
for transition in (
1095
- self .get_issue_transitions_full (issue_key ) or {}
1094
+ self .get_issue_transitions_full (issue_key ) or {}
1096
1095
).get ("transitions" )
1097
1096
]
1098
1097
@@ -1264,7 +1263,7 @@ def user_update_email(self, username, email):
1264
1263
return self .user_update (username , data = data )
1265
1264
1266
1265
def user_create (
1267
- self , username , email , display_name , password = None , notification = None
1266
+ self , username , email , display_name , password = None , notification = None
1268
1267
):
1269
1268
"""
1270
1269
Create a user in Jira
@@ -1361,10 +1360,10 @@ def user_disable(self, username):
1361
1360
return self .user_deactivate (username )
1362
1361
1363
1362
def user_disable_throw_rest_endpoint (
1364
- self ,
1365
- username ,
1366
- url = "rest/scriptrunner/latest/custom/disableUser" ,
1367
- param = "userName" ,
1363
+ self ,
1364
+ username ,
1365
+ url = "rest/scriptrunner/latest/custom/disableUser" ,
1366
+ param = "userName" ,
1368
1367
):
1369
1368
"""The disable method throw own rest enpoint"""
1370
1369
url = "{}?{}={}" .format (url , param , username )
@@ -1386,8 +1385,8 @@ def user_get_websudo(self):
1386
1385
answer .split (
1387
1386
'<meta id="atlassian-token" name="atlassian-token" content="'
1388
1387
)[1 ]
1389
- .split ("\n " )[0 ]
1390
- .split ('"' )[0 ]
1388
+ .split ("\n " )[0 ]
1389
+ .split ('"' )[0 ]
1391
1390
)
1392
1391
if atl_token :
1393
1392
data ["atl_token" ] = atl_token
@@ -1401,12 +1400,12 @@ def invalidate_websudo(self):
1401
1400
return self .delete ("rest/auth/1/websudo" )
1402
1401
1403
1402
def user_find_by_user_string (
1404
- self ,
1405
- username ,
1406
- start = 0 ,
1407
- limit = 50 ,
1408
- include_inactive_users = False ,
1409
- include_active_users = True ,
1403
+ self ,
1404
+ username ,
1405
+ start = 0 ,
1406
+ limit = 50 ,
1407
+ include_inactive_users = False ,
1408
+ include_active_users = True ,
1410
1409
):
1411
1410
"""
1412
1411
Fuzzy search using username and display name
@@ -1542,14 +1541,14 @@ def get_project_versions(self, key, expand=None):
1542
1541
return self .get ("rest/api/2/project/{}/versions" .format (key ), params = params )
1543
1542
1544
1543
def get_project_versions_paginated (
1545
- self ,
1546
- key ,
1547
- start = None ,
1548
- limit = None ,
1549
- order_by = None ,
1550
- expand = None ,
1551
- query = None ,
1552
- status = None ,
1544
+ self ,
1545
+ key ,
1546
+ start = None ,
1547
+ limit = None ,
1548
+ order_by = None ,
1549
+ expand = None ,
1550
+ query = None ,
1551
+ status = None ,
1553
1552
):
1554
1553
"""
1555
1554
Returns all versions for the specified project. Results are paginated.
@@ -1585,7 +1584,7 @@ def get_project_versions_paginated(
1585
1584
return self .get ("rest/api/2/project/{}/version" .format (key ), params = params )
1586
1585
1587
1586
def add_version (
1588
- self , project_key , project_id , version , is_archived = False , is_released = False
1587
+ self , project_key , project_id , version , is_archived = False , is_released = False
1589
1588
):
1590
1589
"""
1591
1590
Add missing version to project
@@ -1694,7 +1693,7 @@ def update_project(self, project_key, data, expand=None):
1694
1693
return self .put (url , data , params = params )
1695
1694
1696
1695
def update_project_category_for_project (
1697
- self , project_key , new_project_category_id , expand = None
1696
+ self , project_key , new_project_category_id , expand = None
1698
1697
):
1699
1698
"""
1700
1699
Updates a project.
@@ -1724,7 +1723,7 @@ def get_notification_scheme_for_project(self, project_id_or_key):
1724
1723
return self .get (url )
1725
1724
1726
1725
def assign_project_notification_scheme (
1727
- self , project_key , new_notification_scheme = ""
1726
+ self , project_key , new_notification_scheme = ""
1728
1727
):
1729
1728
"""
1730
1729
Updates a project.
@@ -1892,7 +1891,7 @@ def get_all_assignable_users_for_project(self, project_key, start=0, limit=50):
1892
1891
return self .get (url )
1893
1892
1894
1893
def get_assignable_users_for_issue (
1895
- self , issue_key , username = None , start = 0 , limit = 50
1894
+ self , issue_key , username = None , start = 0 , limit = 50
1896
1895
):
1897
1896
"""
1898
1897
Provide assignable users for issue
@@ -2208,26 +2207,25 @@ def jql(self, jql, fields="*all", start=0, limit=None, expand=None):
2208
2207
params ["expand" ] = expand
2209
2208
return self .get ("rest/api/2/search" , params = params )
2210
2209
2211
- def csv (self , jql , limit = 1000 ):
2210
+ def csv (self , jql , limit = 1000 , all_fields = True ):
2212
2211
"""
2213
- Get issues from jql search result with all related fields
2212
+ Get issues from jql search result with ALL or CURRENT fields
2213
+ default will be to return all fields
2214
2214
:param jql: JQL query
2215
2215
:param limit: max results in the output file
2216
+ :param all_fields: To return all fields or current fields only
2216
2217
:return: CSV file
2217
2218
"""
2218
- params = {"tempMax" : limit , "jqlQuery" : jql }
2219
- url = "sr/jira.issueviews:searchrequest-csv-all-fields/temp/SearchRequest.csv"
2220
- return self .get (
2221
- url ,
2222
- params = params ,
2223
- not_json_response = True ,
2224
- headers = {"Accept" : "application/csv" },
2225
- )
2226
2219
2227
- """
2228
- Priority
2229
- Reference: https://docs.atlassian.com/software/jira/docs/api/REST/8.5.0/#api/2/priority
2230
- """
2220
+ params = {"tempMax" : limit , "jqlQuery" : jql }
2221
+ if all_fields :
2222
+ url = 'sr/jira.issueviews:searchrequest-csv-all-fields/temp/SearchRequest.csv'
2223
+ else :
2224
+ url = 'sr/jira.issueviews:searchrequest-csv-current-fields/temp/SearchRequest.csv'
2225
+ return self .get (url ,
2226
+ params = params ,
2227
+ not_json_response = True ,
2228
+ headers = {"Accept" : "application/csv" }, )
2231
2229
2232
2230
def get_all_priorities (self ):
2233
2231
"""
@@ -2260,7 +2258,7 @@ def get_all_workflows(self):
2260
2258
return self .get (url )
2261
2259
2262
2260
def get_workflows_paginated (
2263
- self , startAt = None , maxResults = None , workflowName = None , expand = None
2261
+ self , startAt = None , maxResults = None , workflowName = None , expand = None
2264
2262
):
2265
2263
"""
2266
2264
Provide all workflows paginated (see https://developer.atlassian.com/cloud/jira/platform/rest/v2/\
@@ -2599,11 +2597,11 @@ def get_project_validated_key(self, key):
2599
2597
"""
2600
2598
2601
2599
def reindex (
2602
- self ,
2603
- comments = True ,
2604
- change_history = True ,
2605
- worklogs = True ,
2606
- indexing_type = "BACKGROUND_PREFERRED" ,
2600
+ self ,
2601
+ comments = True ,
2602
+ change_history = True ,
2603
+ worklogs = True ,
2604
+ indexing_type = "BACKGROUND_PREFERRED" ,
2607
2605
):
2608
2606
"""
2609
2607
Reindex the Jira instance
@@ -2708,7 +2706,7 @@ def tempo_account_get_accounts_by_jira_project(self, project_id):
2708
2706
return self .get (url )
2709
2707
2710
2708
def tempo_account_associate_with_jira_project (
2711
- self , account_id , project_id , default_account = False , link_type = "MANUAL"
2709
+ self , account_id , project_id , default_account = False , link_type = "MANUAL"
2712
2710
):
2713
2711
"""
2714
2712
The AccountLinkBean for associate Account with project
@@ -2959,7 +2957,7 @@ def tempo_timesheets_get_configuration(self):
2959
2957
return self .get (url )
2960
2958
2961
2959
def tempo_timesheets_get_team_utilization (
2962
- self , team_id , date_from , date_to = None , group_by = None
2960
+ self , team_id , date_from , date_to = None , group_by = None
2963
2961
):
2964
2962
"""
2965
2963
GEt team utulization. Response in json
@@ -2977,13 +2975,13 @@ def tempo_timesheets_get_team_utilization(
2977
2975
return self .get (url , params = params )
2978
2976
2979
2977
def tempo_timesheets_get_worklogs (
2980
- self ,
2981
- date_from = None ,
2982
- date_to = None ,
2983
- username = None ,
2984
- project_key = None ,
2985
- account_key = None ,
2986
- team_id = None ,
2978
+ self ,
2979
+ date_from = None ,
2980
+ date_to = None ,
2981
+ username = None ,
2982
+ project_key = None ,
2983
+ account_key = None ,
2984
+ team_id = None ,
2987
2985
):
2988
2986
"""
2989
2987
@@ -3051,7 +3049,7 @@ def tempo_timesheets_get_worklogs_by_issue(self, issue):
3051
3049
return self .get (url )
3052
3050
3053
3051
def tempo_timesheets_write_worklog (
3054
- self , worker , started , time_spend_in_seconds , issue_id , comment = None
3052
+ self , worker , started , time_spend_in_seconds , issue_id , comment = None
3055
3053
):
3056
3054
"""
3057
3055
Log work for user
@@ -3205,7 +3203,7 @@ def tempo_teams_remove_member(self, team_id, member_id, membership_id):
3205
3203
return self .delete (url )
3206
3204
3207
3205
def tempo_teams_update_member_information (
3208
- self , team_id , member_id , membership_id , data
3206
+ self , team_id , member_id , membership_id , data
3209
3207
):
3210
3208
"""
3211
3209
Update team membership attribute info
@@ -3234,7 +3232,7 @@ def tempo_teams_get_memberships_for_member(self, username):
3234
3232
# Resource: https://docs.atlassian.com/jira-software/REST/7.3.1/
3235
3233
#######################################################################
3236
3234
def get_all_agile_boards (
3237
- self , board_name = None , project_key = None , board_type = None , start = 0 , limit = 50
3235
+ self , board_name = None , project_key = None , board_type = None , start = 0 , limit = 50
3238
3236
):
3239
3237
"""
3240
3238
Returns all boards. This only includes boards that the user has permission to view.
0 commit comments