Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/183 webhook logs #184

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ For example ``tox -epy37`` runs the tests on python 3.7.
Pull Request Guidelines
=======================

BBefore you submit a pull request, check that it meets these guidelines:
Before you submit a pull request, check that it meets these guidelines:

#. Pull request must be named with the following naming scheme:

Expand Down
1 change: 1 addition & 0 deletions changes/183.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add support for listing webhook logs. Also add support for resending a webhook request.
2 changes: 2 additions & 0 deletions taiga/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
UserStoryAttachments,
UserStoryAttributes,
UserStoryStatuses,
WebhookLogs,
Webhooks,
WikiLinks,
WikiPages,
Expand Down Expand Up @@ -100,6 +101,7 @@ def _init_resources(self):
self.wikilinks = WikiLinks(self.raw_request)
self.history = History(self.raw_request)
self.webhooks = Webhooks(self.raw_request)
self.webhook_logs = WebhookLogs(self.raw_request)
self.epics = Epics(self.raw_request)

def me(self):
Expand Down
4 changes: 4 additions & 0 deletions taiga/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
UserStoryStatus,
UserStoryStatuses,
Webhook,
WebhookLog,
WebhookLogs,
Webhooks,
WikiLink,
WikiLinks,
Expand Down Expand Up @@ -116,4 +118,6 @@
"IssueTypes",
"Webhook",
"Webhooks",
"WebhookLog",
"WebhookLogs",
]
31 changes: 30 additions & 1 deletion taiga/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1732,7 +1732,7 @@ def list_webhooks(self):
"""
Get the list of :class:`Webhook` resources for the project.
"""
return Webhooks(self.requester).list(project=self.id)
return Webhooks(self.requester).list(project=self.id, pagination=False)

def add_tag(self, tag, color=None):
"""
Expand Down Expand Up @@ -2052,6 +2052,12 @@ class Webhook(InstanceResource):

allowed_params = ["name", "url", "key"]

def list_logs(self):
"""
Get the list of :class:`Webhook` resources for the project.
"""
return WebhookLogs(self.requester).list(webhook=self.id, pagination=False)


class Webhooks(ListResource):
"""
Expand All @@ -2072,3 +2078,26 @@ def create(self, project, name, url, key, **attrs):
"""
attrs.update({"project": project, "name": name, "url": url, "key": key})
return self._new_resource(payload=attrs)


class WebhookLog(InstanceResource):
"""
WebhookLog model
"""

endpoint = "webhooklogs"

def resend(self) -> "WebhookLog":
"""
Resend the webhook
"""
response = self.requester.post("/{endpoint}/{id}/resend", endpoint=self.endpoint, id=self.id)
return WebhookLog.parse(self.requester, response.json())


class WebhookLogs(ListResource):
"""
WebhookLogs factory
"""

instance = WebhookLog