Skip to content

Commit a1da484

Browse files
djachkovgonchik
andcommitted
New methods in: Jira [Tempo], Bitbucket (#430)
* Bitbucket: add get_users; add example; add to documentation * Jira: add new Tempo method; update docs for new methods; add example Co-authored-by: Gonchik Tsymzhitov <[email protected]>
1 parent f86e269 commit a1da484

File tree

4 files changed

+107
-9
lines changed

4 files changed

+107
-9
lines changed

atlassian/bitbucket.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1659,7 +1659,14 @@ def get_lfs_repo_status(self, project_key, repo):
16591659
return self.get(url)
16601660

16611661
def get_users(self, user_filter=None):
1662-
url = "/rest/api/1.0/users"
1663-
if user_filter:
1664-
url += "?filter={}".format(user_filter)
1665-
return self.get(url)
1662+
"""
1663+
Get list of bitbucket users.
1664+
Use 'user_filter' for get specific users.
1665+
:user_filter: str
1666+
"""
1667+
url = "rest/api/1.0/users"
1668+
params = {}
1669+
if user_filter:
1670+
params['filter'] = user_filter
1671+
return self.get(url, params=params)
1672+

atlassian/jira.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2054,6 +2054,45 @@ def tempo_timesheets_get_worklogs(self, date_from=None, date_to=None, username=N
20542054
url = 'rest/tempo-timesheets/3/worklogs/'
20552055
return self.get(url, params=params)
20562056

2057+
def tempo_4_timesheets_find_worklogs(self, **params):
2058+
"""
2059+
Find existing worklogs with searching parameters.
2060+
NOTE: check if you are using correct types for the parameters!
2061+
:param from: string From Date
2062+
:param to: string To Date
2063+
:param worker: Array of strings
2064+
:param taskId: Array of integers
2065+
:param taskKey: Array of strings
2066+
:param projectId: Array of integers
2067+
:param projectKey: Array of strings
2068+
:param teamId: Array of integers
2069+
:param roleId: Array of integers
2070+
:param accountId: Array of integers
2071+
:param accountKey: Array of strings
2072+
:param filterId: Array of integers
2073+
:param customerId: Array of integers
2074+
:param categoryId: Array of integers
2075+
:param categoryTypeId: Array of integers
2076+
:param epicKey: Array of strings
2077+
:param updatedFrom: string
2078+
:param includeSubtasks: boolean
2079+
:param pageNo: integer
2080+
:param maxResults: integer
2081+
:param offset: integer
2082+
"""
2083+
2084+
url = "rest/tempo-timesheets/4/worklogs/search"
2085+
return self.post(url, data=params)
2086+
2087+
def tempo_timesheets_get_worklogs_by_issue(self, issue):
2088+
"""
2089+
Get Tempo timesheet worklog by issue key or id.
2090+
:param issue: Issue key or Id
2091+
:return:
2092+
"""
2093+
url = "rest/tempo-timesheets/4/worklogs/jira/issue/{issue}".format(issue=issue)
2094+
return self.get(url)
2095+
20572096
def tempo_timesheets_write_worklog(self, worker, started, time_spend_in_seconds, issue_id, comment=None):
20582097
"""
20592098
Log work for user

docs/jira.rst

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,19 +188,19 @@ Manage issues
188188
189189
# Set issue status by transition_id
190190
jira.set_issue_status_by_transition_id(issue_key, transition_id)
191-
191+
192192
# Get issue status
193193
jira.get_issue_status(issue_key)
194-
194+
195195
# Create or Update Issue Links
196196
jira.create_or_update_issue_remote_links(issue_key, link_url, title, global_id=None, relationship=None)
197-
197+
198198
# Get Issue Link by link ID
199199
jira.get_issue_remote_link_by_id(issue_key, link_id)
200-
200+
201201
# Update Issue Link by link ID
202202
jira.update_issue_remote_link_by_id(issue_key, link_id, url, title, global_id=None, relationship=None)
203-
203+
204204
# Delete Issue Links
205205
jira.delete_issue_remote_link_by_id(issue_key, link_id)
206206
@@ -275,3 +275,38 @@ Issue security schemes
275275
# user has the administrative permission.
276276
# Use only_levels=True for get the only levels entries
277277
jira.get_issue_security_scheme(scheme_id, only_levels=False)
278+
279+
TEMPO
280+
----------------------
281+
.. code-block:: python
282+
283+
# Find existing worklogs with the search parameters.
284+
# Look at the tempo docs for additional information:
285+
# https://www.tempo.io/server-api-documentation/timesheets#operation/searchWorklogs
286+
# NOTE: check if you are using correct types for the parameters!
287+
# :param from: string From Date
288+
# :param to: string To Date
289+
# :param worker: Array of strings
290+
# :param taskId: Array of integers
291+
# :param taskKey: Array of strings
292+
# :param projectId: Array of integers
293+
# :param projectKey: Array of strings
294+
# :param teamId: Array of integers
295+
# :param roleId: Array of integers
296+
# :param accountId: Array of integers
297+
# :param accountKey: Array of strings
298+
# :param filterId: Array of integers
299+
# :param customerId: Array of integers
300+
# :param categoryId: Array of integers
301+
# :param categoryTypeId: Array of integers
302+
# :param epicKey: Array of strings
303+
# :param updatedFrom: string
304+
# :param includeSubtasks: boolean
305+
# :param pageNo: integer
306+
# :param maxResults: integer
307+
# :param offset: integer
308+
jira.tempo_4_timesheets_find_worklogs(**params)
309+
310+
# :PRIVATE:
311+
# Get Tempo timesheet worklog by issue key or id.
312+
jira.tempo_timesheets_get_worklogs_by_issue(issue)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# coding=utf-8
2+
from atlassian import Jira
3+
from pprint import pprint
4+
import logging
5+
6+
jira = Jira(
7+
url='http://localhost:8080',
8+
username='admin',
9+
password='admin',
10+
advanced_mode=True # You can use it without advanced mode.
11+
)
12+
13+
logging.basicConfig(level=logging.DEBUG)
14+
# deprecated_issue_worklog = jira.tempo_timesheets_get_worklogs_by_issue("PROJ-1234")
15+
latest_issue_worklog = jira.tempo_4_timesheets_find_worklogs(taskKey=["PROJ-1234"])
16+
# pprint(deprecated_issue_worklog.json())
17+
pprint(latest_issue_worklog.json())

0 commit comments

Comments
 (0)