atlassian-python-api 3.41.16__py3-none-any.whl → 3.41.18__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/bitbucket/__init__.py +58 -8
- atlassian/bitbucket/cloud/repositories/__init__.py +2 -2
- atlassian/bitbucket/server/projects/repos/__init__.py +2 -1
- atlassian/confluence.py +291 -43
- atlassian/insight.py +2 -3
- atlassian/jira.py +32 -27
- atlassian/rest_client.py +45 -36
- atlassian/service_desk.py +9 -9
- {atlassian_python_api-3.41.16.dist-info → atlassian_python_api-3.41.18.dist-info}/METADATA +17 -3
- {atlassian_python_api-3.41.16.dist-info → atlassian_python_api-3.41.18.dist-info}/RECORD +14 -14
- {atlassian_python_api-3.41.16.dist-info → atlassian_python_api-3.41.18.dist-info}/WHEEL +1 -1
- {atlassian_python_api-3.41.16.dist-info → atlassian_python_api-3.41.18.dist-info}/LICENSE +0 -0
- {atlassian_python_api-3.41.16.dist-info → atlassian_python_api-3.41.18.dist-info}/top_level.txt +0 -0
atlassian/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
3.41.
|
|
1
|
+
3.41.18
|
atlassian/bitbucket/__init__.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# coding=utf-8
|
|
2
2
|
import logging
|
|
3
3
|
from enum import Enum
|
|
4
|
-
from typing import Optional, Union
|
|
5
4
|
|
|
6
5
|
from deprecated import deprecated
|
|
7
6
|
from requests import HTTPError
|
|
@@ -1907,6 +1906,22 @@ class Bitbucket(BitbucketBase):
|
|
|
1907
1906
|
params["limit"] = limit
|
|
1908
1907
|
return self._get_paged(url, params)
|
|
1909
1908
|
|
|
1909
|
+
def assign_pull_request_participant_role(
|
|
1910
|
+
self, project_key: str, repository_slug: str, pull_request_id: int, role: str, user: str
|
|
1911
|
+
) -> dict:
|
|
1912
|
+
"""
|
|
1913
|
+
Assign a role to a user for a pull request
|
|
1914
|
+
:param project_key: The project key
|
|
1915
|
+
:param repository_slug: The repository key
|
|
1916
|
+
:param pull_request_id: The pull request id
|
|
1917
|
+
:param role: The role to assign, currently it only accepts REVIEWER
|
|
1918
|
+
:param user: The user to assign the role to
|
|
1919
|
+
:return:
|
|
1920
|
+
"""
|
|
1921
|
+
url = self._url_pull_request_participants(project_key, repository_slug, pull_request_id)
|
|
1922
|
+
data = {"role": role, "user": {"name": user}}
|
|
1923
|
+
return self.post(url, data=data)
|
|
1924
|
+
|
|
1910
1925
|
def get_dashboard_pull_requests(
|
|
1911
1926
|
self,
|
|
1912
1927
|
start=0,
|
|
@@ -2105,6 +2120,37 @@ class Bitbucket(BitbucketBase):
|
|
|
2105
2120
|
data = {"version": comment_version}
|
|
2106
2121
|
return self.delete(url, params=data)
|
|
2107
2122
|
|
|
2123
|
+
def _url_pull_request_blocker_comments(self, project_key, repository_slug, pull_request_id) -> str:
|
|
2124
|
+
url = "{}/blocker-comments".format(self._url_pull_request(project_key, repository_slug, pull_request_id))
|
|
2125
|
+
return url
|
|
2126
|
+
|
|
2127
|
+
def add_pull_request_blocker_comment(
|
|
2128
|
+
self, project_key: str, repository_slug: str, pull_request_id: int, text: dict, severity: str
|
|
2129
|
+
) -> dict:
|
|
2130
|
+
"""
|
|
2131
|
+
Add a comment to a pull request that blocks the merge
|
|
2132
|
+
:param project_key: The project key
|
|
2133
|
+
:param repository_slug: The repository key
|
|
2134
|
+
:param pull_request_id: The pull request id
|
|
2135
|
+
:param text: The text of the comment
|
|
2136
|
+
:param severity: The severity of the comment
|
|
2137
|
+
:return:
|
|
2138
|
+
"""
|
|
2139
|
+
url = self._url_pull_request_blocker_comments(project_key, repository_slug, pull_request_id)
|
|
2140
|
+
data = {"text": text, "severity": severity}
|
|
2141
|
+
return self.post(url, data=data)
|
|
2142
|
+
|
|
2143
|
+
def search_pull_request_blocker_comment(self, project_key: str, repository_slug: str, pull_request_id: int) -> dict:
|
|
2144
|
+
"""
|
|
2145
|
+
Get all comments that block the merge of a pull request
|
|
2146
|
+
:param project_key: The project key
|
|
2147
|
+
:param repository_slug: The repository key
|
|
2148
|
+
:param pull_request_id: The pull request id
|
|
2149
|
+
:return:
|
|
2150
|
+
"""
|
|
2151
|
+
url = self._url_pull_request_blocker_comments(project_key, repository_slug, pull_request_id)
|
|
2152
|
+
return self.get(url)
|
|
2153
|
+
|
|
2108
2154
|
def decline_pull_request(self, project_key, repository_slug, pr_id, pr_version):
|
|
2109
2155
|
"""
|
|
2110
2156
|
Decline a pull request.
|
|
@@ -2208,13 +2254,13 @@ class Bitbucket(BitbucketBase):
|
|
|
2208
2254
|
|
|
2209
2255
|
def merge_pull_request(
|
|
2210
2256
|
self,
|
|
2211
|
-
project_key
|
|
2212
|
-
repository_slug
|
|
2213
|
-
pr_id
|
|
2214
|
-
merge_message
|
|
2215
|
-
close_source_branch
|
|
2216
|
-
merge_strategy
|
|
2217
|
-
pr_version
|
|
2257
|
+
project_key,
|
|
2258
|
+
repository_slug,
|
|
2259
|
+
pr_id,
|
|
2260
|
+
merge_message,
|
|
2261
|
+
close_source_branch=False,
|
|
2262
|
+
merge_strategy=MergeStrategy.MERGE_COMMIT,
|
|
2263
|
+
pr_version=None,
|
|
2218
2264
|
):
|
|
2219
2265
|
"""
|
|
2220
2266
|
Merge pull request
|
|
@@ -2330,6 +2376,7 @@ class Bitbucket(BitbucketBase):
|
|
|
2330
2376
|
limit=None,
|
|
2331
2377
|
until=None,
|
|
2332
2378
|
since=None,
|
|
2379
|
+
path=None,
|
|
2333
2380
|
):
|
|
2334
2381
|
"""
|
|
2335
2382
|
Get commit list from repo
|
|
@@ -2347,6 +2394,7 @@ class Bitbucket(BitbucketBase):
|
|
|
2347
2394
|
fixed system limits. Default by built-in method: None
|
|
2348
2395
|
:param until: OPTIONAL: The commit ID or ref (inclusively) to retrieve commits before
|
|
2349
2396
|
:param since: OPTIONAL: The commit ID or ref (exclusively) to retrieve commits after
|
|
2397
|
+
:param path: OPTIONAL: An optional path to filter commits by
|
|
2350
2398
|
:return:
|
|
2351
2399
|
"""
|
|
2352
2400
|
url = self._url_commits(project_key, repository_slug)
|
|
@@ -2373,6 +2421,8 @@ class Bitbucket(BitbucketBase):
|
|
|
2373
2421
|
params["since"] = since
|
|
2374
2422
|
if until:
|
|
2375
2423
|
params["until"] = until
|
|
2424
|
+
if path:
|
|
2425
|
+
params["path"] = path
|
|
2376
2426
|
return self._get_paged(url, params=params)
|
|
2377
2427
|
|
|
2378
2428
|
def get_commit_changes(self, project_key, repository_slug, hash_newest=None, merges="include", commit_id=None):
|
|
@@ -263,8 +263,8 @@ class Repository(BitbucketCloudBase):
|
|
|
263
263
|
self.__hooks = Hooks(
|
|
264
264
|
"{}/hooks".format(self.url),
|
|
265
265
|
data={"links": {"hooks": {"href": "{}/hooks".format(self.url)}}},
|
|
266
|
-
**self._new_session_args
|
|
267
|
-
)
|
|
266
|
+
**self._new_session_args
|
|
267
|
+
) # fmt: skip
|
|
268
268
|
self.__default_reviewers = DefaultReviewers("{}/default-reviewers".format(self.url), **self._new_session_args)
|
|
269
269
|
self.__deployment_environments = DeploymentEnvironments(
|
|
270
270
|
"{}/environments".format(self.url), **self._new_session_args
|
|
@@ -301,7 +301,8 @@ class Repository(BitbucketServerBase):
|
|
|
301
301
|
For further information visit:
|
|
302
302
|
https://docs.atlassian.com/bitbucket-server/rest/7.13.0/bitbucket-rest.html#idp199
|
|
303
303
|
:param dest_fd: a file-like object to which the archive will be written
|
|
304
|
-
:param at: string: Optional, the commit to download an archive of; if not supplied,
|
|
304
|
+
:param at: string: Optional, the commit to download an archive of; if not supplied,
|
|
305
|
+
an archive of the default branch is downloaded
|
|
305
306
|
:param filename: string: Optional, a filename to include the "Content-Disposition" header
|
|
306
307
|
:param format: string: Optional, the format to stream the archive in; must be one of: zip, tar, tar.gz or tgz.
|
|
307
308
|
If not specified, then the archive will be in zip format.
|
atlassian/confluence.py
CHANGED
|
@@ -1,15 +1,25 @@
|
|
|
1
1
|
# coding=utf-8
|
|
2
|
+
import io
|
|
3
|
+
import json
|
|
2
4
|
import logging
|
|
3
5
|
import os
|
|
4
|
-
import time
|
|
5
|
-
import json
|
|
6
6
|
import re
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
from deprecated import deprecated
|
|
7
|
+
import time
|
|
8
|
+
|
|
10
9
|
from bs4 import BeautifulSoup
|
|
10
|
+
from deprecated import deprecated
|
|
11
|
+
import requests
|
|
12
|
+
from requests import HTTPError
|
|
13
|
+
|
|
11
14
|
from atlassian import utils
|
|
12
|
-
from .errors import
|
|
15
|
+
from .errors import (
|
|
16
|
+
ApiConflictError,
|
|
17
|
+
ApiError,
|
|
18
|
+
ApiNotAcceptable,
|
|
19
|
+
ApiNotFoundError,
|
|
20
|
+
ApiPermissionError,
|
|
21
|
+
ApiValueError,
|
|
22
|
+
)
|
|
13
23
|
from .rest_client import AtlassianRestAPI
|
|
14
24
|
|
|
15
25
|
log = logging.getLogger(__name__)
|
|
@@ -136,6 +146,24 @@ class Confluence(AtlassianRestAPI):
|
|
|
136
146
|
else:
|
|
137
147
|
return False
|
|
138
148
|
|
|
149
|
+
def share_with_others(self, page_id, group, message):
|
|
150
|
+
"""
|
|
151
|
+
Notify members (currently only groups implemented) about something on that page
|
|
152
|
+
"""
|
|
153
|
+
url = "rest/share-page/latest/share"
|
|
154
|
+
params = {
|
|
155
|
+
"contextualPageId": page_id,
|
|
156
|
+
# "emails": [],
|
|
157
|
+
"entityId": page_id,
|
|
158
|
+
"entityType": "page",
|
|
159
|
+
"groups": group,
|
|
160
|
+
"note": message,
|
|
161
|
+
# "users":[]
|
|
162
|
+
}
|
|
163
|
+
r = self.post(url, json=params, headers={"contentType": "application/json; charset=utf-8"}, advanced_mode=True)
|
|
164
|
+
if r.status_code != 200:
|
|
165
|
+
raise Exception("failed sharing content {code}: {reason}".format(code=r.status_code, reason=r.text))
|
|
166
|
+
|
|
139
167
|
def get_page_child_by_type(self, page_id, type="page", start=None, limit=None, expand=None):
|
|
140
168
|
"""
|
|
141
169
|
Provide content by type (page, blog, comment)
|
|
@@ -692,10 +720,76 @@ class Confluence(AtlassianRestAPI):
|
|
|
692
720
|
|
|
693
721
|
return response.get("results")
|
|
694
722
|
|
|
723
|
+
def get_all_pages_by_space_ids_confluence_cloud(
|
|
724
|
+
self,
|
|
725
|
+
space_ids,
|
|
726
|
+
batch_size=250,
|
|
727
|
+
sort=None,
|
|
728
|
+
status=None,
|
|
729
|
+
title=None,
|
|
730
|
+
body_format=None,
|
|
731
|
+
):
|
|
732
|
+
"""
|
|
733
|
+
Get all pages from a set of space ids:
|
|
734
|
+
https://developer.atlassian.com/cloud/confluence/rest/v2/api-group-page/#api-pages-get
|
|
735
|
+
|
|
736
|
+
:param space_ids: A Set of space IDs passed as a filter to Confluence
|
|
737
|
+
:param batch_size: OPTIONAL: The batch size of pages to retrieve from confluence per request MAX is 250.
|
|
738
|
+
Default: 250
|
|
739
|
+
:param sort: OPTIONAL: The order the pages are retrieved in.
|
|
740
|
+
Valid values: id, -id, created-date, -created-date, modified-date, -modified-date, title, -title
|
|
741
|
+
:param status: OPTIONAL: Filter pages based on their status.
|
|
742
|
+
Valid values: current, archived, deleted, trashed
|
|
743
|
+
Default: current,archived
|
|
744
|
+
:param title: OPTIONAL: Filter pages based on their title.
|
|
745
|
+
:param body-format: OPTIONAL: The format of the body in the response. Valid values: storage, atlas_doc_format
|
|
746
|
+
:return:
|
|
747
|
+
"""
|
|
748
|
+
path = "/api/v2/pages"
|
|
749
|
+
params = {}
|
|
750
|
+
if space_ids:
|
|
751
|
+
params["space-id"] = ",".join(space_ids)
|
|
752
|
+
if batch_size:
|
|
753
|
+
params["limit"] = batch_size
|
|
754
|
+
if sort:
|
|
755
|
+
params["sort"] = sort
|
|
756
|
+
if status:
|
|
757
|
+
params["status"] = status
|
|
758
|
+
if title:
|
|
759
|
+
params["title"] = title
|
|
760
|
+
if body_format:
|
|
761
|
+
params["body-format"] = body_format
|
|
762
|
+
|
|
763
|
+
_all_pages = []
|
|
764
|
+
try:
|
|
765
|
+
while True:
|
|
766
|
+
response = self.get(path, params=params)
|
|
767
|
+
|
|
768
|
+
pages = response.get("results")
|
|
769
|
+
_all_pages = _all_pages + pages
|
|
770
|
+
|
|
771
|
+
links = response.get("_links")
|
|
772
|
+
if links is not None and "next" in links:
|
|
773
|
+
path = response["_links"]["next"].removeprefix("/wiki/")
|
|
774
|
+
params = {}
|
|
775
|
+
else:
|
|
776
|
+
break
|
|
777
|
+
except HTTPError as e:
|
|
778
|
+
if e.response.status_code == 400:
|
|
779
|
+
raise ApiValueError(
|
|
780
|
+
"The configured params cannot be interpreted by Confluence"
|
|
781
|
+
"Check the api documentation for valid values for status, expand, and sort params",
|
|
782
|
+
reason=e,
|
|
783
|
+
)
|
|
784
|
+
if e.response.status_code == 401:
|
|
785
|
+
raise HTTPError("Unauthorized (401)", response=response)
|
|
786
|
+
raise
|
|
787
|
+
|
|
788
|
+
return _all_pages
|
|
789
|
+
|
|
695
790
|
@deprecated(version="2.4.2", reason="Use get_all_restrictions_for_content()")
|
|
696
791
|
def get_all_restictions_for_content(self, content_id):
|
|
697
792
|
"""Let's use the get_all_restrictions_for_content()"""
|
|
698
|
-
log.warning("Please, be informed that is deprecated as typo naming")
|
|
699
793
|
return self.get_all_restrictions_for_content(content_id=content_id)
|
|
700
794
|
|
|
701
795
|
def get_all_restrictions_for_content(self, content_id):
|
|
@@ -1324,40 +1418,83 @@ class Confluence(AtlassianRestAPI):
|
|
|
1324
1418
|
comment=comment,
|
|
1325
1419
|
)
|
|
1326
1420
|
|
|
1327
|
-
def download_attachments_from_page(self, page_id, path=None, start=0, limit=50):
|
|
1328
|
-
"""
|
|
1329
|
-
Downloads
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
:param
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1421
|
+
def download_attachments_from_page(self, page_id, path=None, start=0, limit=50, filename=None, to_memory=False):
|
|
1422
|
+
"""
|
|
1423
|
+
Downloads attachments from a Confluence page. Supports downloading all files or a specific file.
|
|
1424
|
+
Files can either be saved to disk or returned as BytesIO objects for in-memory handling.
|
|
1425
|
+
|
|
1426
|
+
:param page_id: str
|
|
1427
|
+
The ID of the Confluence page to fetch attachments from.
|
|
1428
|
+
:param path: str, optional
|
|
1429
|
+
Directory where attachments will be saved. If None, defaults to the current working directory.
|
|
1430
|
+
Ignored if `to_memory` is True.
|
|
1431
|
+
:param start: int, optional
|
|
1432
|
+
The start point for paginated attachment fetching. Default is 0. Ignored if `filename` is specified.
|
|
1433
|
+
:param limit: int, optional
|
|
1434
|
+
The maximum number of attachments to fetch per request. Default is 50. Ignored if `filename` is specified.
|
|
1435
|
+
:param filename: str, optional
|
|
1436
|
+
The name of a specific file to download. If provided, only this file will be fetched.
|
|
1437
|
+
:param to_memory: bool, optional
|
|
1438
|
+
If True, attachments are returned as a dictionary of {filename: BytesIO object}.
|
|
1439
|
+
If False, files are written to the specified directory on disk.
|
|
1440
|
+
:return:
|
|
1441
|
+
- If `to_memory` is True, returns a dictionary {filename: BytesIO object}.
|
|
1442
|
+
- If `to_memory` is False, returns a summary dict: {"attachments_downloaded": int, "path": str}.
|
|
1443
|
+
:raises:
|
|
1444
|
+
- FileNotFoundError: If the specified path does not exist.
|
|
1445
|
+
- PermissionError: If there are permission issues with the specified path.
|
|
1446
|
+
- requests.HTTPError: If the HTTP request to fetch an attachment fails.
|
|
1447
|
+
- Exception: For any unexpected errors.
|
|
1448
|
+
"""
|
|
1449
|
+
# Default path to current working directory if not provided
|
|
1450
|
+
if not to_memory and path is None:
|
|
1338
1451
|
path = os.getcwd()
|
|
1452
|
+
|
|
1339
1453
|
try:
|
|
1340
|
-
attachments
|
|
1341
|
-
if
|
|
1342
|
-
|
|
1454
|
+
# Fetch attachments based on the specified parameters
|
|
1455
|
+
if filename:
|
|
1456
|
+
# Fetch specific file by filename
|
|
1457
|
+
attachments = self.get_attachments_from_content(page_id=page_id, filename=filename)["results"]
|
|
1458
|
+
if not attachments:
|
|
1459
|
+
return "No attachment with filename '{0}' found on the page.".format(filename)
|
|
1460
|
+
else:
|
|
1461
|
+
# Fetch all attachments with pagination
|
|
1462
|
+
attachments = self.get_attachments_from_content(page_id=page_id, start=start, limit=limit)["results"]
|
|
1463
|
+
if not attachments:
|
|
1464
|
+
return "No attachments found on the page."
|
|
1465
|
+
|
|
1466
|
+
# Prepare to handle downloads
|
|
1467
|
+
downloaded_files = {}
|
|
1343
1468
|
for attachment in attachments:
|
|
1344
|
-
file_name = attachment["title"]
|
|
1345
|
-
if not file_name:
|
|
1346
|
-
file_name = attachment["id"] # if the attachment has no title, use attachment_id as a filename
|
|
1469
|
+
file_name = attachment["title"] or attachment["id"] # Use attachment ID if title is unavailable
|
|
1347
1470
|
download_link = self.url + attachment["_links"]["download"]
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1471
|
+
# Fetch the file content
|
|
1472
|
+
response = self._session.get(str(download_link))
|
|
1473
|
+
response.raise_for_status() # Raise error if request fails
|
|
1474
|
+
|
|
1475
|
+
if to_memory:
|
|
1476
|
+
# Store in BytesIO object
|
|
1477
|
+
file_obj = io.BytesIO(response.content)
|
|
1478
|
+
downloaded_files[file_name] = file_obj
|
|
1479
|
+
else:
|
|
1480
|
+
# Save file to disk
|
|
1481
|
+
file_path = os.path.join(path, file_name)
|
|
1482
|
+
with open(file_path, "wb") as file:
|
|
1483
|
+
file.write(response.content)
|
|
1484
|
+
|
|
1485
|
+
# Return results based on storage mode
|
|
1486
|
+
if to_memory:
|
|
1487
|
+
return downloaded_files
|
|
1488
|
+
else:
|
|
1489
|
+
return {"attachments_downloaded": len(attachments), "path": path}
|
|
1352
1490
|
except NotADirectoryError:
|
|
1353
|
-
raise
|
|
1491
|
+
raise FileNotFoundError("The directory '{path}' does not exist.".format(path=path))
|
|
1354
1492
|
except PermissionError:
|
|
1355
|
-
raise PermissionError(
|
|
1356
|
-
|
|
1357
|
-
)
|
|
1358
|
-
except Exception as
|
|
1359
|
-
raise
|
|
1360
|
-
return {"attachments downloaded": len(attachments), " to path ": path}
|
|
1493
|
+
raise PermissionError("Permission denied when trying to save files to '{path}'.".format(path=path))
|
|
1494
|
+
except requests.HTTPError as http_err:
|
|
1495
|
+
raise Exception("HTTP error occurred while downloading attachments: {http_err}".format(http_err=http_err))
|
|
1496
|
+
except Exception as err:
|
|
1497
|
+
raise Exception("An unexpected error occurred: {error}".format(error=err))
|
|
1361
1498
|
|
|
1362
1499
|
def delete_attachment(self, page_id, filename, version=None):
|
|
1363
1500
|
"""
|
|
@@ -1383,9 +1520,11 @@ class Confluence(AtlassianRestAPI):
|
|
|
1383
1520
|
:param version: file version
|
|
1384
1521
|
:return:
|
|
1385
1522
|
"""
|
|
1386
|
-
|
|
1387
|
-
"rest/
|
|
1388
|
-
|
|
1523
|
+
if self.cloud:
|
|
1524
|
+
url = "rest/api/content/{id}/version/{versionId}".format(id=attachment_id, versionId=version)
|
|
1525
|
+
else:
|
|
1526
|
+
url = "rest/experimental/content/{id}/version/{versionId}".format(id=attachment_id, versionId=version)
|
|
1527
|
+
return self.delete(url)
|
|
1389
1528
|
|
|
1390
1529
|
def remove_page_attachment_keep_version(self, page_id, filename, keep_last_versions):
|
|
1391
1530
|
"""
|
|
@@ -1422,7 +1561,10 @@ class Confluence(AtlassianRestAPI):
|
|
|
1422
1561
|
:return
|
|
1423
1562
|
"""
|
|
1424
1563
|
params = {"limit": limit, "start": start}
|
|
1425
|
-
|
|
1564
|
+
if self.cloud:
|
|
1565
|
+
url = "rest/api/content/{id}/version".format(id=attachment_id)
|
|
1566
|
+
else:
|
|
1567
|
+
url = "rest/experimental/content/{id}/version".format(id=attachment_id)
|
|
1426
1568
|
return (self.get(url, params=params) or {}).get("results")
|
|
1427
1569
|
|
|
1428
1570
|
# @todo prepare more attachments info
|
|
@@ -2217,7 +2359,7 @@ class Confluence(AtlassianRestAPI):
|
|
|
2217
2359
|
:param name: str
|
|
2218
2360
|
:return:
|
|
2219
2361
|
"""
|
|
2220
|
-
log.
|
|
2362
|
+
log.info("Removing group: %s during Confluence remove_group method execution", name)
|
|
2221
2363
|
url = "rest/api/admin/group/{groupName}".format(groupName=name)
|
|
2222
2364
|
|
|
2223
2365
|
try:
|
|
@@ -2590,6 +2732,111 @@ class Confluence(AtlassianRestAPI):
|
|
|
2590
2732
|
url = "exportword?pageId={pageId}".format(pageId=page_id)
|
|
2591
2733
|
return self.get(url, headers=headers, not_json_response=True)
|
|
2592
2734
|
|
|
2735
|
+
def get_space_export(self, space_key: str, export_type: str) -> str:
|
|
2736
|
+
"""
|
|
2737
|
+
Export a Confluence space to a file of the specified type.
|
|
2738
|
+
(!) This method was developed for Confluence Cloud and may not work with Confluence on-prem.
|
|
2739
|
+
(!) This is an experimental method that does not trigger an officially supported REST endpoint. It may break if Atlassian changes the space export front-end logic.
|
|
2740
|
+
|
|
2741
|
+
:param space_key: The key of the space to export.
|
|
2742
|
+
:param export_type: The type of export to perform. Valid values are: 'html', 'csv', 'xml', 'pdf'.
|
|
2743
|
+
:return: The URL to download the exported file.
|
|
2744
|
+
"""
|
|
2745
|
+
|
|
2746
|
+
def get_atl_request(url: str):
|
|
2747
|
+
# Nested function used to get atl_token used for XSRF protection. this is only applicable to html/csv/xml space exports
|
|
2748
|
+
try:
|
|
2749
|
+
response = self.get(url, advanced_mode=True)
|
|
2750
|
+
parsed_html = BeautifulSoup(response.text, "html.parser")
|
|
2751
|
+
atl_token = parsed_html.find("input", {"name": "atl_token"}).get("value")
|
|
2752
|
+
return atl_token
|
|
2753
|
+
except Exception as e:
|
|
2754
|
+
raise ApiError("Problems with getting the atl_token for get_space_export method :", reason=e)
|
|
2755
|
+
|
|
2756
|
+
# Checks if space_ke parameter is valid and if api_token has relevant permissions to space
|
|
2757
|
+
self.get_space(space_key=space_key, expand="permissions")
|
|
2758
|
+
|
|
2759
|
+
try:
|
|
2760
|
+
log.info(
|
|
2761
|
+
"Initiated experimental get_space_export method for export type: "
|
|
2762
|
+
+ export_type
|
|
2763
|
+
+ " from Confluence space: "
|
|
2764
|
+
+ space_key
|
|
2765
|
+
)
|
|
2766
|
+
if export_type == "csv":
|
|
2767
|
+
form_data = {
|
|
2768
|
+
"atl_token": get_atl_request(
|
|
2769
|
+
"spaces/exportspacecsv.action?key={space_key}".format(space_key=space_key)
|
|
2770
|
+
),
|
|
2771
|
+
"exportType": "TYPE_CSV",
|
|
2772
|
+
"contentOption": "all",
|
|
2773
|
+
"includeComments": "true",
|
|
2774
|
+
"confirm": "Export",
|
|
2775
|
+
}
|
|
2776
|
+
elif export_type == "html":
|
|
2777
|
+
form_data = {
|
|
2778
|
+
"atl_token": get_atl_request(
|
|
2779
|
+
"spaces/exportspacehtml.action?key={space_key}".format(space_key=space_key)
|
|
2780
|
+
),
|
|
2781
|
+
"exportType": "TYPE_HTML",
|
|
2782
|
+
"contentOption": "visibleOnly",
|
|
2783
|
+
"includeComments": "true",
|
|
2784
|
+
"confirm": "Export",
|
|
2785
|
+
}
|
|
2786
|
+
elif export_type == "xml":
|
|
2787
|
+
form_data = {
|
|
2788
|
+
"atl_token": get_atl_request(
|
|
2789
|
+
"spaces/exportspacexml.action?key={space_key}".format(space_key=space_key)
|
|
2790
|
+
),
|
|
2791
|
+
"exportType": "TYPE_XML",
|
|
2792
|
+
"contentOption": "all",
|
|
2793
|
+
"includeComments": "true",
|
|
2794
|
+
"confirm": "Export",
|
|
2795
|
+
}
|
|
2796
|
+
elif export_type == "pdf":
|
|
2797
|
+
url = "spaces/flyingpdf/doflyingpdf.action?key=" + space_key
|
|
2798
|
+
log.info("Initiated PDF space export")
|
|
2799
|
+
return self.get_pdf_download_url_for_confluence_cloud(url)
|
|
2800
|
+
else:
|
|
2801
|
+
raise ValueError("Invalid export_type parameter value. Valid values are: 'html/csv/xml/pdf'")
|
|
2802
|
+
url = self.url_joiner(
|
|
2803
|
+
url=self.url, path="spaces/doexportspace.action?key={space_key}".format(space_key=space_key)
|
|
2804
|
+
)
|
|
2805
|
+
|
|
2806
|
+
# Sending a POST request that triggers the space export.
|
|
2807
|
+
response = self.session.post(url, headers=self.form_token_headers, data=form_data)
|
|
2808
|
+
parsed_html = BeautifulSoup(response.text, "html.parser")
|
|
2809
|
+
# Getting the poll URL to get the export progress status
|
|
2810
|
+
try:
|
|
2811
|
+
poll_url = parsed_html.find("meta", {"name": "ajs-pollURI"}).get("content")
|
|
2812
|
+
except Exception as e:
|
|
2813
|
+
raise ApiError("Problems with getting the poll_url for get_space_export method :", reason=e)
|
|
2814
|
+
running_task = True
|
|
2815
|
+
while running_task:
|
|
2816
|
+
try:
|
|
2817
|
+
progress_response = self.get(poll_url)
|
|
2818
|
+
log.info("Space" + space_key + " export status: " + progress_response["message"])
|
|
2819
|
+
if progress_response["complete"]:
|
|
2820
|
+
parsed_html = BeautifulSoup(progress_response["message"], "html.parser")
|
|
2821
|
+
download_url = parsed_html.find("a", {"class": "space-export-download-path"}).get("href")
|
|
2822
|
+
if self.url in download_url:
|
|
2823
|
+
return download_url
|
|
2824
|
+
else:
|
|
2825
|
+
combined_url = self.url + download_url
|
|
2826
|
+
# Ensure only one /wiki is included in the path
|
|
2827
|
+
if combined_url.count("/wiki") > 1:
|
|
2828
|
+
combined_url = combined_url.replace("/wiki/wiki", "/wiki")
|
|
2829
|
+
return combined_url
|
|
2830
|
+
time.sleep(30)
|
|
2831
|
+
except Exception as e:
|
|
2832
|
+
raise ApiError(
|
|
2833
|
+
"Encountered error during space export status check from space " + space_key, reason=e
|
|
2834
|
+
)
|
|
2835
|
+
|
|
2836
|
+
return "None" # Return None if the while loop does not return a value
|
|
2837
|
+
except Exception as e:
|
|
2838
|
+
raise ApiError("Encountered error during space export from space " + space_key, reason=e)
|
|
2839
|
+
|
|
2593
2840
|
def export_page(self, page_id):
|
|
2594
2841
|
"""
|
|
2595
2842
|
Alias method for export page as pdf
|
|
@@ -2838,6 +3085,7 @@ class Confluence(AtlassianRestAPI):
|
|
|
2838
3085
|
and provides a link to download the PDF once the process completes.
|
|
2839
3086
|
This functions polls the long-running task page and returns the
|
|
2840
3087
|
download url of the PDF.
|
|
3088
|
+
This method is used in get_space_export() method for space-> PDF export.
|
|
2841
3089
|
:param url: URL to initiate PDF export
|
|
2842
3090
|
:return: Download url for PDF file
|
|
2843
3091
|
"""
|
|
@@ -2927,7 +3175,7 @@ class Confluence(AtlassianRestAPI):
|
|
|
2927
3175
|
|
|
2928
3176
|
def get_whiteboard(self, whiteboard_id):
|
|
2929
3177
|
try:
|
|
2930
|
-
url =
|
|
3178
|
+
url = "/api/v2/whiteboards/%s" % (whiteboard_id)
|
|
2931
3179
|
return self.get(url)
|
|
2932
3180
|
except HTTPError as e:
|
|
2933
3181
|
# Default 404 error handling is ambiguous
|
|
@@ -2940,7 +3188,7 @@ class Confluence(AtlassianRestAPI):
|
|
|
2940
3188
|
|
|
2941
3189
|
def delete_whiteboard(self, whiteboard_id):
|
|
2942
3190
|
try:
|
|
2943
|
-
url =
|
|
3191
|
+
url = "/api/v2/whiteboards/%s" % (whiteboard_id)
|
|
2944
3192
|
return self.delete(url)
|
|
2945
3193
|
except HTTPError as e:
|
|
2946
3194
|
# # Default 404 error handling is ambiguous
|
|
@@ -3076,7 +3324,7 @@ class Confluence(AtlassianRestAPI):
|
|
|
3076
3324
|
:param group_name: str - name of group to add user to
|
|
3077
3325
|
:return: Current state of the group
|
|
3078
3326
|
"""
|
|
3079
|
-
url =
|
|
3327
|
+
url = "rest/api/user/%s/group/%s" % (username, group_name)
|
|
3080
3328
|
return self.put(url)
|
|
3081
3329
|
|
|
3082
3330
|
def add_space_permissions(
|
atlassian/insight.py
CHANGED
|
@@ -118,7 +118,7 @@ class Insight(AtlassianRestAPI):
|
|
|
118
118
|
"""
|
|
119
119
|
if self.cloud:
|
|
120
120
|
raise NotImplementedError
|
|
121
|
-
log.
|
|
121
|
+
log.info("Adding attachment...")
|
|
122
122
|
url = "rest/insight/1.0/attachments/object/{objectId}".format(objectId=object_id)
|
|
123
123
|
with open(filename, "rb") as attachment:
|
|
124
124
|
files = {"file": attachment}
|
|
@@ -131,7 +131,7 @@ class Insight(AtlassianRestAPI):
|
|
|
131
131
|
"""
|
|
132
132
|
if self.cloud:
|
|
133
133
|
raise NotImplementedError
|
|
134
|
-
log.
|
|
134
|
+
log.info("Deleting attachment...")
|
|
135
135
|
url = "rest/insight/1.0/attachments/{attachmentId}".format(attachmentId=attachment_id)
|
|
136
136
|
return self.delete(url)
|
|
137
137
|
|
|
@@ -373,7 +373,6 @@ class Insight(AtlassianRestAPI):
|
|
|
373
373
|
@deprecated(version="3.29.0", reason="Use get_object_reference_info()")
|
|
374
374
|
def get_object_referenceinfo(self, object_id):
|
|
375
375
|
"""Let's use the get_object_reference_info()"""
|
|
376
|
-
log.warning("Please, be informed that is deprecated as typo naming")
|
|
377
376
|
self.get_object_reference_info(object_id)
|
|
378
377
|
|
|
379
378
|
def get_object_reference_info(self, object_id):
|
atlassian/jira.py
CHANGED
|
@@ -255,11 +255,11 @@ class Jira(AtlassianRestAPI):
|
|
|
255
255
|
path = os.getcwd()
|
|
256
256
|
issue_id = self.issue(issue, fields="id")["id"]
|
|
257
257
|
if cloud:
|
|
258
|
-
url = self.url +
|
|
258
|
+
url = self.url + "/secure/issueAttachments/{}.zip".format(issue_id)
|
|
259
259
|
else:
|
|
260
|
-
url = self.url +
|
|
260
|
+
url = self.url + "/secure/attachmentzip/{}.zip".format(issue_id)
|
|
261
261
|
response = self._session.get(url)
|
|
262
|
-
attachment_name =
|
|
262
|
+
attachment_name = "{}_attachments.zip".format(issue_id)
|
|
263
263
|
file_path = os.path.join(path, attachment_name)
|
|
264
264
|
# if Jira issue doesn't have any attachments _session.get request response will return 22 bytes of PKzip format
|
|
265
265
|
file_size = sum(len(chunk) for chunk in response.iter_content(8196))
|
|
@@ -599,7 +599,7 @@ class Jira(AtlassianRestAPI):
|
|
|
599
599
|
return self.get(url)
|
|
600
600
|
|
|
601
601
|
def create_component(self, component):
|
|
602
|
-
log.
|
|
602
|
+
log.info('Creating component "%s"', component["name"])
|
|
603
603
|
base_url = self.resource_url("component")
|
|
604
604
|
url = "{base_url}/".format(base_url=base_url)
|
|
605
605
|
return self.post(url, data=component)
|
|
@@ -610,7 +610,7 @@ class Jira(AtlassianRestAPI):
|
|
|
610
610
|
return self.put(url, data=component)
|
|
611
611
|
|
|
612
612
|
def delete_component(self, component_id):
|
|
613
|
-
log.
|
|
613
|
+
log.info('Deleting component "%s"', component_id)
|
|
614
614
|
base_url = self.resource_url("component")
|
|
615
615
|
return self.delete("{base_url}/{component_id}".format(base_url=base_url, component_id=component_id))
|
|
616
616
|
|
|
@@ -965,7 +965,7 @@ class Jira(AtlassianRestAPI):
|
|
|
965
965
|
:param swap_group: str - swap group
|
|
966
966
|
:return:
|
|
967
967
|
"""
|
|
968
|
-
log.
|
|
968
|
+
log.info("Removing group: %s ", name)
|
|
969
969
|
url = self.resource_url("group")
|
|
970
970
|
if swap_group is not None:
|
|
971
971
|
params = {"groupname": name, "swapGroup": swap_group}
|
|
@@ -1030,7 +1030,7 @@ class Jira(AtlassianRestAPI):
|
|
|
1030
1030
|
:param group_name: str
|
|
1031
1031
|
:return:
|
|
1032
1032
|
"""
|
|
1033
|
-
log.
|
|
1033
|
+
log.info("Removing user: %s from a group: %s", username, group_name)
|
|
1034
1034
|
url = self.resource_url("group/user")
|
|
1035
1035
|
url_domain = self.url
|
|
1036
1036
|
if "atlassian.net" in url_domain:
|
|
@@ -1422,7 +1422,7 @@ class Jira(AtlassianRestAPI):
|
|
|
1422
1422
|
:param issue_key: str
|
|
1423
1423
|
:param attachment: IO Object
|
|
1424
1424
|
"""
|
|
1425
|
-
log.
|
|
1425
|
+
log.info("Adding attachment: %s", attachment)
|
|
1426
1426
|
base_url = self.resource_url("issue")
|
|
1427
1427
|
url = "{base_url}/{issue_key}/attachments".format(base_url=base_url, issue_key=issue_key)
|
|
1428
1428
|
if attachment:
|
|
@@ -1472,13 +1472,13 @@ class Jira(AtlassianRestAPI):
|
|
|
1472
1472
|
else:
|
|
1473
1473
|
params["deleteSubtasks"] = "false"
|
|
1474
1474
|
|
|
1475
|
-
log.
|
|
1475
|
+
log.info("Removing issue %s...", issue_id_or_key)
|
|
1476
1476
|
|
|
1477
1477
|
return self.delete(url, params=params)
|
|
1478
1478
|
|
|
1479
1479
|
# @todo merge with edit_issue method
|
|
1480
1480
|
def issue_update(self, issue_key, fields):
|
|
1481
|
-
log.
|
|
1481
|
+
log.info('Updating issue "%s" with "%s"', issue_key, fields)
|
|
1482
1482
|
base_url = self.resource_url("issue")
|
|
1483
1483
|
url = "{base_url}/{issue_key}".format(base_url=base_url, issue_key=issue_key)
|
|
1484
1484
|
return self.put(url, data={"fields": fields})
|
|
@@ -1512,7 +1512,7 @@ class Jira(AtlassianRestAPI):
|
|
|
1512
1512
|
:param user:
|
|
1513
1513
|
:return:
|
|
1514
1514
|
"""
|
|
1515
|
-
log.
|
|
1515
|
+
log.info('Adding user %s to "%s" watchers', user, issue_key)
|
|
1516
1516
|
data = user
|
|
1517
1517
|
base_url = self.resource_url("issue")
|
|
1518
1518
|
return self.post(
|
|
@@ -1527,7 +1527,7 @@ class Jira(AtlassianRestAPI):
|
|
|
1527
1527
|
:param user:
|
|
1528
1528
|
:return:
|
|
1529
1529
|
"""
|
|
1530
|
-
log.
|
|
1530
|
+
log.info('Deleting user %s from "%s" watchers', user, issue_key)
|
|
1531
1531
|
params = {"username": user}
|
|
1532
1532
|
base_url = self.resource_url("issue")
|
|
1533
1533
|
return self.delete(
|
|
@@ -1613,7 +1613,7 @@ class Jira(AtlassianRestAPI):
|
|
|
1613
1613
|
|
|
1614
1614
|
# @todo refactor and merge with create_issue method
|
|
1615
1615
|
def issue_create(self, fields):
|
|
1616
|
-
log.
|
|
1616
|
+
log.info('Creating issue "%s"', fields["summary"])
|
|
1617
1617
|
url = self.resource_url("issue")
|
|
1618
1618
|
return self.post(url, data={"fields": fields})
|
|
1619
1619
|
|
|
@@ -1730,20 +1730,21 @@ class Jira(AtlassianRestAPI):
|
|
|
1730
1730
|
url += "/" + internal_id
|
|
1731
1731
|
return self.get(url, params=params)
|
|
1732
1732
|
|
|
1733
|
-
def get_issue_tree_recursive(self, issue_key, tree=
|
|
1733
|
+
def get_issue_tree_recursive(self, issue_key, tree=None, depth=None):
|
|
1734
1734
|
"""
|
|
1735
|
-
Returns list that contains the
|
|
1736
|
-
(!) Function only returns child issues from the same
|
|
1737
|
-
|
|
1738
|
-
:param
|
|
1739
|
-
:param
|
|
1740
|
-
:
|
|
1741
|
-
:return: list of dictioanries, key is the parent issue key, value is the child/linked issue key
|
|
1742
|
-
|
|
1735
|
+
Returns a list that contains the tree structure of the root issue, with all subtasks and inward linked issues.
|
|
1736
|
+
(!) Function only returns child issues from the same Jira instance or from an instance to which the API key has access.
|
|
1737
|
+
:param issue_key: Jira issue key
|
|
1738
|
+
:param tree: list to store the tree structure for recursion. Do not change it.
|
|
1739
|
+
:param depth: current depth of the tree for recursion. Do not change it.
|
|
1740
|
+
:return: list of dictionaries containing the tree structure. Dictionary element contains a key (parent issue) and value (child issue).
|
|
1743
1741
|
"""
|
|
1744
|
-
|
|
1742
|
+
if tree is None:
|
|
1743
|
+
tree = []
|
|
1744
|
+
if depth is None:
|
|
1745
|
+
depth = 0
|
|
1745
1746
|
# 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
|
|
1746
|
-
if depth >
|
|
1747
|
+
if depth > 150:
|
|
1747
1748
|
raise Exception("Recursion depth exceeded")
|
|
1748
1749
|
issue = self.get_issue(issue_key)
|
|
1749
1750
|
issue_links = issue["fields"]["issuelinks"]
|
|
@@ -1761,9 +1762,9 @@ class Jira(AtlassianRestAPI):
|
|
|
1761
1762
|
for subtask in subtasks:
|
|
1762
1763
|
if subtask.get("key") is not None:
|
|
1763
1764
|
parent_issue_key = issue["key"]
|
|
1764
|
-
if not [x for x in tree if subtask["key"] in x.keys()]:
|
|
1765
|
+
if not [x for x in tree if subtask["key"] in x.keys()]:
|
|
1765
1766
|
tree.append({parent_issue_key: subtask["key"]})
|
|
1766
|
-
self.get_issue_tree_recursive(subtask["key"], tree, depth + 1)
|
|
1767
|
+
self.get_issue_tree_recursive(subtask["key"], tree, depth + 1)
|
|
1767
1768
|
return tree
|
|
1768
1769
|
|
|
1769
1770
|
def create_or_update_issue_remote_links(
|
|
@@ -1776,6 +1777,7 @@ class Jira(AtlassianRestAPI):
|
|
|
1776
1777
|
icon_url=None,
|
|
1777
1778
|
icon_title=None,
|
|
1778
1779
|
status_resolved=False,
|
|
1780
|
+
application: dict = {},
|
|
1779
1781
|
):
|
|
1780
1782
|
"""
|
|
1781
1783
|
Add Remote Link to Issue, update url if global_id is passed
|
|
@@ -1787,6 +1789,7 @@ class Jira(AtlassianRestAPI):
|
|
|
1787
1789
|
:param icon_url: str, OPTIONAL: Link to a 16x16 icon representing the type of the object in the remote system
|
|
1788
1790
|
:param icon_title: str, OPTIONAL: Text for the tooltip of the main icon describing the type of the object in the remote system
|
|
1789
1791
|
:param status_resolved: bool, OPTIONAL: if set to True, Jira renders the link strikethrough
|
|
1792
|
+
:param application: dict, OPTIONAL: Application description
|
|
1790
1793
|
"""
|
|
1791
1794
|
base_url = self.resource_url("issue")
|
|
1792
1795
|
url = "{base_url}/{issue_key}/remotelink".format(base_url=base_url, issue_key=issue_key)
|
|
@@ -1802,6 +1805,8 @@ class Jira(AtlassianRestAPI):
|
|
|
1802
1805
|
if icon_title:
|
|
1803
1806
|
icon_data["title"] = icon_title
|
|
1804
1807
|
data["object"]["icon"] = icon_data
|
|
1808
|
+
if application:
|
|
1809
|
+
data["application"] = application
|
|
1805
1810
|
return self.post(url, data=data)
|
|
1806
1811
|
|
|
1807
1812
|
def get_issue_remote_link_by_id(self, issue_key, link_id):
|
|
@@ -2136,7 +2141,7 @@ class Jira(AtlassianRestAPI):
|
|
|
2136
2141
|
Default:false.
|
|
2137
2142
|
:return:
|
|
2138
2143
|
"""
|
|
2139
|
-
log.
|
|
2144
|
+
log.info("Creating user %s", display_name)
|
|
2140
2145
|
data = {
|
|
2141
2146
|
"name": username,
|
|
2142
2147
|
"emailAddress": email,
|
atlassian/rest_client.py
CHANGED
|
@@ -12,6 +12,7 @@ except ImportError:
|
|
|
12
12
|
from requests import HTTPError
|
|
13
13
|
from requests_oauthlib import OAuth1, OAuth2
|
|
14
14
|
from six.moves.urllib.parse import urlencode
|
|
15
|
+
import time
|
|
15
16
|
from urllib3.util import Retry
|
|
16
17
|
import urllib3
|
|
17
18
|
|
|
@@ -269,44 +270,52 @@ class AtlassianRestAPI(object):
|
|
|
269
270
|
:param advanced_mode: bool, OPTIONAL: Return the raw response
|
|
270
271
|
:return:
|
|
271
272
|
"""
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
if
|
|
276
|
-
|
|
273
|
+
|
|
274
|
+
while True:
|
|
275
|
+
url = self.url_joiner(None if absolute else self.url, path, trailing)
|
|
276
|
+
params_already_in_url = True if "?" in url else False
|
|
277
|
+
if params or flags:
|
|
278
|
+
if params_already_in_url:
|
|
279
|
+
url += "&"
|
|
280
|
+
else:
|
|
281
|
+
url += "?"
|
|
282
|
+
if params:
|
|
283
|
+
url += urlencode(params or {})
|
|
284
|
+
if flags:
|
|
285
|
+
url += ("&" if params or params_already_in_url else "") + "&".join(flags or [])
|
|
286
|
+
json_dump = None
|
|
287
|
+
if files is None:
|
|
288
|
+
data = None if not data else dumps(data)
|
|
289
|
+
json_dump = None if not json else dumps(json)
|
|
290
|
+
self.log_curl_debug(
|
|
291
|
+
method=method,
|
|
292
|
+
url=url,
|
|
293
|
+
headers=headers,
|
|
294
|
+
data=data if data else json_dump,
|
|
295
|
+
)
|
|
296
|
+
headers = headers or self.default_headers
|
|
297
|
+
response = self._session.request(
|
|
298
|
+
method=method,
|
|
299
|
+
url=url,
|
|
300
|
+
headers=headers,
|
|
301
|
+
data=data,
|
|
302
|
+
json=json,
|
|
303
|
+
timeout=self.timeout,
|
|
304
|
+
verify=self.verify_ssl,
|
|
305
|
+
files=files,
|
|
306
|
+
proxies=self.proxies,
|
|
307
|
+
cert=self.cert,
|
|
308
|
+
)
|
|
309
|
+
response.encoding = "utf-8"
|
|
310
|
+
|
|
311
|
+
log.debug("HTTP: %s %s -> %s %s", method, path, response.status_code, response.reason)
|
|
312
|
+
log.debug("HTTP: Response text -> %s", response.text)
|
|
313
|
+
|
|
314
|
+
if response.status_code == 429:
|
|
315
|
+
time.sleep(int(response.headers["Retry-After"]))
|
|
277
316
|
else:
|
|
278
|
-
|
|
279
|
-
if params:
|
|
280
|
-
url += urlencode(params or {})
|
|
281
|
-
if flags:
|
|
282
|
-
url += ("&" if params or params_already_in_url else "") + "&".join(flags or [])
|
|
283
|
-
json_dump = None
|
|
284
|
-
if files is None:
|
|
285
|
-
data = None if not data else dumps(data)
|
|
286
|
-
json_dump = None if not json else dumps(json)
|
|
287
|
-
self.log_curl_debug(
|
|
288
|
-
method=method,
|
|
289
|
-
url=url,
|
|
290
|
-
headers=headers,
|
|
291
|
-
data=data if data else json_dump,
|
|
292
|
-
)
|
|
293
|
-
headers = headers or self.default_headers
|
|
294
|
-
response = self._session.request(
|
|
295
|
-
method=method,
|
|
296
|
-
url=url,
|
|
297
|
-
headers=headers,
|
|
298
|
-
data=data,
|
|
299
|
-
json=json,
|
|
300
|
-
timeout=self.timeout,
|
|
301
|
-
verify=self.verify_ssl,
|
|
302
|
-
files=files,
|
|
303
|
-
proxies=self.proxies,
|
|
304
|
-
cert=self.cert,
|
|
305
|
-
)
|
|
306
|
-
response.encoding = "utf-8"
|
|
317
|
+
break
|
|
307
318
|
|
|
308
|
-
log.debug("HTTP: %s %s -> %s %s", method, path, response.status_code, response.reason)
|
|
309
|
-
log.debug("HTTP: Response text -> %s", response.text)
|
|
310
319
|
if self.advanced_mode or advanced_mode:
|
|
311
320
|
return response
|
|
312
321
|
|
atlassian/service_desk.py
CHANGED
|
@@ -56,7 +56,7 @@ class ServiceDesk(AtlassianRestAPI):
|
|
|
56
56
|
:param email: str - email address
|
|
57
57
|
:return: New customer
|
|
58
58
|
"""
|
|
59
|
-
log.
|
|
59
|
+
log.info("Creating customer using create_customer method...")
|
|
60
60
|
data = {"fullName": full_name, "email": email}
|
|
61
61
|
|
|
62
62
|
return self.post(
|
|
@@ -236,7 +236,7 @@ class ServiceDesk(AtlassianRestAPI):
|
|
|
236
236
|
:param comment: OPTIONAL: str
|
|
237
237
|
:return: None
|
|
238
238
|
"""
|
|
239
|
-
log.
|
|
239
|
+
log.info("Performing transition for issue: " + issue_id_or_key)
|
|
240
240
|
data = {"id": transition_id, "additionalComment": {"body": comment}}
|
|
241
241
|
url = "rest/servicedeskapi/request/{}/transition".format(issue_id_or_key)
|
|
242
242
|
|
|
@@ -373,7 +373,7 @@ class ServiceDesk(AtlassianRestAPI):
|
|
|
373
373
|
:param name: str
|
|
374
374
|
:return: Organization data
|
|
375
375
|
"""
|
|
376
|
-
log.
|
|
376
|
+
log.info("Creating organization: " + name)
|
|
377
377
|
url = "rest/servicedeskapi/organization"
|
|
378
378
|
data = {"name": name}
|
|
379
379
|
|
|
@@ -387,7 +387,7 @@ class ServiceDesk(AtlassianRestAPI):
|
|
|
387
387
|
:param organization_id: int
|
|
388
388
|
:return:
|
|
389
389
|
"""
|
|
390
|
-
log.
|
|
390
|
+
log.info("Adding organization...")
|
|
391
391
|
url = "rest/servicedeskapi/servicedesk/{}/organization".format(service_desk_id)
|
|
392
392
|
data = {"organizationId": organization_id}
|
|
393
393
|
|
|
@@ -401,7 +401,7 @@ class ServiceDesk(AtlassianRestAPI):
|
|
|
401
401
|
:param organization_id: int
|
|
402
402
|
:return:
|
|
403
403
|
"""
|
|
404
|
-
log.
|
|
404
|
+
log.info("Removing organization...")
|
|
405
405
|
url = "rest/servicedeskapi/servicedesk/{}/organization".format(service_desk_id)
|
|
406
406
|
data = {"organizationId": organization_id}
|
|
407
407
|
|
|
@@ -414,7 +414,7 @@ class ServiceDesk(AtlassianRestAPI):
|
|
|
414
414
|
:param organization_id:
|
|
415
415
|
:return:
|
|
416
416
|
"""
|
|
417
|
-
log.
|
|
417
|
+
log.info("Deleting organization: %s ", organization_id)
|
|
418
418
|
url = "rest/servicedeskapi/organization/{}".format(organization_id)
|
|
419
419
|
|
|
420
420
|
return self.delete(url, headers=self.experimental_headers)
|
|
@@ -430,7 +430,7 @@ class ServiceDesk(AtlassianRestAPI):
|
|
|
430
430
|
:param users_list: list
|
|
431
431
|
:return:
|
|
432
432
|
"""
|
|
433
|
-
log.
|
|
433
|
+
log.info("Adding users: %s ", str(users_list))
|
|
434
434
|
url = "rest/servicedeskapi/organization/{}/user".format(organization_id)
|
|
435
435
|
data = {"usernames": users_list, "accountIds": account_list}
|
|
436
436
|
|
|
@@ -447,7 +447,7 @@ class ServiceDesk(AtlassianRestAPI):
|
|
|
447
447
|
:param account_list: list
|
|
448
448
|
:return:
|
|
449
449
|
"""
|
|
450
|
-
log.
|
|
450
|
+
log.info("Removing users: %s", str(users_list))
|
|
451
451
|
url = "rest/servicedeskapi/organization/{}/user".format(organization_id)
|
|
452
452
|
data = {"usernames": users_list, "accountIds": account_list}
|
|
453
453
|
|
|
@@ -901,7 +901,7 @@ class ServiceDesk(AtlassianRestAPI):
|
|
|
901
901
|
:param request_name: str
|
|
902
902
|
:param request_description: str
|
|
903
903
|
"""
|
|
904
|
-
log.
|
|
904
|
+
log.info("Creating request type")
|
|
905
905
|
data = {
|
|
906
906
|
"issueTypeId": request_type_id,
|
|
907
907
|
"name": request_name,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
2
|
Name: atlassian-python-api
|
|
3
|
-
Version: 3.41.
|
|
3
|
+
Version: 3.41.18
|
|
4
4
|
Summary: Python Atlassian REST API Wrapper
|
|
5
5
|
Home-page: https://github.com/atlassian-api/atlassian-python-api
|
|
6
6
|
Download-URL: https://github.com/atlassian-api/atlassian-python-api
|
|
@@ -49,11 +49,25 @@ Requires-Dist: deprecated
|
|
|
49
49
|
Requires-Dist: requests
|
|
50
50
|
Requires-Dist: six
|
|
51
51
|
Requires-Dist: oauthlib
|
|
52
|
-
Requires-Dist:
|
|
52
|
+
Requires-Dist: requests_oauthlib
|
|
53
53
|
Requires-Dist: jmespath
|
|
54
54
|
Requires-Dist: beautifulsoup4
|
|
55
55
|
Provides-Extra: kerberos
|
|
56
56
|
Requires-Dist: requests-kerberos; extra == "kerberos"
|
|
57
|
+
Dynamic: author
|
|
58
|
+
Dynamic: author-email
|
|
59
|
+
Dynamic: classifier
|
|
60
|
+
Dynamic: description
|
|
61
|
+
Dynamic: download-url
|
|
62
|
+
Dynamic: home-page
|
|
63
|
+
Dynamic: keywords
|
|
64
|
+
Dynamic: license
|
|
65
|
+
Dynamic: maintainer
|
|
66
|
+
Dynamic: maintainer-email
|
|
67
|
+
Dynamic: platform
|
|
68
|
+
Dynamic: provides-extra
|
|
69
|
+
Dynamic: requires-dist
|
|
70
|
+
Dynamic: summary
|
|
57
71
|
|
|
58
72
|
============================
|
|
59
73
|
Atlassian Python API wrapper
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
atlassian/VERSION,sha256=
|
|
1
|
+
atlassian/VERSION,sha256=z1ZgB8gRqxokPyvk5XQGlYHR2gJozsqQ7AfiKhSAi2o,8
|
|
2
2
|
atlassian/__init__.py,sha256=F13CZFoWIj9pDkj83soA7hwwHtvDC6EqFATey9p36PM,768
|
|
3
3
|
atlassian/bamboo.py,sha256=uPpmwkHQ_RiM8BkZvPunl6n1RnpEflKIS9AefZd5ne8,48969
|
|
4
4
|
atlassian/cloud_admin.py,sha256=vZxMA6IrdCQw1KAX3xKal_0ayTWGdMVhe3i0bPpChGk,969
|
|
5
|
-
atlassian/confluence.py,sha256=
|
|
5
|
+
atlassian/confluence.py,sha256=TsKIz_4AthBjVh2LuL8xZhAq0KHCnEpKXLJzReT1m_g,134503
|
|
6
6
|
atlassian/crowd.py,sha256=owgIavDgS5vnPEx-AiBi0mLa2DKV0jKW381vn0uLMfM,9556
|
|
7
7
|
atlassian/errors.py,sha256=GAKr6W4zPn7ZUMRLHG8-UgAdVnxDzKVZ-jyGXAccALE,398
|
|
8
|
-
atlassian/insight.py,sha256=
|
|
9
|
-
atlassian/jira.py,sha256=
|
|
8
|
+
atlassian/insight.py,sha256=6R9jxOqdFZKpWp5KPWVBKftcxdxbWAXbYdycHux3DdE,23717
|
|
9
|
+
atlassian/jira.py,sha256=fCg5aKmbc568ev8Wvc4Q_8G_u0mRk_920TZ2TIxsbzI,210203
|
|
10
10
|
atlassian/marketplace.py,sha256=-y7j0mOi00gBzq1Izj-sXI8khP90rKJUYXijpKW9vs8,2590
|
|
11
11
|
atlassian/portfolio.py,sha256=ioJMyxJW_Uuitszzd0ExoF1t8tykdit7Z7-WYlI6raA,3807
|
|
12
12
|
atlassian/request_utils.py,sha256=HRqGJyeWS3L3SAlgC2x8tKakvyHb1HafxcrHhTNq9iE,1127
|
|
13
|
-
atlassian/rest_client.py,sha256=
|
|
14
|
-
atlassian/service_desk.py,sha256=
|
|
13
|
+
atlassian/rest_client.py,sha256=nkz1ZkdA8YP564MuSvD4JHoYJ1c-WuO2UnCD4L1kzCA,19925
|
|
14
|
+
atlassian/service_desk.py,sha256=Q5ztws347APDonqEqt9dC4yglLoiULynKYZrbHFNUeQ,33499
|
|
15
15
|
atlassian/statuspage.py,sha256=M6Ryz4cpLrjqEiv-W6Uch4_OLjdxVILQpUojeAnYYdA,94470
|
|
16
16
|
atlassian/utils.py,sha256=oKvkGflmgygUcTU-fKd0LBnovgBpu3e5uHsj0sng_vg,10955
|
|
17
17
|
atlassian/xray.py,sha256=3OvLMNfTxfCXgKXxpjhq3a01RemOEtvJH9OqbCJrHEs,26219
|
|
18
|
-
atlassian/bitbucket/__init__.py,sha256=
|
|
18
|
+
atlassian/bitbucket/__init__.py,sha256=VmpVH3EWKm3eQMTFBLVwJDRfDlbQ_EP3EMgRryAPzQA,136984
|
|
19
19
|
atlassian/bitbucket/base.py,sha256=aZpA8J-iMWVahXLCUt-X2MmZ1nG20wCGD0ykKlZrEJ0,6447
|
|
20
20
|
atlassian/bitbucket/cloud/__init__.py,sha256=MX58kb4PKRK5M_iLyh0pya0FG8c9cYJkCAEVsugiGok,821
|
|
21
21
|
atlassian/bitbucket/cloud/base.py,sha256=K2v04dr3K22Wsx8w-fmPQym3vsSflOERYA_TtSMwr4c,4094
|
|
@@ -23,7 +23,7 @@ atlassian/bitbucket/cloud/common/__init__.py,sha256=5r9gwfcmU-AwZXG4kjU_Jpj_R72M
|
|
|
23
23
|
atlassian/bitbucket/cloud/common/builds.py,sha256=Gka9aQIKxzzCU3JGHg97zNEz01_eFyOpJA9su-D2C_I,2366
|
|
24
24
|
atlassian/bitbucket/cloud/common/comments.py,sha256=ktnN9G0Vr49rIAeqTElnEXvpePp6roUw_Om06JnEb-4,1329
|
|
25
25
|
atlassian/bitbucket/cloud/common/users.py,sha256=BbjkMeNFp7JwuewbKL_5qO1geuZ5iu3u5AThPu1pYJo,2390
|
|
26
|
-
atlassian/bitbucket/cloud/repositories/__init__.py,sha256=
|
|
26
|
+
atlassian/bitbucket/cloud/repositories/__init__.py,sha256=go2mUdLJzihGsA73ChaJGafDdrds7LHD_ejBSZ8R_Uk,16969
|
|
27
27
|
atlassian/bitbucket/cloud/repositories/branchRestrictions.py,sha256=E1wr1pheH9UnVLMao8-9rwmNZPJeLRoM1AmFQnfe4jQ,6503
|
|
28
28
|
atlassian/bitbucket/cloud/repositories/commits.py,sha256=mIheLsyIsfBParfNFhSoSJGAP8c-vlHgRVqoQfBOy00,6414
|
|
29
29
|
atlassian/bitbucket/cloud/repositories/defaultReviewers.py,sha256=bSa1iPILiKf9IcWcCYCQtYxQHoqeiuYGBHD7JVmXa-4,3560
|
|
@@ -46,9 +46,9 @@ atlassian/bitbucket/server/globalPermissions.py,sha256=_0LMi4KqQZAfm34tHaMfMyDYS
|
|
|
46
46
|
atlassian/bitbucket/server/common/__init__.py,sha256=0j0CWKFaX1kDqfDQkf3__Y2p24t1tS4wfOV8ZjZ9j5M,40
|
|
47
47
|
atlassian/bitbucket/server/common/permissions.py,sha256=89KLu4PY5BUJZsjTrJ8JbrQ46EHn1qj_P-ZJ-uGv3dA,7318
|
|
48
48
|
atlassian/bitbucket/server/projects/__init__.py,sha256=QXHgvrf3lS14OAbtXNdn9TC8ML2fZUkrC5C8BTR3I_0,7696
|
|
49
|
-
atlassian/bitbucket/server/projects/repos/__init__.py,sha256=
|
|
50
|
-
atlassian_python_api-3.41.
|
|
51
|
-
atlassian_python_api-3.41.
|
|
52
|
-
atlassian_python_api-3.41.
|
|
53
|
-
atlassian_python_api-3.41.
|
|
54
|
-
atlassian_python_api-3.41.
|
|
49
|
+
atlassian/bitbucket/server/projects/repos/__init__.py,sha256=jvoi3Xp8fdL_-00U6XvxsJ6ThxnXsn0QewKYiZu_s_A,10810
|
|
50
|
+
atlassian_python_api-3.41.18.dist-info/LICENSE,sha256=xamAnoX0zfBamIilAfP3nSIt7dIvnj7oueX14l6uKPY,11335
|
|
51
|
+
atlassian_python_api-3.41.18.dist-info/METADATA,sha256=jVu1OTq1MBXCD3EeG5kmU_fyJxH0TRpQhb79QpK6u3Q,9074
|
|
52
|
+
atlassian_python_api-3.41.18.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
53
|
+
atlassian_python_api-3.41.18.dist-info/top_level.txt,sha256=84-EDv8LNaZx01TCGjBzglwPU1JSRJ7fPSq9uy55Sv0,10
|
|
54
|
+
atlassian_python_api-3.41.18.dist-info/RECORD,,
|
|
File without changes
|
{atlassian_python_api-3.41.16.dist-info → atlassian_python_api-3.41.18.dist-info}/top_level.txt
RENAMED
|
File without changes
|