atlassian-python-api 4.0.7__py3-none-any.whl → 5.0.0__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/VERSION +1 -1
- atlassian/__init__.py +18 -1
- atlassian/assets.py +1 -1
- atlassian/bamboo.py +4 -4
- atlassian/bitbucket/__init__.py +3 -3
- atlassian/bitbucket/cloud/repositories/pipelines.py +1 -1
- atlassian/bitbucket/cloud/workspaces/__init__.py +2 -2
- atlassian/bitbucket/cloud/workspaces/projects.py +1 -1
- atlassian/bitbucket/server/__init__.py +1 -1
- atlassian/bitbucket/server/projects/__init__.py +2 -1
- atlassian/bitbucket/server/projects/repos/__init__.py +1 -0
- atlassian/confluence/__init__.py +54 -4106
- atlassian/confluence/base.py +195 -0
- atlassian/confluence/cloud/__init__.py +354 -0
- atlassian/confluence/cloud/base.py +25 -0
- atlassian/confluence/cloud/cloud.py +2480 -0
- atlassian/confluence/server/__init__.py +3988 -0
- atlassian/confluence/server/base.py +25 -0
- atlassian/confluence/server/confluence_server.py +28 -0
- atlassian/confluence_base.py +281 -0
- atlassian/confluence_v2.py +7 -0
- atlassian/crowd.py +1 -1
- atlassian/insight.py +3 -2
- atlassian/jira.py +309 -16
- atlassian/jira_models.py +10 -0
- atlassian/models/__init__.py +5 -0
- atlassian/models/jira/__init__.py +109 -0
- atlassian/models/jira/adf.py +178 -0
- atlassian/models/jira/builders.py +272 -0
- atlassian/models/jira/comment.py +52 -0
- atlassian/models/jira/fields.py +236 -0
- atlassian/models/jira/issues.py +101 -0
- atlassian/models/jira/serializer.py +138 -0
- atlassian/models/jira/transition.py +78 -0
- atlassian/models/jira/update.py +179 -0
- atlassian/models/jira/validation.py +56 -0
- atlassian/models/py.typed +0 -0
- atlassian/rest_client.py +81 -15
- atlassian/service_desk.py +41 -1
- atlassian/statuspage.py +7 -6
- atlassian/tempo/__init__.py +14 -0
- atlassian/tempo/cloud/__init__.py +232 -0
- atlassian/tempo/cloud/base.py +38 -0
- atlassian/tempo/server/__init__.py +78 -0
- atlassian/tempo/server/accounts.py +38 -0
- atlassian/tempo/server/base.py +50 -0
- atlassian/tempo/server/budgets.py +42 -0
- atlassian/tempo/server/events.py +52 -0
- atlassian/tempo/server/planner.py +42 -0
- atlassian/tempo/server/servlet.py +46 -0
- atlassian/tempo/server/teams.py +50 -0
- atlassian/tempo/server/timesheets.py +54 -0
- atlassian/typehints.py +14 -2
- atlassian/xray.py +2 -0
- {atlassian_python_api-4.0.7.dist-info → atlassian_python_api-5.0.0.dist-info}/METADATA +45 -5
- atlassian_python_api-5.0.0.dist-info/RECORD +92 -0
- {atlassian_python_api-4.0.7.dist-info → atlassian_python_api-5.0.0.dist-info}/WHEEL +1 -1
- atlassian_python_api-4.0.7.dist-info/RECORD +0 -58
- {atlassian_python_api-4.0.7.dist-info → atlassian_python_api-5.0.0.dist-info}/licenses/LICENSE +0 -0
- {atlassian_python_api-4.0.7.dist-info → atlassian_python_api-5.0.0.dist-info}/top_level.txt +0 -0
atlassian/jira.py
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import logging
|
|
3
3
|
import os
|
|
4
4
|
import re
|
|
5
|
+
import zipfile
|
|
5
6
|
from typing import Any, BinaryIO, Dict, List, Optional, Union, cast
|
|
6
7
|
from warnings import warn
|
|
7
8
|
|
|
@@ -15,7 +16,7 @@ else:
|
|
|
15
16
|
from typing_extensions import Literal # Python <=3.7
|
|
16
17
|
from .errors import ApiNotFoundError, ApiPermissionError
|
|
17
18
|
from .rest_client import AtlassianRestAPI
|
|
18
|
-
from .typehints import T_id, T_resp_json
|
|
19
|
+
from .typehints import T_id, T_resp_json, copy_type
|
|
19
20
|
|
|
20
21
|
log = logging.getLogger(__name__)
|
|
21
22
|
|
|
@@ -26,6 +27,7 @@ class Jira(AtlassianRestAPI):
|
|
|
26
27
|
Reference: https://docs.atlassian.com/software/jira/docs/api/REST/8.5.0/#api/2
|
|
27
28
|
"""
|
|
28
29
|
|
|
30
|
+
@copy_type(AtlassianRestAPI.__init__)
|
|
29
31
|
def __init__(self, url: str, *args: Any, **kwargs: Any):
|
|
30
32
|
if "api_version" not in kwargs:
|
|
31
33
|
kwargs["api_version"] = "2"
|
|
@@ -239,7 +241,7 @@ class Jira(AtlassianRestAPI):
|
|
|
239
241
|
:param issue: str : jira issue key
|
|
240
242
|
:return: list of integers attachment IDs
|
|
241
243
|
"""
|
|
242
|
-
issue_id = self.get_issue(issue)["fields"]["attachment"]
|
|
244
|
+
issue_id = self.get_issue(issue, fields="attachment")["fields"]["attachment"]
|
|
243
245
|
list_attachments_id = []
|
|
244
246
|
for attachment in issue_id:
|
|
245
247
|
list_attachments_id.append({"filename": attachment["filename"], "attachment_id": attachment["id"]})
|
|
@@ -255,14 +257,70 @@ class Jira(AtlassianRestAPI):
|
|
|
255
257
|
url = f"{base_url}/{attachment_id}"
|
|
256
258
|
return self.get(url)
|
|
257
259
|
|
|
258
|
-
def download_issue_attachments(
|
|
260
|
+
def download_issue_attachments(
|
|
261
|
+
self,
|
|
262
|
+
issue: T_id,
|
|
263
|
+
path: Optional[str] = None,
|
|
264
|
+
overwrite: bool = False,
|
|
265
|
+
stream: bool = False,
|
|
266
|
+
block_size: Optional[int] = 16384,
|
|
267
|
+
timeout: Optional[int] = None,
|
|
268
|
+
) -> Optional[str]:
|
|
259
269
|
"""
|
|
260
270
|
Downloads all attachments from a Jira issue.
|
|
271
|
+
This method downloads zip file compressed from Jira server side, and may fail if total attachment size is too large.
|
|
272
|
+
Use `get_all_attachment_contents()` to download individual attachments and zip from client side.
|
|
261
273
|
:param issue: The issue-key of the Jira issue
|
|
262
274
|
:param path: Path to directory where attachments will be saved. If None, current working directory will be used.
|
|
275
|
+
:param overwrite: If True, always download and create new zip file.
|
|
276
|
+
If False (default), download will be skipped when zip file already exists in path.
|
|
277
|
+
:param stream: If True, request stream mode will be used to download and write files.
|
|
278
|
+
If False (default), whole attachment content will be downloaded into memory first, then will be written to disk afterwards.
|
|
279
|
+
:param block_size: Block size of each stream content chunks. This option is only applicable when stream=True is set.
|
|
280
|
+
Default size of 16 KiB is used to balance speed and memory usage.
|
|
281
|
+
Smaller value will decrease memory usage, but may also decrease download speed if too small.
|
|
282
|
+
:param timeout: Request timeout parameter in seconds. None (default) will never cause timeout.
|
|
263
283
|
:return: A message indicating the result of the download operation.
|
|
264
284
|
"""
|
|
265
|
-
|
|
285
|
+
try:
|
|
286
|
+
if path is None:
|
|
287
|
+
path = os.getcwd()
|
|
288
|
+
issue_id = self.issue(issue, fields="id")["id"]
|
|
289
|
+
attachment_name = f"{issue_id}_attachments.zip"
|
|
290
|
+
file_path = os.path.join(path, attachment_name)
|
|
291
|
+
if not overwrite and os.path.isfile(file_path):
|
|
292
|
+
return "File already exists"
|
|
293
|
+
|
|
294
|
+
if self.cloud:
|
|
295
|
+
url = self.url + f"/secure/issueAttachments/{issue_id}.zip"
|
|
296
|
+
else:
|
|
297
|
+
url = self.url + f"/secure/attachmentzip/{issue_id}.zip"
|
|
298
|
+
response = self._session.get(url, stream=stream, timeout=timeout)
|
|
299
|
+
response.raise_for_status()
|
|
300
|
+
|
|
301
|
+
# if Jira issue doesn't have any attachments _session.get
|
|
302
|
+
# request response will return 22 bytes of PKzip format
|
|
303
|
+
file_size = int(response.headers.get("Content-Length", 0))
|
|
304
|
+
if file_size == 22:
|
|
305
|
+
return "No attachments found on the Jira issue"
|
|
306
|
+
|
|
307
|
+
with open(file_path, "wb") as file:
|
|
308
|
+
if not stream:
|
|
309
|
+
file.write(response.content)
|
|
310
|
+
else:
|
|
311
|
+
for data in response.iter_content(block_size):
|
|
312
|
+
file.write(data)
|
|
313
|
+
|
|
314
|
+
return "Attachments downloaded successfully"
|
|
315
|
+
|
|
316
|
+
except FileNotFoundError:
|
|
317
|
+
raise FileNotFoundError("Verify if directory path is correct and/or if directory exists")
|
|
318
|
+
except PermissionError:
|
|
319
|
+
raise PermissionError(
|
|
320
|
+
"Directory found, but there is a problem with saving file to this directory. Check directory permissions"
|
|
321
|
+
)
|
|
322
|
+
except Exception as e:
|
|
323
|
+
raise e
|
|
266
324
|
|
|
267
325
|
@deprecated(version="3.41.20", reason="Use download_issue_attachments instead")
|
|
268
326
|
def download_attachments_from_issue(
|
|
@@ -312,9 +370,72 @@ class Jira(AtlassianRestAPI):
|
|
|
312
370
|
:param attachment_id: int
|
|
313
371
|
:return: content as bytes
|
|
314
372
|
"""
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
373
|
+
attachment_info = self.get_attachment(attachment_id)
|
|
374
|
+
# Type check for mypy. If attachment is not found, or unavailable, it would raise HTTPError anyways.
|
|
375
|
+
if attachment_info is None:
|
|
376
|
+
return b""
|
|
377
|
+
url = attachment_info["content"]
|
|
378
|
+
return self.get(
|
|
379
|
+
url,
|
|
380
|
+
not_json_response=True,
|
|
381
|
+
absolute=True,
|
|
382
|
+
headers={"Accept": "*/*"},
|
|
383
|
+
)
|
|
384
|
+
|
|
385
|
+
def get_all_attachment_contents(
|
|
386
|
+
self,
|
|
387
|
+
issue: T_id,
|
|
388
|
+
path: Optional[str] = None,
|
|
389
|
+
overwrite: bool = False,
|
|
390
|
+
compression: int = zipfile.ZIP_STORED,
|
|
391
|
+
) -> Optional[str]:
|
|
392
|
+
"""
|
|
393
|
+
Downloads all attachments from a Jira issue by downloading individual files and creating zip file.
|
|
394
|
+
This method is useful when total attachment size is too large for Jira server to compress as single file.
|
|
395
|
+
If total attachment size is small enough, using `download_issue_attachments()` may be more efficient.
|
|
396
|
+
:param issue: The issue-key of the Jira issue
|
|
397
|
+
:param path: Path to directory where attachments will be saved. If None, current working directory will be used.
|
|
398
|
+
:param overwrite: If True, always download and create new zip file.
|
|
399
|
+
If False (default), download will be skipped when zip file already exists in path.
|
|
400
|
+
:param compression: Compression method for zipfile. Should be one of the constants listed in documentation page.
|
|
401
|
+
https://docs.python.org/3/library/zipfile.html#zipfile.ZipFile
|
|
402
|
+
:return: File path of the zip file if file is existing or download is successful. None if attachment does not exist.
|
|
403
|
+
"""
|
|
404
|
+
try:
|
|
405
|
+
if path is None:
|
|
406
|
+
path = os.getcwd()
|
|
407
|
+
issue_data = self.issue(issue, fields="id,attachment")
|
|
408
|
+
issue_id = issue_data["id"]
|
|
409
|
+
attachment_name = f"{issue_id}_attachments.zip"
|
|
410
|
+
file_path = os.path.join(path, attachment_name)
|
|
411
|
+
if not overwrite and os.path.isfile(file_path):
|
|
412
|
+
return file_path
|
|
413
|
+
|
|
414
|
+
attachments_metadata = issue_data["fields"]["attachment"]
|
|
415
|
+
if not attachments_metadata:
|
|
416
|
+
return None
|
|
417
|
+
|
|
418
|
+
with zipfile.ZipFile(file_path, "w", compression=compression) as file:
|
|
419
|
+
for meta in attachments_metadata:
|
|
420
|
+
# stream download should not be used, as writestr expects full content with filename.
|
|
421
|
+
content = self.get(
|
|
422
|
+
meta["content"],
|
|
423
|
+
not_json_response=True,
|
|
424
|
+
absolute=True,
|
|
425
|
+
headers={"Accept": "*/*"},
|
|
426
|
+
)
|
|
427
|
+
file.writestr(meta["filename"], content)
|
|
428
|
+
|
|
429
|
+
return file_path
|
|
430
|
+
|
|
431
|
+
except FileNotFoundError:
|
|
432
|
+
raise FileNotFoundError("Verify if directory path is correct and/or if directory exists")
|
|
433
|
+
except PermissionError:
|
|
434
|
+
raise PermissionError(
|
|
435
|
+
"Directory found, but there is a problem with saving file to this directory. Check directory permissions"
|
|
436
|
+
)
|
|
437
|
+
except Exception as e:
|
|
438
|
+
raise e
|
|
318
439
|
|
|
319
440
|
def remove_attachment(self, attachment_id: T_id) -> T_resp_json:
|
|
320
441
|
"""
|
|
@@ -713,6 +834,60 @@ class Jira(AtlassianRestAPI):
|
|
|
713
834
|
url = f"{base_url}/{option_id}"
|
|
714
835
|
return self.get(url)
|
|
715
836
|
|
|
837
|
+
def get_custom_field_options(
|
|
838
|
+
self,
|
|
839
|
+
field_id: T_id,
|
|
840
|
+
project_id: T_id,
|
|
841
|
+
issue_type_id: Union[T_id, list[str], None] = None,
|
|
842
|
+
query: Optional[str] = None,
|
|
843
|
+
page: Optional[int] = None,
|
|
844
|
+
limit: Optional[int] = None,
|
|
845
|
+
sort: Optional[bool] = None,
|
|
846
|
+
use_all_contexts: Optional[bool] = None,
|
|
847
|
+
) -> T_resp_json:
|
|
848
|
+
"""
|
|
849
|
+
Get list of all options available for a custom field in a specified project.
|
|
850
|
+
Numeric field ID and numeric project ID must be used.
|
|
851
|
+
|
|
852
|
+
This is Experimental API available to Jira data Center.
|
|
853
|
+
At the time of testing, providing multiple project IDs results in 404 response.
|
|
854
|
+
|
|
855
|
+
Reference: https://developer.atlassian.com/server/jira/platform/rest/v11003/api-group-customfields/#api-api-2-customfields-customfieldid-options-get
|
|
856
|
+
|
|
857
|
+
:param field_id: str - The ID of the custom field.
|
|
858
|
+
:param project_id: str - The project ID in a context.
|
|
859
|
+
:param issue_type_id: str, Optional - A list of issue type IDs in a context.
|
|
860
|
+
:param query: str, Optional - A string used to filter options.
|
|
861
|
+
:param page: int, Optional - The page of options to return, starting from 1.
|
|
862
|
+
:param limit: int, Optional - The maximum number of results to return. If empty, return all results.
|
|
863
|
+
:param sort: bool, Optional - Flag to sort options by their names.
|
|
864
|
+
:param use_all_contexts: bool, Optional - Flag to fetch all options regardless of context, project IDs, or issue type IDs.
|
|
865
|
+
"""
|
|
866
|
+
url = self.resource_url(
|
|
867
|
+
f"customFields/{field_id}/options",
|
|
868
|
+
api_version=2,
|
|
869
|
+
)
|
|
870
|
+
params: dict = {}
|
|
871
|
+
if project_id:
|
|
872
|
+
if isinstance(project_id, (list, tuple, set)):
|
|
873
|
+
project_id = ",".join(project_id)
|
|
874
|
+
params["projectIds"] = project_id
|
|
875
|
+
if issue_type_id:
|
|
876
|
+
if isinstance(issue_type_id, (list, tuple, set)):
|
|
877
|
+
issue_type_id = ",".join(issue_type_id)
|
|
878
|
+
params["issueTypeIds"] = issue_type_id
|
|
879
|
+
if query:
|
|
880
|
+
params["query"] = query
|
|
881
|
+
if page is not None:
|
|
882
|
+
params["page"] = page
|
|
883
|
+
if limit is not None:
|
|
884
|
+
params["maxResults"] = limit
|
|
885
|
+
if sort is not None:
|
|
886
|
+
params["sortByOptionName"] = sort
|
|
887
|
+
if use_all_contexts is not None:
|
|
888
|
+
params["useAllContexts"] = use_all_contexts
|
|
889
|
+
return self.get(url, params=params)
|
|
890
|
+
|
|
716
891
|
def get_custom_fields(self, search: Optional[str] = None, start: int = 1, limit: int = 50) -> T_resp_json:
|
|
717
892
|
"""
|
|
718
893
|
Get custom fields. Evaluated on 7.12
|
|
@@ -1341,6 +1516,40 @@ class Jira(AtlassianRestAPI):
|
|
|
1341
1516
|
url = f"{base_url}/{issue_key}?expand=changelog"
|
|
1342
1517
|
return self._get_response_content(url, fields=[("changelog", params)])
|
|
1343
1518
|
|
|
1519
|
+
def get_changelogs_bulk(
|
|
1520
|
+
self,
|
|
1521
|
+
issue_ids_or_keys: List[str],
|
|
1522
|
+
fields_by: Optional[str] = None,
|
|
1523
|
+
next_page_token: Optional[str] = None,
|
|
1524
|
+
max_results: Optional[int] = None,
|
|
1525
|
+
) -> T_resp_json:
|
|
1526
|
+
"""
|
|
1527
|
+
Returns changelogs for multiple issues in bulk.
|
|
1528
|
+
Only Jira Cloud platform.
|
|
1529
|
+
|
|
1530
|
+
Reference: https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-changelog-bulkfetch-post
|
|
1531
|
+
|
|
1532
|
+
:param issue_ids_or_keys: List of issue IDs or keys to fetch changelogs for. Required.
|
|
1533
|
+
:param fields_by: OPTIONAL: Whether to filter changelog entries by field ID or field name.
|
|
1534
|
+
Valid values: "id", "name".
|
|
1535
|
+
:param next_page_token: OPTIONAL: Token for the next page of results (pagination).
|
|
1536
|
+
:param max_results: OPTIONAL: Maximum number of results to return.
|
|
1537
|
+
:return: Paginated list of changelogs for the given issues.
|
|
1538
|
+
"""
|
|
1539
|
+
if not self.cloud:
|
|
1540
|
+
raise ValueError("``get_changelogs_bulk`` method is only available for Jira Cloud platform")
|
|
1541
|
+
url = self.resource_url("changelog/bulkfetch", api_version=3)
|
|
1542
|
+
data: dict = {"issueIdsOrKeys": issue_ids_or_keys}
|
|
1543
|
+
if fields_by is not None:
|
|
1544
|
+
if fields_by not in ("id", "name"):
|
|
1545
|
+
raise ValueError("``fields_by`` must be either 'id' or 'name'")
|
|
1546
|
+
data["fieldsByKeys"] = fields_by == "name"
|
|
1547
|
+
if next_page_token is not None:
|
|
1548
|
+
data["nextPageToken"] = next_page_token
|
|
1549
|
+
if max_results is not None:
|
|
1550
|
+
data["maxResults"] = int(max_results)
|
|
1551
|
+
return self.post(url, data=data)
|
|
1552
|
+
|
|
1344
1553
|
def issue_add_json_worklog(self, key: str, worklog: Union[dict, str]):
|
|
1345
1554
|
"""
|
|
1346
1555
|
|
|
@@ -1821,6 +2030,28 @@ class Jira(AtlassianRestAPI):
|
|
|
1821
2030
|
params: dict = {"notifyUsers": "true" if notify_users else "false"}
|
|
1822
2031
|
return self.put(url, data=data, params=params)
|
|
1823
2032
|
|
|
2033
|
+
def issue_pin_comment(self, issue_key: str, comment_id: T_id) -> T_resp_json:
|
|
2034
|
+
"""
|
|
2035
|
+
Pin a comment on a Jira issue
|
|
2036
|
+
:param issue_key: str
|
|
2037
|
+
:param comment_id: int or str
|
|
2038
|
+
:return:
|
|
2039
|
+
"""
|
|
2040
|
+
base_url = self.resource_url("issue")
|
|
2041
|
+
url = f"{base_url}/{issue_key}/comment/{comment_id}/pin"
|
|
2042
|
+
return self.put(url, data=True)
|
|
2043
|
+
|
|
2044
|
+
def issue_unpin_comment(self, issue_key: str, comment_id: T_id) -> T_resp_json:
|
|
2045
|
+
"""
|
|
2046
|
+
Unpin a comment on a Jira issue
|
|
2047
|
+
:param issue_key: str
|
|
2048
|
+
:param comment_id: int or str
|
|
2049
|
+
:return:
|
|
2050
|
+
"""
|
|
2051
|
+
base_url = self.resource_url("issue")
|
|
2052
|
+
url = f"{base_url}/{issue_key}/comment/{comment_id}/pin"
|
|
2053
|
+
return self.put(url, data=False)
|
|
2054
|
+
|
|
1824
2055
|
def scrap_regex_from_issue(self, issue: str, regex: str):
|
|
1825
2056
|
"""
|
|
1826
2057
|
This function scrapes the output of the given regex matches from the issue's description and comments.
|
|
@@ -1833,7 +2064,7 @@ class Jira(AtlassianRestAPI):
|
|
|
1833
2064
|
list: A list of matches.
|
|
1834
2065
|
"""
|
|
1835
2066
|
regex_output = []
|
|
1836
|
-
issue_output = self.get_issue(issue)
|
|
2067
|
+
issue_output = self.get_issue(issue, fields="description,comment")
|
|
1837
2068
|
description = issue_output["fields"]["description"]
|
|
1838
2069
|
comments = issue_output["fields"]["comment"]["comments"]
|
|
1839
2070
|
|
|
@@ -1903,7 +2134,7 @@ class Jira(AtlassianRestAPI):
|
|
|
1903
2134
|
# Check the recursion depth. In case of any bugs that would result in infinite recursion, this will prevent the function from crashing your app. Python default for REcursionError is 1000
|
|
1904
2135
|
if depth > 150:
|
|
1905
2136
|
raise Exception("Recursion depth exceeded")
|
|
1906
|
-
issue = self.get_issue(issue_key)
|
|
2137
|
+
issue = self.get_issue(issue_key, fields="issuelinks,subtasks")
|
|
1907
2138
|
issue_links = issue["fields"]["issuelinks"]
|
|
1908
2139
|
subtasks = issue["fields"]["subtasks"]
|
|
1909
2140
|
for issue_link in issue_links:
|
|
@@ -2056,7 +2287,7 @@ class Jira(AtlassianRestAPI):
|
|
|
2056
2287
|
|
|
2057
2288
|
def get_issue_status_changelog(self, issue_id: T_id):
|
|
2058
2289
|
# Get the issue details with changelog
|
|
2059
|
-
response_get_issue = self.get_issue(issue_id, expand="changelog")
|
|
2290
|
+
response_get_issue = self.get_issue(issue_id, fields="id", expand="changelog")
|
|
2060
2291
|
status_change_history = []
|
|
2061
2292
|
for history in response_get_issue["changelog"]["histories"]:
|
|
2062
2293
|
for item in history["items"]:
|
|
@@ -3202,7 +3433,7 @@ class Jira(AtlassianRestAPI):
|
|
|
3202
3433
|
response = self.jql(jql, fields="*none")
|
|
3203
3434
|
if self.advanced_mode:
|
|
3204
3435
|
return cast("Response", response)
|
|
3205
|
-
return cast("dict", response)["
|
|
3436
|
+
return len(cast("dict", response)["issues"])
|
|
3206
3437
|
|
|
3207
3438
|
def get_all_project_issues(
|
|
3208
3439
|
self, project: str, fields: Union[str, List[str]] = "*all", start: int = 0, limit: Optional[int] = None
|
|
@@ -3638,7 +3869,7 @@ class Jira(AtlassianRestAPI):
|
|
|
3638
3869
|
url = self.resource_url("search/approximate-count")
|
|
3639
3870
|
return self.post(url, data)
|
|
3640
3871
|
|
|
3641
|
-
def match_jql(self, issue_ids: List[int], jqls: List[str]) -> Optional[
|
|
3872
|
+
def match_jql(self, issue_ids: List[int], jqls: List[str]) -> Optional[Dict[Any, Any]]:
|
|
3642
3873
|
"""
|
|
3643
3874
|
Checks which issues match a list of JQL queries.
|
|
3644
3875
|
|
|
@@ -3910,6 +4141,60 @@ class Jira(AtlassianRestAPI):
|
|
|
3910
4141
|
url = f"{base_url}/{priority_id}"
|
|
3911
4142
|
return self.get(url)
|
|
3912
4143
|
|
|
4144
|
+
def get_autocomplete_data(self) -> T_resp_json:
|
|
4145
|
+
"""
|
|
4146
|
+
Returns full information about visible fields that can be autocompleted in JQL.
|
|
4147
|
+
|
|
4148
|
+
Available in Jira Data Center, Jira Cloud v2, Jira Cloud v3.
|
|
4149
|
+
|
|
4150
|
+
Reference: https://developer.atlassian.com/server/jira/platform/rest/v11003/api-group-jql/#api-api-2-jql-autocompletedata-get
|
|
4151
|
+
https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-jql/#api-rest-api-2-jql-autocompletedata-get
|
|
4152
|
+
:return:
|
|
4153
|
+
"""
|
|
4154
|
+
url = self.resource_url("jql/autocompletedata")
|
|
4155
|
+
return self.get(url)
|
|
4156
|
+
|
|
4157
|
+
def get_autocomplete_suggestion(
|
|
4158
|
+
self,
|
|
4159
|
+
field_name: Optional[str] = None,
|
|
4160
|
+
field_value: Optional[str] = None,
|
|
4161
|
+
predicate_name: Optional[str] = None,
|
|
4162
|
+
predicate_value: Optional[str] = None,
|
|
4163
|
+
) -> T_resp_json:
|
|
4164
|
+
"""
|
|
4165
|
+
Returns auto complete suggestions for JQL search.
|
|
4166
|
+
|
|
4167
|
+
Suggestions can be obtained by providing:
|
|
4168
|
+
|
|
4169
|
+
`fieldName` to get a list of all values for the field.
|
|
4170
|
+
`fieldName` and `fieldValue` to get a list of values containing the text in `fieldValue`.
|
|
4171
|
+
`fieldName` and `predicateName` to get a list of all predicate values for the field.
|
|
4172
|
+
`fieldName`, `predicateName`, and `predicateValue` to get a list of predicate values containing the text in `predicateValue`.
|
|
4173
|
+
|
|
4174
|
+
Although auto complete suggestion can be used to retrieve possible option for a field,
|
|
4175
|
+
it may be more appropriate to use `get_custom_field_options()` method to get project-specific options for a field.
|
|
4176
|
+
|
|
4177
|
+
Reference: https://developer.atlassian.com/server/jira/platform/rest/v11003/api-group-jql/#api-api-2-jql-autocompletedata-suggestions-get
|
|
4178
|
+
https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-jql/#api-rest-api-2-jql-autocompletedata-suggestions-get
|
|
4179
|
+
|
|
4180
|
+
:param field_name: str, Optional - The field name for which the suggestions are generated.
|
|
4181
|
+
:param field_value: str, Optional - The portion of the field value that has already been provided by the user.
|
|
4182
|
+
:param predicate_name: str, Optional - The predicate for which the suggestions are generated. Suggestions are generated only for: "by", "from" and "to".
|
|
4183
|
+
:param predicate_value: str, Optional - The portion of the predicate value that has already been provided by the user.
|
|
4184
|
+
:return:
|
|
4185
|
+
"""
|
|
4186
|
+
url = self.resource_url("jql/autocompletedata/suggestions")
|
|
4187
|
+
params: dict = {}
|
|
4188
|
+
if field_name:
|
|
4189
|
+
params["fieldName"] = field_name
|
|
4190
|
+
if field_value:
|
|
4191
|
+
params["fieldValue"] = field_value
|
|
4192
|
+
if predicate_name:
|
|
4193
|
+
params["predicateName"] = predicate_name
|
|
4194
|
+
if predicate_value:
|
|
4195
|
+
params["predicateValue"] = predicate_value
|
|
4196
|
+
return self.get(url, params=params)
|
|
4197
|
+
|
|
3913
4198
|
"""
|
|
3914
4199
|
Workflow
|
|
3915
4200
|
Reference: https://docs.atlassian.com/software/jira/docs/api/REST/8.5.0/#api/2/workflow
|
|
@@ -4444,7 +4729,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
|
|
|
4444
4729
|
params["indexChangeHistory"] = change_history
|
|
4445
4730
|
if not worklogs:
|
|
4446
4731
|
params["indexWorklogs"] = worklogs
|
|
4447
|
-
if
|
|
4732
|
+
if indexing_type:
|
|
4448
4733
|
params["type"] = indexing_type
|
|
4449
4734
|
url = self.resource_url("reindex")
|
|
4450
4735
|
return self.post(url, params=params)
|
|
@@ -4472,7 +4757,8 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
|
|
|
4472
4757
|
:return:
|
|
4473
4758
|
"""
|
|
4474
4759
|
url = self.resource_url("reindex")
|
|
4475
|
-
|
|
4760
|
+
response = self.request("GET", path=url, allow_redirects=False)
|
|
4761
|
+
return response.json()
|
|
4476
4762
|
|
|
4477
4763
|
def reindex_project(self, project_key: str) -> T_resp_json:
|
|
4478
4764
|
return self.post(
|
|
@@ -4481,8 +4767,15 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
|
|
|
4481
4767
|
headers=self.form_token_headers,
|
|
4482
4768
|
)
|
|
4483
4769
|
|
|
4484
|
-
def reindex_issue(self,
|
|
4485
|
-
|
|
4770
|
+
def reindex_issue(self, issue_ids: list) -> T_resp_json:
|
|
4771
|
+
"""
|
|
4772
|
+
Reindex specific issues by their IDs.
|
|
4773
|
+
:param issue_ids: list of issue IDs (numeric) to reindex
|
|
4774
|
+
:return:
|
|
4775
|
+
"""
|
|
4776
|
+
url = self.resource_url("reindex/issue")
|
|
4777
|
+
params = {"issueId": ",".join(str(i) for i in issue_ids)}
|
|
4778
|
+
return self.post(url, params=params)
|
|
4486
4779
|
|
|
4487
4780
|
def index_checker(self, max_results: int = 100) -> T_resp_json:
|
|
4488
4781
|
"""
|
atlassian/jira_models.py
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"""Convenience alias for atlassian.models.jira.
|
|
2
|
+
|
|
3
|
+
Allows shorter imports:
|
|
4
|
+
from atlassian.jira_models import task, serialize
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from atlassian.models.jira import * # noqa: F401,F403
|
|
10
|
+
from atlassian.models.jira import __all__ # noqa: F401
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"""Type-safe Jira issue models with fluent builders.
|
|
2
|
+
|
|
3
|
+
Quick start:
|
|
4
|
+
from atlassian.models.jira import task, serialize
|
|
5
|
+
|
|
6
|
+
issue = (
|
|
7
|
+
task()
|
|
8
|
+
.project("PROJ")
|
|
9
|
+
.summary("My task")
|
|
10
|
+
.priority("High")
|
|
11
|
+
.build()
|
|
12
|
+
)
|
|
13
|
+
jira.issue_create(fields=serialize(issue)["fields"])
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
|
|
18
|
+
from atlassian.models.jira.adf import ADFBuilder, InlineNode, MentionNode, TextNode
|
|
19
|
+
from atlassian.models.jira.builders import (
|
|
20
|
+
EpicBuilder,
|
|
21
|
+
IssueBuilder,
|
|
22
|
+
StoryBuilder,
|
|
23
|
+
SubTaskBuilder,
|
|
24
|
+
TaskBuilder,
|
|
25
|
+
BugBuilder,
|
|
26
|
+
bug,
|
|
27
|
+
epic,
|
|
28
|
+
story,
|
|
29
|
+
subtask,
|
|
30
|
+
task,
|
|
31
|
+
)
|
|
32
|
+
from atlassian.models.jira.fields import (
|
|
33
|
+
Component,
|
|
34
|
+
CustomField,
|
|
35
|
+
IssueFields,
|
|
36
|
+
IssueLink,
|
|
37
|
+
IssueType,
|
|
38
|
+
Parent,
|
|
39
|
+
Priority,
|
|
40
|
+
PriorityLevel,
|
|
41
|
+
Project,
|
|
42
|
+
User,
|
|
43
|
+
Version,
|
|
44
|
+
)
|
|
45
|
+
from atlassian.models.jira.issues import (
|
|
46
|
+
Bug,
|
|
47
|
+
Epic,
|
|
48
|
+
JiraIssue,
|
|
49
|
+
Story,
|
|
50
|
+
SubTask,
|
|
51
|
+
Task,
|
|
52
|
+
get_issue_type_registry,
|
|
53
|
+
issue_type_for,
|
|
54
|
+
)
|
|
55
|
+
from atlassian.models.jira.comment import Comment, Visibility
|
|
56
|
+
from atlassian.models.jira.serializer import FieldMapping, bulk_serialize, serialize, to_fields_dict
|
|
57
|
+
from atlassian.models.jira.transition import Transition, TransitionBuilder
|
|
58
|
+
from atlassian.models.jira.update import UpdateBuilder, UpdatePayload
|
|
59
|
+
from atlassian.models.jira.validation import ValidationError, validate, validate_or_raise
|
|
60
|
+
|
|
61
|
+
__all__ = [
|
|
62
|
+
"ADFBuilder",
|
|
63
|
+
"Bug",
|
|
64
|
+
"BugBuilder",
|
|
65
|
+
"Comment",
|
|
66
|
+
"Component",
|
|
67
|
+
"CustomField",
|
|
68
|
+
"Epic",
|
|
69
|
+
"EpicBuilder",
|
|
70
|
+
"FieldMapping",
|
|
71
|
+
"InlineNode",
|
|
72
|
+
"IssueBuilder",
|
|
73
|
+
"IssueFields",
|
|
74
|
+
"IssueLink",
|
|
75
|
+
"IssueType",
|
|
76
|
+
"JiraIssue",
|
|
77
|
+
"MentionNode",
|
|
78
|
+
"Parent",
|
|
79
|
+
"Priority",
|
|
80
|
+
"PriorityLevel",
|
|
81
|
+
"Project",
|
|
82
|
+
"Story",
|
|
83
|
+
"StoryBuilder",
|
|
84
|
+
"SubTask",
|
|
85
|
+
"SubTaskBuilder",
|
|
86
|
+
"Task",
|
|
87
|
+
"TaskBuilder",
|
|
88
|
+
"TextNode",
|
|
89
|
+
"Transition",
|
|
90
|
+
"TransitionBuilder",
|
|
91
|
+
"UpdateBuilder",
|
|
92
|
+
"UpdatePayload",
|
|
93
|
+
"User",
|
|
94
|
+
"ValidationError",
|
|
95
|
+
"Version",
|
|
96
|
+
"Visibility",
|
|
97
|
+
"bug",
|
|
98
|
+
"bulk_serialize",
|
|
99
|
+
"epic",
|
|
100
|
+
"get_issue_type_registry",
|
|
101
|
+
"issue_type_for",
|
|
102
|
+
"serialize",
|
|
103
|
+
"story",
|
|
104
|
+
"subtask",
|
|
105
|
+
"task",
|
|
106
|
+
"to_fields_dict",
|
|
107
|
+
"validate",
|
|
108
|
+
"validate_or_raise",
|
|
109
|
+
]
|