python-jira-plus 1.0.3__tar.gz → 1.0.4__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-jira-plus
3
- Version: 1.0.3
3
+ Version: 1.0.4
4
4
  Summary: Enhanced Python client for JIRA with better error handling, pagination, and metadata validation.
5
5
  Home-page: https://github.com/aviz92/python-jira-plus
6
6
  Author: Avi Zaguri
@@ -21,18 +21,18 @@ class ServerType(Enum):
21
21
 
22
22
  class JiraPlus:
23
23
  def __init__(
24
- self, base_url: Optional[str] = None,
25
- server_type: ServerType = ServerType.CLOUD,
26
- urllib3_log_level: int = logging.WARNING
24
+ self, base_url: Optional[str] = None,
25
+ server_type: ServerType = ServerType.CLOUD,
26
+ urllib3_log_level: int = logging.WARNING,
27
+ jira_username: Optional[str] = None,
28
+ jira_token: Optional[str] = None
27
29
  ) -> None:
28
30
  self.logger = logging.getLogger()
29
31
  logging.getLogger("urllib3").setLevel(urllib3_log_level)
30
32
 
31
- self.jira_username = os.getenv('JIRA_USER_NAME')
32
- self.jira_token = os.getenv('JIRA_TOKEN')
33
-
34
- if not base_url:
35
- self.base_url = os.getenv('JIRA_BASE_URL')
33
+ self.jira_username = jira_username or os.getenv('JIRA_USER_NAME')
34
+ self.jira_token = jira_token or os.getenv('JIRA_TOKEN')
35
+ self.base_url = base_url or os.getenv('JIRA_BASE_URL')
36
36
 
37
37
  self.server_type = server_type
38
38
  self.server = f'https://{self.base_url}'
@@ -40,8 +40,7 @@ class JiraPlus:
40
40
  self.jira_client = self.create_connection()
41
41
  self.check_client_connection()
42
42
 
43
- @retry(stop_max_attempt_number=3,
44
- wait_fixed=180000) # Retry 3 times with a 3-min (180000) delay between each attempt
43
+ @retry(stop_max_attempt_number=3, wait_fixed=180000) # Retry 3 times with a 3-min (180000) delay between each attempt
45
44
  def create_connection(self) -> Optional[JIRA]:
46
45
  jira_client = JIRA(
47
46
  basic_auth=(self.jira_username, self.jira_token),
@@ -81,10 +80,10 @@ class JiraPlus:
81
80
  return False
82
81
 
83
82
  def get_issue_by_key(
84
- self,
85
- key: str,
86
- specific_fields: str | list[str] = '*all',
87
- json_result: bool = True
83
+ self,
84
+ key: str,
85
+ specific_fields: str | list[str] = '*all',
86
+ json_result: bool = True
88
87
  ) -> None | Issue | dict[str, Any]:
89
88
  try:
90
89
  jira_issue = self.jira_client.issue(id=key, fields=specific_fields)
@@ -99,12 +98,12 @@ class JiraPlus:
99
98
  return None
100
99
 
101
100
  def get_objects_by_query(
102
- self,
103
- query: str,
104
- max_results: int = 5000,
105
- specific_fields: Union[str, list[str]] = "*all",
106
- jira_err_count: int = 3,
107
- json_result: bool = True,
101
+ self,
102
+ query: str,
103
+ max_results: int = 5000,
104
+ specific_fields: Union[str, list[str]] = "*all",
105
+ jira_err_count: int = 3,
106
+ json_result: bool = True,
108
107
  ) -> Optional[Union[ResultList[Issue], dict]]:
109
108
  return self._paginate_query(
110
109
  query=query,
@@ -115,12 +114,12 @@ class JiraPlus:
115
114
  )
116
115
 
117
116
  def _paginate_query(
118
- self,
119
- query: str,
120
- max_results: int,
121
- specific_fields: Union[str, list[str]],
122
- jira_err_limit: int,
123
- json_result: bool
117
+ self,
118
+ query: str,
119
+ max_results: int,
120
+ specific_fields: Union[str, list[str]],
121
+ jira_err_limit: int,
122
+ json_result: bool
124
123
  ) -> Union[ResultList[Issue] | list]:
125
124
  start_at = 0
126
125
  all_issues = []
@@ -172,10 +171,10 @@ class JiraPlus:
172
171
  return meta, issue_meta
173
172
 
174
173
  def get_allowed_values(
175
- self,
176
- project_key: str,
177
- issue_type: str,
178
- field_id_or_name: str,
174
+ self,
175
+ project_key: str,
176
+ issue_type: str,
177
+ field_id_or_name: str,
179
178
  ) -> Optional[list]:
180
179
  """
181
180
  Returns the allowed values for a specific field in a project + issue type context.
@@ -209,10 +208,10 @@ class JiraPlus:
209
208
  return describe_allowed_value(value, allowed_values=allowed_values)
210
209
 
211
210
  def validate_fields(
212
- self,
213
- project_key: str,
214
- issue_type: str,
215
- fields: Optional[dict] = None
211
+ self,
212
+ project_key: str,
213
+ issue_type: str,
214
+ fields: Optional[dict] = None
216
215
  ) -> None:
217
216
  meta, issue_meta = self._fetch_metadata(project_key=project_key, issue_type=issue_type)
218
217
  field_types = meta['projects'][0]['issuetypes'][0]['fields']
@@ -246,13 +245,13 @@ class JiraPlus:
246
245
  return issue_meta['fields'].keys()
247
246
 
248
247
  def create_issue(
249
- self,
250
- project_key: str,
251
- summary: str,
252
- description: str,
253
- issue_type: str,
254
- assignee: Optional[str] = None,
255
- custom_fields: Optional[dict] = None,
248
+ self,
249
+ project_key: str,
250
+ summary: str,
251
+ description: str,
252
+ issue_type: str,
253
+ assignee: Optional[str] = None,
254
+ custom_fields: Optional[dict] = None,
256
255
  ) -> Optional[Issue]:
257
256
  issue_fields = {
258
257
  "project": {"key": project_key},
@@ -261,7 +260,8 @@ class JiraPlus:
261
260
  "description": description,
262
261
  }
263
262
  if assignee:
264
- issue_fields["assignee"] = {"accountId": assignee} if self.server_type == ServerType.CLOUD else {"name": assignee}
263
+ issue_fields["assignee"] = {"accountId": assignee} if self.server_type == ServerType.CLOUD else {
264
+ "name": assignee}
265
265
 
266
266
  if custom_fields:
267
267
  issue_fields = issue_fields | custom_fields
@@ -279,9 +279,9 @@ class JiraPlus:
279
279
  return None
280
280
 
281
281
  def update_issue(
282
- self,
283
- issue_key: str,
284
- fields_to_update: dict
282
+ self,
283
+ issue_key: str,
284
+ fields_to_update: dict
285
285
  ) -> Optional[Issue]:
286
286
  try:
287
287
  issue = self.jira_client.issue(issue_key)
@@ -350,11 +350,11 @@ class JiraPlus:
350
350
  self.logger.exception(f"Exception - Attachment {file_path} was not uploaded to issue {issue_key}\n{err}")
351
351
 
352
352
  def transition_issue(
353
- self,
354
- issue_key: str,
355
- transition_name: str,
356
- fields: Optional[dict] = None,
357
- comment: Optional[str] = None,
353
+ self,
354
+ issue_key: str,
355
+ transition_name: str,
356
+ fields: Optional[dict] = None,
357
+ comment: Optional[str] = None,
358
358
  ) -> bool:
359
359
  try:
360
360
  transitions = self.jira_client.transitions(issue_key)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-jira-plus
3
- Version: 1.0.3
3
+ Version: 1.0.4
4
4
  Summary: Enhanced Python client for JIRA with better error handling, pagination, and metadata validation.
5
5
  Home-page: https://github.com/aviz92/python-jira-plus
6
6
  Author: Avi Zaguri
@@ -1,6 +1,6 @@
1
1
  from setuptools import setup, find_packages
2
2
 
3
- package_version = '1.0.3'
3
+ package_version = '1.0.4'
4
4
 
5
5
  package_name = 'python-jira-plus'
6
6
  package_description = 'Enhanced Python client for JIRA with better error handling, pagination, and metadata validation.'