diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 3321ceb..48db7c3 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -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: diff --git a/changes/183.feature b/changes/183.feature new file mode 100644 index 0000000..3ffe48c --- /dev/null +++ b/changes/183.feature @@ -0,0 +1 @@ +Add support for listing webhook logs. Also add support for resending a webhook request. diff --git a/taiga/client.py b/taiga/client.py index c18d336..c4f434a 100644 --- a/taiga/client.py +++ b/taiga/client.py @@ -32,6 +32,7 @@ UserStoryAttachments, UserStoryAttributes, UserStoryStatuses, + WebhookLogs, Webhooks, WikiLinks, WikiPages, @@ -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): diff --git a/taiga/models/__init__.py b/taiga/models/__init__.py index 6df380b..91fb34a 100644 --- a/taiga/models/__init__.py +++ b/taiga/models/__init__.py @@ -51,6 +51,8 @@ UserStoryStatus, UserStoryStatuses, Webhook, + WebhookLog, + WebhookLogs, Webhooks, WikiLink, WikiLinks, @@ -116,4 +118,6 @@ "IssueTypes", "Webhook", "Webhooks", + "WebhookLog", + "WebhookLogs", ] diff --git a/taiga/models/models.py b/taiga/models/models.py index f01d7f1..fa1c4b7 100644 --- a/taiga/models/models.py +++ b/taiga/models/models.py @@ -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): """ @@ -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): """ @@ -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