|
| 1 | +from typing import Any, Dict, Optional |
| 2 | + |
1 | 3 | from huntflow_api_client.entities.base import ( |
2 | 4 | BaseEntity, |
3 | 5 | CreateEntityMixin, |
4 | 6 | DeleteEntityMixin, |
5 | 7 | ListEntityMixin, |
6 | 8 | ) |
| 9 | +from huntflow_api_client.models.consts import WebhookType |
7 | 10 | from huntflow_api_client.models.request.webhooks import WebhookRequest |
8 | 11 | from huntflow_api_client.models.response.webhooks import WebhookResponse, WebhooksListResponse |
9 | 12 |
|
10 | 13 |
|
11 | 14 | class Webhook(BaseEntity, ListEntityMixin, CreateEntityMixin, DeleteEntityMixin): |
12 | | - async def list(self, account_id: int) -> WebhooksListResponse: |
| 15 | + async def list( |
| 16 | + self, |
| 17 | + account_id: int, |
| 18 | + webhook_type: Optional[WebhookType] = None, |
| 19 | + ) -> WebhooksListResponse: |
13 | 20 | """ |
14 | 21 | API method reference https://api.huntflow.ai/v2/docs#get-/accounts/-account_id-/hooks |
15 | 22 |
|
16 | 23 | :param account_id: Organization ID |
| 24 | + :param webhook_type: Webhook type. If no value provided, webhooks of all types will be |
| 25 | + returned. |
17 | 26 | :return: List of webhooks |
18 | 27 | """ |
19 | 28 | path = f"/accounts/{account_id}/hooks" |
20 | | - response = await self._api.request("GET", path) |
| 29 | + params: Dict[str, Any] = {} |
| 30 | + if webhook_type: |
| 31 | + params["webhook_type"] = webhook_type.value |
| 32 | + response = await self._api.request("GET", path, params=params) |
21 | 33 | return WebhooksListResponse.model_validate(response.json()) |
22 | 34 |
|
23 | 35 | async def create(self, account_id: int, data: WebhookRequest) -> WebhookResponse: |
|
0 commit comments