From 62c7aafbbe48189f8d8882d82492b7149299d4a8 Mon Sep 17 00:00:00 2001 From: Philip Flohr Date: Tue, 14 May 2024 13:54:15 +0200 Subject: [PATCH 1/3] Add possibility to list webhook logs and to resend requests --- taiga/client.py | 2 ++ taiga/models/__init__.py | 4 ++++ taiga/models/models.py | 31 ++++++++++++++++++++++++++++++- 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/taiga/client.py b/taiga/client.py index c18d336..000773b 100644 --- a/taiga/client.py +++ b/taiga/client.py @@ -33,6 +33,7 @@ UserStoryAttributes, UserStoryStatuses, Webhooks, + WebhookLogs, 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..56d9038 100644 --- a/taiga/models/__init__.py +++ b/taiga/models/__init__.py @@ -52,6 +52,8 @@ UserStoryStatuses, Webhook, Webhooks, + WebhookLog, + WebhookLogs, WikiLink, WikiLinks, WikiPage, @@ -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 From 3bb2aaf7b1a93e628b4817f9550faecb1fd0730f Mon Sep 17 00:00:00 2001 From: Philip Flohr Date: Tue, 14 May 2024 14:15:33 +0200 Subject: [PATCH 2/3] Update sorting --- taiga/client.py | 2 +- taiga/models/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/taiga/client.py b/taiga/client.py index 000773b..c4f434a 100644 --- a/taiga/client.py +++ b/taiga/client.py @@ -32,8 +32,8 @@ UserStoryAttachments, UserStoryAttributes, UserStoryStatuses, - Webhooks, WebhookLogs, + Webhooks, WikiLinks, WikiPages, ) diff --git a/taiga/models/__init__.py b/taiga/models/__init__.py index 56d9038..91fb34a 100644 --- a/taiga/models/__init__.py +++ b/taiga/models/__init__.py @@ -51,9 +51,9 @@ UserStoryStatus, UserStoryStatuses, Webhook, - Webhooks, WebhookLog, WebhookLogs, + Webhooks, WikiLink, WikiLinks, WikiPage, From 25000cea0afffb8228f26ba30cfeb0f2ca0fc7d7 Mon Sep 17 00:00:00 2001 From: Philip Flohr Date: Tue, 14 May 2024 14:29:23 +0200 Subject: [PATCH 3/3] Add changes file, fix typo in contribution guideline --- CONTRIBUTING.rst | 2 +- changes/183.feature | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 changes/183.feature 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.