brynq-sdk-jira 2.1.0__tar.gz → 3.0.0__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: 1.0
2
2
  Name: brynq_sdk_jira
3
- Version: 2.1.0
3
+ Version: 3.0.0
4
4
  Summary: JIRA wrapper from BrynQ
5
5
  Home-page: UNKNOWN
6
6
  Author: BrynQ
@@ -1,19 +1,21 @@
1
1
  import json
2
- from typing import Union, List
2
+ from typing import Union, List, Literal, Optional
3
3
  import pandas as pd
4
4
  import requests
5
5
  from brynq_sdk_brynq import BrynQ
6
6
 
7
7
  class Jira(BrynQ):
8
- def __init__(self, label: Union[str, List], debug=False):
8
+ def __init__(self, system_type: Optional[Literal['source', 'target']] = None, debug=False):
9
9
  super().__init__()
10
- credentials = self.get_system_credential(system='jira', label=label)
10
+ credentials = self.interfaces.credentials.get(system="jira", system_type=system_type)
11
+ credentials = credentials.get('data')
11
12
  self.base_url = credentials['base_url']
12
13
  self.headers = {
13
14
  "Authorization": f"Basic {credentials['access_token']}",
14
15
  "Content-Type": "application/json"
15
16
  }
16
17
  self.debug = debug
18
+ self.timeout = 3600
17
19
 
18
20
  def get_issues(self, jql_filter: str = None, jira_filter_id: int = None, get_extra_fields: list = None, expand_fields: list = None) -> pd.DataFrame:
19
21
  """
@@ -46,7 +48,7 @@ class Jira(BrynQ):
46
48
  url = f"{self.base_url}rest/api/3/search/jira/filter/{jira_filter_id}"
47
49
  else:
48
50
  url = f"{self.base_url}rest/api/3/search"
49
- response = requests.post(url=url, headers=self.headers, data=json.dumps(query))
51
+ response = requests.post(url=url, headers=self.headers, data=json.dumps(query), timeout=self.timeout)
50
52
  if response.status_code == 200:
51
53
  response_json = response.json()
52
54
  no_of_loops += 1
@@ -79,7 +81,7 @@ class Jira(BrynQ):
79
81
  }
80
82
  if self.debug:
81
83
  print(query)
82
- response = requests.get(f"{self.base_url}rest/api/3/project/search", headers=self.headers, params=query)
84
+ response = requests.get(f"{self.base_url}rest/api/3/project/search", headers=self.headers, params=query, timeout=self.timeout)
83
85
  if response.status_code == 200:
84
86
  response_json = response.json()
85
87
  response.raise_for_status()
@@ -103,7 +105,7 @@ class Jira(BrynQ):
103
105
  :return: A dataframe with the versions.
104
106
  """
105
107
  url = f"{self.base_url}rest/api/latest/project/{project_key}/versions"
106
- response = requests.get(url=url, headers=self.headers)
108
+ response = requests.get(url=url, headers=self.headers, timeout=self.timeout)
107
109
  if response.status_code == 200:
108
110
  response_json = response.json()
109
111
  df = pd.json_normalize(response_json)
@@ -123,7 +125,7 @@ class Jira(BrynQ):
123
125
  all_users = []
124
126
 
125
127
  while True:
126
- response = requests.get(f"{self.base_url}rest/api/3/users/search?startAt={start_at}&maxResults={max_results}", headers=self.headers)
128
+ response = requests.get(f"{self.base_url}rest/api/3/users/search?startAt={start_at}&maxResults={max_results}", headers=self.headers, timeout=self.timeout)
127
129
  response.raise_for_status()
128
130
  if response.status_code == 200:
129
131
  users = response.json() # A list of user objects
@@ -2,20 +2,22 @@ import json
2
2
  import requests
3
3
  from itertools import islice
4
4
  from brynq_sdk_brynq import BrynQ
5
- from typing import Union, List
5
+ from typing import Union, List, Literal, Optional
6
6
 
7
7
 
8
8
  class Tempo(BrynQ):
9
- def __init__(self, label: Union[str, List], debug=False):
9
+ def __init__(self, system_type: Optional[Literal['source', 'target']] = None, debug=False):
10
10
  super().__init__()
11
11
  self.debug = debug
12
- credentials = self.get_system_credential(system='tempo-timesheets', label=label)
12
+ credentials = self.interfaces.credentials.get(system="tempo-timesheets", system_type=system_type)
13
+ credentials = credentials.get('data')
13
14
  self.headers = {
14
15
  "Authorization": f"Bearer {credentials['api_token']}",
15
16
  "Content-Type": "application/json"
16
17
  }
17
18
  if self.debug:
18
19
  print(self.headers)
20
+ self.timeout = 3600
19
21
 
20
22
  def get_tempo_hours(self, from_date: str = None, to_date: str = None, updated_from: str = None) -> json:
21
23
  """
@@ -39,7 +41,7 @@ class Tempo(BrynQ):
39
41
 
40
42
  while not got_all_results:
41
43
  loop_parameters = parameters | {"limit": 1000, "offset": 1000 * no_of_loops}
42
- response = requests.get('https://api.tempo.io/4/worklogs', headers=self.headers, params=loop_parameters)
44
+ response = requests.get('https://api.tempo.io/4/worklogs', headers=self.headers, params=loop_parameters, timeout=self.timeout)
43
45
  if response.status_code == 200:
44
46
  response_json = response.json()
45
47
  no_of_loops += 1
@@ -78,7 +80,7 @@ class Tempo(BrynQ):
78
80
 
79
81
  while not got_all_results:
80
82
  parameters["offset"] = 1000 * no_of_loops
81
- response = requests.get('https://api.tempo.io/4/teams', headers=self.headers, params=parameters)
83
+ response = requests.get('https://api.tempo.io/4/teams', headers=self.headers, params=parameters, timeout=self.timeout)
82
84
  if response.status_code == 200:
83
85
  response_json = response.json()
84
86
  total_response.extend(response_json["results"])
@@ -106,7 +108,7 @@ class Tempo(BrynQ):
106
108
 
107
109
  while not got_all_results:
108
110
  parameters = {"limit": 1000, "offset": 1000 * no_of_loops}
109
- response = requests.get(f'https://api.tempo.io/4/teams/{team_id}/members', headers=self.headers, params=parameters)
111
+ response = requests.get(f'https://api.tempo.io/4/teams/{team_id}/members', headers=self.headers, params=parameters, timeout=self.timeout)
110
112
  if response.status_code == 200:
111
113
  response_json = response.json()
112
114
  total_response.extend(response_json["results"])
@@ -132,7 +134,7 @@ class Tempo(BrynQ):
132
134
 
133
135
  while not got_all_results:
134
136
  loop_parameters = parameters | {"limit": 1000, "offset": 1000 * no_of_loops}
135
- response = requests.get('https://api.tempo.io/4/accounts', headers=self.headers, params=loop_parameters)
137
+ response = requests.get('https://api.tempo.io/4/accounts', headers=self.headers, params=loop_parameters, timeout=self.timeout)
136
138
  if response.status_code == 200:
137
139
  response_json = response.json()
138
140
  no_of_loops += 1
@@ -168,7 +170,7 @@ class Tempo(BrynQ):
168
170
 
169
171
  while not got_all_results:
170
172
  loop_parameters = parameters | {"limit": 1000, "offset": 1000 * no_of_loops}
171
- response = requests.get(f"https://api.tempo.io/4/worklogs/account/{account_key}", headers=self.headers, params=loop_parameters)
173
+ response = requests.get(f"https://api.tempo.io/4/worklogs/account/{account_key}", headers=self.headers, params=loop_parameters, timeout=self.timeout)
172
174
  if response.status_code == 200:
173
175
  response_json = response.json()
174
176
  total_response.extend(response_json.get("results", []))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.0
2
2
  Name: brynq-sdk-jira
3
- Version: 2.1.0
3
+ Version: 3.0.0
4
4
  Summary: JIRA wrapper from BrynQ
5
5
  Home-page: UNKNOWN
6
6
  Author: BrynQ
@@ -1,3 +1,3 @@
1
- brynq-sdk-brynq>=2
1
+ brynq-sdk-brynq<5,>=4
2
2
  pandas<3,>=1
3
3
  requests<=3,>=2
@@ -2,7 +2,7 @@ from setuptools import setup, find_namespace_packages
2
2
 
3
3
  setup(
4
4
  name='brynq_sdk_jira',
5
- version='2.1.0',
5
+ version='3.0.0',
6
6
  description='JIRA wrapper from BrynQ',
7
7
  long_description='JIRA wrapper from BrynQ',
8
8
  author='BrynQ',
@@ -10,7 +10,7 @@ setup(
10
10
  packages=find_namespace_packages(include=['brynq_sdk*']),
11
11
  license='BrynQ License',
12
12
  install_requires=[
13
- 'brynq-sdk-brynq>=2',
13
+ 'brynq-sdk-brynq>=4,<5',
14
14
  'pandas>=1,<3',
15
15
  'requests>=2,<=3'
16
16
  ],
File without changes