atlassian-python-api 4.0.0__py3-none-any.whl → 4.0.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
atlassian/jira.py CHANGED
@@ -1,13 +1,17 @@
1
1
  # coding=utf-8
2
2
  import logging
3
- import re
4
3
  import os
4
+ import re
5
+ from typing import Any, BinaryIO, Dict, List, Optional, Union, cast
5
6
  from warnings import warn
7
+
6
8
  from deprecated import deprecated
7
- from requests import HTTPError
9
+ from requests import HTTPError, Response
10
+ from typing_extensions import Literal
8
11
 
9
12
  from .errors import ApiNotFoundError, ApiPermissionError
10
13
  from .rest_client import AtlassianRestAPI
14
+ from .typehints import T_id, T_resp_json
11
15
 
12
16
  log = logging.getLogger(__name__)
13
17
 
@@ -18,7 +22,7 @@ class Jira(AtlassianRestAPI):
18
22
  Reference: https://docs.atlassian.com/software/jira/docs/api/REST/8.5.0/#api/2
19
23
  """
20
24
 
21
- def __init__(self, url, *args, **kwargs):
25
+ def __init__(self, url: str, *args: Any, **kwargs: Any):
22
26
  if "api_version" not in kwargs:
23
27
  kwargs["api_version"] = "2"
24
28
 
@@ -26,12 +30,12 @@ class Jira(AtlassianRestAPI):
26
30
 
27
31
  def _get_paged(
28
32
  self,
29
- url,
30
- params=None,
31
- data=None,
32
- flags=None,
33
- trailing=None,
34
- absolute=False,
33
+ url: str,
34
+ params: Optional[dict] = None,
35
+ data: Optional[dict] = None,
36
+ flags: Optional[list] = None,
37
+ trailing: Optional[bool] = None,
38
+ absolute: bool = False,
35
39
  ):
36
40
  """
37
41
  Used to get the paged data
@@ -51,13 +55,16 @@ class Jira(AtlassianRestAPI):
51
55
  params = {}
52
56
 
53
57
  while True:
54
- response = super(Jira, self).get(
55
- url,
56
- trailing=trailing,
57
- params=params,
58
- data=data,
59
- flags=flags,
60
- absolute=absolute,
58
+ response = cast(
59
+ "dict",
60
+ super(Jira, self).get(
61
+ url,
62
+ trailing=trailing,
63
+ params=params,
64
+ data=data,
65
+ flags=flags,
66
+ absolute=absolute,
67
+ ),
61
68
  )
62
69
  values = response.get("values", [])
63
70
  for value in values:
@@ -66,7 +73,7 @@ class Jira(AtlassianRestAPI):
66
73
  if response.get("isLast", False) or len(values) == 0:
67
74
  break
68
75
 
69
- url = response.get("nextPage")
76
+ url = cast("str", response.get("nextPage"))
70
77
  if url is None:
71
78
  break
72
79
  # From now on we have absolute URLs with parameters
@@ -82,12 +89,12 @@ class Jira(AtlassianRestAPI):
82
89
 
83
90
  def get_permissions(
84
91
  self,
85
- permissions,
86
- project_id=None,
87
- project_key=None,
88
- issue_id=None,
89
- issue_key=None,
90
- ):
92
+ permissions: str,
93
+ project_id: Optional[T_id] = None,
94
+ project_key: Optional[T_id] = None,
95
+ issue_id: Optional[T_id] = None,
96
+ issue_key: Optional[T_id] = None,
97
+ ) -> T_resp_json:
91
98
  """
92
99
  Returns a list of permissions indicating which permissions the user has. Details of the user's permissions can
93
100
  be obtained in a global, project, issue or comment context.
@@ -122,7 +129,7 @@ class Jira(AtlassianRestAPI):
122
129
  """
123
130
 
124
131
  url = self.resource_url("mypermissions")
125
- params = {"permissions": permissions}
132
+ params: Dict[str, Union[str, int]] = {"permissions": permissions}
126
133
 
127
134
  if project_id:
128
135
  params["projectId"] = project_id
@@ -135,7 +142,7 @@ class Jira(AtlassianRestAPI):
135
142
 
136
143
  return self.get(url, params=params)
137
144
 
138
- def get_all_permissions(self):
145
+ def get_all_permissions(self) -> T_resp_json:
139
146
  """
140
147
  Returns all permissions that are present in the Jira instance -
141
148
  Global, Project and the global ones added by plugins
@@ -149,7 +156,9 @@ class Jira(AtlassianRestAPI):
149
156
  Reference: https://docs.atlassian.com/software/jira/docs/api/REST/8.5.0/#api/2/application-properties
150
157
  """
151
158
 
152
- def get_property(self, key=None, permission_level=None, key_filter=None):
159
+ def get_property(
160
+ self, key: Optional[T_id] = None, permission_level: Optional[str] = None, key_filter: Optional[str] = None
161
+ ) -> T_resp_json:
153
162
  """
154
163
  Returns an application property
155
164
  :param key: str
@@ -159,7 +168,7 @@ class Jira(AtlassianRestAPI):
159
168
  """
160
169
 
161
170
  url = self.resource_url("application-properties")
162
- params = {}
171
+ params: dict = {}
163
172
 
164
173
  if key:
165
174
  params["key"] = key
@@ -170,7 +179,7 @@ class Jira(AtlassianRestAPI):
170
179
 
171
180
  return self.get(url, params=params)
172
181
 
173
- def set_property(self, property_id, value):
182
+ def set_property(self, property_id: T_id, value: str) -> T_resp_json:
174
183
  """
175
184
  Modify an application property via PUT. The "value" field present in the PUT will override the existing value.
176
185
  :param property_id:
@@ -183,7 +192,7 @@ class Jira(AtlassianRestAPI):
183
192
 
184
193
  return self.put(url, data=data)
185
194
 
186
- def get_advanced_settings(self):
195
+ def get_advanced_settings(self) -> T_resp_json:
187
196
  """
188
197
  Returns the properties that are displayed on the "General Configuration > Advanced Settings" page.
189
198
  :return:
@@ -197,7 +206,7 @@ class Jira(AtlassianRestAPI):
197
206
  Reference: https://docs.atlassian.com/software/jira/docs/api/REST/8.5.0/#api/2/applicationrole
198
207
  """
199
208
 
200
- def get_all_application_roles(self):
209
+ def get_all_application_roles(self) -> T_resp_json:
201
210
  """
202
211
  Returns all ApplicationRoles in the system
203
212
  :return:
@@ -205,7 +214,7 @@ class Jira(AtlassianRestAPI):
205
214
  url = self.resource_url("applicationrole")
206
215
  return self.get(url) or {}
207
216
 
208
- def get_application_role(self, role_key):
217
+ def get_application_role(self, role_key: str) -> T_resp_json:
209
218
  """
210
219
  Returns the ApplicationRole with passed key if it exists
211
220
  :param role_key: str
@@ -220,7 +229,7 @@ class Jira(AtlassianRestAPI):
220
229
  Reference: https://docs.atlassian.com/software/jira/docs/api/REST/8.5.0/#api/2/attachment
221
230
  """
222
231
 
223
- def get_attachments_ids_from_issue(self, issue):
232
+ def get_attachments_ids_from_issue(self, issue: T_id) -> List[Dict[str, str]]:
224
233
  """
225
234
  Get attachments IDs from jira issue
226
235
  :param issue: str : jira issue key
@@ -232,7 +241,7 @@ class Jira(AtlassianRestAPI):
232
241
  list_attachments_id.append({"filename": attachment["filename"], "attachment_id": attachment["id"]})
233
242
  return list_attachments_id
234
243
 
235
- def get_attachment(self, attachment_id):
244
+ def get_attachment(self, attachment_id: T_id) -> T_resp_json:
236
245
  """
237
246
  Returns the meta-data for an attachment, including the URI of the actual attached file
238
247
  :param attachment_id: int
@@ -242,7 +251,7 @@ class Jira(AtlassianRestAPI):
242
251
  url = f"{base_url}/{attachment_id}"
243
252
  return self.get(url)
244
253
 
245
- def download_issue_attachments(self, issue, path=None):
254
+ def download_issue_attachments(self, issue: T_id, path: Optional[str] = None) -> Optional[str]:
246
255
  """
247
256
  Downloads all attachments from a Jira issue.
248
257
  :param issue: The issue-key of the Jira issue
@@ -252,7 +261,9 @@ class Jira(AtlassianRestAPI):
252
261
  return self.download_attachments_from_issue(issue=issue, path=path, cloud=self.cloud)
253
262
 
254
263
  @deprecated(version="3.41.20", reason="Use download_issue_attachments instead")
255
- def download_attachments_from_issue(self, issue, path=None, cloud=True):
264
+ def download_attachments_from_issue(
265
+ self, issue: T_id, path: Optional[str] = None, cloud: bool = True
266
+ ) -> Optional[str]:
256
267
  """
257
268
  Downloads all attachments from a Jira issue.
258
269
  :param issue: The issue-key of the Jira issue
@@ -291,7 +302,7 @@ class Jira(AtlassianRestAPI):
291
302
  except Exception as e:
292
303
  raise e
293
304
 
294
- def get_attachment_content(self, attachment_id):
305
+ def get_attachment_content(self, attachment_id: T_id) -> bytes:
295
306
  """
296
307
  Returns the content for an attachment
297
308
  :param attachment_id: int
@@ -301,7 +312,7 @@ class Jira(AtlassianRestAPI):
301
312
  url = f"{base_url}/content/{attachment_id}"
302
313
  return self.get(url, not_json_response=True)
303
314
 
304
- def remove_attachment(self, attachment_id):
315
+ def remove_attachment(self, attachment_id: T_id) -> T_resp_json:
305
316
  """
306
317
  Remove an attachment from an issue
307
318
  :param attachment_id: int
@@ -311,7 +322,7 @@ class Jira(AtlassianRestAPI):
311
322
  url = f"{base_url}/{attachment_id}"
312
323
  return self.delete(url)
313
324
 
314
- def get_attachment_meta(self):
325
+ def get_attachment_meta(self) -> T_resp_json:
315
326
  """
316
327
  Returns the meta information for an attachments,
317
328
  specifically if they are enabled and the maximum upload size allowed
@@ -320,7 +331,7 @@ class Jira(AtlassianRestAPI):
320
331
  url = self.resource_url("attachment/meta")
321
332
  return self.get(url)
322
333
 
323
- def get_attachment_expand_human(self, attachment_id):
334
+ def get_attachment_expand_human(self, attachment_id: T_id) -> T_resp_json:
324
335
  """
325
336
  Returns the information for an expandable attachment in human-readable format
326
337
  :param attachment_id: int
@@ -330,7 +341,7 @@ class Jira(AtlassianRestAPI):
330
341
  url = f"{base_url}/{attachment_id}/expand/human"
331
342
  return self.get(url)
332
343
 
333
- def get_attachment_expand_raw(self, attachment_id):
344
+ def get_attachment_expand_raw(self, attachment_id: T_id) -> T_resp_json:
334
345
  """
335
346
  Returns the information for an expandable attachment in raw format
336
347
  :param attachment_id: int
@@ -347,12 +358,12 @@ class Jira(AtlassianRestAPI):
347
358
 
348
359
  def get_audit_records(
349
360
  self,
350
- offset=None,
351
- limit=None,
352
- filter=None,
353
- from_date=None,
354
- to_date=None,
355
- ):
361
+ offset: Optional[int] = None,
362
+ limit: Optional[int] = None,
363
+ filter: Optional[str] = None,
364
+ from_date: Optional[str] = None,
365
+ to_date: Optional[str] = None,
366
+ ) -> T_resp_json:
356
367
  """
357
368
  Returns auditing records filtered using provided parameters
358
369
  :param offset: the number of record from which search starts
@@ -368,7 +379,7 @@ class Jira(AtlassianRestAPI):
368
379
  the 'to' timestamp will be provided in response
369
380
  :return:
370
381
  """
371
- params = {}
382
+ params: dict = {}
372
383
  if offset:
373
384
  params["offset"] = offset
374
385
  if limit:
@@ -382,7 +393,7 @@ class Jira(AtlassianRestAPI):
382
393
  url = self.resource_url("auditing/record")
383
394
  return self.get(url, params=params) or {}
384
395
 
385
- def post_audit_record(self, audit_record):
396
+ def post_audit_record(self, audit_record: Union[dict, str]) -> T_resp_json:
386
397
  """
387
398
  Store a record in Audit Log
388
399
  :param audit_record: json with compat https://docs.atlassian.com/jira/REST/schema/audit-record#
@@ -396,7 +407,7 @@ class Jira(AtlassianRestAPI):
396
407
  Reference: https://docs.atlassian.com/software/jira/docs/api/REST/8.5.0/#api/2/avatar
397
408
  """
398
409
 
399
- def get_all_system_avatars(self, avatar_type="user"):
410
+ def get_all_system_avatars(self, avatar_type: str = "user") -> T_resp_json:
400
411
  """
401
412
  Returns all system avatars of the given type.
402
413
  :param avatar_type:
@@ -412,11 +423,15 @@ class Jira(AtlassianRestAPI):
412
423
  Reference: https://docs.atlassian.com/software/jira/docs/api/REST/8.5.0/#api/2/cluster
413
424
  """
414
425
 
415
- def get_cluster_all_nodes(self):
426
+ def get_cluster_all_nodes(self) -> T_resp_json:
427
+ """
428
+ Get all nodes in the cluster
429
+ :return:
430
+ """
416
431
  url = self.resource_url("cluster/nodes")
417
432
  return self.get(url)
418
433
 
419
- def delete_cluster_node(self, node_id):
434
+ def delete_cluster_node(self, node_id: T_id) -> T_resp_json:
420
435
  """
421
436
  Delete the node from the cluster if state of node is OFFLINE
422
437
  :param node_id: str
@@ -426,7 +441,7 @@ class Jira(AtlassianRestAPI):
426
441
  url = f"{base_url}/{node_id}"
427
442
  return self.delete(url)
428
443
 
429
- def set_node_to_offline(self, node_id):
444
+ def set_node_to_offline(self, node_id: T_id) -> T_resp_json:
430
445
  """
431
446
  Change the node's state to offline if the node is reporting as active, but is not alive
432
447
  :param node_id: str
@@ -436,16 +451,18 @@ class Jira(AtlassianRestAPI):
436
451
  url = f"{base_url}/{node_id}/offline"
437
452
  return self.put(url)
438
453
 
439
- def get_cluster_alive_nodes(self):
454
+ def get_cluster_alive_nodes(self) -> list:
440
455
  """
441
456
  Get cluster nodes where alive = True
442
457
  :return: list of node dicts
443
458
  """
444
- return [_ for _ in self.get_cluster_all_nodes() if _["alive"]]
459
+ nodes = self.get_cluster_all_nodes()
460
+ return [_ for _ in nodes.values() if _["alive"]] if nodes else []
445
461
 
446
- def request_current_index_from_node(self, node_id):
462
+ def request_current_index_from_node(self, node_id: T_id) -> T_resp_json:
447
463
  """
448
- Request current index from node (the request is processed asynchronously)
464
+ Request current index from node (the request is processed asynchronously).
465
+ This method is deprecated as it is Lucene specific and is planned for removal in Jira 11.
449
466
  :return:
450
467
  """
451
468
  base_url = self.resource_url("cluster/index-snapshot")
@@ -457,7 +474,7 @@ class Jira(AtlassianRestAPI):
457
474
  Reference: https://confluence.atlassian.com/support/create-a-support-zip-using-the-rest-api-in-data-center-applications-952054641.html
458
475
  """
459
476
 
460
- def generate_support_zip_on_nodes(self, node_ids):
477
+ def generate_support_zip_on_nodes(self, node_ids: list) -> T_resp_json:
461
478
  """
462
479
  Generate a support zip on targeted nodes of a cluster
463
480
  :param node_ids: list
@@ -467,7 +484,7 @@ class Jira(AtlassianRestAPI):
467
484
  url = "/rest/troubleshooting/latest/support-zip/cluster"
468
485
  return self.post(url, data=data)
469
486
 
470
- def check_support_zip_status(self, cluster_task_id):
487
+ def check_support_zip_status(self, cluster_task_id: T_id) -> T_resp_json:
471
488
  """
472
489
  Check status of support zip creation task
473
490
  :param cluster_task_id: str
@@ -476,7 +493,7 @@ class Jira(AtlassianRestAPI):
476
493
  url = f"/rest/troubleshooting/latest/support-zip/status/cluster/{cluster_task_id}"
477
494
  return self.get(url)
478
495
 
479
- def download_support_zip(self, file_name):
496
+ def download_support_zip(self, file_name: str) -> bytes:
480
497
  """
481
498
  Download created support zip file
482
499
  :param file_name: str
@@ -490,12 +507,48 @@ class Jira(AtlassianRestAPI):
490
507
  Reference: https://docs.atlassian.com/software/jira/docs/api/REST/8.5.0/#api/2/cluster/zdu
491
508
  """
492
509
 
493
- def get_cluster_zdu_state(self):
510
+ def approve_cluster_zdu_upgrade(self) -> T_resp_json:
511
+ """
512
+ Approves the cluster upgrade.
513
+ :return:
514
+ """
515
+ url = self.resource_url("cluster/zdu/approve")
516
+ return self.post(url)
517
+
518
+ def cancel_cluster_zdu_upgrade(self) -> T_resp_json:
519
+ """
520
+ Cancels the ongoing cluster upgrade.
521
+ :return:
522
+ """
523
+ url = self.resource_url("cluster/zdu/cancel")
524
+ return self.post(url)
525
+
526
+ def retry_cluster_zdu_upgrade(self) -> T_resp_json:
527
+ """
528
+ Retries the cluster upgrade.
529
+ :return:
530
+ """
531
+ url = self.resource_url("cluster/zdu/retryUpgrade")
532
+ return self.post(url)
533
+
534
+ def start_cluster_zdu_upgrade(self) -> T_resp_json:
535
+ """
536
+ Starts the cluster upgrade.
537
+ :return:
538
+ """
539
+ url = self.resource_url("cluster/zdu/start")
540
+ return self.post(url)
541
+
542
+ def get_cluster_zdu_state(self) -> T_resp_json:
543
+ """
544
+ Get the state of the cluster upgrade.
545
+ :return:
546
+ """
494
547
  url = self.resource_url("cluster/zdu/state")
495
548
  return self.get(url)
496
549
 
497
550
  # Issue Comments
498
- def issue_get_comments(self, issue_id):
551
+ def issue_get_comments(self, issue_id: T_id) -> T_resp_json:
499
552
  """
500
553
  Get Comments on an Issue.
501
554
  :param issue_id: Issue ID
@@ -506,10 +559,10 @@ class Jira(AtlassianRestAPI):
506
559
  url = f"{base_url}/{issue_id}/comment"
507
560
  return self.get(url)
508
561
 
509
- def issues_get_comments_by_id(self, *args):
562
+ def issues_get_comments_by_id(self, *args: int) -> T_resp_json:
510
563
  """
511
564
  Get Comments on Multiple Issues
512
- :param *args: int Issue ID's
565
+ :param args: int Issue ID's
513
566
  :raises: requests.exceptions.HTTPError
514
567
  :return:
515
568
  """
@@ -520,7 +573,7 @@ class Jira(AtlassianRestAPI):
520
573
  url = f"{base_url}/list"
521
574
  return self.post(url, data=data)
522
575
 
523
- def issue_get_comment(self, issue_id, comment_id):
576
+ def issue_get_comment(self, issue_id: T_id, comment_id: T_id) -> T_resp_json:
524
577
  """
525
578
  Get a single comment
526
579
  :param issue_id: int or str
@@ -537,7 +590,7 @@ class Jira(AtlassianRestAPI):
537
590
  Reference: https://docs.atlassian.com/software/jira/docs/api/REST/8.5.0/#api/2/comment/{commentId}/properties
538
591
  """
539
592
 
540
- def get_comment_properties_keys(self, comment_id):
593
+ def get_comment_properties_keys(self, comment_id: T_id) -> T_resp_json:
541
594
  """
542
595
  Returns the keys of all properties for the comment identified by the key or by the id.
543
596
  :param comment_id:
@@ -547,7 +600,7 @@ class Jira(AtlassianRestAPI):
547
600
  url = f"{base_url}/{comment_id}/properties"
548
601
  return self.get(url)
549
602
 
550
- def get_comment_property(self, comment_id, property_key):
603
+ def get_comment_property(self, comment_id: T_id, property_key: str) -> T_resp_json:
551
604
  """
552
605
  Returns the value a property for a comment
553
606
  :param comment_id: int
@@ -558,7 +611,7 @@ class Jira(AtlassianRestAPI):
558
611
  url = f"{base_url}/{comment_id}/properties/{property_key}"
559
612
  return self.get(url)
560
613
 
561
- def set_comment_property(self, comment_id, property_key, value_property):
614
+ def set_comment_property(self, comment_id: T_id, property_key: str, value_property: object) -> T_resp_json:
562
615
  """
563
616
  Returns the keys of all properties for the comment identified by the key or by the id.
564
617
  :param comment_id: int
@@ -571,7 +624,7 @@ class Jira(AtlassianRestAPI):
571
624
  data = {"value": value_property}
572
625
  return self.put(url, data=data)
573
626
 
574
- def delete_comment_property(self, comment_id, property_key):
627
+ def delete_comment_property(self, comment_id: T_id, property_key: str) -> T_resp_json:
575
628
  """
576
629
  Deletes a property for a comment
577
630
  :param comment_id: int
@@ -587,11 +640,11 @@ class Jira(AtlassianRestAPI):
587
640
  Reference: https://docs.atlassian.com/software/jira/docs/api/REST/8.5.0/#api/2/component
588
641
  """
589
642
 
590
- def component(self, component_id):
643
+ def component(self, component_id: T_id) -> T_resp_json:
591
644
  base_url = self.resource_url("component")
592
645
  return self.get(f"{base_url}/{component_id}")
593
646
 
594
- def get_component_related_issues(self, component_id):
647
+ def get_component_related_issues(self, component_id: T_id) -> T_resp_json:
595
648
  """
596
649
  Returns counts of issues related to this component.
597
650
  :param component_id:
@@ -601,23 +654,23 @@ class Jira(AtlassianRestAPI):
601
654
  url = f"{base_url}/{component_id}/relatedIssueCounts"
602
655
  return self.get(url)
603
656
 
604
- def create_component(self, component):
657
+ def create_component(self, component: dict) -> T_resp_json:
605
658
  log.info('Creating component "%s"', component["name"])
606
659
  base_url = self.resource_url("component")
607
660
  url = f"{base_url}/"
608
661
  return self.post(url, data=component)
609
662
 
610
- def update_component(self, component, component_id):
663
+ def update_component(self, component: dict, component_id: T_id) -> T_resp_json:
611
664
  base_url = self.resource_url("component")
612
665
  url = f"{base_url}/{component_id}"
613
666
  return self.put(url, data=component)
614
667
 
615
- def delete_component(self, component_id):
668
+ def delete_component(self, component_id: T_id) -> T_resp_json:
616
669
  log.info('Deleting component "%s"', component_id)
617
670
  base_url = self.resource_url("component")
618
671
  return self.delete(f"{base_url}/{component_id}")
619
672
 
620
- def update_component_lead(self, component_id, lead):
673
+ def update_component_lead(self, component_id: T_id, lead: str) -> T_resp_json:
621
674
  data = {"id": component_id, "leadUserName": lead}
622
675
  base_url = self.resource_url("component")
623
676
  return self.put(
@@ -630,7 +683,7 @@ class Jira(AtlassianRestAPI):
630
683
  Reference: https://docs.atlassian.com/software/jira/docs/api/REST/8.5.0/#api/2/configuration
631
684
  """
632
685
 
633
- def get_configurations_of_jira(self):
686
+ def get_configurations_of_jira(self) -> T_resp_json:
634
687
  """
635
688
  Returns the information if the optional features in JIRA are enabled or disabled.
636
689
  If the time tracking is enabled, it also returns the detailed information about time tracking configuration.
@@ -646,7 +699,7 @@ class Jira(AtlassianRestAPI):
646
699
  https://docs.atlassian.com/software/jira/docs/api/REST/8.5.0/#api/2/field
647
700
  """
648
701
 
649
- def get_custom_field_option(self, option_id):
702
+ def get_custom_field_option(self, option_id: T_id) -> T_resp_json:
650
703
  """
651
704
  Returns a full representation of the Custom Field Option that has the given id.
652
705
  :param option_id:
@@ -656,7 +709,7 @@ class Jira(AtlassianRestAPI):
656
709
  url = f"{base_url}/{option_id}"
657
710
  return self.get(url)
658
711
 
659
- def get_custom_fields(self, search=None, start=1, limit=50):
712
+ def get_custom_fields(self, search: Optional[str] = None, start: int = 1, limit: int = 50) -> T_resp_json:
660
713
  """
661
714
  Get custom fields. Evaluated on 7.12
662
715
  Get fields paginated in cloud
@@ -669,7 +722,7 @@ class Jira(AtlassianRestAPI):
669
722
  url = self.resource_url("field/search")
670
723
  else:
671
724
  url = self.resource_url("customFields")
672
- params = {}
725
+ params: dict = {}
673
726
  if search:
674
727
  params["search"] = search
675
728
  if start:
@@ -678,7 +731,7 @@ class Jira(AtlassianRestAPI):
678
731
  params["maxResults"] = limit
679
732
  return self.get(url, params=params)
680
733
 
681
- def get_all_fields(self):
734
+ def get_all_fields(self) -> T_resp_json:
682
735
  """
683
736
  Returns a list of all fields, both System and Custom
684
737
  :return: application/jsonContains a full representation of all visible fields in JSON.
@@ -686,7 +739,9 @@ class Jira(AtlassianRestAPI):
686
739
  url = self.resource_url("field")
687
740
  return self.get(url)
688
741
 
689
- def create_custom_field(self, name, type, search_key=None, description=None):
742
+ def create_custom_field(
743
+ self, name: str, type: str, search_key: Optional[str] = None, description: Optional[str] = None
744
+ ) -> T_resp_json:
690
745
  """
691
746
  Creates a custom field with the given name and type
692
747
  :param name: str - name of the custom field
@@ -702,7 +757,7 @@ class Jira(AtlassianRestAPI):
702
757
  data["description"] = description
703
758
  return self.post(url, data=data)
704
759
 
705
- def get_custom_field_option_context(self, field_id, context_id):
760
+ def get_custom_field_option_context(self, field_id: T_id, context_id: T_id) -> T_resp_json:
706
761
  """
707
762
  Gets the current values of a custom field
708
763
  :param field_id:
@@ -717,7 +772,7 @@ class Jira(AtlassianRestAPI):
717
772
  )
718
773
  return self.get(url)
719
774
 
720
- def add_custom_field_option(self, field_id, context_id, options):
775
+ def add_custom_field_option(self, field_id: T_id, context_id: T_id, options: list) -> T_resp_json:
721
776
  """
722
777
  Adds the values given to the custom field
723
778
  Administrator permission required
@@ -728,7 +783,7 @@ class Jira(AtlassianRestAPI):
728
783
 
729
784
  Reference: https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issue-custom-field-options/#api-rest-api-2-field-fieldid-context-contextid-option-post
730
785
  """
731
- data = {"options": []}
786
+ data: dict = {"options": []}
732
787
  for i in options:
733
788
  data["options"].append({"disabled": "false", "value": i})
734
789
 
@@ -743,7 +798,7 @@ class Jira(AtlassianRestAPI):
743
798
  Reference: https://docs.atlassian.com/software/jira/docs/api/REST/8.5.0/#api/2/dashboard
744
799
  """
745
800
 
746
- def get_dashboards(self, filter="", start=0, limit=10):
801
+ def get_dashboards(self, filter: str = "", start: int = 0, limit: int = 10) -> Optional[dict]:
747
802
  """
748
803
  Returns a list of all dashboards, optionally filtering them.
749
804
  :param filter: OPTIONAL: an optional filter that is applied to the list of dashboards.
@@ -758,7 +813,7 @@ class Jira(AtlassianRestAPI):
758
813
  the value that is effectively being used.
759
814
  :return:
760
815
  """
761
- params = {}
816
+ params: dict = {}
762
817
  if filter:
763
818
  params["filter"] = filter
764
819
  if start:
@@ -768,7 +823,7 @@ class Jira(AtlassianRestAPI):
768
823
  url = self.resource_url("dashboard")
769
824
  return self.get(url, params=params)
770
825
 
771
- def get_dashboard(self, dashboard_id):
826
+ def get_dashboard(self, dashboard_id: T_id) -> Optional[dict]:
772
827
  """
773
828
  Returns a single dashboard
774
829
 
@@ -783,7 +838,7 @@ class Jira(AtlassianRestAPI):
783
838
  Reference: https://docs.atlassian.com/software/jira/docs/api/REST/8.5.0/#api/2/filter
784
839
  """
785
840
 
786
- def create_filter(self, name, jql, description=None, favourite=False):
841
+ def create_filter(self, name: str, jql: str, description: Optional[str] = None, favourite: bool = False):
787
842
  """
788
843
  :param name: str
789
844
  :param jql: str
@@ -799,7 +854,14 @@ class Jira(AtlassianRestAPI):
799
854
  url = self.resource_url("filter")
800
855
  return self.post(url, data=data)
801
856
 
802
- def edit_filter(self, filter_id, name, jql=None, description=None, favourite=None):
857
+ def edit_filter(
858
+ self,
859
+ filter_id: T_id,
860
+ name: str,
861
+ jql: Optional[str] = None,
862
+ description: Optional[str] = None,
863
+ favourite: Optional[bool] = None,
864
+ ):
803
865
  """
804
866
  Updates an existing filter.
805
867
  :param filter_id: Filter ID
@@ -809,7 +871,7 @@ class Jira(AtlassianRestAPI):
809
871
  :param favourite: Indicates if filter is selected as favorite
810
872
  :return: Returns updated filter information
811
873
  """
812
- data = {"name": name}
874
+ data: dict = {"name": name}
813
875
  if jql:
814
876
  data["jql"] = jql
815
877
  if description:
@@ -820,7 +882,7 @@ class Jira(AtlassianRestAPI):
820
882
  url = f"{base_url}/{filter_id}"
821
883
  return self.put(url, data=data)
822
884
 
823
- def get_filter(self, filter_id):
885
+ def get_filter(self, filter_id: T_id):
824
886
  """
825
887
  Returns a full representation of a filter that has the given id.
826
888
  :param filter_id:
@@ -830,7 +892,7 @@ class Jira(AtlassianRestAPI):
830
892
  url = f"{base_url}/{filter_id}"
831
893
  return self.get(url)
832
894
 
833
- def update_filter(self, filter_id, jql, **kwargs):
895
+ def update_filter(self, filter_id: T_id, jql: str, **kwargs: Any):
834
896
  """
835
897
  :param filter_id: int
836
898
  :param jql: str
@@ -846,7 +908,7 @@ class Jira(AtlassianRestAPI):
846
908
  url = f"{base_url}/{filter_id}"
847
909
  return self.put(url, data=data)
848
910
 
849
- def delete_filter(self, filter_id):
911
+ def delete_filter(self, filter_id: T_id):
850
912
  """
851
913
  Deletes a filter that has the given id.
852
914
  :param filter_id:
@@ -856,7 +918,7 @@ class Jira(AtlassianRestAPI):
856
918
  url = f"{base_url}/{filter_id}"
857
919
  return self.delete(url)
858
920
 
859
- def get_filter_share_permissions(self, filter_id):
921
+ def get_filter_share_permissions(self, filter_id: T_id):
860
922
  """
861
923
  Gets share permissions of a filter.
862
924
  :param filter_id: Filter ID
@@ -868,14 +930,14 @@ class Jira(AtlassianRestAPI):
868
930
 
869
931
  def add_filter_share_permission(
870
932
  self,
871
- filter_id,
872
- type,
873
- project_id=None,
874
- project_role_id=None,
875
- groupname=None,
876
- user_key=None,
877
- view=None,
878
- edit=None,
933
+ filter_id: T_id,
934
+ type: str,
935
+ project_id: Optional[T_id] = None,
936
+ project_role_id: Optional[T_id] = None,
937
+ groupname: Optional[str] = None,
938
+ user_key: Optional[str] = None,
939
+ view: Optional[str] = None,
940
+ edit: Optional[str] = None,
879
941
  ):
880
942
  """
881
943
  Adds share permission for a filter. See the documentation of the sharePermissions.
@@ -891,7 +953,7 @@ class Jira(AtlassianRestAPI):
891
953
  """
892
954
  base_url = self.resource_url("filter")
893
955
  url = f"{base_url}/{filter_id}/permission"
894
- data = {"type": type}
956
+ data: dict = {"type": type}
895
957
  if project_id:
896
958
  data["projectId"] = project_id
897
959
  if project_role_id:
@@ -906,7 +968,7 @@ class Jira(AtlassianRestAPI):
906
968
  data["edit"] = edit
907
969
  return self.post(url, data=data)
908
970
 
909
- def delete_filter_share_permission(self, filter_id, permission_id):
971
+ def delete_filter_share_permission(self, filter_id: T_id, permission_id: T_id):
910
972
  """
911
973
  Removes share permission
912
974
  :param filter_id: Filter ID
@@ -923,7 +985,7 @@ class Jira(AtlassianRestAPI):
923
985
  https://docs.atlassian.com/software/jira/docs/api/REST/8.5.0/#api/2/groups
924
986
  """
925
987
 
926
- def get_groups(self, query=None, exclude=None, limit=20):
988
+ def get_groups(self, query: Optional[str] = None, exclude: Optional[str] = None, limit: int = 20):
927
989
  """
928
990
  REST endpoint for searching groups in a group picker
929
991
  Returns groups with substrings matching a given query. This is mainly for use with the group picker,
@@ -938,7 +1000,7 @@ class Jira(AtlassianRestAPI):
938
1000
  :return: Returned even if no groups match the given substring
939
1001
  """
940
1002
  url = self.resource_url("groups/picker")
941
- params = {}
1003
+ params: dict = {}
942
1004
  if query:
943
1005
  params["query"] = query
944
1006
  else:
@@ -949,7 +1011,7 @@ class Jira(AtlassianRestAPI):
949
1011
  params["maxResults"] = limit
950
1012
  return self.get(url, params=params)
951
1013
 
952
- def create_group(self, name):
1014
+ def create_group(self, name: str):
953
1015
  """
954
1016
  Create a group by given group parameter
955
1017
 
@@ -960,7 +1022,7 @@ class Jira(AtlassianRestAPI):
960
1022
  data = {"name": name}
961
1023
  return self.post(url, data=data)
962
1024
 
963
- def remove_group(self, name, swap_group=None):
1025
+ def remove_group(self, name: str, swap_group: Optional[str] = None):
964
1026
  """
965
1027
  Delete a group by given group parameter
966
1028
  If you delete a group and content is restricted to that group, the content will be hidden from all users
@@ -979,7 +1041,9 @@ class Jira(AtlassianRestAPI):
979
1041
 
980
1042
  return self.delete(url, params=params)
981
1043
 
982
- def get_all_users_from_group(self, group, include_inactive_users=False, start=0, limit=50):
1044
+ def get_all_users_from_group(
1045
+ self, group: str, include_inactive_users: bool = False, start: int = 0, limit: int = 50
1046
+ ):
983
1047
  """
984
1048
  Just wrapping method user group members
985
1049
  :param group:
@@ -990,7 +1054,7 @@ class Jira(AtlassianRestAPI):
990
1054
  :return:
991
1055
  """
992
1056
  url = self.resource_url("group/member")
993
- params = {}
1057
+ params: dict = {}
994
1058
  if group:
995
1059
  params["groupname"] = group
996
1060
  params["includeInactiveUsers"] = include_inactive_users
@@ -998,7 +1062,9 @@ class Jira(AtlassianRestAPI):
998
1062
  params["maxResults"] = limit
999
1063
  return self.get(url, params=params)
1000
1064
 
1001
- def add_user_to_group(self, username=None, group_name=None, account_id=None):
1065
+ def add_user_to_group(
1066
+ self, username: Optional[str] = None, group_name: Optional[str] = None, account_id: Optional[str] = None
1067
+ ):
1002
1068
  """
1003
1069
  Add given user to a group
1004
1070
 
@@ -1013,7 +1079,7 @@ class Jira(AtlassianRestAPI):
1013
1079
  :return: Current state of the group
1014
1080
  """
1015
1081
  url = self.resource_url("group/user")
1016
- params = {"groupname": group_name}
1082
+ params: dict = {"groupname": group_name}
1017
1083
  url_domain = self.url
1018
1084
  if "atlassian.net" in url_domain:
1019
1085
  data = {"accountId": account_id}
@@ -1021,7 +1087,9 @@ class Jira(AtlassianRestAPI):
1021
1087
  data = {"name": username}
1022
1088
  return self.post(url, params=params, data=data)
1023
1089
 
1024
- def remove_user_from_group(self, username=None, group_name=None, account_id=None):
1090
+ def remove_user_from_group(
1091
+ self, username: Optional[str] = None, group_name: Optional[str] = None, account_id: Optional[str] = None
1092
+ ) -> T_resp_json:
1025
1093
  """
1026
1094
  Remove given user from a group
1027
1095
 
@@ -1045,8 +1113,13 @@ class Jira(AtlassianRestAPI):
1045
1113
  return self.delete(url, params=params)
1046
1114
 
1047
1115
  def get_users_with_browse_permission_to_a_project(
1048
- self, username, issue_key=None, project_key=None, start=0, limit=100
1049
- ):
1116
+ self,
1117
+ username: str,
1118
+ issue_key: Optional[str] = None,
1119
+ project_key: Optional[str] = None,
1120
+ start: int = 0,
1121
+ limit: int = 100,
1122
+ ) -> T_resp_json:
1050
1123
  """
1051
1124
  Returns a list of active users that match the search string. This resource cannot be accessed anonymously
1052
1125
  and requires the Browse Users global permission. Given an issue key this resource will provide a list of users
@@ -1060,7 +1133,7 @@ class Jira(AtlassianRestAPI):
1060
1133
  :return: List of active users who has browser permission for the given project_key or issue_key
1061
1134
  """
1062
1135
  url = self.resource_url("user/viewissue/search")
1063
- params = {}
1136
+ params: dict = {}
1064
1137
  if username:
1065
1138
  params["username"] = username
1066
1139
  if issue_key:
@@ -1079,15 +1152,22 @@ class Jira(AtlassianRestAPI):
1079
1152
  Reference: https://docs.atlassian.com/software/jira/docs/api/REST/8.5.0/#api/2/issue
1080
1153
  """
1081
1154
 
1082
- def issue(self, key, fields="*all", expand=None):
1155
+ def issue(self, key: T_id, fields: Union[str, dict] = "*all", expand: Optional[str] = None):
1083
1156
  base_url = self.resource_url("issue")
1084
1157
  url = f"{base_url}/{key}?fields={fields}"
1085
- params = {}
1158
+ params: dict = {}
1086
1159
  if expand:
1087
1160
  params["expand"] = expand
1088
1161
  return self.get(url, params=params)
1089
1162
 
1090
- def get_issue(self, issue_id_or_key, fields=None, properties=None, update_history=True, expand=None):
1163
+ def get_issue(
1164
+ self,
1165
+ issue_id_or_key: T_id,
1166
+ fields: Union[str, list, tuple, set, None] = None,
1167
+ properties: Optional[str] = None,
1168
+ update_history: bool = True,
1169
+ expand: Optional[str] = None,
1170
+ ):
1091
1171
  """
1092
1172
  Returns a full representation of the issue for the given issue key
1093
1173
  By default, all fields are returned in this get-issue resource
@@ -1101,7 +1181,7 @@ class Jira(AtlassianRestAPI):
1101
1181
  """
1102
1182
  base_url = self.resource_url("issue")
1103
1183
  url = f"{base_url}/{issue_id_or_key}"
1104
- params = {}
1184
+ params: dict = {}
1105
1185
 
1106
1186
  if fields is not None:
1107
1187
  if isinstance(fields, (list, tuple, set)):
@@ -1114,7 +1194,7 @@ class Jira(AtlassianRestAPI):
1114
1194
  params["updateHistory"] = str(update_history).lower()
1115
1195
  return self.get(url, params=params)
1116
1196
 
1117
- def epic_issues(self, epic, fields="*all", expand=None):
1197
+ def epic_issues(self, epic: str, fields: Union[str, list] = "*all", expand: Optional[str] = None):
1118
1198
  """
1119
1199
  Given an epic return all child issues
1120
1200
  By default, all fields are returned in this get-issue resource
@@ -1128,12 +1208,12 @@ class Jira(AtlassianRestAPI):
1128
1208
  """
1129
1209
  base_url = self.resource_url("epic", api_root="rest/agile", api_version="1.0")
1130
1210
  url = f"{base_url}/{epic}/issue?fields={fields}"
1131
- params = {}
1211
+ params: dict = {}
1132
1212
  if expand:
1133
1213
  params["expand"] = expand
1134
1214
  return self.get(url, params=params)
1135
1215
 
1136
- def bulk_issue(self, issue_list, fields="*all"):
1216
+ def bulk_issue(self, issue_list: list, fields: Union[str, list] = "*all"):
1137
1217
  """
1138
1218
  :param fields:
1139
1219
  :param list issue_list:
@@ -1147,7 +1227,7 @@ class Jira(AtlassianRestAPI):
1147
1227
  matched_issue_keys.append(key)
1148
1228
  jql = f"key in ({', '.join(set(matched_issue_keys))})"
1149
1229
  query_result = self.jql(jql, fields=fields)
1150
- if "errorMessages" in list(query_result.keys()):
1230
+ if query_result and "errorMessages" in list(query_result.keys()):
1151
1231
  for message in query_result["errorMessages"]:
1152
1232
  for key in issue_list:
1153
1233
  if key in message:
@@ -1156,7 +1236,7 @@ class Jira(AtlassianRestAPI):
1156
1236
  query_result, missing_issues = self.bulk_issue(issue_list, fields)
1157
1237
  return query_result, missing_issues
1158
1238
 
1159
- def issue_createmeta(self, project, expand="projects.issuetypes.fields"):
1239
+ def issue_createmeta(self, project: str, expand: str = "projects.issuetypes.fields") -> T_resp_json:
1160
1240
  """
1161
1241
  This function is deprecated.
1162
1242
  See https://confluence.atlassian.com/jiracore/createmeta-rest-endpoint-to-be-removed-975040986.html
@@ -1168,13 +1248,13 @@ class Jira(AtlassianRestAPI):
1168
1248
  DeprecationWarning,
1169
1249
  stacklevel=2,
1170
1250
  )
1171
- params = {}
1251
+ params: dict = {}
1172
1252
  if expand:
1173
1253
  params["expand"] = expand
1174
1254
  url = self.resource_url(f"issue/createmeta?projectKeys={project}")
1175
1255
  return self.get(url, params=params)
1176
1256
 
1177
- def issue_createmeta_issuetypes(self, project, start=None, limit=None):
1257
+ def issue_createmeta_issuetypes(self, project: str, start: Optional[int] = None, limit: Optional[int] = None):
1178
1258
  """
1179
1259
  Get create metadata issue types for a project
1180
1260
  Returns a page of issue type metadata for a specified project.
@@ -1185,14 +1265,16 @@ class Jira(AtlassianRestAPI):
1185
1265
  :return:
1186
1266
  """
1187
1267
  url = self.resource_url(f"issue/createmeta/{project}/issuetypes")
1188
- params = {}
1268
+ params: dict = {}
1189
1269
  if start:
1190
1270
  params["startAt"] = start
1191
1271
  if limit:
1192
1272
  params["maxResults"] = limit
1193
1273
  return self.get(url, params=params)
1194
1274
 
1195
- def issue_createmeta_fieldtypes(self, project, issue_type_id, start=None, limit=None):
1275
+ def issue_createmeta_fieldtypes(
1276
+ self, project: str, issue_type_id: str, start: Optional[int] = None, limit: Optional[int] = None
1277
+ ):
1196
1278
  """
1197
1279
  Get create field metadata for a project and issue type id
1198
1280
  Returns a page of field metadata for a specified project and issuetype id.
@@ -1205,19 +1287,19 @@ class Jira(AtlassianRestAPI):
1205
1287
  :return:
1206
1288
  """
1207
1289
  url = self.resource_url(f"issue/createmeta/{project}/issuetypes/{issue_type_id}")
1208
- params = {}
1290
+ params: dict = {}
1209
1291
  if start:
1210
1292
  params["startAt"] = start
1211
1293
  if limit:
1212
1294
  params["maxResults"] = limit
1213
1295
  return self.get(url, params=params)
1214
1296
 
1215
- def issue_editmeta(self, key):
1297
+ def issue_editmeta(self, key: str):
1216
1298
  base_url = self.resource_url("issue")
1217
1299
  url = f"{base_url}/{key}/editmeta"
1218
1300
  return self.get(url)
1219
1301
 
1220
- def get_issue_changelog(self, issue_key, start=None, limit=None):
1302
+ def get_issue_changelog(self, issue_key: str, start: Optional[int] = None, limit: Optional[int] = None):
1221
1303
  """
1222
1304
  Get issue related change log
1223
1305
  :param issue_key:
@@ -1226,7 +1308,7 @@ class Jira(AtlassianRestAPI):
1226
1308
  :return:
1227
1309
  """
1228
1310
  base_url = self.resource_url("issue")
1229
- params = {}
1311
+ params: dict = {}
1230
1312
  if start:
1231
1313
  params["startAt"] = start
1232
1314
  if limit:
@@ -1239,7 +1321,7 @@ class Jira(AtlassianRestAPI):
1239
1321
  url = f"{base_url}/{issue_key}?expand=changelog"
1240
1322
  return self._get_response_content(url, fields=[("changelog", params)])
1241
1323
 
1242
- def issue_add_json_worklog(self, key, worklog):
1324
+ def issue_add_json_worklog(self, key: str, worklog: Union[dict, str]):
1243
1325
  """
1244
1326
 
1245
1327
  :param key:
@@ -1250,7 +1332,7 @@ class Jira(AtlassianRestAPI):
1250
1332
  url = f"{base_url}/{key}/worklog"
1251
1333
  return self.post(url, data=worklog)
1252
1334
 
1253
- def issue_worklog(self, key, started, time_sec, comment=None):
1335
+ def issue_worklog(self, key: str, started: str, time_sec: int, comment: Optional[str] = None):
1254
1336
  """
1255
1337
  :param key:
1256
1338
  :param time_sec: int: second
@@ -1263,7 +1345,7 @@ class Jira(AtlassianRestAPI):
1263
1345
  data["comment"] = comment
1264
1346
  return self.issue_add_json_worklog(key=key, worklog=data)
1265
1347
 
1266
- def issue_get_worklog(self, issue_id_or_key):
1348
+ def issue_get_worklog(self, issue_id_or_key: str):
1267
1349
  """
1268
1350
  Returns all work logs for an issue.
1269
1351
  Note: Work logs won't be returned if the Log work field is hidden for the project.
@@ -1275,7 +1357,7 @@ class Jira(AtlassianRestAPI):
1275
1357
 
1276
1358
  return self.get(url)
1277
1359
 
1278
- def issue_archive(self, issue_id_or_key, notify_users=None):
1360
+ def issue_archive(self, issue_id_or_key: str, notify_users: Optional[bool] = None):
1279
1361
  """
1280
1362
  Archives an issue.
1281
1363
  :param issue_id_or_key: Issue id or issue key
@@ -1283,14 +1365,14 @@ class Jira(AtlassianRestAPI):
1283
1365
  The default value of None will apply the default behavior of Jira
1284
1366
  :return:
1285
1367
  """
1286
- params = {}
1368
+ params: dict = {}
1287
1369
  if notify_users is not None:
1288
1370
  params["notifyUsers"] = notify_users
1289
1371
  base_url = self.resource_url("issue")
1290
1372
  url = f"{base_url}/{issue_id_or_key}/archive"
1291
1373
  return self.put(url, params=params)
1292
1374
 
1293
- def issue_restore(self, issue_id_or_key):
1375
+ def issue_restore(self, issue_id_or_key: str):
1294
1376
  """
1295
1377
  Restores an archived issue.
1296
1378
  :param issue_id_or_key: Issue id or issue key
@@ -1300,17 +1382,19 @@ class Jira(AtlassianRestAPI):
1300
1382
  url = f"{base_url}/{issue_id_or_key}/restore"
1301
1383
  return self.put(url)
1302
1384
 
1303
- def issue_field_value(self, key, field):
1385
+ def issue_field_value(self, key: str, field: str):
1304
1386
  base_url = self.resource_url("issue")
1305
1387
  issue = self.get(f"{base_url}/{key}?fields={field}")
1306
- return issue["fields"][field]
1388
+ if issue:
1389
+ return issue["fields"][field]
1307
1390
 
1308
- def issue_fields(self, key):
1391
+ def issue_fields(self, key: str):
1309
1392
  base_url = self.resource_url("issue")
1310
1393
  issue = self.get(f"{base_url}/{key}")
1311
- return issue["fields"]
1394
+ if issue:
1395
+ return issue["fields"]
1312
1396
 
1313
- def update_issue_field(self, key, fields="*all", notify_users=True):
1397
+ def update_issue_field(self, key: T_id, fields: Union[str, dict] = "*all", notify_users: bool = True):
1314
1398
  """
1315
1399
  Update an issue's fields.
1316
1400
  :param key: str Issue id or issye key
@@ -1321,14 +1405,14 @@ class Jira(AtlassianRestAPI):
1321
1405
  Reference: https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issues/#api-rest-api-2-issue-issueidorkey-put
1322
1406
  """
1323
1407
  base_url = self.resource_url("issue")
1324
- params = {"notifyUsers": "true" if notify_users else "false"}
1408
+ params: dict = {"notifyUsers": "true" if notify_users else "false"}
1325
1409
  return self.put(
1326
1410
  f"{base_url}/{key}",
1327
1411
  data={"fields": fields},
1328
1412
  params=params,
1329
1413
  )
1330
1414
 
1331
- def bulk_update_issue_field(self, key_list, fields="*all"):
1415
+ def bulk_update_issue_field(self, key_list: list, fields: Union[str, dict] = "*all") -> bool:
1332
1416
  """
1333
1417
  :param key_list: list of issues with common filed to be updated
1334
1418
  :param fields: common fields to be updated
@@ -1346,7 +1430,7 @@ class Jira(AtlassianRestAPI):
1346
1430
  return False
1347
1431
  return True
1348
1432
 
1349
- def issue_field_value_append(self, issue_id_or_key, field, value, notify_users=True):
1433
+ def issue_field_value_append(self, issue_id_or_key: str, field: str, value: str, notify_users: bool = True):
1350
1434
  """
1351
1435
  Add value to a multiple value field
1352
1436
 
@@ -1357,7 +1441,7 @@ class Jira(AtlassianRestAPI):
1357
1441
  if False, do not send any email notifications. (only works with admin privilege)
1358
1442
  """
1359
1443
  base_url = self.resource_url("issue")
1360
- params = {"notifyUsers": True if notify_users else False}
1444
+ params: dict = {"notifyUsers": True if notify_users else False}
1361
1445
  current_value = self.issue_field_value(key=issue_id_or_key, field=field)
1362
1446
 
1363
1447
  if current_value:
@@ -1373,7 +1457,7 @@ class Jira(AtlassianRestAPI):
1373
1457
  params=params,
1374
1458
  )
1375
1459
 
1376
- def get_issue_labels(self, issue_key):
1460
+ def get_issue_labels(self, issue_key: str) -> T_resp_json:
1377
1461
  """
1378
1462
  Get issue labels.
1379
1463
  :param issue_key:
@@ -1385,7 +1469,7 @@ class Jira(AtlassianRestAPI):
1385
1469
  return self.get(url)
1386
1470
  return self._get_response_content(url, fields=[("fields",), ("labels",)])
1387
1471
 
1388
- def update_issue(self, issue_key, update):
1472
+ def update_issue(self, issue_key: T_id, update: Union[str, dict]) -> T_resp_json:
1389
1473
  """
1390
1474
  :param issue_key: the issue to update
1391
1475
  :param update: the update to make
@@ -1394,7 +1478,7 @@ class Jira(AtlassianRestAPI):
1394
1478
  endpoint = f"/rest/api/2/issue/{issue_key}"
1395
1479
  return self.put(endpoint, data=update)
1396
1480
 
1397
- def label_issue(self, issue_key, labels):
1481
+ def label_issue(self, issue_key: T_id, labels: list):
1398
1482
  """
1399
1483
  :param issue_key: the issue to update
1400
1484
  :param labels: the labels to add
@@ -1403,7 +1487,7 @@ class Jira(AtlassianRestAPI):
1403
1487
  labels = [{"add": label} for label in labels]
1404
1488
  return self.update_issue(issue_key, {"update": {"labels": labels}})
1405
1489
 
1406
- def unlabel_issue(self, issue_key, labels):
1490
+ def unlabel_issue(self, issue_key: T_id, labels: list):
1407
1491
  """
1408
1492
  :param issue_key: the issue to update
1409
1493
  :param labels: the labels to remove
@@ -1412,7 +1496,7 @@ class Jira(AtlassianRestAPI):
1412
1496
  labels = [{"remove": label} for label in labels]
1413
1497
  return self.update_issue(issue_key, {"update": {"labels": labels}})
1414
1498
 
1415
- def add_attachment(self, issue_key, filename):
1499
+ def add_attachment(self, issue_key: str, filename: str):
1416
1500
  """
1417
1501
  Add attachment to Issue
1418
1502
  :param issue_key: str
@@ -1421,7 +1505,7 @@ class Jira(AtlassianRestAPI):
1421
1505
  with open(filename, "rb") as attachment:
1422
1506
  return self.add_attachment_object(issue_key, attachment)
1423
1507
 
1424
- def add_attachment_object(self, issue_key, attachment):
1508
+ def add_attachment_object(self, issue_key: str, attachment: BinaryIO):
1425
1509
  """
1426
1510
  Add attachment to Issue
1427
1511
  :param issue_key: str
@@ -1437,11 +1521,11 @@ class Jira(AtlassianRestAPI):
1437
1521
  return None
1438
1522
  return self.post(url, headers=self.no_check_headers, files=files)
1439
1523
 
1440
- def issue_exists(self, issue_key):
1524
+ def issue_exists(self, issue_key: str) -> Optional[bool]:
1441
1525
  original_value = self.advanced_mode
1442
1526
  self.advanced_mode = True
1443
1527
  try:
1444
- resp = self.issue(issue_key, fields="*none")
1528
+ resp = cast("Response", self.issue(issue_key, fields="*none"))
1445
1529
  if resp.status_code == 404:
1446
1530
  log.info('Issue "%s" does not exists', issue_key)
1447
1531
  return False
@@ -1451,7 +1535,7 @@ class Jira(AtlassianRestAPI):
1451
1535
  finally:
1452
1536
  self.advanced_mode = original_value
1453
1537
 
1454
- def issue_deleted(self, issue_key):
1538
+ def issue_deleted(self, issue_key: str) -> bool:
1455
1539
  exists = self.issue_exists(issue_key)
1456
1540
  if exists:
1457
1541
  log.info('Issue "%s" is not deleted', issue_key)
@@ -1459,7 +1543,7 @@ class Jira(AtlassianRestAPI):
1459
1543
  log.info('Issue "%s" is deleted', issue_key)
1460
1544
  return not exists
1461
1545
 
1462
- def delete_issue(self, issue_id_or_key, delete_subtasks=True):
1546
+ def delete_issue(self, issue_id_or_key: str, delete_subtasks: bool = True):
1463
1547
  """
1464
1548
  Delete an issue
1465
1549
  If the issue has subtasks you must set the parameter delete_subtasks = True to delete the issue
@@ -1470,7 +1554,7 @@ class Jira(AtlassianRestAPI):
1470
1554
  """
1471
1555
  base_url = self.resource_url("issue")
1472
1556
  url = f"{base_url}/{issue_id_or_key}"
1473
- params = {}
1557
+ params: dict = {}
1474
1558
 
1475
1559
  if delete_subtasks is True:
1476
1560
  params["deleteSubtasks"] = "true"
@@ -1482,15 +1566,50 @@ class Jira(AtlassianRestAPI):
1482
1566
  return self.delete(url, params=params)
1483
1567
 
1484
1568
  # @todo merge with edit_issue method
1485
- def issue_update(self, issue_key, fields):
1486
- log.info('Updating issue "%s" with "%s"', issue_key, fields)
1569
+ # https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issues/#api-rest-api-2-issue-issueidorkey-put
1570
+ def issue_update(
1571
+ self,
1572
+ issue_key: str,
1573
+ fields: Union[str, dict],
1574
+ update: Optional[dict[Any, Any]] = None,
1575
+ history_metadata: Optional[dict[Any, Any]] = None,
1576
+ properties: Optional[list[Any]] = None,
1577
+ notify_users: bool = True,
1578
+ ):
1579
+ """
1580
+ Updates a Jira issue with specified fields, updates, history metadata, and properties.
1581
+
1582
+
1583
+ :param issue_key: The key or ID of the issue to update.
1584
+ :param fields: A dictionary containing field updates.
1585
+ :param update: A dictionary containing advanced updates (e.g., add/remove operations for labels).
1586
+ :param history_metadata: Metadata for tracking the history of changes.
1587
+ :param properties: A list of properties to add or update on the issue.
1588
+ :param notify_users: Whether to notify users of the update. default: True
1589
+ :return: Response from the PUT request.
1590
+ """
1591
+ log.info(f'Updating issue "{issue_key}" with "{fields}", "{update}", "{history_metadata}", and "{properties}"')
1592
+
1487
1593
  base_url = self.resource_url("issue")
1488
1594
  url = f"{base_url}/{issue_key}"
1489
- return self.put(url, data={"fields": fields})
1595
+ params = {
1596
+ "fields": fields,
1597
+ "update": update or {},
1598
+ "historyMetadata": history_metadata or {},
1599
+ "properties": properties or [],
1600
+ }
1601
+ # Remove empty keys to avoid sending unnecessary data
1602
+ params = {key: value for key, value in params.items() if value}
1603
+ if notify_users is True:
1604
+ params["notifyUsers"] = "true"
1605
+ else:
1606
+ params["notifyUsers"] = "false"
1607
+ return self.put(url, data=params)
1490
1608
 
1491
- def edit_issue(self, issue_id_or_key, fields, notify_users=True):
1609
+ # https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issues/#api-rest-api-2-issue-issueidorkey-put
1610
+ def edit_issue(self, issue_id_or_key: str, fields: Union[str, dict], notify_users: bool = True):
1492
1611
  """
1493
- Edits an issue from a JSON representation
1612
+ Edits an issue fields from a JSON representation
1494
1613
  The issue can either be updated by setting explicit the field
1495
1614
  value(s) or by using an operation to change the field value
1496
1615
 
@@ -1501,7 +1620,7 @@ class Jira(AtlassianRestAPI):
1501
1620
  """
1502
1621
  base_url = self.resource_url("issue")
1503
1622
  url = f"{base_url}/{issue_id_or_key}"
1504
- params = {}
1623
+ params: dict = {}
1505
1624
  data = {"update": fields}
1506
1625
 
1507
1626
  if notify_users is True:
@@ -1510,7 +1629,7 @@ class Jira(AtlassianRestAPI):
1510
1629
  params["notifyUsers"] = "false"
1511
1630
  return self.put(url, data=data, params=params)
1512
1631
 
1513
- def issue_add_watcher(self, issue_key, user):
1632
+ def issue_add_watcher(self, issue_key: str, user: str):
1514
1633
  """
1515
1634
  Start watching issue
1516
1635
  :param issue_key:
@@ -1525,7 +1644,7 @@ class Jira(AtlassianRestAPI):
1525
1644
  data=data,
1526
1645
  )
1527
1646
 
1528
- def issue_delete_watcher(self, issue_key, user):
1647
+ def issue_delete_watcher(self, issue_key: str, user: Optional[str] = None, account_id: Optional[str] = None):
1529
1648
  """
1530
1649
  Stop watching issue
1531
1650
  :param issue_key:
@@ -1533,14 +1652,18 @@ class Jira(AtlassianRestAPI):
1533
1652
  :return:
1534
1653
  """
1535
1654
  log.info('Deleting user %s from "%s" watchers', user, issue_key)
1536
- params = {"username": user}
1537
1655
  base_url = self.resource_url("issue")
1656
+ params = {}
1657
+ if self.cloud:
1658
+ params = {"accountId": account_id}
1659
+ else:
1660
+ params = {"username": user}
1538
1661
  return self.delete(
1539
1662
  f"{base_url}/{issue_key}/watchers",
1540
1663
  params=params,
1541
1664
  )
1542
1665
 
1543
- def issue_get_watchers(self, issue_key):
1666
+ def issue_get_watchers(self, issue_key: str):
1544
1667
  """
1545
1668
  Get watchers for an issue
1546
1669
  :param issue_key: Issue ID or Key
@@ -1549,7 +1672,7 @@ class Jira(AtlassianRestAPI):
1549
1672
  base_url = self.resource_url("issue")
1550
1673
  return self.get(f"{base_url}/{issue_key}/watchers")
1551
1674
 
1552
- def assign_issue(self, issue, account_id=None):
1675
+ def assign_issue(self, issue: T_id, account_id: Optional[str] = None):
1553
1676
  """Assign an issue to a user. None will set it to unassigned. -1 will set it to Automatic.
1554
1677
  :param issue : the issue ID or key to assign
1555
1678
  :type issue: int or str
@@ -1566,7 +1689,7 @@ class Jira(AtlassianRestAPI):
1566
1689
  data = {"name": account_id}
1567
1690
  return self.put(url, data=data)
1568
1691
 
1569
- def create_issue(self, fields, update_history=False, update=None):
1692
+ def create_issue(self, fields: Union[str, dict], update_history: bool = False, update: Optional[dict] = None):
1570
1693
  """
1571
1694
  Creates an issue or a sub-task from a JSON representation
1572
1695
  :param fields: JSON data
@@ -1597,7 +1720,7 @@ class Jira(AtlassianRestAPI):
1597
1720
  data = {"fields": fields}
1598
1721
  if update:
1599
1722
  data["update"] = update
1600
- params = {}
1723
+ params: dict = {}
1601
1724
 
1602
1725
  if update_history is True:
1603
1726
  params["updateHistory"] = "true"
@@ -1605,7 +1728,7 @@ class Jira(AtlassianRestAPI):
1605
1728
  params["updateHistory"] = "false"
1606
1729
  return self.post(url, params=params, data=data)
1607
1730
 
1608
- def create_issues(self, list_of_issues_data):
1731
+ def create_issues(self, list_of_issues_data: list):
1609
1732
  """
1610
1733
  Creates issues or sub-tasks from a JSON representation
1611
1734
  Creates many issues in one bulk operation
@@ -1617,12 +1740,12 @@ class Jira(AtlassianRestAPI):
1617
1740
  return self.post(url, data=data)
1618
1741
 
1619
1742
  # @todo refactor and merge with create_issue method
1620
- def issue_create(self, fields):
1743
+ def issue_create(self, fields: dict):
1621
1744
  log.info('Creating issue "%s"', fields["summary"])
1622
1745
  url = self.resource_url("issue")
1623
1746
  return self.post(url, data={"fields": fields})
1624
1747
 
1625
- def issue_create_or_update(self, fields):
1748
+ def issue_create_or_update(self, fields: dict):
1626
1749
  issue_key = fields.get("issuekey", None)
1627
1750
 
1628
1751
  if not issue_key or not self.issue_exists(issue_key):
@@ -1638,7 +1761,7 @@ class Jira(AtlassianRestAPI):
1638
1761
  fields.pop("issuekey", None)
1639
1762
  return self.issue_update(issue_key, fields)
1640
1763
 
1641
- def issue_add_comment(self, issue_key, comment, visibility=None):
1764
+ def issue_add_comment(self, issue_key: str, comment: str, visibility: Optional[dict] = None):
1642
1765
  """
1643
1766
  Add comment into Jira issue
1644
1767
  :param issue_key:
@@ -1648,12 +1771,19 @@ class Jira(AtlassianRestAPI):
1648
1771
  """
1649
1772
  base_url = self.resource_url("issue")
1650
1773
  url = f"{base_url}/{issue_key}/comment"
1651
- data = {"body": comment}
1774
+ data: dict = {"body": comment}
1652
1775
  if visibility:
1653
1776
  data["visibility"] = visibility
1654
1777
  return self.post(url, data=data)
1655
1778
 
1656
- def issue_edit_comment(self, issue_key, comment_id, comment, visibility=None, notify_users=True):
1779
+ def issue_edit_comment(
1780
+ self,
1781
+ issue_key: str,
1782
+ comment_id: T_id,
1783
+ comment: str,
1784
+ visibility: Optional[dict] = None,
1785
+ notify_users: bool = True,
1786
+ ):
1657
1787
  """
1658
1788
  Updates an existing comment
1659
1789
  :param issue_key: str
@@ -1665,13 +1795,13 @@ class Jira(AtlassianRestAPI):
1665
1795
  """
1666
1796
  base_url = self.resource_url("issue")
1667
1797
  url = f"{base_url}/{issue_key}/comment/{comment_id}"
1668
- data = {"body": comment}
1798
+ data: dict = {"body": comment}
1669
1799
  if visibility:
1670
1800
  data["visibility"] = visibility
1671
- params = {"notifyUsers": "true" if notify_users else "false"}
1801
+ params: dict = {"notifyUsers": "true" if notify_users else "false"}
1672
1802
  return self.put(url, data=data, params=params)
1673
1803
 
1674
- def scrap_regex_from_issue(self, issue, regex):
1804
+ def scrap_regex_from_issue(self, issue: str, regex: str):
1675
1805
  """
1676
1806
  This function scrapes the output of the given regex matches from the issue's description and comments.
1677
1807
 
@@ -1703,20 +1833,24 @@ class Jira(AtlassianRestAPI):
1703
1833
  except HTTPError as e:
1704
1834
  if e.response.status_code == 404:
1705
1835
  # Raise ApiError as the documented reason is ambiguous
1706
- log.error("couldn't find issue: ", issue["key"])
1836
+ log.error("couldn't find issue: ", issue)
1707
1837
  raise ApiNotFoundError(
1708
1838
  "There is no content with the given issue ud,"
1709
1839
  "or the calling user does not have permission to view the issue",
1710
1840
  reason=e,
1711
1841
  )
1712
1842
 
1713
- def get_issue_remotelinks(self, issue_key, global_id=None, internal_id=None):
1843
+ def get_issue_remotelinks(
1844
+ self, issue_key: str, global_id: Optional[T_id] = None, internal_id: Optional[str] = None
1845
+ ):
1714
1846
  """
1715
1847
  Compatibility naming method with get_issue_remote_links()
1716
1848
  """
1717
1849
  return self.get_issue_remote_links(issue_key, global_id, internal_id)
1718
1850
 
1719
- def get_issue_remote_links(self, issue_key, global_id=None, internal_id=None):
1851
+ def get_issue_remote_links(
1852
+ self, issue_key: str, global_id: Optional[T_id] = None, internal_id: Optional[str] = None
1853
+ ):
1720
1854
  """
1721
1855
  Finding all Remote Links on an issue, also with filtering by Global ID and internal ID
1722
1856
  :param issue_key:
@@ -1726,14 +1860,14 @@ class Jira(AtlassianRestAPI):
1726
1860
  """
1727
1861
  base_url = self.resource_url("issue")
1728
1862
  url = f"{base_url}/{issue_key}/remotelink"
1729
- params = {}
1863
+ params: dict = {}
1730
1864
  if global_id:
1731
1865
  params["globalId"] = global_id
1732
1866
  if internal_id:
1733
1867
  url += "/" + internal_id
1734
1868
  return self.get(url, params=params)
1735
1869
 
1736
- def get_issue_tree_recursive(self, issue_key, tree=None, depth=None):
1870
+ def get_issue_tree_recursive(self, issue_key: str, tree: Optional[list] = None, depth: Optional[int] = None):
1737
1871
  """
1738
1872
  Returns a list that contains the tree structure of the root issue, with all subtasks and inward linked issues.
1739
1873
  (!) Function only returns child issues from the same Jira instance or from an instance to which the API key has access.
@@ -1772,14 +1906,14 @@ class Jira(AtlassianRestAPI):
1772
1906
 
1773
1907
  def create_or_update_issue_remote_links(
1774
1908
  self,
1775
- issue_key,
1776
- link_url,
1777
- title,
1778
- global_id=None,
1779
- relationship=None,
1780
- icon_url=None,
1781
- icon_title=None,
1782
- status_resolved=False,
1909
+ issue_key: str,
1910
+ link_url: str,
1911
+ title: str,
1912
+ global_id: Optional[T_id] = None,
1913
+ relationship: Optional[str] = None,
1914
+ icon_url: Optional[str] = None,
1915
+ icon_title: Optional[str] = None,
1916
+ status_resolved: bool = False,
1783
1917
  application: dict = {},
1784
1918
  ):
1785
1919
  """
@@ -1796,7 +1930,7 @@ class Jira(AtlassianRestAPI):
1796
1930
  """
1797
1931
  base_url = self.resource_url("issue")
1798
1932
  url = f"{base_url}/{issue_key}/remotelink"
1799
- data = {"object": {"url": link_url, "title": title, "status": {"resolved": status_resolved}}}
1933
+ data: dict = {"object": {"url": link_url, "title": title, "status": {"resolved": status_resolved}}}
1800
1934
  if global_id:
1801
1935
  data["globalId"] = global_id
1802
1936
  if relationship:
@@ -1812,12 +1946,20 @@ class Jira(AtlassianRestAPI):
1812
1946
  data["application"] = application
1813
1947
  return self.post(url, data=data)
1814
1948
 
1815
- def get_issue_remote_link_by_id(self, issue_key, link_id):
1949
+ def get_issue_remote_link_by_id(self, issue_key: str, link_id: T_id):
1816
1950
  base_url = self.resource_url("issue")
1817
1951
  url = f"{base_url}/{issue_key}/remotelink/{link_id}"
1818
1952
  return self.get(url)
1819
1953
 
1820
- def update_issue_remote_link_by_id(self, issue_key, link_id, url, title, global_id=None, relationship=None):
1954
+ def update_issue_remote_link_by_id(
1955
+ self,
1956
+ issue_key: str,
1957
+ link_id: T_id,
1958
+ url: str,
1959
+ title: str,
1960
+ global_id: Optional[T_id] = None,
1961
+ relationship: Optional[str] = None,
1962
+ ):
1821
1963
  """
1822
1964
  Update existing Remote Link on Issue
1823
1965
  :param issue_key: str
@@ -1828,7 +1970,7 @@ class Jira(AtlassianRestAPI):
1828
1970
  :param relationship: str, Optional. Default by built-in method: 'Web Link'
1829
1971
 
1830
1972
  """
1831
- data = {"object": {"url": url, "title": title}}
1973
+ data: dict = {"object": {"url": url, "title": title}}
1832
1974
  if global_id:
1833
1975
  data["globalId"] = global_id
1834
1976
  if relationship:
@@ -1837,7 +1979,7 @@ class Jira(AtlassianRestAPI):
1837
1979
  url = f"{base_url}/{issue_key}/remotelink/{link_id}"
1838
1980
  return self.put(url, data=data)
1839
1981
 
1840
- def delete_issue_remote_link_by_id(self, issue_key, link_id):
1982
+ def delete_issue_remote_link_by_id(self, issue_key: str, link_id: T_id) -> T_resp_json:
1841
1983
  """
1842
1984
  Deletes Remote Link on Issue
1843
1985
  :param issue_key: str
@@ -1847,30 +1989,28 @@ class Jira(AtlassianRestAPI):
1847
1989
  url = f"{base_url}/{issue_key}/remotelink/{link_id}"
1848
1990
  return self.delete(url)
1849
1991
 
1850
- def get_issue_transitions(self, issue_key):
1992
+ def get_issue_transitions(self, issue_key: str) -> List[dict]:
1851
1993
  if self.advanced_mode:
1852
- return [
1853
- {
1854
- "name": transition["name"],
1855
- "id": int(transition["id"]),
1856
- "to": transition["to"]["name"],
1857
- }
1858
- for transition in (self.get_issue_transitions_full(issue_key).json() or {}).get("transitions")
1859
- ]
1994
+ resp = cast("Response", self.get_issue_transitions_full(issue_key))
1995
+ d: Dict[str, list] = resp.json() or {}
1860
1996
  else:
1861
- return [
1862
- {
1863
- "name": transition["name"],
1864
- "id": int(transition["id"]),
1865
- "to": transition["to"]["name"],
1866
- }
1867
- for transition in (self.get_issue_transitions_full(issue_key) or {}).get("transitions")
1868
- ]
1997
+ d = self.get_issue_transitions_full(issue_key) or {}
1869
1998
 
1870
- def issue_transition(self, issue_key, status):
1999
+ return [
2000
+ {
2001
+ "name": transition["name"],
2002
+ "id": int(transition["id"]),
2003
+ "to": transition["to"]["name"],
2004
+ }
2005
+ for transition in cast("List[dict]", d.get("transitions"))
2006
+ ]
2007
+
2008
+ def issue_transition(self, issue_key: str, status: str) -> T_resp_json:
1871
2009
  return self.set_issue_status(issue_key, status)
1872
2010
 
1873
- def set_issue_status(self, issue_key, status_name, fields=None, update=None):
2011
+ def set_issue_status(
2012
+ self, issue_key: str, status_name: str, fields: Union[str, dict, None] = None, update: Optional[dict] = None
2013
+ ):
1874
2014
  """
1875
2015
  Setting status by status_name. Field defaults to None for transitions without mandatory fields.
1876
2016
  If there are mandatory fields for the transition, these can be set using a dict in 'fields'.
@@ -1887,14 +2027,14 @@ class Jira(AtlassianRestAPI):
1887
2027
  base_url = self.resource_url("issue")
1888
2028
  url = f"{base_url}/{issue_key}/transitions"
1889
2029
  transition_id = self.get_transition_id_to_status_name(issue_key, status_name)
1890
- data = {"transition": {"id": transition_id}}
2030
+ data: dict = {"transition": {"id": transition_id}}
1891
2031
  if fields is not None:
1892
2032
  data["fields"] = fields
1893
2033
  if update is not None:
1894
2034
  data["update"] = update
1895
2035
  return self.post(url, data=data)
1896
2036
 
1897
- def get_issue_status_changelog(self, issue_id):
2037
+ def get_issue_status_changelog(self, issue_id: T_id):
1898
2038
  # Get the issue details with changelog
1899
2039
  response_get_issue = self.get_issue(issue_id, expand="changelog")
1900
2040
  status_change_history = []
@@ -1908,7 +2048,7 @@ class Jira(AtlassianRestAPI):
1908
2048
 
1909
2049
  return status_change_history
1910
2050
 
1911
- def set_issue_status_by_transition_id(self, issue_key, transition_id):
2051
+ def set_issue_status_by_transition_id(self, issue_key: str, transition_id: T_id):
1912
2052
  """
1913
2053
  Setting status by transition_id
1914
2054
  :param issue_key: str
@@ -1918,19 +2058,21 @@ class Jira(AtlassianRestAPI):
1918
2058
  url = f"{base_url}/{issue_key}/transitions"
1919
2059
  return self.post(url, data={"transition": {"id": transition_id}})
1920
2060
 
1921
- def get_issue_status(self, issue_key):
2061
+ def get_issue_status(self, issue_key: str):
1922
2062
  base_url = self.resource_url("issue")
1923
2063
  url = f"{base_url}/{issue_key}?fields=status"
1924
2064
  fields = [("fields",), ("status",), ("name",)]
1925
2065
  return self._get_response_content(url, fields=fields) or {}
1926
2066
 
1927
- def get_issue_status_id(self, issue_key):
2067
+ def get_issue_status_id(self, issue_key: str) -> str:
1928
2068
  base_url = self.resource_url("issue")
1929
2069
  url = f"{base_url}/{issue_key}?fields=status"
1930
2070
  fields = [("fields",), ("status",), ("id",)]
1931
2071
  return self._get_response_content(url, fields=fields)
1932
2072
 
1933
- def get_issue_transitions_full(self, issue_key, transition_id=None, expand=None):
2073
+ def get_issue_transitions_full(
2074
+ self, issue_key: str, transition_id: Optional[T_id] = None, expand: Optional[str] = None
2075
+ ) -> T_resp_json:
1934
2076
  """
1935
2077
  Get a list of the transitions possible for this issue by the current user,
1936
2078
  along with fields that are required and their types.
@@ -1944,14 +2086,14 @@ class Jira(AtlassianRestAPI):
1944
2086
  """
1945
2087
  base_url = self.resource_url("issue")
1946
2088
  url = f"{base_url}/{issue_key}/transitions"
1947
- params = {}
2089
+ params: dict = {}
1948
2090
  if transition_id:
1949
2091
  params["transitionId"] = transition_id
1950
2092
  if expand:
1951
2093
  params["expand"] = expand
1952
2094
  return self.get(url, params=params)
1953
2095
 
1954
- def get_issue_property_keys(self, issue_key):
2096
+ def get_issue_property_keys(self, issue_key: str):
1955
2097
  """
1956
2098
  Get Property Keys on an Issue.
1957
2099
  :param issue_key: Issue KEY
@@ -1962,22 +2104,22 @@ class Jira(AtlassianRestAPI):
1962
2104
  url = f"{base_url}/{issue_key}/properties"
1963
2105
  return self.get(url)
1964
2106
 
1965
- def set_issue_property(self, issue_key, property_key, data):
2107
+ def set_issue_property(self, issue_key: str, property_key: str, data: dict):
1966
2108
  base_url = self.resource_url("issue")
1967
2109
  url = f"{base_url}/{issue_key}/properties/{property_key}"
1968
2110
  return self.put(url, data=data)
1969
2111
 
1970
- def get_issue_property(self, issue_key, property_key):
2112
+ def get_issue_property(self, issue_key: str, property_key: str):
1971
2113
  base_url = self.resource_url("issue")
1972
2114
  url = f"{base_url}/{issue_key}/properties/{property_key}"
1973
2115
  return self.get(url)
1974
2116
 
1975
- def delete_issue_property(self, issue_key, property_key):
2117
+ def delete_issue_property(self, issue_key: str, property_key: str):
1976
2118
  base_url = self.resource_url("issue")
1977
2119
  url = f"{base_url}/{issue_key}/properties/{property_key}"
1978
2120
  return self.delete(url)
1979
2121
 
1980
- def get_updated_worklogs(self, since, expand=None):
2122
+ def get_updated_worklogs(self, since: str, expand: Optional[str] = None):
1981
2123
  """
1982
2124
  Returns a list of IDs and update timestamps for worklogs updated after a date and time.
1983
2125
  :param since: The date and time, as a UNIX timestamp in milliseconds, after which updated worklogs are returned.
@@ -1985,7 +2127,7 @@ class Jira(AtlassianRestAPI):
1985
2127
  This parameter accepts properties that returns the properties of each worklog.
1986
2128
  """
1987
2129
  url = self.resource_url("worklog/updated")
1988
- params = {}
2130
+ params: dict = {}
1989
2131
  if since:
1990
2132
  params["since"] = str(int(since * 1000))
1991
2133
  if expand:
@@ -1993,19 +2135,19 @@ class Jira(AtlassianRestAPI):
1993
2135
 
1994
2136
  return self.get(url, params=params)
1995
2137
 
1996
- def get_deleted_worklogs(self, since):
2138
+ def get_deleted_worklogs(self, since: str):
1997
2139
  """
1998
2140
  Returns a list of IDs and timestamps for worklogs deleted after a date and time.
1999
2141
  :param since: The date and time, as a UNIX timestamp in milliseconds, after which deleted worklogs are returned.
2000
2142
  """
2001
2143
  url = self.resource_url("worklog/deleted")
2002
- params = {}
2144
+ params: dict = {}
2003
2145
  if since:
2004
2146
  params["since"] = str(int(since * 1000))
2005
2147
 
2006
2148
  return self.get(url, params=params)
2007
2149
 
2008
- def get_worklogs(self, ids, expand=None):
2150
+ def get_worklogs(self, ids: List[T_id], expand: Optional[str] = None):
2009
2151
  """
2010
2152
  Returns worklog details for a list of worklog IDs.
2011
2153
  :param expand: Use expand to include additional information about worklogs in the response.
@@ -2014,7 +2156,7 @@ class Jira(AtlassianRestAPI):
2014
2156
  """
2015
2157
 
2016
2158
  url = self.resource_url("worklog/list")
2017
- params = {}
2159
+ params: dict = {}
2018
2160
  if expand:
2019
2161
  params["expand"] = expand
2020
2162
  data = {"ids": ids}
@@ -2025,7 +2167,13 @@ class Jira(AtlassianRestAPI):
2025
2167
  Reference: https://docs.atlassian.com/software/jira/docs/api/REST/8.5.0/#api/2/user
2026
2168
  """
2027
2169
 
2028
- def user(self, username=None, key=None, account_id=None, expand=None):
2170
+ def user(
2171
+ self,
2172
+ username: Optional[str] = None,
2173
+ key: Optional[str] = None,
2174
+ account_id: Optional[str] = None,
2175
+ expand: Optional[str] = None,
2176
+ ):
2029
2177
  """
2030
2178
  Returns a user. This resource cannot be accessed anonymously.
2031
2179
  You can use only one parameter: username or key
@@ -2036,7 +2184,7 @@ class Jira(AtlassianRestAPI):
2036
2184
  :param expand: Can be 'groups,applicationRoles'
2037
2185
  :return:
2038
2186
  """
2039
- params = {}
2187
+ params: dict = {}
2040
2188
  major_parameter_enabled = False
2041
2189
  if account_id:
2042
2190
  params = {"accountId": account_id}
@@ -2064,7 +2212,7 @@ class Jira(AtlassianRestAPI):
2064
2212
  url = self.resource_url("myself")
2065
2213
  return self.get(url)
2066
2214
 
2067
- def is_active_user(self, username):
2215
+ def is_active_user(self, username: str):
2068
2216
  """
2069
2217
  Check status of user
2070
2218
  :param username:
@@ -2072,7 +2220,7 @@ class Jira(AtlassianRestAPI):
2072
2220
  """
2073
2221
  return self.user(username).get("active")
2074
2222
 
2075
- def user_remove(self, username=None, account_id=None, key=None):
2223
+ def user_remove(self, username: Optional[str] = None, account_id: Optional[str] = None, key: Optional[str] = None):
2076
2224
  """
2077
2225
  Remove user from Jira if this user does not have any activity
2078
2226
  :param key:
@@ -2080,7 +2228,7 @@ class Jira(AtlassianRestAPI):
2080
2228
  :param username:
2081
2229
  :return:
2082
2230
  """
2083
- params = {}
2231
+ params: dict = {}
2084
2232
  if username:
2085
2233
  params["username"] = username
2086
2234
  if account_id:
@@ -2090,7 +2238,7 @@ class Jira(AtlassianRestAPI):
2090
2238
  url = self.resource_url("user")
2091
2239
  return self.delete(url, params=params)
2092
2240
 
2093
- def user_update(self, username, data):
2241
+ def user_update(self, username: str, data: dict):
2094
2242
  """
2095
2243
  Update user attributes based on json
2096
2244
  :param username:
@@ -2101,7 +2249,7 @@ class Jira(AtlassianRestAPI):
2101
2249
  url = f"{base_url}?username={username}"
2102
2250
  return self.put(url, data=data)
2103
2251
 
2104
- def user_update_username(self, old_username, new_username):
2252
+ def user_update_username(self, old_username: str, new_username: str):
2105
2253
  """
2106
2254
  Update username
2107
2255
  :param old_username:
@@ -2111,7 +2259,7 @@ class Jira(AtlassianRestAPI):
2111
2259
  data = {"name": new_username}
2112
2260
  return self.user_update(old_username, data=data)
2113
2261
 
2114
- def user_update_email(self, username, email):
2262
+ def user_update_email(self, username: str, email: str):
2115
2263
  """
2116
2264
  Update user email for new domain changes
2117
2265
  :param username:
@@ -2121,7 +2269,14 @@ class Jira(AtlassianRestAPI):
2121
2269
  data = {"name": username, "emailAddress": email}
2122
2270
  return self.user_update(username, data=data)
2123
2271
 
2124
- def user_create(self, username, email, display_name, password=None, notification=None):
2272
+ def user_create(
2273
+ self,
2274
+ username: str,
2275
+ email: str,
2276
+ display_name: str,
2277
+ password: Optional[str] = None,
2278
+ notification: Optional[bool] = None,
2279
+ ):
2125
2280
  """
2126
2281
  Create a user in Jira
2127
2282
  :param username:
@@ -2133,7 +2288,7 @@ class Jira(AtlassianRestAPI):
2133
2288
  :return:
2134
2289
  """
2135
2290
  log.info("Creating user %s", display_name)
2136
- data = {
2291
+ data: dict = {
2137
2292
  "name": username,
2138
2293
  "emailAddress": email,
2139
2294
  "displayName": display_name,
@@ -2149,7 +2304,7 @@ class Jira(AtlassianRestAPI):
2149
2304
  url = self.resource_url("user")
2150
2305
  return self.post(url, data=data)
2151
2306
 
2152
- def user_properties(self, username=None, account_id=None):
2307
+ def user_properties(self, username: Optional[str] = None, account_id: Optional[str] = None):
2153
2308
  """
2154
2309
  Get user property
2155
2310
  :param username:
@@ -2164,7 +2319,9 @@ class Jira(AtlassianRestAPI):
2164
2319
  url = f"{base_url}?accountId={account_id}"
2165
2320
  return self.get(url)
2166
2321
 
2167
- def user_property(self, username=None, account_id=None, key_property=None):
2322
+ def user_property(
2323
+ self, username: Optional[str] = None, account_id: Optional[str] = None, key_property: Optional[str] = None
2324
+ ):
2168
2325
  """
2169
2326
  Get user property
2170
2327
  :param username:
@@ -2172,7 +2329,7 @@ class Jira(AtlassianRestAPI):
2172
2329
  :param key_property:
2173
2330
  :return:
2174
2331
  """
2175
- params = {}
2332
+ params: dict = {}
2176
2333
  if username or not self.cloud:
2177
2334
  params = {"username": username}
2178
2335
  elif account_id or self.cloud:
@@ -2185,10 +2342,10 @@ class Jira(AtlassianRestAPI):
2185
2342
 
2186
2343
  def user_set_property(
2187
2344
  self,
2188
- username=None,
2189
- account_id=None,
2190
- key_property=None,
2191
- value_property=None,
2345
+ username: Optional[str] = None,
2346
+ account_id: Optional[str] = None,
2347
+ key_property: Optional[str] = None,
2348
+ value_property: Union[str, dict, None] = None,
2192
2349
  ):
2193
2350
  """
2194
2351
  Set property for user
@@ -2207,7 +2364,9 @@ class Jira(AtlassianRestAPI):
2207
2364
 
2208
2365
  return self.put(url, data=value_property)
2209
2366
 
2210
- def user_delete_property(self, username=None, account_id=None, key_property=None):
2367
+ def user_delete_property(
2368
+ self, username: Optional[str] = None, account_id: Optional[str] = None, key_property: Optional[str] = None
2369
+ ):
2211
2370
  """
2212
2371
  Delete property for user
2213
2372
  :param username:
@@ -2217,14 +2376,14 @@ class Jira(AtlassianRestAPI):
2217
2376
  """
2218
2377
  base_url = self.resource_url("user/properties")
2219
2378
  url = f"{base_url}/{key_property}"
2220
- params = {}
2379
+ params: dict = {}
2221
2380
  if username or not self.cloud:
2222
2381
  params = {"username": username}
2223
2382
  elif account_id or self.cloud:
2224
2383
  params = {"accountId": account_id}
2225
2384
  return self.delete(url, params=params)
2226
2385
 
2227
- def user_update_or_create_property_through_rest_point(self, username, key, value):
2386
+ def user_update_or_create_property_through_rest_point(self, username: str, key: str, value: str):
2228
2387
  """
2229
2388
  ATTENTION!
2230
2389
  This method used after configuration of rest endpoint on Jira side
@@ -2234,10 +2393,10 @@ class Jira(AtlassianRestAPI):
2234
2393
  :return:
2235
2394
  """
2236
2395
  url = "rest/scriptrunner/latest/custom/updateUserProperty"
2237
- params = {"username": username, "property": key, "value": value}
2396
+ params: dict = {"username": username, "property": key, "value": value}
2238
2397
  return self.get(url, params=params)
2239
2398
 
2240
- def user_deactivate(self, username):
2399
+ def user_deactivate(self, username: str):
2241
2400
  """
2242
2401
  Disable user. Works from 8.3.0 Release
2243
2402
  https://docs.atlassian.com/software/jira/docs/api/REST/8.3.0/#api/2/user-updateUser
@@ -2247,15 +2406,15 @@ class Jira(AtlassianRestAPI):
2247
2406
  data = {"active": "false", "name": username}
2248
2407
  return self.user_update(username=username, data=data)
2249
2408
 
2250
- def user_disable(self, username):
2409
+ def user_disable(self, username: str):
2251
2410
  """Override the disable method"""
2252
2411
  return self.user_deactivate(username)
2253
2412
 
2254
2413
  def user_disable_throw_rest_endpoint(
2255
2414
  self,
2256
- username,
2257
- url="rest/scriptrunner/latest/custom/disableUser",
2258
- param="userName",
2415
+ username: str,
2416
+ url: str = "rest/scriptrunner/latest/custom/disableUser",
2417
+ param: str = "userName",
2259
2418
  ):
2260
2419
  """The disable method throw own rest endpoint"""
2261
2420
  url = f"{url}?{param}={username}"
@@ -2292,8 +2451,8 @@ class Jira(AtlassianRestAPI):
2292
2451
 
2293
2452
  def users_get_all(
2294
2453
  self,
2295
- start=0,
2296
- limit=50,
2454
+ start: int = 0,
2455
+ limit: int = 50,
2297
2456
  ):
2298
2457
  """
2299
2458
  :param start:
@@ -2301,7 +2460,7 @@ class Jira(AtlassianRestAPI):
2301
2460
  :return:
2302
2461
  """
2303
2462
  url = self.resource_url("users/search")
2304
- params = {
2463
+ params: dict = {
2305
2464
  "startAt": start,
2306
2465
  "maxResults": limit,
2307
2466
  }
@@ -2309,14 +2468,14 @@ class Jira(AtlassianRestAPI):
2309
2468
 
2310
2469
  def user_find_by_user_string(
2311
2470
  self,
2312
- username=None,
2313
- query=None,
2314
- account_id=None,
2315
- property_key=None,
2316
- start=0,
2317
- limit=50,
2318
- include_inactive_users=False,
2319
- include_active_users=True,
2471
+ username: Optional[str] = None,
2472
+ query: Optional[str] = None,
2473
+ account_id: Optional[str] = None,
2474
+ property_key: Optional[str] = None,
2475
+ start: int = 0,
2476
+ limit: int = 50,
2477
+ include_inactive_users: bool = False,
2478
+ include_active_users: bool = True,
2320
2479
  ):
2321
2480
  """
2322
2481
  Fuzzy search using display name, emailAddress or property, or an exact search for accountId or username
@@ -2339,7 +2498,7 @@ class Jira(AtlassianRestAPI):
2339
2498
  :return:
2340
2499
  """
2341
2500
  url = self.resource_url("user/search")
2342
- params = {
2501
+ params: dict = {
2343
2502
  "includeActive": str(include_active_users).lower(),
2344
2503
  "includeInactive": str(include_inactive_users).lower(),
2345
2504
  "startAt": start,
@@ -2369,7 +2528,7 @@ class Jira(AtlassianRestAPI):
2369
2528
 
2370
2529
  return self.get(url, params=params)
2371
2530
 
2372
- def is_user_in_application(self, username, application_key):
2531
+ def is_user_in_application(self, username: str, application_key: str) -> bool:
2373
2532
  """
2374
2533
  Utility function to test whether a user has an application role
2375
2534
  :param username: The username of the user to test.
@@ -2383,7 +2542,7 @@ class Jira(AtlassianRestAPI):
2383
2542
  return True
2384
2543
  return False
2385
2544
 
2386
- def add_user_to_application(self, username, application_key):
2545
+ def add_user_to_application(self, username: str, application_key: str):
2387
2546
  """
2388
2547
  Add a user to an application
2389
2548
  :param username: The username of the user to add.
@@ -2391,7 +2550,7 @@ class Jira(AtlassianRestAPI):
2391
2550
  :return: True if the user was added to the application, else False
2392
2551
  :see: https://docs.atlassian.com/software/jira/docs/api/REST/7.5.3/#api/2/user-addUserToApplication
2393
2552
  """
2394
- params = {"username": username, "applicationKey": application_key}
2553
+ params: dict = {"username": username, "applicationKey": application_key}
2395
2554
  url = self.resource_url("user/application")
2396
2555
  return self.post(url, params=params) is None
2397
2556
 
@@ -2400,7 +2559,7 @@ class Jira(AtlassianRestAPI):
2400
2559
  Reference: https://docs.atlassian.com/software/jira/docs/api/REST/8.5.0/#api/2/project
2401
2560
  """
2402
2561
 
2403
- def get_user_groups(self, account_id=None):
2562
+ def get_user_groups(self, account_id: Optional[str] = None):
2404
2563
  """
2405
2564
  Get groups of a user
2406
2565
  This API is only available for Jira Cloud platform
@@ -2411,10 +2570,10 @@ class Jira(AtlassianRestAPI):
2411
2570
  url = self.resource_url("user/groups")
2412
2571
  return self.get(url, params=params)
2413
2572
 
2414
- def get_all_projects(self, included_archived=None, expand=None):
2573
+ def get_all_projects(self, included_archived: Optional[bool] = None, expand: Optional[str] = None):
2415
2574
  return self.projects(included_archived, expand)
2416
2575
 
2417
- def projects(self, included_archived=None, expand=None):
2576
+ def projects(self, included_archived: Optional[bool] = None, expand: Optional[str] = None):
2418
2577
  """
2419
2578
  Returns all projects which are visible for the currently logged-in user.
2420
2579
  If no user is logged in, it returns the list of projects that are visible when using anonymous access.
@@ -2423,7 +2582,7 @@ class Jira(AtlassianRestAPI):
2423
2582
  :return:
2424
2583
  """
2425
2584
 
2426
- params = {}
2585
+ params: dict = {}
2427
2586
  if included_archived:
2428
2587
  params["includeArchived"] = included_archived
2429
2588
  if expand:
@@ -2439,7 +2598,7 @@ class Jira(AtlassianRestAPI):
2439
2598
  url = self.resource_url("project")
2440
2599
  return self.get(url, params=params)
2441
2600
 
2442
- def create_project_from_raw_json(self, json):
2601
+ def create_project_from_raw_json(self, json: Union[str, dict]):
2443
2602
  """
2444
2603
  Creates a new project.
2445
2604
  {
@@ -2462,7 +2621,7 @@ class Jira(AtlassianRestAPI):
2462
2621
  """
2463
2622
  return self.post("rest/api/2/project", json=json)
2464
2623
 
2465
- def create_project_from_shared_template(self, project_id, key, name, lead):
2624
+ def create_project_from_shared_template(self, project_id: T_id, key: str, name: str, lead: str):
2466
2625
  """
2467
2626
  Creates a new project based on an existing project.
2468
2627
  :param str project_id: The numeric ID of the project to clone
@@ -2478,7 +2637,7 @@ class Jira(AtlassianRestAPI):
2478
2637
  json=json,
2479
2638
  )
2480
2639
 
2481
- def delete_project(self, key):
2640
+ def delete_project(self, key: str):
2482
2641
  """
2483
2642
  DELETE /rest/api/2/project/<project_key>
2484
2643
  :param key: str
@@ -2488,7 +2647,7 @@ class Jira(AtlassianRestAPI):
2488
2647
  url = f"{base_url}/{key}"
2489
2648
  return self.delete(url)
2490
2649
 
2491
- def archive_project(self, key):
2650
+ def archive_project(self, key: str):
2492
2651
  """
2493
2652
  Archives a project.
2494
2653
  :param key:
@@ -2497,21 +2656,21 @@ class Jira(AtlassianRestAPI):
2497
2656
  url = f"{base_url}/{key}/archive"
2498
2657
  return self.put(url)
2499
2658
 
2500
- def project(self, key, expand=None):
2659
+ def project(self, key: str, expand: Optional[str] = None):
2501
2660
  """
2502
2661
  Get project with details
2503
2662
  :param key:
2504
2663
  :param expand:
2505
2664
  :return:
2506
2665
  """
2507
- params = {}
2666
+ params: dict = {}
2508
2667
  if expand:
2509
2668
  params["expand"] = expand
2510
2669
  base_url = self.resource_url("project")
2511
2670
  url = f"{base_url}/{key}"
2512
2671
  return self.get(url, params=params)
2513
2672
 
2514
- def get_project(self, key, expand=None):
2673
+ def get_project(self, key: str, expand: Optional[str] = None):
2515
2674
  """
2516
2675
  Contains a full representation of a project in JSON format.
2517
2676
  All project keys associated with the project will only be returned if expand=projectKeys.
@@ -2521,7 +2680,7 @@ class Jira(AtlassianRestAPI):
2521
2680
  """
2522
2681
  return self.project(key=key, expand=expand)
2523
2682
 
2524
- def get_project_components(self, key):
2683
+ def get_project_components(self, key: str):
2525
2684
  """
2526
2685
  Get project components using project key
2527
2686
  :param key: str
@@ -2531,14 +2690,14 @@ class Jira(AtlassianRestAPI):
2531
2690
  url = f"{base_url}/{key}/components"
2532
2691
  return self.get(url)
2533
2692
 
2534
- def get_project_versions(self, key, expand=None):
2693
+ def get_project_versions(self, key: str, expand: Optional[str] = None):
2535
2694
  """
2536
2695
  Contains a full representation of the specified project's versions.
2537
2696
  :param key:
2538
2697
  :param expand: the parameters to expand
2539
2698
  :return:
2540
2699
  """
2541
- params = {}
2700
+ params: dict = {}
2542
2701
  if expand is not None:
2543
2702
  params["expand"] = expand
2544
2703
  base_url = self.resource_url("project")
@@ -2547,13 +2706,13 @@ class Jira(AtlassianRestAPI):
2547
2706
 
2548
2707
  def get_project_versions_paginated(
2549
2708
  self,
2550
- key,
2551
- start=None,
2552
- limit=None,
2553
- order_by=None,
2554
- expand=None,
2555
- query=None,
2556
- status=None,
2709
+ key: str,
2710
+ start: Optional[int] = None,
2711
+ limit: Optional[int] = None,
2712
+ order_by: Optional[str] = None,
2713
+ expand: Optional[str] = None,
2714
+ query: Optional[str] = None,
2715
+ status: Optional[str] = None,
2557
2716
  ):
2558
2717
  """
2559
2718
  Returns all versions for the specified project. Results are paginated.
@@ -2573,7 +2732,7 @@ class Jira(AtlassianRestAPI):
2573
2732
  This parameter accepts a comma-separated list. The status values are released, unreleased, and archived.
2574
2733
  :return:
2575
2734
  """
2576
- params = {}
2735
+ params: dict = {}
2577
2736
  if start is not None:
2578
2737
  params["startAt"] = int(start)
2579
2738
  if limit is not None:
@@ -2590,7 +2749,7 @@ class Jira(AtlassianRestAPI):
2590
2749
  url = f"{base_url}/{key}/version"
2591
2750
  return self.get(url, params=params)
2592
2751
 
2593
- def get_version(self, version):
2752
+ def get_version(self, version: T_id):
2594
2753
  """
2595
2754
  Returns a specific version with the given id.
2596
2755
  :param version: The id of the version to return
@@ -2601,11 +2760,11 @@ class Jira(AtlassianRestAPI):
2601
2760
 
2602
2761
  def add_version(
2603
2762
  self,
2604
- project_key,
2605
- project_id,
2606
- version,
2607
- is_archived=False,
2608
- is_released=False,
2763
+ project_key: str,
2764
+ project_id: T_id,
2765
+ version: str,
2766
+ is_archived: bool = False,
2767
+ is_released: bool = False,
2609
2768
  ):
2610
2769
  """
2611
2770
  Add missing version to project
@@ -2626,7 +2785,7 @@ class Jira(AtlassianRestAPI):
2626
2785
  url = self.resource_url("version")
2627
2786
  return self.post(url, data=payload)
2628
2787
 
2629
- def delete_version(self, version, moved_fixed=None, move_affected=None):
2788
+ def delete_version(self, version: str, moved_fixed: Optional[str] = None, move_affected: Optional[str] = None):
2630
2789
  """
2631
2790
  Delete version from the project
2632
2791
  :param int version: the version id to delete
@@ -2644,13 +2803,13 @@ class Jira(AtlassianRestAPI):
2644
2803
 
2645
2804
  def update_version(
2646
2805
  self,
2647
- version,
2648
- name=None,
2649
- description=None,
2650
- is_archived=None,
2651
- is_released=None,
2652
- start_date=None,
2653
- release_date=None,
2806
+ version: str,
2807
+ name: Optional[str] = None,
2808
+ description: Optional[str] = None,
2809
+ is_archived: Optional[bool] = None,
2810
+ is_released: Optional[bool] = None,
2811
+ start_date: Optional[str] = None,
2812
+ release_date: Optional[str] = None,
2654
2813
  ):
2655
2814
  """
2656
2815
  Update a project version
@@ -2674,7 +2833,7 @@ class Jira(AtlassianRestAPI):
2674
2833
  url = f"{base_url}/{version}"
2675
2834
  return self.put(url, data=payload)
2676
2835
 
2677
- def move_version(self, version, after=None, position=None):
2836
+ def move_version(self, version: T_id, after: Optional[T_id] = None, position: Optional[str] = None):
2678
2837
  """
2679
2838
  Reposition a project version
2680
2839
  :param version: The version id to move
@@ -2694,7 +2853,7 @@ class Jira(AtlassianRestAPI):
2694
2853
  raise ValueError(f"position must be one of Earlier, Later, First, or Last. Got {position}")
2695
2854
  return self.post(url, data={"position": position})
2696
2855
 
2697
- def get_project_roles(self, project_key):
2856
+ def get_project_roles(self, project_key: str):
2698
2857
  """
2699
2858
  Provide associated project roles
2700
2859
  :param project_key:
@@ -2704,7 +2863,7 @@ class Jira(AtlassianRestAPI):
2704
2863
  url = f"{base_url}/{project_key}/role"
2705
2864
  return self.get(url)
2706
2865
 
2707
- def get_project_actors_for_role_project(self, project_key, role_id):
2866
+ def get_project_actors_for_role_project(self, project_key: str, role_id: T_id):
2708
2867
  """
2709
2868
  Returns the details for a given project role in a project.
2710
2869
  :param project_key:
@@ -2715,7 +2874,13 @@ class Jira(AtlassianRestAPI):
2715
2874
  url = f"{base_url}/{project_key}/role/{role_id}"
2716
2875
  return self._get_response_content(url, fields=[("actors",)])
2717
2876
 
2718
- def delete_project_actors(self, project_key, role_id, actor, actor_type=None):
2877
+ def delete_project_actors(
2878
+ self,
2879
+ project_key: str,
2880
+ role_id: T_id,
2881
+ actor: str,
2882
+ actor_type: Union[Literal["user"], Literal["group"], None] = None,
2883
+ ):
2719
2884
  """
2720
2885
  Deletes actors (users or groups) from a project role.
2721
2886
  Delete a user from the role: /rest/api/2/project/{projectIdOrKey}/role/{roleId}?user={username}
@@ -2728,12 +2893,12 @@ class Jira(AtlassianRestAPI):
2728
2893
  """
2729
2894
  base_url = self.resource_url("project")
2730
2895
  url = f"{base_url}/{project_key}/role/{role_id}"
2731
- params = {}
2896
+ params: dict = {}
2732
2897
  if actor_type is not None and actor_type in ["group", "user"]:
2733
2898
  params[actor_type] = actor
2734
2899
  return self.delete(url, params=params)
2735
2900
 
2736
- def add_user_into_project_role(self, project_key, role_id, user_name):
2901
+ def add_user_into_project_role(self, project_key: str, role_id: T_id, user_name: str):
2737
2902
  """
2738
2903
 
2739
2904
  :param project_key:
@@ -2743,7 +2908,7 @@ class Jira(AtlassianRestAPI):
2743
2908
  """
2744
2909
  return self.add_project_actor_in_role(project_key, role_id, user_name, "atlassian-user-role-actor")
2745
2910
 
2746
- def add_project_actor_in_role(self, project_key, role_id, actor, actor_type):
2911
+ def add_project_actor_in_role(self, project_key: str, role_id: T_id, actor: str, actor_type: str):
2747
2912
  """
2748
2913
 
2749
2914
  :param project_key:
@@ -2762,7 +2927,7 @@ class Jira(AtlassianRestAPI):
2762
2927
 
2763
2928
  return self.post(url, data=data)
2764
2929
 
2765
- def update_project(self, project_key, data, expand=None):
2930
+ def update_project(self, project_key: str, data: dict, expand: Optional[str] = None):
2766
2931
  """
2767
2932
  Updates a project.
2768
2933
  Only non-null values sent in JSON will be updated in the project.
@@ -2775,12 +2940,14 @@ class Jira(AtlassianRestAPI):
2775
2940
  """
2776
2941
  base_url = self.resource_url("project")
2777
2942
  url = f"{base_url}/{project_key}"
2778
- params = {}
2943
+ params: dict = {}
2779
2944
  if expand:
2780
2945
  params["expand"] = expand
2781
2946
  return self.put(url, data, params=params)
2782
2947
 
2783
- def update_project_category_for_project(self, project_key, new_project_category_id, expand=None):
2948
+ def update_project_category_for_project(
2949
+ self, project_key: str, new_project_category_id: T_id, expand: Optional[str] = None
2950
+ ):
2784
2951
  """
2785
2952
  Updates a project.
2786
2953
  Update project: /rest/api/2/project/{projectIdOrKey}
@@ -2798,7 +2965,7 @@ class Jira(AtlassianRestAPI):
2798
2965
  https://docs.atlassian.com/software/jira/docs/api/REST/8.5.0/#api/2/project/{projectKeyOrId}/notificationscheme
2799
2966
  """
2800
2967
 
2801
- def get_notification_scheme_for_project(self, project_id_or_key):
2968
+ def get_notification_scheme_for_project(self, project_id_or_key: str):
2802
2969
  """
2803
2970
  Gets a notification scheme associated with the project.
2804
2971
  Follow the documentation of /notificationscheme/{id} resource for all details about returned value.
@@ -2809,7 +2976,7 @@ class Jira(AtlassianRestAPI):
2809
2976
  url = f"{base_url}/{project_id_or_key}/notificationscheme"
2810
2977
  return self.get(url)
2811
2978
 
2812
- def assign_project_notification_scheme(self, project_key, new_notification_scheme=""):
2979
+ def assign_project_notification_scheme(self, project_key: str, new_notification_scheme: str = ""):
2813
2980
  """
2814
2981
  Updates a project.
2815
2982
  Update project: /rest/api/2/project/{projectIdOrKey}
@@ -2833,7 +3000,7 @@ class Jira(AtlassianRestAPI):
2833
3000
  """
2834
3001
  return self.get_notification_schemes().get("values") or []
2835
3002
 
2836
- def get_notification_scheme(self, notification_scheme_id, expand=None):
3003
+ def get_notification_scheme(self, notification_scheme_id: T_id, expand: Optional[str] = None):
2837
3004
  """
2838
3005
  Returns a full representation of the notification scheme for the given id.
2839
3006
  Use 'expand' to get details
@@ -2872,12 +3039,12 @@ class Jira(AtlassianRestAPI):
2872
3039
  """
2873
3040
  base_url = self.resource_url("notificationscheme")
2874
3041
  url = f"{base_url}/{notification_scheme_id}"
2875
- params = {}
3042
+ params: dict = {}
2876
3043
  if expand:
2877
3044
  params["expand"] = expand
2878
3045
  return self.get(url, params=params)
2879
3046
 
2880
- def get_project_notification_scheme(self, project_id_or_key):
3047
+ def get_project_notification_scheme(self, project_id_or_key: str):
2881
3048
  """
2882
3049
  Gets a notification scheme assigned with a project
2883
3050
 
@@ -2894,7 +3061,7 @@ class Jira(AtlassianRestAPI):
2894
3061
  https://docs.atlassian.com/software/jira/docs/api/REST/8.5.0/#api/2/project/{projectKeyOrId}/permissionscheme
2895
3062
  """
2896
3063
 
2897
- def assign_project_permission_scheme(self, project_id_or_key, permission_scheme_id):
3064
+ def assign_project_permission_scheme(self, project_id_or_key: str, permission_scheme_id: T_id):
2898
3065
  """
2899
3066
  Assigns a permission scheme with a project.
2900
3067
  :param project_id_or_key:
@@ -2906,7 +3073,7 @@ class Jira(AtlassianRestAPI):
2906
3073
  data = {"id": permission_scheme_id}
2907
3074
  return self.put(url, data=data)
2908
3075
 
2909
- def get_project_permission_scheme(self, project_id_or_key, expand=None):
3076
+ def get_project_permission_scheme(self, project_id_or_key: str, expand: Optional[str] = None):
2910
3077
  """
2911
3078
  Gets a permission scheme assigned with a project
2912
3079
  Use 'expand' to get details
@@ -2917,12 +3084,12 @@ class Jira(AtlassianRestAPI):
2917
3084
  """
2918
3085
  base_url = self.resource_url("project")
2919
3086
  url = f"{base_url}/{project_id_or_key}/permissionscheme"
2920
- params = {}
3087
+ params: dict = {}
2921
3088
  if expand:
2922
3089
  params["expand"] = expand
2923
3090
  return self.get(url, params=params)
2924
3091
 
2925
- def create_permission_scheme(self, name, description, permissions):
3092
+ def create_permission_scheme(self, name: str, description: str, permissions: dict):
2926
3093
  """
2927
3094
  Create a new permission scheme
2928
3095
 
@@ -2945,7 +3112,7 @@ class Jira(AtlassianRestAPI):
2945
3112
  url = self.resource_url("issuetype")
2946
3113
  return self.get(url)
2947
3114
 
2948
- def create_issue_type(self, name, description="", type="standard"):
3115
+ def create_issue_type(self, name: str, description: str = "", type: str = "standard"):
2949
3116
  """
2950
3117
  Create a new issue type
2951
3118
  :param name:
@@ -2983,28 +3150,33 @@ class Jira(AtlassianRestAPI):
2983
3150
  "lead_email": lead["emailAddress"],
2984
3151
  }
2985
3152
 
2986
- def get_project_issuekey_last(self, project):
3153
+ def get_project_issuekey_last(self, project: str):
2987
3154
  jql = f'project = "{project}" ORDER BY issuekey DESC'
2988
3155
  response = self.jql(jql)
2989
3156
  if self.advanced_mode:
2990
- return response
2991
- return (response.get("issues") or {"key": None})[0]["key"]
3157
+ return cast("Response", response)
3158
+
3159
+ return (cast("dict", response).__getitem__("issues") or {"key": None})[0]["key"]
2992
3160
 
2993
- def get_project_issuekey_all(self, project, start=0, limit=None, expand=None):
3161
+ def get_project_issuekey_all(
3162
+ self, project: str, start: int = 0, limit: Optional[int] = None, expand: Optional[str] = None
3163
+ ):
2994
3164
  jql = f'project = "{project}" ORDER BY issuekey ASC'
2995
3165
  response = self.jql(jql, start=start, limit=limit, expand=expand)
2996
3166
  if self.advanced_mode:
2997
- return response
2998
- return [issue["key"] for issue in response["issues"]]
3167
+ return cast("Response", response)
3168
+ return [issue["key"] for issue in cast("dict", response)["issues"]]
2999
3169
 
3000
- def get_project_issues_count(self, project):
3170
+ def get_project_issues_count(self, project: str):
3001
3171
  jql = f'project = "{project}" '
3002
3172
  response = self.jql(jql, fields="*none")
3003
3173
  if self.advanced_mode:
3004
- return response
3005
- return response["total"]
3174
+ return cast("Response", response)
3175
+ return cast("dict", response)["total"]
3006
3176
 
3007
- def get_all_project_issues(self, project, fields="*all", start=0, limit=None):
3177
+ def get_all_project_issues(
3178
+ self, project: str, fields: Union[str, List[str]] = "*all", start: int = 0, limit: Optional[int] = None
3179
+ ):
3008
3180
  """
3009
3181
  Get the Issues for a Project
3010
3182
  :param project: Project Key name
@@ -3016,10 +3188,10 @@ class Jira(AtlassianRestAPI):
3016
3188
  jql = f'project = "{project}" ORDER BY key'
3017
3189
  response = self.jql(jql, fields=fields, start=start, limit=limit)
3018
3190
  if self.advanced_mode:
3019
- return response
3020
- return response["issues"]
3191
+ return cast("Response", response)
3192
+ return cast("dict", response)["issues"]
3021
3193
 
3022
- def get_all_assignable_users_for_project(self, project_key, start=0, limit=50):
3194
+ def get_all_assignable_users_for_project(self, project_key: str, start: int = 0, limit: int = 50):
3023
3195
  """
3024
3196
  Provide assignable users for project
3025
3197
  :param project_key:
@@ -3032,7 +3204,9 @@ class Jira(AtlassianRestAPI):
3032
3204
  url = f"{base_url}?project={project_key}&startAt={start}&maxResults={limit}"
3033
3205
  return self.get(url)
3034
3206
 
3035
- def get_assignable_users_for_issue(self, issue_key, username=None, start=0, limit=50):
3207
+ def get_assignable_users_for_issue(
3208
+ self, issue_key: str, username: Optional[str] = None, start: int = 0, limit: int = 50
3209
+ ) -> T_resp_json:
3036
3210
  """
3037
3211
  Provide assignable users for issue
3038
3212
  :param issue_key:
@@ -3048,17 +3222,17 @@ class Jira(AtlassianRestAPI):
3048
3222
  url += f"&username={username}"
3049
3223
  return self.get(url)
3050
3224
 
3051
- def get_status_id_from_name(self, status_name):
3225
+ def get_status_id_from_name(self, status_name: str):
3052
3226
  base_url = self.resource_url("status")
3053
3227
  url = f"{base_url}/{status_name}"
3054
3228
  return int(self._get_response_content(url, fields=[("id",)]))
3055
3229
 
3056
- def get_status_for_project(self, project_key):
3230
+ def get_status_for_project(self, project_key: str) -> T_resp_json:
3057
3231
  base_url = self.resource_url("project")
3058
3232
  url = f"{base_url}/{project_key}/statuses"
3059
3233
  return self.get(url)
3060
3234
 
3061
- def get_all_time_tracking_providers(self):
3235
+ def get_all_time_tracking_providers(self) -> T_resp_json:
3062
3236
  """
3063
3237
  Returns all time tracking providers. By default, Jira only has one time tracking provider: JIRA provided time
3064
3238
  tracking. However, you can install other time tracking providers via apps from the Atlassian Marketplace.
@@ -3066,7 +3240,7 @@ class Jira(AtlassianRestAPI):
3066
3240
  url = self.resource_url("configuration/timetracking/list")
3067
3241
  return self.get(url)
3068
3242
 
3069
- def get_selected_time_tracking_provider(self):
3243
+ def get_selected_time_tracking_provider(self) -> T_resp_json:
3070
3244
  """
3071
3245
  Returns the time tracking provider that is currently selected. Note that if time tracking is disabled,
3072
3246
  then a successful but empty response is returned.
@@ -3074,7 +3248,7 @@ class Jira(AtlassianRestAPI):
3074
3248
  url = self.resource_url("configuration/timetracking")
3075
3249
  return self.get(url)
3076
3250
 
3077
- def get_time_tracking_settings(self):
3251
+ def get_time_tracking_settings(self) -> T_resp_json:
3078
3252
  """
3079
3253
  Returns the time tracking settings. This includes settings such as the time format, default time unit,
3080
3254
  and others.
@@ -3082,17 +3256,18 @@ class Jira(AtlassianRestAPI):
3082
3256
  url = self.resource_url("configuration/timetracking/options")
3083
3257
  return self.get(url)
3084
3258
 
3085
- def get_transition_id_to_status_name(self, issue_key, status_name):
3259
+ def get_transition_id_to_status_name(self, issue_key: str, status_name: str) -> Optional[int]:
3086
3260
  for transition in self.get_issue_transitions(issue_key):
3087
3261
  if status_name.lower() == transition["to"].lower():
3088
3262
  return int(transition["id"])
3263
+ return None
3089
3264
 
3090
3265
  """
3091
3266
  The Link Issue Resource provides functionality to manage issue links.
3092
3267
  Reference: https://docs.atlassian.com/software/jira/docs/api/REST/8.5.0/#api/2/issueLink
3093
3268
  """
3094
3269
 
3095
- def create_issue_link(self, data):
3270
+ def create_issue_link(self, data: dict) -> T_resp_json:
3096
3271
  """
3097
3272
  Creates an issue link between two issues.
3098
3273
  The user requires the link issue permission for the issue which will be linked to another issue.
@@ -3118,7 +3293,7 @@ class Jira(AtlassianRestAPI):
3118
3293
  url = self.resource_url("issueLink")
3119
3294
  return self.post(url, data=data)
3120
3295
 
3121
- def get_issue_link(self, link_id):
3296
+ def get_issue_link(self, link_id: T_id) -> T_resp_json:
3122
3297
  """
3123
3298
  Returns an issue link with the specified id.
3124
3299
  :param link_id: the issue link id.
@@ -3128,7 +3303,7 @@ class Jira(AtlassianRestAPI):
3128
3303
  url = f"{base_url}/{link_id}"
3129
3304
  return self.get(url)
3130
3305
 
3131
- def remove_issue_link(self, link_id):
3306
+ def remove_issue_link(self, link_id: T_id) -> T_resp_json:
3132
3307
  """
3133
3308
  Deletes an issue link with the specified id.
3134
3309
  To be able to delete an issue link you must be able to view both issues
@@ -3145,7 +3320,7 @@ class Jira(AtlassianRestAPI):
3145
3320
  Reference: https://docs.atlassian.com/software/jira/docs/api/REST/8.5.0/#api/2/issueLinkType
3146
3321
  """
3147
3322
 
3148
- def get_issue_link_types(self):
3323
+ def get_issue_link_types(self) -> list:
3149
3324
  """Returns a list of available issue link types,
3150
3325
  if issue linking is enabled.
3151
3326
  Each issue link type has an id,
@@ -3154,14 +3329,14 @@ class Jira(AtlassianRestAPI):
3154
3329
  url = self.resource_url("issueLinkType")
3155
3330
  return self._get_response_content(url, fields=[("issueLinkTypes",)])
3156
3331
 
3157
- def get_issue_link_types_names(self):
3332
+ def get_issue_link_types_names(self) -> list:
3158
3333
  """
3159
3334
  Provide issue link type names
3160
3335
  :return:
3161
3336
  """
3162
3337
  return [link_type["name"] for link_type in self.get_issue_link_types()]
3163
3338
 
3164
- def create_issue_link_type_by_json(self, data):
3339
+ def create_issue_link_type_by_json(self, data: dict) -> T_resp_json:
3165
3340
  """Create a new issue link type.
3166
3341
  :param data:
3167
3342
  {
@@ -3174,7 +3349,7 @@ class Jira(AtlassianRestAPI):
3174
3349
  url = self.resource_url("issueLinkType")
3175
3350
  return self.post(url, data=data)
3176
3351
 
3177
- def create_issue_link_type(self, link_type_name, inward, outward):
3352
+ def create_issue_link_type(self, link_type_name: str, inward: str, outward: str) -> Union[T_resp_json, str]:
3178
3353
  """Create a new issue link type.
3179
3354
  :param outward:
3180
3355
  :param inward:
@@ -3187,19 +3362,19 @@ class Jira(AtlassianRestAPI):
3187
3362
  data = {"name": link_type_name, "inward": inward, "outward": outward}
3188
3363
  return self.create_issue_link_type_by_json(data=data)
3189
3364
 
3190
- def get_issue_link_type(self, issue_link_type_id):
3365
+ def get_issue_link_type(self, issue_link_type_id: T_id) -> T_resp_json:
3191
3366
  """Returns for a given issue link type id all information about this issue link type."""
3192
3367
  base_url = self.resource_url("issueLinkType")
3193
3368
  url = f"{base_url}/{issue_link_type_id}"
3194
3369
  return self.get(url)
3195
3370
 
3196
- def delete_issue_link_type(self, issue_link_type_id):
3371
+ def delete_issue_link_type(self, issue_link_type_id: T_id) -> T_resp_json:
3197
3372
  """Delete the specified issue link type."""
3198
3373
  base_url = self.resource_url("issueLinkType")
3199
3374
  url = f"{base_url}/{issue_link_type_id}"
3200
3375
  return self.delete(url)
3201
3376
 
3202
- def update_issue_link_type(self, issue_link_type_id, data):
3377
+ def update_issue_link_type(self, issue_link_type_id: T_id, data: dict) -> T_resp_json:
3203
3378
  """
3204
3379
  Update the specified issue link type.
3205
3380
  :param issue_link_type_id:
@@ -3219,7 +3394,7 @@ class Jira(AtlassianRestAPI):
3219
3394
  Reference: https://docs.atlassian.com/software/jira/docs/api/REST/8.5.0/#api/2/resolution
3220
3395
  """
3221
3396
 
3222
- def get_all_resolutions(self):
3397
+ def get_all_resolutions(self) -> T_resp_json:
3223
3398
  """
3224
3399
  Returns a list of all resolutions.
3225
3400
  :return:
@@ -3227,7 +3402,7 @@ class Jira(AtlassianRestAPI):
3227
3402
  url = self.resource_url("resolution")
3228
3403
  return self.get(url)
3229
3404
 
3230
- def get_resolution_by_id(self, resolution_id):
3405
+ def get_resolution_by_id(self, resolution_id: T_id) -> T_resp_json:
3231
3406
  """
3232
3407
  Get Resolution info by id
3233
3408
  :param resolution_id:
@@ -3242,7 +3417,7 @@ class Jira(AtlassianRestAPI):
3242
3417
  Reference: https://docs.atlassian.com/software/jira/docs/api/REST/8.5.0/#api/2/role
3243
3418
  """
3244
3419
 
3245
- def get_all_global_project_roles(self):
3420
+ def get_all_global_project_roles(self) -> T_resp_json:
3246
3421
  """
3247
3422
  Get all the ProjectRoles available in Jira. Currently, this list is global.
3248
3423
  :return:
@@ -3255,7 +3430,7 @@ class Jira(AtlassianRestAPI):
3255
3430
  Reference: https://docs.atlassian.com/software/jira/docs/api/REST/8.5.0/#api/2/screens
3256
3431
  """
3257
3432
 
3258
- def get_all_screens(self):
3433
+ def get_all_screens(self) -> T_resp_json:
3259
3434
  """
3260
3435
  Get all available screens from Jira
3261
3436
  :return: list of json elements of screen with field id, name. description
@@ -3263,7 +3438,7 @@ class Jira(AtlassianRestAPI):
3263
3438
  url = self.resource_url("screens")
3264
3439
  return self.get(url)
3265
3440
 
3266
- def get_all_available_screen_fields(self, screen_id):
3441
+ def get_all_available_screen_fields(self, screen_id: T_id) -> T_resp_json:
3267
3442
  """
3268
3443
  Get all available fields by screen id
3269
3444
  :param screen_id:
@@ -3273,7 +3448,7 @@ class Jira(AtlassianRestAPI):
3273
3448
  url = f"{base_url}/{screen_id}/availableFields"
3274
3449
  return self.get(url)
3275
3450
 
3276
- def get_screen_tabs(self, screen_id):
3451
+ def get_screen_tabs(self, screen_id: T_id) -> Optional[list]:
3277
3452
  """
3278
3453
  Get tabs for the screen id
3279
3454
  :param screen_id:
@@ -3281,9 +3456,9 @@ class Jira(AtlassianRestAPI):
3281
3456
  """
3282
3457
  base_url = self.resource_url("screens")
3283
3458
  url = f"{base_url}/{screen_id}/tabs"
3284
- return self.get(url)
3459
+ return self.get(url) # type: ignore[return-value]
3285
3460
 
3286
- def get_screen_tab_fields(self, screen_id, tab_id):
3461
+ def get_screen_tab_fields(self, screen_id: T_id, tab_id: T_id) -> Optional[list]:
3287
3462
  """
3288
3463
  Get fields by the tab id and the screen id
3289
3464
  :param tab_id:
@@ -3292,24 +3467,24 @@ class Jira(AtlassianRestAPI):
3292
3467
  """
3293
3468
  base_url = self.resource_url("screens")
3294
3469
  url = f"{base_url}/{screen_id}/tabs/{tab_id}/fields"
3295
- return self.get(url)
3470
+ return self.get(url) # type: ignore[return-value]
3296
3471
 
3297
- def get_all_screen_fields(self, screen_id):
3472
+ def get_all_screen_fields(self, screen_id: T_id) -> list:
3298
3473
  """
3299
3474
  Get all fields by screen id
3300
3475
  :param screen_id:
3301
3476
  :return:
3302
3477
  """
3303
- screen_tabs = self.get_screen_tabs(screen_id)
3304
- fields = []
3478
+ screen_tabs = self.get_screen_tabs(screen_id) or []
3479
+ fields: list = []
3305
3480
  for screen_tab in screen_tabs:
3306
3481
  tab_id = screen_tab["id"]
3307
3482
  if tab_id:
3308
- tab_fields = self.get_screen_tab_fields(screen_id=screen_id, tab_id=tab_id)
3483
+ tab_fields = self.get_screen_tab_fields(screen_id=screen_id, tab_id=tab_id) or []
3309
3484
  fields = fields + tab_fields
3310
3485
  return fields
3311
3486
 
3312
- def add_field(self, field_id, screen_id, tab_id):
3487
+ def add_field(self, field_id: T_id, screen_id: T_id, tab_id: T_id) -> T_resp_json:
3313
3488
  """
3314
3489
  Add field to a given tab in a screen
3315
3490
  :param field_id: field or custom field ID to be added
@@ -3327,13 +3502,13 @@ class Jira(AtlassianRestAPI):
3327
3502
 
3328
3503
  def jql(
3329
3504
  self,
3330
- jql,
3331
- fields="*all",
3332
- start=0,
3333
- limit=None,
3334
- expand=None,
3335
- validate_query=None,
3336
- ):
3505
+ jql: str,
3506
+ fields: Union[str, List[str]] = "*all",
3507
+ start: int = 0,
3508
+ limit: Optional[int] = None,
3509
+ expand: Optional[str] = None,
3510
+ validate_query: Optional[str] = None,
3511
+ ) -> T_resp_json:
3337
3512
  """
3338
3513
  Get issues from jql search result with all related fields
3339
3514
  :param jql:
@@ -3355,7 +3530,7 @@ class Jira(AtlassianRestAPI):
3355
3530
  )
3356
3531
  else:
3357
3532
  raise ValueError("The `jql` method is deprecated in Jira Cloud. Use `enhanced_jql` method instead.")
3358
- params = {}
3533
+ params: dict = {}
3359
3534
  if start is not None:
3360
3535
  params["startAt"] = int(start)
3361
3536
  if limit is not None:
@@ -3375,11 +3550,11 @@ class Jira(AtlassianRestAPI):
3375
3550
 
3376
3551
  def enhanced_jql(
3377
3552
  self,
3378
- jql,
3379
- fields="*all",
3380
- nextPageToken=None,
3381
- limit=None,
3382
- expand=None,
3553
+ jql: str,
3554
+ fields: Union[str, List[str]] = "*all",
3555
+ nextPageToken: Optional[str] = None,
3556
+ limit: Optional[int] = None,
3557
+ expand: Optional[str] = None,
3383
3558
  ):
3384
3559
  """
3385
3560
  Get issues from jql search result with all related fields
@@ -3394,7 +3569,8 @@ class Jira(AtlassianRestAPI):
3394
3569
 
3395
3570
  if not self.cloud:
3396
3571
  raise ValueError("``enhanced_jql`` method is only available for Jira Cloud platform")
3397
- params = {}
3572
+ params: dict = {}
3573
+
3398
3574
  if nextPageToken is not None:
3399
3575
  params["nextPageToken"] = str(nextPageToken)
3400
3576
  if limit is not None:
@@ -3412,7 +3588,7 @@ class Jira(AtlassianRestAPI):
3412
3588
 
3413
3589
  def approximate_issue_count(
3414
3590
  self,
3415
- jql,
3591
+ jql: str,
3416
3592
  ):
3417
3593
  """
3418
3594
  Get an approximate count of issues matching a JQL search string.
@@ -3431,13 +3607,13 @@ class Jira(AtlassianRestAPI):
3431
3607
 
3432
3608
  def jql_get_list_of_tickets(
3433
3609
  self,
3434
- jql,
3435
- fields="*all",
3436
- start=0,
3437
- limit=None,
3438
- expand=None,
3439
- validate_query=None,
3440
- ):
3610
+ jql: str,
3611
+ fields: Union[str, dict] = "*all",
3612
+ start: int = 0,
3613
+ limit: Optional[int] = None,
3614
+ expand: Optional[str] = None,
3615
+ validate_query: Optional[str] = None,
3616
+ ) -> list:
3441
3617
  """
3442
3618
  Get issues from jql search result with all related fields
3443
3619
  :param jql:
@@ -3462,7 +3638,7 @@ class Jira(AtlassianRestAPI):
3462
3638
  "The `jql_get_list_of_tickets` method is deprecated in Jira Cloud. Use `enhanced_jql_get_list_of_tickets` method instead."
3463
3639
  )
3464
3640
 
3465
- params = {}
3641
+ params: dict = {}
3466
3642
  if limit is not None:
3467
3643
  params["maxResults"] = int(limit)
3468
3644
  if fields is not None:
@@ -3477,7 +3653,7 @@ class Jira(AtlassianRestAPI):
3477
3653
  params["validateQuery"] = validate_query
3478
3654
  url = self.resource_url("search")
3479
3655
 
3480
- results = []
3656
+ results: List[object] = []
3481
3657
  while True:
3482
3658
  params["startAt"] = int(start)
3483
3659
  response = self.get(url, params=params)
@@ -3496,10 +3672,10 @@ class Jira(AtlassianRestAPI):
3496
3672
 
3497
3673
  def enhanced_jql_get_list_of_tickets(
3498
3674
  self,
3499
- jql,
3500
- fields="*all",
3501
- limit=None,
3502
- expand=None,
3675
+ jql: str,
3676
+ fields: Union[str, dict] = "*all",
3677
+ limit: Optional[int] = None,
3678
+ expand: Optional[str] = None,
3503
3679
  ):
3504
3680
  """
3505
3681
  Get issues from JQL search result with all related fields using nextPageToken pagination.
@@ -3517,7 +3693,7 @@ class Jira(AtlassianRestAPI):
3517
3693
  if not self.cloud:
3518
3694
  raise ValueError("``enhanced_jql_get_list_of_tickets`` is only available for Jira Cloud.")
3519
3695
 
3520
- params = {}
3696
+ params: dict = {}
3521
3697
  if limit is not None:
3522
3698
  params["maxResults"] = int(limit)
3523
3699
  if fields is not None:
@@ -3548,7 +3724,14 @@ class Jira(AtlassianRestAPI):
3548
3724
  break
3549
3725
  return results
3550
3726
 
3551
- def csv(self, jql, limit=1000, all_fields=True, start=None, delimiter=None):
3727
+ def csv(
3728
+ self,
3729
+ jql: str,
3730
+ limit: int = 1000,
3731
+ all_fields: bool = True,
3732
+ start: Optional[int] = None,
3733
+ delimiter: Optional[str] = None,
3734
+ ) -> bytes:
3552
3735
  """
3553
3736
  Get issues from jql search result with ALL or CURRENT fields
3554
3737
  default will be to return all fields
@@ -3560,7 +3743,7 @@ class Jira(AtlassianRestAPI):
3560
3743
  :return: CSV file
3561
3744
  """
3562
3745
 
3563
- params = {"jqlQuery": jql}
3746
+ params: dict = {"jqlQuery": jql}
3564
3747
  if limit:
3565
3748
  params["tempMax"] = limit
3566
3749
  if start:
@@ -3580,7 +3763,7 @@ class Jira(AtlassianRestAPI):
3580
3763
  headers={"Accept": "application/csv"},
3581
3764
  )
3582
3765
 
3583
- def excel(self, jql, limit=1000, all_fields=True, start=None):
3766
+ def excel(self, jql: str, limit: int = 1000, all_fields: bool = True, start: Optional[int] = None) -> bytes:
3584
3767
  """
3585
3768
  Get issues from jql search result with ALL or CURRENT fields
3586
3769
  default will be to return all fields
@@ -3591,7 +3774,7 @@ class Jira(AtlassianRestAPI):
3591
3774
  :return: CSV file
3592
3775
  """
3593
3776
 
3594
- params = {"jqlQuery": jql}
3777
+ params: dict = {"jqlQuery": jql}
3595
3778
  if limit:
3596
3779
  params["tempMax"] = limit
3597
3780
  if start:
@@ -3609,7 +3792,9 @@ class Jira(AtlassianRestAPI):
3609
3792
  headers={"Accept": "application/vnd.ms-excel"},
3610
3793
  )
3611
3794
 
3612
- def export_html(self, jql, limit=None, all_fields=True, start=None):
3795
+ def export_html(
3796
+ self, jql: str, limit: Optional[int] = None, all_fields: bool = True, start: Optional[int] = None
3797
+ ) -> bytes:
3613
3798
  """
3614
3799
  Get issues from jql search result with ALL or CURRENT fields
3615
3800
  default will be to return all fields
@@ -3620,7 +3805,7 @@ class Jira(AtlassianRestAPI):
3620
3805
  :return: HTML file
3621
3806
  """
3622
3807
 
3623
- params = {"jqlQuery": jql}
3808
+ params: dict = {"jqlQuery": jql}
3624
3809
  if limit:
3625
3810
  params["tempMax"] = limit
3626
3811
  if start:
@@ -3638,7 +3823,7 @@ class Jira(AtlassianRestAPI):
3638
3823
  headers={"Accept": "application/xhtml+xml"},
3639
3824
  )
3640
3825
 
3641
- def get_all_priorities(self):
3826
+ def get_all_priorities(self) -> T_resp_json:
3642
3827
  """
3643
3828
  Returns a list of all priorities.
3644
3829
  :return:
@@ -3646,7 +3831,7 @@ class Jira(AtlassianRestAPI):
3646
3831
  url = self.resource_url("priority")
3647
3832
  return self.get(url)
3648
3833
 
3649
- def get_priority_by_id(self, priority_id):
3834
+ def get_priority_by_id(self, priority_id: T_id) -> T_resp_json:
3650
3835
  """
3651
3836
  Get Priority info by id
3652
3837
  :param priority_id:
@@ -3661,7 +3846,7 @@ class Jira(AtlassianRestAPI):
3661
3846
  Reference: https://docs.atlassian.com/software/jira/docs/api/REST/8.5.0/#api/2/workflow
3662
3847
  """
3663
3848
 
3664
- def get_all_workflows(self):
3849
+ def get_all_workflows(self) -> T_resp_json:
3665
3850
  """
3666
3851
  Provide all workflows for application admin
3667
3852
  :return:
@@ -3669,7 +3854,13 @@ class Jira(AtlassianRestAPI):
3669
3854
  url = self.resource_url("workflow")
3670
3855
  return self.get(url)
3671
3856
 
3672
- def get_workflows_paginated(self, start_at=None, max_results=None, workflow_name=None, expand=None):
3857
+ def get_workflows_paginated(
3858
+ self,
3859
+ start_at: Optional[int] = None,
3860
+ max_results: Optional[int] = None,
3861
+ workflow_name: Optional[str] = None,
3862
+ expand: Optional[str] = None,
3863
+ ) -> T_resp_json:
3673
3864
  """
3674
3865
  Provide all workflows paginated (see https://developer.atlassian.com/cloud/jira/platform/rest/v2/\
3675
3866
  api-group-workflows/#api-rest-api-2-workflow-search-get)
@@ -3683,7 +3874,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
3683
3874
  """
3684
3875
  url = self.resource_url("workflow/search")
3685
3876
 
3686
- params = {}
3877
+ params: dict = {}
3687
3878
  if start_at:
3688
3879
  params["startAt"] = start_at
3689
3880
  if max_results:
@@ -3695,7 +3886,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
3695
3886
 
3696
3887
  return self.get(url, params=params)
3697
3888
 
3698
- def get_all_statuses(self):
3889
+ def get_all_statuses(self) -> T_resp_json:
3699
3890
  """
3700
3891
  Returns a list of all statuses
3701
3892
  :return:
@@ -3703,7 +3894,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
3703
3894
  url = self.resource_url("status")
3704
3895
  return self.get(url)
3705
3896
 
3706
- def get_plugins_info(self):
3897
+ def get_plugins_info(self) -> T_resp_json:
3707
3898
  """
3708
3899
  Provide plugins info
3709
3900
  :return a json of installed plugins
@@ -3711,7 +3902,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
3711
3902
  url = "rest/plugins/1.0/"
3712
3903
  return self.get(url, headers=self.no_check_headers, trailing=True)
3713
3904
 
3714
- def get_plugin_info(self, plugin_key):
3905
+ def get_plugin_info(self, plugin_key: str) -> T_resp_json:
3715
3906
  """
3716
3907
  Provide plugin info
3717
3908
  :return a json of installed plugins
@@ -3719,7 +3910,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
3719
3910
  url = f"rest/plugins/1.0/{plugin_key}-key"
3720
3911
  return self.get(url, headers=self.no_check_headers, trailing=True)
3721
3912
 
3722
- def get_plugin_license_info(self, plugin_key):
3913
+ def get_plugin_license_info(self, plugin_key: str) -> T_resp_json:
3723
3914
  """
3724
3915
  Provide plugin license info
3725
3916
  :return a json specific License query
@@ -3727,7 +3918,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
3727
3918
  url = f"rest/plugins/1.0/{plugin_key}-key/license"
3728
3919
  return self.get(url, headers=self.no_check_headers, trailing=True)
3729
3920
 
3730
- def upload_plugin(self, plugin_path):
3921
+ def upload_plugin(self, plugin_path: str) -> T_resp_json:
3731
3922
  """
3732
3923
  Provide plugin path for upload into Jira e.g. useful for auto deploy
3733
3924
  :param plugin_path:
@@ -3743,7 +3934,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
3743
3934
  url = f"rest/plugins/1.0/?token={upm_token}"
3744
3935
  return self.post(url, files=files, headers=self.no_check_headers)
3745
3936
 
3746
- def delete_plugin(self, plugin_key):
3937
+ def delete_plugin(self, plugin_key: str) -> T_resp_json:
3747
3938
  """
3748
3939
  Delete plugin
3749
3940
  :param plugin_key:
@@ -3752,11 +3943,11 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
3752
3943
  url = f"rest/plugins/1.0/{plugin_key}-key"
3753
3944
  return self.delete(url)
3754
3945
 
3755
- def check_plugin_manager_status(self):
3946
+ def check_plugin_manager_status(self) -> Response:
3756
3947
  url = "rest/plugins/latest/safe-mode"
3757
3948
  return self.request(method="GET", path=url, headers=self.safe_mode_headers)
3758
3949
 
3759
- def update_plugin_license(self, plugin_key, raw_license):
3950
+ def update_plugin_license(self, plugin_key: str, raw_license: str) -> T_resp_json:
3760
3951
  """
3761
3952
  Update license for plugin
3762
3953
  :param plugin_key:
@@ -3771,7 +3962,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
3771
3962
  data = {"rawLicense": raw_license}
3772
3963
  return self.put(url, data=data, headers=app_headers)
3773
3964
 
3774
- def disable_plugin(self, plugin_key):
3965
+ def disable_plugin(self, plugin_key: str) -> T_resp_json:
3775
3966
  """
3776
3967
  Disable a plugin
3777
3968
  :param plugin_key:
@@ -3785,7 +3976,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
3785
3976
  data = {"status": "disabled"}
3786
3977
  return self.put(url, data=data, headers=app_headers)
3787
3978
 
3788
- def enable_plugin(self, plugin_key):
3979
+ def enable_plugin(self, plugin_key: str) -> T_resp_json:
3789
3980
  """
3790
3981
  Enable a plugin
3791
3982
  :param plugin_key:
@@ -3799,7 +3990,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
3799
3990
  data = {"status": "enabled"}
3800
3991
  return self.put(url, data=data, headers=app_headers)
3801
3992
 
3802
- def get_all_permissionschemes(self, expand=None):
3993
+ def get_all_permissionschemes(self, expand: Optional[str] = None):
3803
3994
  """
3804
3995
  Returns a list of all permission schemes.
3805
3996
  By default, only shortened beans are returned.
@@ -3810,12 +4001,12 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
3810
4001
  :return:
3811
4002
  """
3812
4003
  url = self.resource_url("permissionscheme")
3813
- params = {}
4004
+ params: dict = {}
3814
4005
  if expand:
3815
4006
  params["expand"] = expand
3816
4007
  return self._get_response_content(url, params=params, fields=[("permissionSchemes",)])
3817
4008
 
3818
- def get_permissionscheme(self, permission_id, expand=None):
4009
+ def get_permissionscheme(self, permission_id: T_id, expand: Optional[str] = None) -> T_resp_json:
3819
4010
  """
3820
4011
  Returns a list of all permission schemes.
3821
4012
  By default, only shortened beans are returned.
@@ -3828,12 +4019,12 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
3828
4019
  """
3829
4020
  base_url = self.resource_url("permissionscheme")
3830
4021
  url = f"{base_url}/{permission_id}"
3831
- params = {}
4022
+ params: dict = {}
3832
4023
  if expand:
3833
4024
  params["expand"] = expand
3834
4025
  return self.get(url, params=params)
3835
4026
 
3836
- def set_permissionscheme_grant(self, permission_id, new_permission):
4027
+ def set_permissionscheme_grant(self, permission_id: T_id, new_permission: str) -> T_resp_json:
3837
4028
  """
3838
4029
  Creates a permission grant in a permission scheme.
3839
4030
  Example:
@@ -3854,7 +4045,15 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
3854
4045
  url = f"{base_url}/{permission_id}/permission"
3855
4046
  return self.post(url, data=new_permission)
3856
4047
 
3857
- def update_permissionscheme(self, permission_id, name, description=None, permissions=None, scope=None, expand=None):
4048
+ def update_permissionscheme(
4049
+ self,
4050
+ permission_id: str,
4051
+ name: str,
4052
+ description: Optional[str] = None,
4053
+ permissions: Optional[list[dict]] = None,
4054
+ scope: Optional[str] = None,
4055
+ expand: Optional[str] = None,
4056
+ ):
3858
4057
  """
3859
4058
  Updates a permission scheme. Below are some important things to note when using this resource:
3860
4059
  - If a permissions list is present in the request, then it is set in the permission scheme, overwriting all existing grants.
@@ -3887,7 +4086,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
3887
4086
  """
3888
4087
  base_url = self.resource_url("permissionscheme")
3889
4088
  url = f"{base_url}/{permission_id}"
3890
- data = {"name": name}
4089
+ data: dict = {"name": name}
3891
4090
  if description is not None:
3892
4091
  data["description"] = description
3893
4092
  if permissions is not None:
@@ -3908,7 +4107,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
3908
4107
  https://docs.atlassian.com/software/jira/docs/api/REST/8.5.0/#api/2/priorityschemes
3909
4108
  """
3910
4109
 
3911
- def get_issue_security_schemes(self):
4110
+ def get_issue_security_schemes(self) -> T_resp_json:
3912
4111
  """
3913
4112
  Returns all issue security schemes that are defined
3914
4113
  Administrator permission required
@@ -3918,7 +4117,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
3918
4117
  url = self.resource_url("issuesecurityschemes")
3919
4118
  return self._get_response_content(url, fields=[("issueSecuritySchemes",)])
3920
4119
 
3921
- def get_issue_security_scheme(self, scheme_id, only_levels=False):
4120
+ def get_issue_security_scheme(self, scheme_id: T_id, only_levels: bool = False) -> T_resp_json:
3922
4121
  """
3923
4122
  Returns the issue security scheme along with that are defined
3924
4123
 
@@ -3937,7 +4136,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
3937
4136
  else:
3938
4137
  return self.get(url)
3939
4138
 
3940
- def get_project_issue_security_scheme(self, project_id_or_key, only_levels=False):
4139
+ def get_project_issue_security_scheme(self, project_id_or_key: int, only_levels: bool = False) -> T_resp_json:
3941
4140
  """
3942
4141
  Returns the issue security scheme for project
3943
4142
 
@@ -3967,7 +4166,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
3967
4166
  return response.get("levels") or None
3968
4167
  return response
3969
4168
 
3970
- def get_all_priority_schemes(self, start=0, limit=100, expand=None):
4169
+ def get_all_priority_schemes(self, start: int = 0, limit: int = 100, expand: Optional[str] = None) -> T_resp_json:
3971
4170
  """
3972
4171
  Returns all priority schemes.
3973
4172
  All project keys associated with the priority scheme will only be returned
@@ -3978,7 +4177,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
3978
4177
  :return:
3979
4178
  """
3980
4179
  url = self.resource_url("priorityschemes")
3981
- params = {}
4180
+ params: dict = {}
3982
4181
  if start:
3983
4182
  params["startAt"] = int(start)
3984
4183
  if limit:
@@ -3987,7 +4186,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
3987
4186
  params["expand"] = expand
3988
4187
  return self.get(url, params=params)
3989
4188
 
3990
- def create_priority_scheme(self, data):
4189
+ def create_priority_scheme(self, data: dict) -> T_resp_json:
3991
4190
  """
3992
4191
  Creates new priority scheme.
3993
4192
  :param data:
@@ -4012,7 +4211,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4012
4211
  https://docs.atlassian.com/software/jira/docs/api/REST/8.5.0/#api/2/project/{projectKeyOrId}/priorityscheme
4013
4212
  """
4014
4213
 
4015
- def get_priority_scheme_of_project(self, project_key_or_id, expand=None):
4214
+ def get_priority_scheme_of_project(self, project_key_or_id: str, expand: Optional[str] = None) -> T_resp_json:
4016
4215
  """
4017
4216
  Gets a full representation of a priority scheme in JSON format used by specified project.
4018
4217
  Resource for associating priority scheme schemes and projects.
@@ -4021,14 +4220,14 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4021
4220
  :param expand: notificationSchemeEvents,user,group,projectRole,field,all
4022
4221
  :return:
4023
4222
  """
4024
- params = {}
4223
+ params: dict = {}
4025
4224
  if expand:
4026
4225
  params["expand"] = expand
4027
4226
  base_url = self.resource_url("project")
4028
4227
  url = f"{base_url}/{project_key_or_id}/priorityscheme"
4029
4228
  return self.get(url, params=params)
4030
4229
 
4031
- def assign_priority_scheme_for_project(self, project_key_or_id, priority_scheme_id):
4230
+ def assign_priority_scheme_for_project(self, project_key_or_id: str, priority_scheme_id: T_id) -> T_resp_json:
4032
4231
  """
4033
4232
  Assigns project with priority scheme. Priority scheme assign with migration is possible from the UI.
4034
4233
  Operation will fail if migration is needed as a result of operation
@@ -4050,7 +4249,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4050
4249
  https://docs.atlassian.com/software/jira/docs/api/REST/8.5.0/#api/2/project/{projectKeyOrId}/securitylevel
4051
4250
  """
4052
4251
 
4053
- def get_security_level_for_project(self, project_key_or_id):
4252
+ def get_security_level_for_project(self, project_key_or_id: T_id) -> T_resp_json:
4054
4253
  """
4055
4254
  Returns all security levels for the project that the current logged-in user has access to.
4056
4255
  If the user does not have the Set Issue Security permission, the list will be empty.
@@ -4066,7 +4265,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4066
4265
  Reference: https://docs.atlassian.com/software/jira/docs/api/REST/8.5.0/#api/2/project/type
4067
4266
  """
4068
4267
 
4069
- def get_all_project_types(self):
4268
+ def get_all_project_types(self) -> T_resp_json:
4070
4269
  """
4071
4270
  Returns all the project types defined on the Jira instance,
4072
4271
  not taking into account whether the license to use those project types is valid or not.
@@ -4080,7 +4279,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4080
4279
  Reference: https://docs.atlassian.com/software/jira/docs/api/REST/8.5.0/#api/2/projectCategory
4081
4280
  """
4082
4281
 
4083
- def get_all_project_categories(self):
4282
+ def get_all_project_categories(self) -> T_resp_json:
4084
4283
  """
4085
4284
  Returns all project categories
4086
4285
  :return: Returns a list of project categories.
@@ -4093,13 +4292,13 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4093
4292
  Reference: https://docs.atlassian.com/software/jira/docs/api/REST/8.5.0/#api/2/projectvalidate
4094
4293
  """
4095
4294
 
4096
- def get_project_validated_key(self, key):
4295
+ def get_project_validated_key(self, key: str) -> T_resp_json:
4097
4296
  """
4098
4297
  Validates a project key.
4099
4298
  :param key: the project key
4100
4299
  :return:
4101
4300
  """
4102
- params = {"key": key}
4301
+ params: dict = {"key": key}
4103
4302
  url = self.resource_url("projectvalidate/key")
4104
4303
  return self.get(url, params=params)
4105
4304
 
@@ -4107,7 +4306,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4107
4306
  REST resources for Issue Type Schemes
4108
4307
  """
4109
4308
 
4110
- def add_issue_type_scheme(self, scheme_id, project_key):
4309
+ def add_issue_type_scheme(self, scheme_id: T_id, project_key: str) -> T_resp_json:
4111
4310
  """
4112
4311
  Associate an issue type scheme with an additional project
4113
4312
  https://docs.atlassian.com/software/jira/docs/api/REST/8.5.8#api/2/issuetypescheme-addProjectAssociationsToScheme
@@ -4119,7 +4318,9 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4119
4318
  data = {"idsOrKeys": [project_key]}
4120
4319
  return self.post(url, data=data)
4121
4320
 
4122
- def create_issuetype_scheme(self, name, description, default_issue_type_id, issue_type_ids):
4321
+ def create_issuetype_scheme(
4322
+ self, name: str, description: str, default_issue_type_id: T_id, issue_type_ids: list
4323
+ ) -> T_resp_json:
4123
4324
  """
4124
4325
  Create an issue type scheme
4125
4326
  https://docs.atlassian.com/software/jira/docs/api/REST/8.13.6/#api/2/issuetypescheme-createIssueTypeScheme
@@ -4144,11 +4345,11 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4144
4345
 
4145
4346
  def reindex(
4146
4347
  self,
4147
- comments=True,
4148
- change_history=True,
4149
- worklogs=True,
4150
- indexing_type="BACKGROUND_PREFERRED",
4151
- ):
4348
+ comments: bool = True,
4349
+ change_history: bool = True,
4350
+ worklogs: bool = True,
4351
+ indexing_type: str = "BACKGROUND_PREFERRED",
4352
+ ) -> T_resp_json:
4152
4353
  """
4153
4354
  Reindex the Jira instance
4154
4355
  Kicks off a reindex. Need Admin permissions to perform this reindex.
@@ -4167,7 +4368,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4167
4368
  :param indexing_type: OPTIONAL: The default value for the type is BACKGROUND_PREFERRED
4168
4369
  :return:
4169
4370
  """
4170
- params = {}
4371
+ params: dict = {}
4171
4372
  if not comments:
4172
4373
  params["indexComments"] = comments
4173
4374
  if not change_history:
@@ -4179,7 +4380,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4179
4380
  url = self.resource_url("reindex")
4180
4381
  return self.post(url, params=params)
4181
4382
 
4182
- def reindex_with_type(self, indexing_type="BACKGROUND_PREFERRED"):
4383
+ def reindex_with_type(self, indexing_type: str = "BACKGROUND_PREFERRED") -> T_resp_json:
4183
4384
  """
4184
4385
  Reindex the Jira instance
4185
4386
  Type of re-indexing available:
@@ -4193,7 +4394,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4193
4394
  """
4194
4395
  return self.reindex(indexing_type=indexing_type)
4195
4396
 
4196
- def reindex_status(self):
4397
+ def reindex_status(self) -> T_resp_json:
4197
4398
  """
4198
4399
  Returns information on the system reindexes.
4199
4400
  If a reindex is currently taking place then information about this reindex is returned.
@@ -4204,27 +4405,27 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4204
4405
  url = self.resource_url("reindex")
4205
4406
  return self.get(url)
4206
4407
 
4207
- def reindex_project(self, project_key):
4408
+ def reindex_project(self, project_key: str) -> T_resp_json:
4208
4409
  return self.post(
4209
4410
  "secure/admin/IndexProject.jspa",
4210
4411
  data=f"confirmed=true&key={project_key}",
4211
4412
  headers=self.form_token_headers,
4212
4413
  )
4213
4414
 
4214
- def reindex_issue(self, list_of_):
4415
+ def reindex_issue(self, list_of_: list) -> None:
4215
4416
  pass
4216
4417
 
4217
- def index_checker(self, max_results=100):
4418
+ def index_checker(self, max_results: int = 100) -> T_resp_json:
4218
4419
  """
4219
4420
  Jira DC Index health checker
4220
4421
  :param max_results:
4221
4422
  :return:
4222
4423
  """
4223
4424
  url = "rest/indexanalyzer/1/state"
4224
- params = {"maxResults": max_results}
4425
+ params: dict = {"maxResults": max_results}
4225
4426
  return self.get(url, params=params)
4226
4427
 
4227
- def get_server_info(self, do_health_check=False):
4428
+ def get_server_info(self, do_health_check: bool = False) -> T_resp_json:
4228
4429
  """
4229
4430
  Returns general information about the current Jira server.
4230
4431
  with health checks or not.
@@ -4239,14 +4440,16 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4239
4440
  #######################################################################
4240
4441
  # Tempo Account REST API implements
4241
4442
  #######################################################################
4242
- def tempo_account_get_accounts(self, skip_archived=None, expand=None):
4443
+ def tempo_account_get_accounts(
4444
+ self, skip_archived: Optional[bool] = None, expand: Optional[str] = None
4445
+ ) -> T_resp_json:
4243
4446
  """
4244
4447
  Get all Accounts that the logged-in user has permission to browse.
4245
4448
  :param skip_archived: bool OPTIONAL: skip archived Accounts, either true or false, default value true.
4246
4449
  :param expand: bool OPTIONAL: With expanded data or not
4247
4450
  :return:
4248
4451
  """
4249
- params = {}
4452
+ params: dict = {}
4250
4453
  if skip_archived is not None:
4251
4454
  params["skipArchived"] = skip_archived
4252
4455
  if expand is not None:
@@ -4254,7 +4457,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4254
4457
  url = "rest/tempo-accounts/1/account"
4255
4458
  return self.get(url, params=params)
4256
4459
 
4257
- def tempo_account_get_accounts_by_jira_project(self, project_id):
4460
+ def tempo_account_get_accounts_by_jira_project(self, project_id: T_id) -> T_resp_json:
4258
4461
  """
4259
4462
  Get Accounts by JIRA Project. The Caller must have the Browse Account permission for Account.
4260
4463
  This will return Accounts for which the Caller has Browse Account Permission for.
@@ -4265,8 +4468,8 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4265
4468
  return self.get(url)
4266
4469
 
4267
4470
  def tempo_account_associate_with_jira_project(
4268
- self, account_id, project_id, default_account=False, link_type="MANUAL"
4269
- ):
4471
+ self, account_id: T_id, project_id: T_id, default_account: bool = False, link_type: str = "MANUAL"
4472
+ ) -> T_resp_json:
4270
4473
  """
4271
4474
  The AccountLinkBean for associate Account with project
4272
4475
  Adds a link to an Account.
@@ -4300,7 +4503,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4300
4503
  url = "rest/tempo-accounts/1/link/"
4301
4504
  return self.post(url, data=data)
4302
4505
 
4303
- def tempo_account_add_account(self, data=None):
4506
+ def tempo_account_add_account(self, data: Optional[dict] = None) -> Union[T_resp_json, str]:
4304
4507
  """
4305
4508
  Creates Account, adding new Account requires the Manage Accounts Permission.
4306
4509
  :param data: String then it will convert to json
@@ -4317,7 +4520,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4317
4520
  """
4318
4521
  return self.post(url, data=data)
4319
4522
 
4320
- def tempo_account_delete_account_by_id(self, account_id):
4523
+ def tempo_account_delete_account_by_id(self, account_id: str) -> T_resp_json:
4321
4524
  """
4322
4525
  Delete an Account by id. Caller must have the Manage Account Permission for the Account.
4323
4526
  The Account can not be deleted if it has an AccountLinkBean.
@@ -4327,17 +4530,17 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4327
4530
  url = f"rest/tempo-accounts/1/account/{account_id}/"
4328
4531
  return self.delete(url)
4329
4532
 
4330
- def tempo_account_get_rate_table_by_account_id(self, account_id):
4533
+ def tempo_account_get_rate_table_by_account_id(self, account_id: str) -> T_resp_json:
4331
4534
  """
4332
4535
  Returns a rate table for the specified account.
4333
4536
  :param account_id: the account id.
4334
4537
  :return:
4335
4538
  """
4336
- params = {"scopeType": "ACCOUNT", "scopeId": account_id}
4539
+ params: dict = {"scopeType": "ACCOUNT", "scopeId": account_id}
4337
4540
  url = "rest/tempo-accounts/1/ratetable"
4338
4541
  return self.get(url, params=params)
4339
4542
 
4340
- def tempo_account_get_all_account_by_customer_id(self, customer_id):
4543
+ def tempo_account_get_all_account_by_customer_id(self, customer_id: T_id) -> T_resp_json:
4341
4544
  """
4342
4545
  Get un-archived Accounts by customer. The Caller must have the Browse Account permission for the Account.
4343
4546
  :param customer_id: the Customer id.
@@ -4346,7 +4549,9 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4346
4549
  url = f"rest/tempo-accounts/1/account/customer/{customer_id}/"
4347
4550
  return self.get(url)
4348
4551
 
4349
- def tempo_account_get_customers(self, query=None, count_accounts=None):
4552
+ def tempo_account_get_customers(
4553
+ self, query: Optional[str] = None, count_accounts: Optional[bool] = None
4554
+ ) -> T_resp_json:
4350
4555
  """
4351
4556
  Gets all or some Attribute whose key or name contain a specific substring.
4352
4557
  Attributes can be a Category or Customer.
@@ -4354,7 +4559,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4354
4559
  :param count_accounts: bool OPTIONAL: provide how many associated Accounts with Customer
4355
4560
  :return: list of customers
4356
4561
  """
4357
- params = {}
4562
+ params: dict = {}
4358
4563
  if query is not None:
4359
4564
  params["query"] = query
4360
4565
  if count_accounts is not None:
@@ -4362,7 +4567,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4362
4567
  url = "rest/tempo-accounts/1/customer"
4363
4568
  return self.get(url, params=params)
4364
4569
 
4365
- def tempo_account_add_new_customer(self, key, name):
4570
+ def tempo_account_add_new_customer(self, key: str, name: str) -> T_resp_json:
4366
4571
  """
4367
4572
  Gets all or some Attribute whose key or name contain a specific substring.
4368
4573
  Attributes can be a Category or Customer.
@@ -4374,7 +4579,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4374
4579
  url = "rest/tempo-accounts/1/customer"
4375
4580
  return self.post(url, data=data)
4376
4581
 
4377
- def tempo_account_add_customer(self, data=None):
4582
+ def tempo_account_add_customer(self, data: Optional[dict] = None) -> Union[T_resp_json, str]:
4378
4583
  """
4379
4584
  Gets all or some Attribute whose key or name contain a specific substring.
4380
4585
  Attributes can be a Category or Customer.
@@ -4389,7 +4594,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4389
4594
  url = "rest/tempo-accounts/1/customer"
4390
4595
  return self.post(url, data=data)
4391
4596
 
4392
- def tempo_account_get_customer_by_id(self, customer_id=1):
4597
+ def tempo_account_get_customer_by_id(self, customer_id: T_id = 1) -> T_resp_json:
4393
4598
  """
4394
4599
  Get Account Attribute whose key or name contain a specific substring. Attribute can be a Category or Customer.
4395
4600
  :param customer_id: id of Customer record
@@ -4398,7 +4603,9 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4398
4603
  url = f"rest/tempo-accounts/1/customer/{customer_id}"
4399
4604
  return self.get(url)
4400
4605
 
4401
- def tempo_account_update_customer_by_id(self, customer_id=1, data=None):
4606
+ def tempo_account_update_customer_by_id(
4607
+ self, customer_id: T_id = 1, data: Optional[dict] = None
4608
+ ) -> Union[T_resp_json, str]:
4402
4609
  """
4403
4610
  Updates an Attribute. Caller must have Manage Account Permission. Attribute can be a Category or Customer.
4404
4611
  :param customer_id: id of Customer record
@@ -4419,7 +4626,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4419
4626
  url = f"rest/tempo-accounts/1/customer/{customer_id}"
4420
4627
  return self.put(url, data=data)
4421
4628
 
4422
- def tempo_account_delete_customer_by_id(self, customer_id=1):
4629
+ def tempo_account_delete_customer_by_id(self, customer_id: T_id = 1) -> T_resp_json:
4423
4630
  """
4424
4631
  Delete an Attribute. Caller must have Manage Account Permission. Attribute can be a Category or Customer.
4425
4632
  :param customer_id: id of Customer record
@@ -4428,7 +4635,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4428
4635
  url = f"rest/tempo-accounts/1/customer/{customer_id}"
4429
4636
  return self.delete(url)
4430
4637
 
4431
- def tempo_account_export_accounts(self):
4638
+ def tempo_account_export_accounts(self) -> bytes:
4432
4639
  """
4433
4640
  Get csv export file of Accounts from Tempo
4434
4641
  :return: csv file
@@ -4437,7 +4644,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4437
4644
  url = "rest/tempo-accounts/1/export"
4438
4645
  return self.get(url, headers=headers, not_json_response=True)
4439
4646
 
4440
- def tempo_holiday_get_schemes(self):
4647
+ def tempo_holiday_get_schemes(self) -> T_resp_json:
4441
4648
  """
4442
4649
  Provide a holiday schemes
4443
4650
  :return:
@@ -4445,7 +4652,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4445
4652
  url = "rest/tempo-core/2/holidayschemes/"
4446
4653
  return self.get(url)
4447
4654
 
4448
- def tempo_holiday_get_scheme_info(self, scheme_id):
4655
+ def tempo_holiday_get_scheme_info(self, scheme_id: T_id) -> T_resp_json:
4449
4656
  """
4450
4657
  Provide a holiday scheme
4451
4658
  :return:
@@ -4453,7 +4660,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4453
4660
  url = f"rest/tempo-core/2/holidayschemes/{scheme_id}"
4454
4661
  return self.get(url)
4455
4662
 
4456
- def tempo_holiday_get_scheme_members(self, scheme_id):
4663
+ def tempo_holiday_get_scheme_members(self, scheme_id: T_id) -> T_resp_json:
4457
4664
  """
4458
4665
  Provide a holiday scheme members
4459
4666
  :return:
@@ -4461,7 +4668,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4461
4668
  url = f"rest/tempo-core/2/holidayschemes/{scheme_id}/members"
4462
4669
  return self.get(url)
4463
4670
 
4464
- def tempo_holiday_put_into_scheme_member(self, scheme_id, username):
4671
+ def tempo_holiday_put_into_scheme_member(self, scheme_id: T_id, username: str) -> T_resp_json:
4465
4672
  """
4466
4673
  Provide a holiday scheme
4467
4674
  :return:
@@ -4470,7 +4677,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4470
4677
  data = {"id": scheme_id}
4471
4678
  return self.put(url, data=data)
4472
4679
 
4473
- def tempo_holiday_scheme_set_default(self, scheme_id):
4680
+ def tempo_holiday_scheme_set_default(self, scheme_id: T_id) -> T_resp_json:
4474
4681
  """
4475
4682
  Set as default the holiday scheme
4476
4683
  :param scheme_id:
@@ -4480,7 +4687,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4480
4687
  data = {"id": scheme_id}
4481
4688
  return self.post(url, data=data)
4482
4689
 
4483
- def tempo_workload_scheme_get_members(self, scheme_id):
4690
+ def tempo_workload_scheme_get_members(self, scheme_id: T_id) -> T_resp_json:
4484
4691
  """
4485
4692
  Provide a workload scheme members
4486
4693
  :param scheme_id:
@@ -4489,7 +4696,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4489
4696
  url = f"rest/tempo-core/1/workloadscheme/users/{scheme_id}"
4490
4697
  return self.get(url)
4491
4698
 
4492
- def tempo_workload_scheme_set_member(self, scheme_id, member):
4699
+ def tempo_workload_scheme_set_member(self, scheme_id: T_id, member: str) -> T_resp_json:
4493
4700
  """
4494
4701
  Provide a workload scheme members
4495
4702
  :param member: username of user
@@ -4500,7 +4707,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4500
4707
  data = {"id": scheme_id}
4501
4708
  return self.put(url, data=data)
4502
4709
 
4503
- def tempo_timesheets_get_configuration(self):
4710
+ def tempo_timesheets_get_configuration(self) -> T_resp_json:
4504
4711
  """
4505
4712
  Provide the configs of timesheets
4506
4713
  :return:
@@ -4508,7 +4715,9 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4508
4715
  url = "rest/tempo-timesheets/3/private/config/"
4509
4716
  return self.get(url)
4510
4717
 
4511
- def tempo_timesheets_get_team_utilization(self, team_id, date_from, date_to=None, group_by=None):
4718
+ def tempo_timesheets_get_team_utilization(
4719
+ self, team_id: T_id, date_from: str, date_to: Optional[str] = None, group_by: Optional[str] = None
4720
+ ) -> T_resp_json:
4512
4721
  """
4513
4722
  Get team utilization. Response in json
4514
4723
  :param team_id:
@@ -4518,7 +4727,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4518
4727
  :return:
4519
4728
  """
4520
4729
  url = f"rest/tempo-timesheets/3/report/team/{team_id}/utilization"
4521
- params = {"dateFrom": date_from, "dateTo": date_to}
4730
+ params: dict = {"dateFrom": date_from, "dateTo": date_to}
4522
4731
 
4523
4732
  if group_by:
4524
4733
  params["groupBy"] = group_by
@@ -4526,13 +4735,13 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4526
4735
 
4527
4736
  def tempo_timesheets_get_worklogs(
4528
4737
  self,
4529
- date_from=None,
4530
- date_to=None,
4531
- username=None,
4532
- project_key=None,
4533
- account_key=None,
4534
- team_id=None,
4535
- ):
4738
+ date_from: Optional[str] = None,
4739
+ date_to: Optional[str] = None,
4740
+ username: Optional[str] = None,
4741
+ project_key: Optional[str] = None,
4742
+ account_key: Optional[str] = None,
4743
+ team_id: Optional[T_id] = None,
4744
+ ) -> T_resp_json:
4536
4745
  """
4537
4746
 
4538
4747
  :param date_from: yyyy-MM-dd
@@ -4543,7 +4752,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4543
4752
  :param team_id: id of the Team you wish to get the worklogs for
4544
4753
  :return:
4545
4754
  """
4546
- params = {}
4755
+ params: dict = {}
4547
4756
  if date_from:
4548
4757
  params["dateFrom"] = date_from
4549
4758
  if date_to:
@@ -4560,7 +4769,9 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4560
4769
  return self.get(url, params=params)
4561
4770
 
4562
4771
  # noinspection PyIncorrectDocstring
4563
- def tempo_4_timesheets_find_worklogs(self, date_from=None, date_to=None, **params):
4772
+ def tempo_4_timesheets_find_worklogs(
4773
+ self, date_from: Optional[str] = None, date_to: Optional[str] = None, **params: Any
4774
+ ) -> T_resp_json:
4564
4775
  """
4565
4776
  Find existing worklogs with searching parameters.
4566
4777
  NOTE: check if you are using correct types for the parameters!
@@ -4595,7 +4806,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4595
4806
  url = "rest/tempo-timesheets/4/worklogs/search"
4596
4807
  return self.post(url, data=params)
4597
4808
 
4598
- def tempo_timesheets_get_worklogs_by_issue(self, issue):
4809
+ def tempo_timesheets_get_worklogs_by_issue(self, issue: str) -> T_resp_json:
4599
4810
  """
4600
4811
  Get Tempo timesheet worklog by issue key or id.
4601
4812
  :param issue: Issue key or ID
@@ -4604,7 +4815,9 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4604
4815
  url = f"rest/tempo-timesheets/4/worklogs/jira/issue/{issue}"
4605
4816
  return self.get(url)
4606
4817
 
4607
- def tempo_timesheets_write_worklog(self, worker, started, time_spend_in_seconds, issue_id, comment=None):
4818
+ def tempo_timesheets_write_worklog(
4819
+ self, worker: str, started: str, time_spend_in_seconds: int, issue_id: T_id, comment: Optional[str] = None
4820
+ ) -> T_resp_json:
4608
4821
  """
4609
4822
  Log work for user
4610
4823
  :param worker:
@@ -4625,7 +4838,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4625
4838
  url = "rest/tempo-timesheets/4/worklogs/"
4626
4839
  return self.post(url, data=data)
4627
4840
 
4628
- def tempo_timesheets_approval_worklog_report(self, user_key, period_start_date):
4841
+ def tempo_timesheets_approval_worklog_report(self, user_key: str, period_start_date: str) -> T_resp_json:
4629
4842
  """
4630
4843
  Return timesheets for approval
4631
4844
  :param user_key:
@@ -4633,14 +4846,14 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4633
4846
  :return:
4634
4847
  """
4635
4848
  url = "rest/tempo-timesheets/4/timesheet-approval/current"
4636
- params = {}
4849
+ params: dict = {}
4637
4850
  if period_start_date:
4638
4851
  params["periodStartDate"] = period_start_date
4639
4852
  if user_key:
4640
4853
  params["userKey"] = user_key
4641
4854
  return self.get(url, params=params)
4642
4855
 
4643
- def tempo_timesheets_get_required_times(self, from_date, to_date, user_name):
4856
+ def tempo_timesheets_get_required_times(self, from_date: str, to_date: str, user_name: str) -> T_resp_json:
4644
4857
  """
4645
4858
  Provide time how much should work
4646
4859
  :param from_date:
@@ -4649,7 +4862,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4649
4862
  :return:
4650
4863
  """
4651
4864
  url = "rest/tempo-timesheets/3/private/days"
4652
- params = {}
4865
+ params: dict = {}
4653
4866
  if from_date:
4654
4867
  params["from"] = from_date
4655
4868
  if to_date:
@@ -4658,16 +4871,16 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4658
4871
  params["user"] = user_name
4659
4872
  return self.get(url, params=params)
4660
4873
 
4661
- def tempo_timesheets_approval_status(self, period_start_date, user_name):
4874
+ def tempo_timesheets_approval_status(self, period_start_date: str, user_name: str) -> T_resp_json:
4662
4875
  url = "rest/tempo-timesheets/4/timesheet-approval/approval-statuses"
4663
- params = {}
4876
+ params: dict = {}
4664
4877
  if user_name:
4665
4878
  params["userKey"] = user_name
4666
4879
  if period_start_date:
4667
4880
  params["periodStartDate"] = period_start_date
4668
4881
  return self.get(url, params=params)
4669
4882
 
4670
- def tempo_get_links_to_project(self, project_id):
4883
+ def tempo_get_links_to_project(self, project_id: T_id) -> T_resp_json:
4671
4884
  """
4672
4885
  Gets all links to a specific project
4673
4886
  :param project_id:
@@ -4676,7 +4889,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4676
4889
  url = f"rest/tempo-accounts/1/link/project/{project_id}/"
4677
4890
  return self.get(url)
4678
4891
 
4679
- def tempo_get_default_link_to_project(self, project_id):
4892
+ def tempo_get_default_link_to_project(self, project_id: T_id) -> T_resp_json:
4680
4893
  """
4681
4894
  Gets the default link to a specific project
4682
4895
  :param project_id:
@@ -4685,14 +4898,14 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4685
4898
  url = f"rest/tempo-accounts/1/link/project/{project_id}/default/"
4686
4899
  return self.get(url)
4687
4900
 
4688
- def tempo_teams_get_all_teams(self, expand=None):
4901
+ def tempo_teams_get_all_teams(self, expand: Optional[str] = None) -> T_resp_json:
4689
4902
  url = "rest/tempo-teams/2/team"
4690
- params = {}
4903
+ params: dict = {}
4691
4904
  if expand:
4692
4905
  params["expand"] = expand
4693
4906
  return self.get(url, params=params)
4694
4907
 
4695
- def tempo_teams_add_member(self, team_id, member_key):
4908
+ def tempo_teams_add_member(self, team_id: T_id, member_key: str) -> T_resp_json:
4696
4909
  """
4697
4910
  Add team member
4698
4911
  :param team_id:
@@ -4705,7 +4918,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4705
4918
  }
4706
4919
  return self.tempo_teams_add_member_raw(team_id, member_data=data)
4707
4920
 
4708
- def tempo_teams_add_membership(self, team_id, member_id):
4921
+ def tempo_teams_add_membership(self, team_id: T_id, member_id: T_id) -> T_resp_json:
4709
4922
  """
4710
4923
  Add team member
4711
4924
  :param team_id:
@@ -4721,7 +4934,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4721
4934
  url = f"rest/tempo-teams/2/team/{team_id}/member/{member_id}/membership"
4722
4935
  return self.post(url, data=data)
4723
4936
 
4724
- def tempo_teams_add_member_raw(self, team_id, member_data):
4937
+ def tempo_teams_add_member_raw(self, team_id: T_id, member_data: dict) -> T_resp_json:
4725
4938
  """
4726
4939
  Add team member
4727
4940
  :param team_id:
@@ -4732,7 +4945,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4732
4945
  data = member_data
4733
4946
  return self.post(url, data=data)
4734
4947
 
4735
- def tempo_teams_get_members(self, team_id):
4948
+ def tempo_teams_get_members(self, team_id: T_id) -> T_resp_json:
4736
4949
  """
4737
4950
  Get members from team
4738
4951
  :param team_id:
@@ -4741,7 +4954,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4741
4954
  url = f"rest/tempo-teams/2/team/{team_id}/member/"
4742
4955
  return self.get(url)
4743
4956
 
4744
- def tempo_teams_remove_member(self, team_id, member_id, membership_id):
4957
+ def tempo_teams_remove_member(self, team_id: T_id, member_id: T_id, membership_id: T_id) -> T_resp_json:
4745
4958
  """
4746
4959
  Remove team membership
4747
4960
  :param team_id:
@@ -4752,7 +4965,9 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4752
4965
  url = f"rest/tempo-teams/2/team/{team_id}/member/{member_id}/membership/{membership_id}"
4753
4966
  return self.delete(url)
4754
4967
 
4755
- def tempo_teams_update_member_information(self, team_id, member_id, membership_id, data):
4968
+ def tempo_teams_update_member_information(
4969
+ self, team_id: T_id, member_id: T_id, membership_id: T_id, data: dict
4970
+ ) -> T_resp_json:
4756
4971
  """
4757
4972
  Update team membership attribute info
4758
4973
  :param team_id:
@@ -4764,13 +4979,13 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4764
4979
  url = f"rest/tempo-teams/2/team/{team_id}/member/{member_id}/membership/{membership_id}"
4765
4980
  return self.put(url, data=data)
4766
4981
 
4767
- def tempo_timesheets_get_period_configuration(self):
4982
+ def tempo_timesheets_get_period_configuration(self) -> T_resp_json:
4768
4983
  return self.get("rest/tempo-timesheets/3/period-configuration")
4769
4984
 
4770
- def tempo_timesheets_get_private_configuration(self):
4985
+ def tempo_timesheets_get_private_configuration(self) -> T_resp_json:
4771
4986
  return self.get("rest/tempo-timesheets/3/private/config")
4772
4987
 
4773
- def tempo_teams_get_memberships_for_member(self, username):
4988
+ def tempo_teams_get_memberships_for_member(self, username: str) -> T_resp_json:
4774
4989
  return self.get(f"rest/tempo-teams/2/user/{username}/memberships")
4775
4990
 
4776
4991
  #######################################################################
@@ -4778,7 +4993,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4778
4993
  # Resource: https://docs.atlassian.com/jira-software/REST/7.3.1/
4779
4994
  #######################################################################
4780
4995
  # /rest/agile/1.0/backlog/issue
4781
- def move_issues_to_backlog(self, issue_keys):
4996
+ def move_issues_to_backlog(self, issue_keys: list) -> T_resp_json:
4782
4997
  """
4783
4998
  Move issues to backlog
4784
4999
  :param issue_keys: list of issues
@@ -4786,7 +5001,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4786
5001
  """
4787
5002
  return self.add_issues_to_backlog(issues=issue_keys)
4788
5003
 
4789
- def add_issues_to_backlog(self, issues):
5004
+ def add_issues_to_backlog(self, issues: list) -> T_resp_json:
4790
5005
  """
4791
5006
  Adding Issue(s) to Backlog
4792
5007
  :param issues: list: List of Issue Keys
@@ -4801,7 +5016,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4801
5016
  data = dict(issues=issues)
4802
5017
  return self.post(url, data=data)
4803
5018
 
4804
- def get_agile_board_by_filter_id(self, filter_id):
5019
+ def get_agile_board_by_filter_id(self, filter_id: T_id) -> T_resp_json:
4805
5020
  """
4806
5021
  Gets an agile board by the filter id
4807
5022
  :param filter_id: int, str
@@ -4810,7 +5025,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4810
5025
  return self.get(url)
4811
5026
 
4812
5027
  # /rest/agile/1.0/board
4813
- def create_agile_board(self, name, type, filter_id, location=None):
5028
+ def create_agile_board(self, name: str, type: str, filter_id: T_id, location: Optional[dict] = None) -> T_resp_json:
4814
5029
  """
4815
5030
  Create an agile board
4816
5031
  :param name: str: Must be less than 255 characters.
@@ -4818,7 +5033,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4818
5033
  :param filter_id: int
4819
5034
  :param location: dict, Optional. Only specify this for Jira Cloud!
4820
5035
  """
4821
- data = {"name": name, "type": type, "filterId": filter_id}
5036
+ data: dict = {"name": name, "type": type, "filterId": filter_id}
4822
5037
  if location:
4823
5038
  data["location"] = location
4824
5039
  url = "rest/agile/1.0/board"
@@ -4826,12 +5041,12 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4826
5041
 
4827
5042
  def get_all_agile_boards(
4828
5043
  self,
4829
- board_name=None,
4830
- project_key=None,
4831
- board_type=None,
4832
- start=0,
4833
- limit=50,
4834
- ):
5044
+ board_name: Optional[str] = None,
5045
+ project_key: Optional[str] = None,
5046
+ board_type: Optional[str] = None,
5047
+ start: int = 0,
5048
+ limit: int = 50,
5049
+ ) -> T_resp_json:
4835
5050
  """
4836
5051
  Returns all boards. This only includes boards that the user has permission to view.
4837
5052
  :param board_name:
@@ -4842,7 +5057,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4842
5057
  :return:
4843
5058
  """
4844
5059
  url = "rest/agile/1.0/board"
4845
- params = {}
5060
+ params: dict = {}
4846
5061
  if board_name:
4847
5062
  params["name"] = board_name
4848
5063
  if project_key:
@@ -4856,7 +5071,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4856
5071
 
4857
5072
  return self.get(url, params=params)
4858
5073
 
4859
- def delete_agile_board(self, board_id):
5074
+ def delete_agile_board(self, board_id: T_id) -> T_resp_json:
4860
5075
  """
4861
5076
  Delete agile board by id
4862
5077
  :param board_id:
@@ -4865,7 +5080,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4865
5080
  url = f"rest/agile/1.0/board/{str(board_id)}"
4866
5081
  return self.delete(url)
4867
5082
 
4868
- def get_agile_board(self, board_id):
5083
+ def get_agile_board(self, board_id: T_id) -> T_resp_json:
4869
5084
  """
4870
5085
  Get agile board info by id
4871
5086
  :param board_id:
@@ -4874,7 +5089,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4874
5089
  url = f"rest/agile/1.0/board/{str(board_id)}"
4875
5090
  return self.get(url)
4876
5091
 
4877
- def get_issues_for_backlog(self, board_id):
5092
+ def get_issues_for_backlog(self, board_id: T_id) -> T_resp_json:
4878
5093
  """
4879
5094
  Returns all issues from the board's backlog, for the given board ID.
4880
5095
  This only includes issues that the user has permission to view.
@@ -4887,7 +5102,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4887
5102
  url = f"rest/agile/1.0/board/{board_id}/backlog"
4888
5103
  return self.get(url)
4889
5104
 
4890
- def get_agile_board_configuration(self, board_id):
5105
+ def get_agile_board_configuration(self, board_id: T_id) -> T_resp_json:
4891
5106
  """
4892
5107
  Get the board configuration. The response contains the following fields:
4893
5108
  id - ID of the board.
@@ -4914,7 +5129,15 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4914
5129
  url = f"rest/agile/1.0/board/{str(board_id)}/configuration"
4915
5130
  return self.get(url)
4916
5131
 
4917
- def get_issues_for_board(self, board_id, jql, fields="*all", start=0, limit=None, expand=None):
5132
+ def get_issues_for_board(
5133
+ self,
5134
+ board_id: T_id,
5135
+ jql: str,
5136
+ fields: str = "*all",
5137
+ start: int = 0,
5138
+ limit: Optional[int] = None,
5139
+ expand: Optional[str] = None,
5140
+ ) -> T_resp_json:
4918
5141
  """
4919
5142
  Returns all issues from a board, for a given board Id.
4920
5143
  This only includes issues that the user has permission to view.
@@ -4930,7 +5153,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4930
5153
  :param expand: OPTIONAL: expand the search result
4931
5154
  :return:
4932
5155
  """
4933
- params = {}
5156
+ params: dict = {}
4934
5157
  if start is not None:
4935
5158
  params["startAt"] = int(start)
4936
5159
  if limit is not None:
@@ -4950,11 +5173,11 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4950
5173
  # /rest/agile/1.0/board/{boardId}/epic
4951
5174
  def get_epics(
4952
5175
  self,
4953
- board_id,
4954
- done=False,
4955
- start=0,
4956
- limit=50,
4957
- ):
5176
+ board_id: T_id,
5177
+ done: bool = False,
5178
+ start: int = 0,
5179
+ limit: int = 50,
5180
+ ) -> T_resp_json:
4958
5181
  """
4959
5182
  Returns all epics from the board, for the given board Id.
4960
5183
  This only includes epics that the user has permission to view.
@@ -4968,7 +5191,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4968
5191
  :return:
4969
5192
  """
4970
5193
  url = f"rest/agile/1.0/board/{board_id}/epic"
4971
- params = {}
5194
+ params: dict = {}
4972
5195
  if done:
4973
5196
  params["done"] = done
4974
5197
  if start:
@@ -4978,8 +5201,16 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4978
5201
  return self.get(url, params=params)
4979
5202
 
4980
5203
  def get_issues_for_epic(
4981
- self, board_id, epic_id, jql="", validate_query="", fields="*all", expand="", start=0, limit=50
4982
- ):
5204
+ self,
5205
+ board_id: T_id,
5206
+ epic_id: T_id,
5207
+ jql: str = "",
5208
+ validate_query: str = "",
5209
+ fields: str = "*all",
5210
+ expand: str = "",
5211
+ start: int = 0,
5212
+ limit: int = 50,
5213
+ ) -> T_resp_json:
4983
5214
  """
4984
5215
  Returns all issues that belong to an epic on the board, for the given epic Id and the board Id.
4985
5216
  This only includes issues that the user has permission to view.
@@ -5006,7 +5237,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
5006
5237
  :return:
5007
5238
  """
5008
5239
  url = f"/rest/agile/1.0/board/{board_id}/epic/{epic_id}/issue"
5009
- params = {}
5240
+ params: dict = {}
5010
5241
  if jql:
5011
5242
  params["jql"] = jql
5012
5243
  if validate_query:
@@ -5023,14 +5254,14 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
5023
5254
 
5024
5255
  def get_issues_without_epic(
5025
5256
  self,
5026
- board_id,
5027
- jql="",
5028
- validate_query="",
5029
- fields="*all",
5030
- expand="",
5031
- start=0,
5032
- limit=50,
5033
- ):
5257
+ board_id: T_id,
5258
+ jql: str = "",
5259
+ validate_query: str = "",
5260
+ fields: str = "*all",
5261
+ expand: str = "",
5262
+ start: int = 0,
5263
+ limit: int = 50,
5264
+ ) -> T_resp_json:
5034
5265
  """
5035
5266
  Returns all issues that do not belong to any epic on a board, for a given board Id.
5036
5267
  This only includes issues that the user has permission to view.
@@ -5055,7 +5286,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
5055
5286
  :return:
5056
5287
  """
5057
5288
  url = f"/rest/agile/1.0/board/{board_id}/epic/none/issue"
5058
- params = {}
5289
+ params: dict = {}
5059
5290
  if jql:
5060
5291
  params["jql"] = jql
5061
5292
  if validate_query:
@@ -5071,7 +5302,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
5071
5302
  return self.get(url, params=params)
5072
5303
 
5073
5304
  # rest/agile/1.0/board/{boardId}/project
5074
- def get_all_projects_associated_with_board(self, board_id, start=0, limit=50):
5305
+ def get_all_projects_associated_with_board(self, board_id: T_id, start: int = 0, limit: int = 50) -> T_resp_json:
5075
5306
  """
5076
5307
  Returns all projects that are associated with the board,
5077
5308
  for the given board ID. A project is associated with a board only
@@ -5091,7 +5322,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
5091
5322
  :return:
5092
5323
  """
5093
5324
  url = f"/rest/agile/1.0/board/{board_id}/project"
5094
- params = {}
5325
+ params: dict = {}
5095
5326
  if start:
5096
5327
  params["startAt"] = start
5097
5328
  if limit:
@@ -5099,7 +5330,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
5099
5330
  return self.get(url, params=params)
5100
5331
 
5101
5332
  # /rest/agile/1.0/board/{boardId}/properties
5102
- def get_agile_board_properties(self, board_id):
5333
+ def get_agile_board_properties(self, board_id: T_id) -> T_resp_json:
5103
5334
  """
5104
5335
  Returns the keys of all properties for the board identified by the id.
5105
5336
  The user who retrieves the property keys is required to have permissions to view the board.
@@ -5108,7 +5339,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
5108
5339
  url = f"rest/agile/1.0/board/{board_id}/properties"
5109
5340
  return self.get(url)
5110
5341
 
5111
- def set_agile_board_property(self, board_id, property_key):
5342
+ def set_agile_board_property(self, board_id: T_id, property_key: str) -> T_resp_json:
5112
5343
  """
5113
5344
  Sets the value of the specified board's property.
5114
5345
  You can use this resource to store a custom data
@@ -5121,7 +5352,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
5121
5352
  url = f"/rest/agile/1.0/board/{board_id}/properties/{property_key}"
5122
5353
  return self.put(url)
5123
5354
 
5124
- def get_agile_board_property(self, board_id, property_key):
5355
+ def get_agile_board_property(self, board_id: T_id, property_key: str) -> T_resp_json:
5125
5356
  """
5126
5357
  Returns the value of the property with a given key from the board identified by the provided id.
5127
5358
  The user who retrieves the property is required to have permissions to view the board.
@@ -5132,7 +5363,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
5132
5363
  url = f"/rest/agile/1.0/board/{board_id}/properties/{property_key}"
5133
5364
  return self.get(url)
5134
5365
 
5135
- def delete_agile_board_property(self, board_id, property_key):
5366
+ def delete_agile_board_property(self, board_id: T_id, property_key: str) -> T_resp_json:
5136
5367
  """
5137
5368
  Removes the property from the board identified by the id.
5138
5369
  Ths user removing the property is required to have permissions to modify the board.
@@ -5144,7 +5375,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
5144
5375
  return self.delete(url)
5145
5376
 
5146
5377
  # /rest/agile/1.0/board/{boardId}/settings/refined-velocity
5147
- def get_agile_board_refined_velocity(self, board_id):
5378
+ def get_agile_board_refined_velocity(self, board_id: T_id) -> T_resp_json:
5148
5379
  """
5149
5380
  Returns the estimation statistic settings of the board.
5150
5381
  :param board_id:
@@ -5153,7 +5384,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
5153
5384
  url = f"/rest/agile/1.0/board/{board_id}/settings/refined-velocity"
5154
5385
  return self.get(url)
5155
5386
 
5156
- def set_agile_board_refined_velocity(self, board_id, data):
5387
+ def set_agile_board_refined_velocity(self, board_id: T_id, data: dict) -> T_resp_json:
5157
5388
  """
5158
5389
  Sets the estimation statistic settings of the board.
5159
5390
  :param board_id:
@@ -5165,7 +5396,9 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
5165
5396
 
5166
5397
  # /rest/agile/1.0/board/{boardId}/sprint
5167
5398
 
5168
- def get_all_sprints_from_board(self, board_id, state=None, start=0, limit=50):
5399
+ def get_all_sprints_from_board(
5400
+ self, board_id: T_id, state: Optional[str] = None, start: int = 0, limit: int = 50
5401
+ ) -> T_resp_json:
5169
5402
  """
5170
5403
  Returns all sprints from a board, for a given board ID.
5171
5404
  This only includes sprints that the user has permission to view.
@@ -5181,7 +5414,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
5181
5414
  See the 'Pagination' section at the top of this page for more details.
5182
5415
  :return:
5183
5416
  """
5184
- params = {}
5417
+ params: dict = {}
5185
5418
  if start:
5186
5419
  params["startAt"] = start
5187
5420
  if limit:
@@ -5192,7 +5425,9 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
5192
5425
  return self.get(url, params=params)
5193
5426
 
5194
5427
  @deprecated(version="3.42.0", reason="Use get_all_sprints_from_board instead")
5195
- def get_all_sprint(self, board_id, state=None, start=0, limit=50):
5428
+ def get_all_sprint(
5429
+ self, board_id: T_id, state: Optional[str] = None, start: int = 0, limit: int = 50
5430
+ ) -> T_resp_json:
5196
5431
  """
5197
5432
  Returns all sprints from a board, for a given board ID.
5198
5433
  :param board_id:
@@ -5204,8 +5439,16 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
5204
5439
  return self.get_all_sprints_from_board(board_id, state, start, limit)
5205
5440
 
5206
5441
  def get_all_issues_for_sprint_in_board(
5207
- self, board_id, sprint_id, jql="", validateQuery=True, fields="", expand="", start=0, limit=50
5208
- ):
5442
+ self,
5443
+ board_id: T_id,
5444
+ sprint_id: T_id,
5445
+ jql: str = "",
5446
+ validateQuery: bool = True,
5447
+ fields: str = "",
5448
+ expand: str = "",
5449
+ start: int = 0,
5450
+ limit: int = 50,
5451
+ ) -> T_resp_json:
5209
5452
  """
5210
5453
  Get all issues you have access to that belong to the sprint from the board.
5211
5454
  Issue returned from this resource contains additional fields like: sprint, closedSprints, flagged and epic.
@@ -5230,7 +5473,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
5230
5473
  If you exceed this limit, your results will be truncated.
5231
5474
  """
5232
5475
  url = f"/rest/agile/1.0/board/{board_id}/sprint/{sprint_id}/issue"
5233
- params = {}
5476
+ params: dict = {}
5234
5477
  if jql:
5235
5478
  params["jql"] = jql
5236
5479
  if validateQuery:
@@ -5246,7 +5489,9 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
5246
5489
  return self.get(url, params=params)
5247
5490
 
5248
5491
  # /rest/agile/1.0/board/{boardId}/version
5249
- def get_all_versions_from_board(self, board_id, released="true", start=0, limit=50):
5492
+ def get_all_versions_from_board(
5493
+ self, board_id: T_id, released: str = "true", start: int = 0, limit: int = 50
5494
+ ) -> T_resp_json:
5250
5495
  """
5251
5496
  Returns all versions from a board, for a given board ID.
5252
5497
  This only includes versions that the user has permission to view.
@@ -5265,7 +5510,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
5265
5510
  See the 'Pagination' section at the top of this page for more details.
5266
5511
  :return:
5267
5512
  """
5268
- params = {}
5513
+ params: dict = {}
5269
5514
  if released:
5270
5515
  params["released"] = released
5271
5516
  if start:
@@ -5275,7 +5520,14 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
5275
5520
  url = f"rest/agile/1.0/board/{board_id}/version"
5276
5521
  return self.get(url, params=params)
5277
5522
 
5278
- def create_sprint(self, name, board_id, start_date=None, end_date=None, goal=None):
5523
+ def create_sprint(
5524
+ self,
5525
+ name: str,
5526
+ board_id: T_id,
5527
+ start_date: Optional[str] = None,
5528
+ end_date: Optional[str] = None,
5529
+ goal: Optional[str] = None,
5530
+ ) -> T_resp_json:
5279
5531
  """
5280
5532
  Create a sprint within a board.
5281
5533
  ! User requires `Manage Sprints` permission for relevant boards.
@@ -5302,7 +5554,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
5302
5554
  data["goal"] = goal
5303
5555
  return self.post(url, data=data)
5304
5556
 
5305
- def add_issues_to_sprint(self, sprint_id, issues):
5557
+ def add_issues_to_sprint(self, sprint_id: T_id, issues: List[str]) -> T_resp_json:
5306
5558
  """
5307
5559
  Adding Issue(s) to Sprint
5308
5560
  :param sprint_id: int/str: The ID for the Sprint.
@@ -5320,7 +5572,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
5320
5572
  data = dict(issues=issues)
5321
5573
  return self.post(url, data=data)
5322
5574
 
5323
- def get_sprint(self, sprint_id):
5575
+ def get_sprint(self, sprint_id: T_id) -> T_resp_json:
5324
5576
  """
5325
5577
  Returns the sprint for a given sprint ID.
5326
5578
  The sprint will only be returned if the user can view the board that the sprint was created on,
@@ -5331,7 +5583,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
5331
5583
  url = f"rest/agile/1.0/sprint/{sprint_id}"
5332
5584
  return self.get(url)
5333
5585
 
5334
- def rename_sprint(self, sprint_id, name, start_date, end_date):
5586
+ def rename_sprint(self, sprint_id: T_id, name: str, start_date: str, end_date: str) -> T_resp_json:
5335
5587
  """
5336
5588
 
5337
5589
  :param sprint_id:
@@ -5345,7 +5597,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
5345
5597
  data={"name": name, "startDate": start_date, "endDate": end_date},
5346
5598
  )
5347
5599
 
5348
- def delete_sprint(self, sprint_id):
5600
+ def delete_sprint(self, sprint_id: T_id) -> T_resp_json:
5349
5601
  """
5350
5602
  Deletes a sprint.
5351
5603
  Once a sprint is deleted, all issues in the sprint will be moved to the backlog.
@@ -5355,7 +5607,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
5355
5607
  """
5356
5608
  return self.delete(f"rest/agile/1.0/sprint/{sprint_id}")
5357
5609
 
5358
- def update_partially_sprint(self, sprint_id, data):
5610
+ def update_partially_sprint(self, sprint_id: T_id, data: dict) -> T_resp_json:
5359
5611
  """
5360
5612
  Performs a partial update of a sprint.
5361
5613
  A partial update means that fields not present in the request JSON will not be updated.
@@ -5375,7 +5627,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
5375
5627
  """
5376
5628
  return self.post(f"rest/agile/1.0/sprint/{sprint_id}", data=data)
5377
5629
 
5378
- def get_sprint_issues(self, sprint_id, start, limit):
5630
+ def get_sprint_issues(self, sprint_id: T_id, start: T_id, limit: T_id) -> T_resp_json:
5379
5631
  """
5380
5632
  Returns all issues in a sprint, for a given sprint ID.
5381
5633
  This only includes issues that the user has permission to view.
@@ -5392,7 +5644,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
5392
5644
  If you exceed this limit, your results will be truncated.
5393
5645
  :return:
5394
5646
  """
5395
- params = {}
5647
+ params: dict = {}
5396
5648
  if start:
5397
5649
  params["startAt"] = start
5398
5650
  if limit:
@@ -5400,7 +5652,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
5400
5652
  url = f"rest/agile/1.0/sprint/{sprint_id}/issue"
5401
5653
  return self.get(url, params=params)
5402
5654
 
5403
- def update_rank(self, issues_to_rank, rank_before, customfield_number):
5655
+ def update_rank(self, issues_to_rank: list, rank_before: str, customfield_number: T_id) -> T_resp_json:
5404
5656
  """
5405
5657
  Updates the rank of issues (max 50), placing them before a given issue.
5406
5658
  :param issues_to_rank: List of issues to rank (max 50)
@@ -5408,6 +5660,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
5408
5660
  :param customfield_number: The number of the custom field Rank
5409
5661
  :return:
5410
5662
  """
5663
+
5411
5664
  return self.put(
5412
5665
  "rest/agile/1.0/issue/rank",
5413
5666
  data={
@@ -5417,7 +5670,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
5417
5670
  },
5418
5671
  )
5419
5672
 
5420
- def dvcs_get_linked_repos(self):
5673
+ def dvcs_get_linked_repos(self) -> T_resp_json:
5421
5674
  """
5422
5675
  Get DVCS linked repos
5423
5676
  :return:
@@ -5425,7 +5678,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
5425
5678
  url = "rest/bitbucket/1.0/repositories"
5426
5679
  return self.get(url)
5427
5680
 
5428
- def dvcs_update_linked_repo_with_remote(self, repository_id):
5681
+ def dvcs_update_linked_repo_with_remote(self, repository_id: T_id) -> T_resp_json:
5429
5682
  """
5430
5683
  Resync delayed sync repo
5431
5684
  https://confluence.atlassian.com/jirakb/delays-for-commits-to-display-in-development-panel-in-jira-server-779160823.html
@@ -5435,7 +5688,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
5435
5688
  url = f"rest/bitbucket/1.0/repositories/{repository_id}/sync"
5436
5689
  return self.post(url)
5437
5690
 
5438
- def flag_issue(self, issue_keys, flag=True):
5691
+ def flag_issue(self, issue_keys: List[T_id], flag: bool = True) -> T_resp_json:
5439
5692
  """
5440
5693
  Flags or un-flags one or multiple issues in Jira with a flag indicator.
5441
5694
  :param issue_keys: List of issue keys to flag or un-flag.
@@ -5449,7 +5702,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
5449
5702
  data = {"issueKeys": issue_keys, "flag": flag}
5450
5703
  return self.post(url, data)
5451
5704
 
5452
- def health_check(self):
5705
+ def health_check(self) -> T_resp_json:
5453
5706
  """
5454
5707
  Get health status of Jira.
5455
5708
  https://confluence.atlassian.com/jirakb/how-to-retrieve-health-check-results-using-rest-api-867195158.html
@@ -5462,7 +5715,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
5462
5715
  response = self.get("rest/supportHealthCheck/1.0/check/")
5463
5716
  return response
5464
5717
 
5465
- def duplicated_account_checks_detail(self):
5718
+ def duplicated_account_checks_detail(self) -> T_resp_json:
5466
5719
  """
5467
5720
  Health check: Duplicate user accounts detail
5468
5721
  https://confluence.atlassian.com/jirakb/health-check-duplicate-user-accounts-1063554355.html
@@ -5471,7 +5724,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
5471
5724
  response = self.get("rest/api/2/user/duplicated/list")
5472
5725
  return response
5473
5726
 
5474
- def duplicated_account_checks_flush(self):
5727
+ def duplicated_account_checks_flush(self) -> T_resp_json:
5475
5728
  """
5476
5729
  Health check: Duplicate user accounts by flush
5477
5730
  The responses returned by the count and list methods are stored in the duplicate users cache for 10 minutes.
@@ -5480,11 +5733,11 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
5480
5733
  https://confluence.atlassian.com/jirakb/health-check-duplicate-user-accounts-1063554355.html
5481
5734
  :return:
5482
5735
  """
5483
- params = {"flush": "true"}
5736
+ params: dict = {"flush": "true"}
5484
5737
  response = self.get("rest/api/2/user/duplicated/list", params=params)
5485
5738
  return response
5486
5739
 
5487
- def duplicated_account_checks_count(self):
5740
+ def duplicated_account_checks_count(self) -> T_resp_json:
5488
5741
  """
5489
5742
  Health check: Duplicate user accounts count
5490
5743
  https://confluence.atlassian.com/jirakb/health-check-duplicate-user-accounts-1063554355.html