atlassian-python-api 4.0.0__py3-none-any.whl → 4.0.1__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 CHANGED
@@ -1 +1 @@
1
- 4.0.0
1
+ 4.0.1
atlassian/bamboo.py CHANGED
@@ -746,11 +746,13 @@ class Bamboo(AtlassianRestAPI):
746
746
  return self.delete(self.resource_url(resource))
747
747
 
748
748
  @property
749
- def get_projects(self):
749
+ def get_projects(self, start=0, limit=25):
750
750
  """Method used to list all projects defined in Bamboo.
751
- Projects without any plan are not listed."""
752
- start_idx = 0
753
- max_results = 25
751
+ Projects without any plan are not listed.
752
+ :return: GET request
753
+ """
754
+ start_idx = start
755
+ max_results = limit
754
756
 
755
757
  while True:
756
758
  resource = f"project?start-index={start_idx}&max-result={max_results}"
@@ -1,13 +1,15 @@
1
1
  # coding=utf-8
2
2
  import logging
3
3
  from enum import Enum
4
+ from typing import Optional
4
5
 
5
6
  from deprecated import deprecated
6
7
  from requests import HTTPError
7
8
 
8
- from .base import BitbucketBase
9
9
  from atlassian.bitbucket.cloud import Cloud
10
10
 
11
+ from .base import BitbucketBase
12
+
11
13
  log = logging.getLogger(__name__)
12
14
 
13
15
 
@@ -1891,7 +1893,7 @@ class Bitbucket(BitbucketBase):
1891
1893
 
1892
1894
  def assign_pull_request_participant_role(
1893
1895
  self, project_key: str, repository_slug: str, pull_request_id: int, role: str, user: str
1894
- ) -> dict:
1896
+ ) -> Optional[dict]:
1895
1897
  """
1896
1898
  Assign a role to a user for a pull request
1897
1899
  :param project_key: The project key
@@ -2117,7 +2119,9 @@ class Bitbucket(BitbucketBase):
2117
2119
  data = {"text": text, "severity": severity}
2118
2120
  return self.post(url, data=data)
2119
2121
 
2120
- def search_pull_request_blocker_comment(self, project_key: str, repository_slug: str, pull_request_id: int) -> dict:
2122
+ def search_pull_request_blocker_comment(
2123
+ self, project_key: str, repository_slug: str, pull_request_id: int
2124
+ ) -> Optional[dict]:
2121
2125
  """
2122
2126
  Get all comments that block the merge of a pull request
2123
2127
  :param project_key: The project key
@@ -1,5 +1,4 @@
1
1
  # coding=utf-8
2
-
3
2
  from ..base import BitbucketCloudBase
4
3
 
5
4
 
@@ -7,7 +6,7 @@ class RepositoryVariables(BitbucketCloudBase):
7
6
  def __init__(self, url, *args, **kwargs):
8
7
  super(RepositoryVariables, self).__init__(url, *args, **kwargs)
9
8
 
10
- def __get_object(self, data):
9
+ def __get_object(self, data) -> "RepositoryVariable":
11
10
  return RepositoryVariable(
12
11
  self.url_joiner(self.url, data["uuid"]),
13
12
  data,
@@ -61,7 +60,7 @@ class RepositoryVariables(BitbucketCloudBase):
61
60
 
62
61
  return
63
62
 
64
- def get(self, uuid):
63
+ def get(self, uuid: str): # type: ignore[override]
65
64
  """
66
65
  Returns the pipeline with the uuid in this repository.
67
66
 
atlassian/confluence.py CHANGED
@@ -5,13 +5,15 @@ import logging
5
5
  import os
6
6
  import re
7
7
  import time
8
+ from typing import cast
8
9
 
10
+ import requests
9
11
  from bs4 import BeautifulSoup
10
12
  from deprecated import deprecated
11
- import requests
12
13
  from requests import HTTPError
13
14
 
14
15
  from atlassian import utils
16
+
15
17
  from .errors import (
16
18
  ApiConflictError,
17
19
  ApiError,
@@ -343,7 +345,7 @@ class Confluence(AtlassianRestAPI):
343
345
  try:
344
346
  return response.get("results")[0]
345
347
  except (IndexError, TypeError) as e:
346
- log.error("Can't find '%s' page on the %s!", title, self.url)
348
+ log.error(f"Can't find '{title}' page on {self.url}")
347
349
  log.debug(e)
348
350
  return None
349
351
 
@@ -1468,7 +1470,7 @@ class Confluence(AtlassianRestAPI):
1468
1470
  downloaded_files = {}
1469
1471
  for attachment in attachments:
1470
1472
  file_name = attachment["title"] or attachment["id"] # Use attachment ID if title is unavailable
1471
- download_link = self.url + attachment["_links"]["download"]
1473
+ download_link = attachment["_links"]["download"]
1472
1474
  # Fetch the file content
1473
1475
  response = self.get(str(download_link), not_json_response=True)
1474
1476
 
@@ -1644,7 +1646,7 @@ class Confluence(AtlassianRestAPI):
1644
1646
 
1645
1647
  return response
1646
1648
 
1647
- def remove_page_label(self, page_id, label):
1649
+ def remove_page_label(self, page_id: str, label: str):
1648
1650
  """
1649
1651
  Delete Confluence page label
1650
1652
  :param page_id: content_id format
@@ -1803,7 +1805,7 @@ class Confluence(AtlassianRestAPI):
1803
1805
  log.debug('Old Content: """%s"""', confluence_body_content)
1804
1806
  log.debug('New Content: """%s"""', body)
1805
1807
 
1806
- if confluence_body_content.strip() == body.strip():
1808
+ if confluence_body_content.strip().lower() == body.strip().lower():
1807
1809
  log.info("Content of %s is exactly the same", page_id)
1808
1810
  return True
1809
1811
  else:
@@ -2709,7 +2711,7 @@ class Confluence(AtlassianRestAPI):
2709
2711
  """
2710
2712
  headers = self.form_token_headers
2711
2713
  url = f"spaces/flyingpdf/pdfpageexport.action?pageId={page_id}"
2712
- if self.api_version == "cloud":
2714
+ if self.api_version == "cloud" or self.cloud:
2713
2715
  url = self.get_pdf_download_url_for_confluence_cloud(url)
2714
2716
  if not url:
2715
2717
  log.error("Failed to get download PDF url.")
@@ -2740,13 +2742,13 @@ class Confluence(AtlassianRestAPI):
2740
2742
  :return: The URL to download the exported file.
2741
2743
  """
2742
2744
 
2743
- def get_atl_request(url: str):
2745
+ def get_atl_request(link: str):
2744
2746
  # Nested function used to get atl_token used for XSRF protection.
2745
2747
  # This is only applicable to html/csv/xml space exports
2746
2748
  try:
2747
- response = self.get(url, advanced_mode=True)
2749
+ response = self.get(link, advanced_mode=True)
2748
2750
  parsed_html = BeautifulSoup(response.text, "html.parser")
2749
- atl_token = parsed_html.find("input", {"name": "atl_token"}).get("value")
2751
+ atl_token = parsed_html.find("input", {"name": "atl_token"}).get("value") # type: ignore[union-attr]
2750
2752
  return atl_token
2751
2753
  except Exception as e:
2752
2754
  raise ApiError("Problems with getting the atl_token for get_space_export method :", reason=e)
@@ -2798,17 +2800,17 @@ class Confluence(AtlassianRestAPI):
2798
2800
  parsed_html = BeautifulSoup(response.text, "html.parser")
2799
2801
  # Getting the poll URL to get the export progress status
2800
2802
  try:
2801
- poll_url = parsed_html.find("meta", {"name": "ajs-pollURI"}).get("content")
2803
+ poll_url = cast("str", parsed_html.find("meta", {"name": "ajs-pollURI"}).get("content")) # type: ignore[union-attr]
2802
2804
  except Exception as e:
2803
2805
  raise ApiError("Problems with getting the poll_url for get_space_export method :", reason=e)
2804
2806
  running_task = True
2805
2807
  while running_task:
2806
2808
  try:
2807
- progress_response = self.get(poll_url)
2808
- log.info("Space" + space_key + " export status: " + progress_response["message"])
2809
- if progress_response["complete"]:
2810
- parsed_html = BeautifulSoup(progress_response["message"], "html.parser")
2811
- download_url = parsed_html.find("a", {"class": "space-export-download-path"}).get("href")
2809
+ progress_response = self.get(poll_url) or {}
2810
+ log.info(f"Space {space_key} export status: {progress_response.get('message', 'None')}")
2811
+ if progress_response is not {} and progress_response.get("complete"):
2812
+ parsed_html = BeautifulSoup(progress_response.get("message"), "html.parser")
2813
+ download_url = cast("str", parsed_html.find("a", {"class": "space-export-download-path"}).get("href")) # type: ignore
2812
2814
  if self.url in download_url:
2813
2815
  return download_url
2814
2816
  else:
@@ -3347,7 +3349,7 @@ class Confluence(AtlassianRestAPI):
3347
3349
  To learn more about how to use these APIs,
3348
3350
  please refer to the Confluence JSON-RPC documentation on Atlassian Developers.
3349
3351
  """
3350
- if self.api_version == "cloud":
3352
+ if self.api_version == "cloud" or self.cloud:
3351
3353
  return {}
3352
3354
  url = "rpc/json-rpc/confluenceservice-v2"
3353
3355
  data = {
@@ -3365,7 +3367,7 @@ class Confluence(AtlassianRestAPI):
3365
3367
  To learn more about how to use these APIs,
3366
3368
  please refer to the Confluence JSON-RPC documentation on Atlassian Developers.
3367
3369
  """
3368
- if self.api_version == "cloud":
3370
+ if self.api_version == "cloud" or self.cloud:
3369
3371
  return self.get_space(space_key=space_key, expand="permissions")
3370
3372
  url = "rpc/json-rpc/confluenceservice-v2"
3371
3373
  data = {