brynq-sdk-jira 3.0.2__tar.gz → 3.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.
- {brynq_sdk_jira-3.0.2 → brynq_sdk_jira-3.0.4}/PKG-INFO +1 -1
- {brynq_sdk_jira-3.0.2 → brynq_sdk_jira-3.0.4}/brynq_sdk_jira/jira.py +19 -0
- {brynq_sdk_jira-3.0.2 → brynq_sdk_jira-3.0.4}/brynq_sdk_jira/tempo.py +98 -0
- {brynq_sdk_jira-3.0.2 → brynq_sdk_jira-3.0.4}/brynq_sdk_jira.egg-info/PKG-INFO +1 -1
- {brynq_sdk_jira-3.0.2 → brynq_sdk_jira-3.0.4}/setup.py +1 -1
- {brynq_sdk_jira-3.0.2 → brynq_sdk_jira-3.0.4}/brynq_sdk_jira/__init__.py +0 -0
- {brynq_sdk_jira-3.0.2 → brynq_sdk_jira-3.0.4}/brynq_sdk_jira.egg-info/SOURCES.txt +0 -0
- {brynq_sdk_jira-3.0.2 → brynq_sdk_jira-3.0.4}/brynq_sdk_jira.egg-info/dependency_links.txt +0 -0
- {brynq_sdk_jira-3.0.2 → brynq_sdk_jira-3.0.4}/brynq_sdk_jira.egg-info/not-zip-safe +0 -0
- {brynq_sdk_jira-3.0.2 → brynq_sdk_jira-3.0.4}/brynq_sdk_jira.egg-info/requires.txt +0 -0
- {brynq_sdk_jira-3.0.2 → brynq_sdk_jira-3.0.4}/brynq_sdk_jira.egg-info/top_level.txt +0 -0
- {brynq_sdk_jira-3.0.2 → brynq_sdk_jira-3.0.4}/setup.cfg +0 -0
|
@@ -162,3 +162,22 @@ class Jira(BrynQ):
|
|
|
162
162
|
|
|
163
163
|
df = pd.json_normalize(all_users)
|
|
164
164
|
return df
|
|
165
|
+
|
|
166
|
+
def update_issue(self, issue, fields : dict):
|
|
167
|
+
try:
|
|
168
|
+
url = f"{self.base_url}rest/api/3/issue/{issue}"
|
|
169
|
+
payload = {
|
|
170
|
+
"fields" : fields
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
resp = requests.put(
|
|
174
|
+
url,
|
|
175
|
+
json= payload,
|
|
176
|
+
headers= self.headers,
|
|
177
|
+
timeout=60
|
|
178
|
+
)
|
|
179
|
+
|
|
180
|
+
return resp
|
|
181
|
+
except Exception as e:
|
|
182
|
+
message = "Error updating issue"
|
|
183
|
+
return message
|
|
@@ -55,6 +55,82 @@ class Tempo(BrynQ):
|
|
|
55
55
|
|
|
56
56
|
return total_response
|
|
57
57
|
|
|
58
|
+
def get_tempo_timesheet_approvals(self, from_date: str, to_date: str, team_id: int = 19) -> json:
|
|
59
|
+
"""
|
|
60
|
+
This function retrieves approved timesheet approvals for a given team in Tempo
|
|
61
|
+
over the specified date range.
|
|
62
|
+
|
|
63
|
+
:param from_date: string <yyyy-MM-dd> - retrieve results starting with this date
|
|
64
|
+
:param to_date: string <yyyy-MM-dd> - retrieve results up to and including this date
|
|
65
|
+
:param team_id: int (default 19) - Tempo team ID whose approvals are retrieved
|
|
66
|
+
:return: json response with results
|
|
67
|
+
"""
|
|
68
|
+
total_response = []
|
|
69
|
+
got_all_results = False
|
|
70
|
+
no_of_loops = 0
|
|
71
|
+
|
|
72
|
+
parameters = {
|
|
73
|
+
"from": from_date,
|
|
74
|
+
"to": to_date,
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
while not got_all_results:
|
|
78
|
+
loop_parameters = parameters | {"limit": 50, "offset": 50 * no_of_loops}
|
|
79
|
+
url = f"https://api.tempo.io/4/timesheet-approvals/team/{team_id}"
|
|
80
|
+
response = requests.get(
|
|
81
|
+
url,
|
|
82
|
+
headers=self.headers,
|
|
83
|
+
params=loop_parameters,
|
|
84
|
+
timeout=self.timeout
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
if response.status_code == 200:
|
|
88
|
+
response_json = response.json()
|
|
89
|
+
no_of_loops += 1
|
|
90
|
+
got_all_results = False if int(response_json['metadata']['count']) == 50 else True
|
|
91
|
+
total_response += response_json['results']
|
|
92
|
+
else:
|
|
93
|
+
raise ConnectionError(
|
|
94
|
+
f"Error getting timesheet approvals from Tempo: {response.status_code, response.text}"
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
if self.debug:
|
|
98
|
+
print(f"Received {len(total_response)} timesheet approvals from Tempo")
|
|
99
|
+
|
|
100
|
+
return total_response
|
|
101
|
+
|
|
102
|
+
def call_api(self, url: str, limit: int = 50) -> list[dict]:
|
|
103
|
+
"""
|
|
104
|
+
Calls the Tempo API and retrieves all paginated results for a given endpoint.
|
|
105
|
+
|
|
106
|
+
Args:
|
|
107
|
+
url (str): The API endpoint URL to call.
|
|
108
|
+
limit (int): Max results to fetch per request (default 50).
|
|
109
|
+
|
|
110
|
+
Returns:
|
|
111
|
+
list[dict]: A list of all results across all pages.
|
|
112
|
+
"""
|
|
113
|
+
all_results = []
|
|
114
|
+
offset = 0
|
|
115
|
+
while True:
|
|
116
|
+
querystring = {"limit": str(limit), "offset": str(offset)}
|
|
117
|
+
response = requests.get(url, headers=self.headers, params=querystring)
|
|
118
|
+
response.raise_for_status()
|
|
119
|
+
data = response.json()
|
|
120
|
+
|
|
121
|
+
# append results
|
|
122
|
+
results = data.get("results", [])
|
|
123
|
+
all_results.extend(results)
|
|
124
|
+
|
|
125
|
+
# pagination check
|
|
126
|
+
count = data.get("metadata", {}).get("count", 0)
|
|
127
|
+
if count < limit:
|
|
128
|
+
break
|
|
129
|
+
|
|
130
|
+
offset += limit
|
|
131
|
+
|
|
132
|
+
return all_results
|
|
133
|
+
|
|
58
134
|
def get_tempo_teams(self, team_members: List[str] = None, name: str = None) -> json:
|
|
59
135
|
"""
|
|
60
136
|
Fetches teams from the Tempo API in smaller batches to prevent long URLs if team_members is specified,
|
|
@@ -184,6 +260,28 @@ class Tempo(BrynQ):
|
|
|
184
260
|
|
|
185
261
|
return total_response
|
|
186
262
|
|
|
263
|
+
def update_worklog(self, worklog_id: Union[str, int], data: Union[str, dict]) -> requests.Response:
|
|
264
|
+
"""
|
|
265
|
+
Updates a Tempo worklog by ID.
|
|
266
|
+
|
|
267
|
+
Args:
|
|
268
|
+
worklog_id (str | int): ID of the worklog to update.
|
|
269
|
+
data (str | dict): The payload to send in the update request (JSON string or dict).
|
|
270
|
+
|
|
271
|
+
Returns:
|
|
272
|
+
requests.Response: The HTTP response object from Tempo API.
|
|
273
|
+
"""
|
|
274
|
+
url = f"https://api.tempo.io/4/worklogs/{worklog_id}"
|
|
275
|
+
|
|
276
|
+
# Ensure we send valid JSON
|
|
277
|
+
if isinstance(data, dict):
|
|
278
|
+
payload = json.dumps(data)
|
|
279
|
+
else:
|
|
280
|
+
payload = data
|
|
281
|
+
|
|
282
|
+
response = requests.put(url, headers=self.headers, data=payload, timeout=self.timeout)
|
|
283
|
+
return response
|
|
284
|
+
|
|
187
285
|
def _chunk_list(self, data_list, chunk_size):
|
|
188
286
|
"""Splits a list into chunks of `chunk_size`."""
|
|
189
287
|
it = iter(data_list)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|