Skip to content

Commit 370d4d4

Browse files
committed
Added 'update_worklog', 'delete_worklog' for v4
Added tempoapiclient.client_v4.Tempo.update_worklog() method. Added tempoapiclient.client_v4.Tempo.delete_worklog() method. Added brief usage instructions for the new methods in README.md.
1 parent e46ac75 commit 370d4d4

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,21 @@ You need an API token for communicating with tempo REST APIs.
6868
startTime="17:00:00"
6969
)
7070

71+
#### Update Worklog
72+
73+
logged_worklog = tempo.update_worklog(
74+
id="<id_of_the_worklog_to_be_updated>" # required
75+
accountId="<your_jira_account_id>", # required
76+
dateFrom="2019-11-11", # required
77+
timeSpentSeconds=3600, # required
78+
description="Something", # optional
79+
startTime="17:00:00" # optional
80+
)
81+
82+
#### Delete Worklog
83+
84+
delete_response = tempo.delete_worklog(<worklog_id>)
85+
7186
There are also functions to retrieve `user` and `team`-specific worklogs.
7287

7388

tempoapiclient/client_v4.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,8 +640,50 @@ def create_worklog(self, accountId, issueId, dateFrom, timeSpentSeconds, billabl
640640

641641
return self.post(url, data=data)
642642

643+
def update_worklog(self, id, accountId, dateFrom, timeSpentSeconds, billableSeconds=None, description=None,
644+
remainingEstimateSeconds=None, startTime=None):
645+
"""
646+
Updates an existing Worklog using the provided input and returns the updated Worklog.
647+
:param id: The ID of the Worklog to be updated
648+
:param accountId: The Author account ID of the user author
649+
:param dateFrom: The start date of the Worklog
650+
:param timeSpentSeconds: The total amount of time spent in seconds
651+
:param billableSeconds: The amount of seconds billable
652+
:param description: The description of the Worklog
653+
:param remainingEstimateSeconds: The total amount of estimated remaining seconds
654+
:param startTime: The start time of the Worklog
655+
656+
See https://apidocs.tempo.io/#tag/Worklogs/operation/updateWorklog
657+
"""
658+
659+
url = f"/worklogs/{id}"
660+
661+
data = {
662+
"authorAccountId": str(accountId),
663+
"startDate": self._resolve_date(dateFrom).isoformat(),
664+
"timeSpentSeconds": int(timeSpentSeconds),
665+
}
666+
667+
if billableSeconds:
668+
data["billableSeconds"] = int(billableSeconds)
669+
if description:
670+
data["description"] = str(description)
671+
if remainingEstimateSeconds:
672+
data["remainingEstimateSeconds"] = int(remainingEstimateSeconds)
673+
if startTime:
674+
data["startTime"] = self._resolve_time(startTime).isoformat()
675+
676+
return self.put(url, data=data)
643677

678+
def delete_worklog(self, id):
679+
"""
680+
Deletes a Worklog
681+
:param id: The ID of the Worklog to be deleted
644682
683+
See https://apidocs.tempo.io/#tag/Worklogs/operation/deleteWorklog
684+
"""
685+
url = f"/worklogs/{id}"
686+
return self.delete(url)
645687

646688
# Customer
647689

0 commit comments

Comments
 (0)