@@ -4993,6 +4993,19 @@ def tempo_teams_get_memberships_for_member(self, username: str) -> T_resp_json:
4993
4993
# Resource: https://docs.atlassian.com/jira-software/REST/7.3.1/
4994
4994
#######################################################################
4995
4995
# /rest/agile/1.0/backlog/issue
4996
+ def get_agile_resource_url (self , resource : str , legacy_api : bool = False ) -> str :
4997
+ """
4998
+ Prepare an 'Agile' API-specific URL relying on defaults set for the client.
4999
+
5000
+ :param resource: Name of an endpoint
5001
+ :param legacy_api: If True - use 'greenhopper' as an API type, else - use a newer, 'agile', name.
5002
+ :return: String with a full URL path to resource
5003
+ """
5004
+ api_version = "1.0"
5005
+ api_type = "greenhopper" if legacy_api else "agile"
5006
+ api_root = self .api_root .replace ("rest/api" , f"rest/{ api_type } " )
5007
+ return self .resource_url (resource = resource , api_root = api_root , api_version = api_version )
5008
+
4996
5009
def move_issues_to_backlog (self , issue_keys : list ) -> T_resp_json :
4997
5010
"""
4998
5011
Move issues to backlog
@@ -5012,7 +5025,8 @@ def add_issues_to_backlog(self, issues: list) -> T_resp_json:
5012
5025
"""
5013
5026
if not isinstance (issues , list ):
5014
5027
raise ValueError ("`issues` param should be List of Issue Keys" )
5015
- url = "/rest/agile/1.0/backlog/issue"
5028
+ resource = "backlog/issue"
5029
+ url = self .get_agile_resource_url (resource )
5016
5030
data = dict (issues = issues )
5017
5031
return self .post (url , data = data )
5018
5032
@@ -5021,7 +5035,8 @@ def get_agile_board_by_filter_id(self, filter_id: T_id) -> T_resp_json:
5021
5035
Gets an agile board by the filter id
5022
5036
:param filter_id: int, str
5023
5037
"""
5024
- url = f"rest/agile/1.0/board/filter/{ filter_id } "
5038
+ resource = f"board/filter/{ filter_id } "
5039
+ url = self .get_agile_resource_url (resource )
5025
5040
return self .get (url )
5026
5041
5027
5042
# /rest/agile/1.0/board
@@ -5033,10 +5048,11 @@ def create_agile_board(self, name: str, type: str, filter_id: T_id, location: Op
5033
5048
:param filter_id: int
5034
5049
:param location: dict, Optional. Only specify this for Jira Cloud!
5035
5050
"""
5051
+ resource = "board"
5052
+ url = self .get_agile_resource_url (resource )
5036
5053
data : dict = {"name" : name , "type" : type , "filterId" : filter_id }
5037
5054
if location :
5038
5055
data ["location" ] = location
5039
- url = "rest/agile/1.0/board"
5040
5056
return self .post (url , data = data )
5041
5057
5042
5058
def get_all_agile_boards (
@@ -5056,7 +5072,8 @@ def get_all_agile_boards(
5056
5072
:param limit:
5057
5073
:return:
5058
5074
"""
5059
- url = "rest/agile/1.0/board"
5075
+ resource = "board"
5076
+ url = self .get_agile_resource_url (resource )
5060
5077
params : dict = {}
5061
5078
if board_name :
5062
5079
params ["name" ] = board_name
@@ -5077,7 +5094,8 @@ def delete_agile_board(self, board_id: T_id) -> T_resp_json:
5077
5094
:param board_id:
5078
5095
:return:
5079
5096
"""
5080
- url = f"rest/agile/1.0/board/{ str (board_id )} "
5097
+ resource = f"board/{ board_id } "
5098
+ url = self .get_agile_resource_url (resource )
5081
5099
return self .delete (url )
5082
5100
5083
5101
def get_agile_board (self , board_id : T_id ) -> T_resp_json :
@@ -5086,7 +5104,8 @@ def get_agile_board(self, board_id: T_id) -> T_resp_json:
5086
5104
:param board_id:
5087
5105
:return:
5088
5106
"""
5089
- url = f"rest/agile/1.0/board/{ str (board_id )} "
5107
+ resource = f"board/{ board_id } "
5108
+ url = self .get_agile_resource_url (resource )
5090
5109
return self .get (url )
5091
5110
5092
5111
def get_issues_for_backlog (self , board_id : T_id ) -> T_resp_json :
@@ -5099,7 +5118,8 @@ def get_issues_for_backlog(self, board_id: T_id) -> T_resp_json:
5099
5118
By default, the returned issues are ordered by rank.
5100
5119
:param board_id: int, str
5101
5120
"""
5102
- url = f"rest/agile/1.0/board/{ board_id } /backlog"
5121
+ resource = f"board/{ board_id } /backlog"
5122
+ url = self .get_agile_resource_url (resource )
5103
5123
return self .get (url )
5104
5124
5105
5125
def get_agile_board_configuration (self , board_id : T_id ) -> T_resp_json :
@@ -5126,7 +5146,8 @@ def get_agile_board_configuration(self, board_id: T_id) -> T_resp_json:
5126
5146
:param board_id:
5127
5147
:return:
5128
5148
"""
5129
- url = f"rest/agile/1.0/board/{ str (board_id )} /configuration"
5149
+ resource = f"board/{ board_id } /configuration"
5150
+ url = self .get_agile_resource_url (resource )
5130
5151
return self .get (url )
5131
5152
5132
5153
def get_issues_for_board (
@@ -5153,6 +5174,8 @@ def get_issues_for_board(
5153
5174
:param expand: OPTIONAL: expand the search result
5154
5175
:return:
5155
5176
"""
5177
+ resource = f"board/{ board_id } /issue"
5178
+ url = self .get_agile_resource_url (resource )
5156
5179
params : dict = {}
5157
5180
if start is not None :
5158
5181
params ["startAt" ] = int (start )
@@ -5167,7 +5190,6 @@ def get_issues_for_board(
5167
5190
if expand is not None :
5168
5191
params ["expand" ] = expand
5169
5192
5170
- url = f"rest/agile/1.0/board/{ board_id } /issue"
5171
5193
return self .get (url , params = params )
5172
5194
5173
5195
# /rest/agile/1.0/board/{boardId}/epic
@@ -5190,7 +5212,8 @@ def get_epics(
5190
5212
See the 'Pagination' section at the top of this page for more details.
5191
5213
:return:
5192
5214
"""
5193
- url = f"rest/agile/1.0/board/{ board_id } /epic"
5215
+ resource = f"board/{ board_id } /epic"
5216
+ url = self .get_agile_resource_url (resource )
5194
5217
params : dict = {}
5195
5218
if done :
5196
5219
params ["done" ] = done
@@ -5236,7 +5259,8 @@ def get_issues_for_epic(
5236
5259
If you exceed this limit, your results will be truncated.
5237
5260
:return:
5238
5261
"""
5239
- url = f"/rest/agile/1.0/board/{ board_id } /epic/{ epic_id } /issue"
5262
+ resource = f"board/{ board_id } /epic/{ epic_id } /issue"
5263
+ url = self .get_agile_resource_url (resource )
5240
5264
params : dict = {}
5241
5265
if jql :
5242
5266
params ["jql" ] = jql
@@ -5285,7 +5309,8 @@ def get_issues_without_epic(
5285
5309
If you exceed this limit, your results will be truncated.
5286
5310
:return:
5287
5311
"""
5288
- url = f"/rest/agile/1.0/board/{ board_id } /epic/none/issue"
5312
+ resource = f"board/{ board_id } /epic/none/issue"
5313
+ url = self .get_agile_resource_url (resource )
5289
5314
params : dict = {}
5290
5315
if jql :
5291
5316
params ["jql" ] = jql
@@ -5321,7 +5346,8 @@ def get_all_projects_associated_with_board(self, board_id: T_id, start: int = 0,
5321
5346
See the 'Pagination' section at the top of this page for more details
5322
5347
:return:
5323
5348
"""
5324
- url = f"/rest/agile/1.0/board/{ board_id } /project"
5349
+ resource = f"board/{ board_id } /project"
5350
+ url = self .get_agile_resource_url (resource )
5325
5351
params : dict = {}
5326
5352
if start :
5327
5353
params ["startAt" ] = start
@@ -5336,7 +5362,8 @@ def get_agile_board_properties(self, board_id: T_id) -> T_resp_json:
5336
5362
The user who retrieves the property keys is required to have permissions to view the board.
5337
5363
:param board_id: int, str
5338
5364
"""
5339
- url = f"rest/agile/1.0/board/{ board_id } /properties"
5365
+ resource = f"board/{ board_id } /properties"
5366
+ url = self .get_agile_resource_url (resource )
5340
5367
return self .get (url )
5341
5368
5342
5369
def set_agile_board_property (self , board_id : T_id , property_key : str ) -> T_resp_json :
@@ -5349,7 +5376,8 @@ def set_agile_board_property(self, board_id: T_id, property_key: str) -> T_resp_
5349
5376
:param property_key:
5350
5377
:return:
5351
5378
"""
5352
- url = f"/rest/agile/1.0/board/{ board_id } /properties/{ property_key } "
5379
+ resource = f"board/{ board_id } /properties/{ property_key } "
5380
+ url = self .get_agile_resource_url (resource )
5353
5381
return self .put (url )
5354
5382
5355
5383
def get_agile_board_property (self , board_id : T_id , property_key : str ) -> T_resp_json :
@@ -5360,7 +5388,8 @@ def get_agile_board_property(self, board_id: T_id, property_key: str) -> T_resp_
5360
5388
:param property_key:
5361
5389
:return:
5362
5390
"""
5363
- url = f"/rest/agile/1.0/board/{ board_id } /properties/{ property_key } "
5391
+ resource = f"board/{ board_id } /properties/{ property_key } "
5392
+ url = self .get_agile_resource_url (resource )
5364
5393
return self .get (url )
5365
5394
5366
5395
def delete_agile_board_property (self , board_id : T_id , property_key : str ) -> T_resp_json :
@@ -5371,7 +5400,8 @@ def delete_agile_board_property(self, board_id: T_id, property_key: str) -> T_re
5371
5400
:param property_key:
5372
5401
:return:
5373
5402
"""
5374
- url = f"/rest/agile/1.0/board/{ board_id } /properties/{ property_key } "
5403
+ resource = f"board/{ board_id } /properties/{ property_key } "
5404
+ url = self .get_agile_resource_url (resource )
5375
5405
return self .delete (url )
5376
5406
5377
5407
# /rest/agile/1.0/board/{boardId}/settings/refined-velocity
@@ -5381,7 +5411,8 @@ def get_agile_board_refined_velocity(self, board_id: T_id) -> T_resp_json:
5381
5411
:param board_id:
5382
5412
:return:
5383
5413
"""
5384
- url = f"/rest/agile/1.0/board/{ board_id } /settings/refined-velocity"
5414
+ resource = f"board/{ board_id } /settings/refined-velocity"
5415
+ url = self .get_agile_resource_url (resource )
5385
5416
return self .get (url )
5386
5417
5387
5418
def set_agile_board_refined_velocity (self , board_id : T_id , data : dict ) -> T_resp_json :
@@ -5391,7 +5422,8 @@ def set_agile_board_refined_velocity(self, board_id: T_id, data: dict) -> T_resp
5391
5422
:param data:
5392
5423
:return:
5393
5424
"""
5394
- url = f"/rest/agile/1.0/board/{ board_id } /settings/refined-velocity"
5425
+ resource = f"board/{ board_id } /settings/refined-velocity"
5426
+ url = self .get_agile_resource_url (resource )
5395
5427
return self .put (url , data = data )
5396
5428
5397
5429
# /rest/agile/1.0/board/{boardId}/sprint
@@ -5414,14 +5446,15 @@ def get_all_sprints_from_board(
5414
5446
See the 'Pagination' section at the top of this page for more details.
5415
5447
:return:
5416
5448
"""
5449
+ resource = f"board/{ board_id } /sprint"
5450
+ url = self .get_agile_resource_url (resource )
5417
5451
params : dict = {}
5418
5452
if start :
5419
5453
params ["startAt" ] = start
5420
5454
if limit :
5421
5455
params ["maxResults" ] = limit
5422
5456
if state :
5423
5457
params ["state" ] = state
5424
- url = f"rest/agile/1.0/board/{ board_id } /sprint"
5425
5458
return self .get (url , params = params )
5426
5459
5427
5460
@deprecated (version = "3.42.0" , reason = "Use get_all_sprints_from_board instead" )
@@ -5472,7 +5505,8 @@ def get_all_issues_for_sprint_in_board(
5472
5505
'jira.search.views.default.max' in your JIRA instance.
5473
5506
If you exceed this limit, your results will be truncated.
5474
5507
"""
5475
- url = f"/rest/agile/1.0/board/{ board_id } /sprint/{ sprint_id } /issue"
5508
+ resource = f"board/{ board_id } /sprint/{ sprint_id } /issue"
5509
+ url = self .get_agile_resource_url (resource )
5476
5510
params : dict = {}
5477
5511
if jql :
5478
5512
params ["jql" ] = jql
@@ -5510,14 +5544,15 @@ def get_all_versions_from_board(
5510
5544
See the 'Pagination' section at the top of this page for more details.
5511
5545
:return:
5512
5546
"""
5547
+ resource = f"board/{ board_id } /version"
5548
+ url = self .get_agile_resource_url (resource )
5513
5549
params : dict = {}
5514
5550
if released :
5515
5551
params ["released" ] = released
5516
5552
if start :
5517
5553
params ["startAt" ] = start
5518
5554
if limit :
5519
5555
params ["maxResults" ] = limit
5520
- url = f"rest/agile/1.0/board/{ board_id } /version"
5521
5556
return self .get (url , params = params )
5522
5557
5523
5558
def create_sprint (
@@ -5544,7 +5579,8 @@ def create_sprint(
5544
5579
https://docs.atlassian.com/jira-software/REST/8.9.0/#agile/1.0/sprint
5545
5580
isoformat can be created with datetime.datetime.isoformat()
5546
5581
"""
5547
- url = "/rest/agile/1.0/sprint"
5582
+ resource = "sprint"
5583
+ url = self .get_agile_resource_url (resource )
5548
5584
data = dict (name = name , originBoardId = board_id )
5549
5585
if start_date :
5550
5586
data ["startDate" ] = start_date
@@ -5580,7 +5616,8 @@ def get_sprint(self, sprint_id: T_id) -> T_resp_json:
5580
5616
:param sprint_id:
5581
5617
:return:
5582
5618
"""
5583
- url = f"rest/agile/1.0/sprint/{ sprint_id } "
5619
+ resource = f"sprint/{ sprint_id } "
5620
+ url = self .get_agile_resource_url (resource )
5584
5621
return self .get (url )
5585
5622
5586
5623
def rename_sprint (self , sprint_id : T_id , name : str , start_date : str , end_date : str ) -> T_resp_json :
@@ -5592,8 +5629,10 @@ def rename_sprint(self, sprint_id: T_id, name: str, start_date: str, end_date: s
5592
5629
:param end_date:
5593
5630
:return:
5594
5631
"""
5632
+ resource = f"sprint/{ sprint_id } "
5633
+ url = self .get_agile_resource_url (resource , legacy_api = True )
5595
5634
return self .put (
5596
- f"rest/greenhopper/1.0/sprint/ { sprint_id } " ,
5635
+ url ,
5597
5636
data = {"name" : name , "startDate" : start_date , "endDate" : end_date },
5598
5637
)
5599
5638
@@ -5605,7 +5644,9 @@ def delete_sprint(self, sprint_id: T_id) -> T_resp_json:
5605
5644
:param sprint_id:
5606
5645
:return:
5607
5646
"""
5608
- return self .delete (f"rest/agile/1.0/sprint/{ sprint_id } " )
5647
+ resource = f"sprint/{ sprint_id } "
5648
+ url = self .get_agile_resource_url (resource )
5649
+ return self .delete (url )
5609
5650
5610
5651
def update_partially_sprint (self , sprint_id : T_id , data : dict ) -> T_resp_json :
5611
5652
"""
@@ -5625,7 +5666,9 @@ def update_partially_sprint(self, sprint_id: T_id, data: dict) -> T_resp_json:
5625
5666
:param data: { "name": "new name"}
5626
5667
:return:
5627
5668
"""
5628
- return self .post (f"rest/agile/1.0/sprint/{ sprint_id } " , data = data )
5669
+ resource = f"sprint/{ sprint_id } "
5670
+ url = self .get_agile_resource_url (resource )
5671
+ return self .post (url , data = data )
5629
5672
5630
5673
def get_sprint_issues (self , sprint_id : T_id , start : T_id , limit : T_id ) -> T_resp_json :
5631
5674
"""
@@ -5644,12 +5687,13 @@ def get_sprint_issues(self, sprint_id: T_id, start: T_id, limit: T_id) -> T_resp
5644
5687
If you exceed this limit, your results will be truncated.
5645
5688
:return:
5646
5689
"""
5690
+ resource = f"sprint/{ sprint_id } /issue"
5691
+ url = self .get_agile_resource_url (resource )
5647
5692
params : dict = {}
5648
5693
if start :
5649
5694
params ["startAt" ] = start
5650
5695
if limit :
5651
5696
params ["maxResults" ] = limit
5652
- url = f"rest/agile/1.0/sprint/{ sprint_id } /issue"
5653
5697
return self .get (url , params = params )
5654
5698
5655
5699
def update_rank (self , issues_to_rank : list , rank_before : str , customfield_number : T_id ) -> T_resp_json :
@@ -5660,9 +5704,11 @@ def update_rank(self, issues_to_rank: list, rank_before: str, customfield_number
5660
5704
:param customfield_number: The number of the custom field Rank
5661
5705
:return:
5662
5706
"""
5707
+ resource = "issue/rank"
5708
+ url = self .get_agile_resource_url (resource )
5663
5709
5664
5710
return self .put (
5665
- "rest/agile/1.0/issue/rank" ,
5711
+ url ,
5666
5712
data = {
5667
5713
"issues" : issues_to_rank ,
5668
5714
"rankBeforeIssue" : rank_before ,
@@ -5698,7 +5744,8 @@ def flag_issue(self, issue_keys: List[T_id], flag: bool = True) -> T_resp_json:
5698
5744
:return: POST request response.
5699
5745
:rtype: dict
5700
5746
"""
5701
- url = "rest/greenhopper/1.0/xboard/issue/flag/flag.json"
5747
+ resource = f"xboard/issue/flag/flag.json"
5748
+ url = self .get_agile_resource_url (resource , legacy_api = True )
5702
5749
data = {"issueKeys" : issue_keys , "flag" : flag }
5703
5750
return self .post (url , data )
5704
5751
0 commit comments