diff --git a/huntflow_api_client/entities/webhooks.py b/huntflow_api_client/entities/webhooks.py index 5c0c7a9..260dd3a 100644 --- a/huntflow_api_client/entities/webhooks.py +++ b/huntflow_api_client/entities/webhooks.py @@ -1,23 +1,35 @@ +from typing import Optional + from huntflow_api_client.entities.base import ( BaseEntity, CreateEntityMixin, DeleteEntityMixin, ListEntityMixin, ) +from huntflow_api_client.models.consts import WebhookType from huntflow_api_client.models.request.webhooks import WebhookRequest from huntflow_api_client.models.response.webhooks import WebhookResponse, WebhooksListResponse class Webhook(BaseEntity, ListEntityMixin, CreateEntityMixin, DeleteEntityMixin): - async def list(self, account_id: int) -> WebhooksListResponse: + async def list( + self, + account_id: int, + webhook_type: Optional[WebhookType] = None, + ) -> WebhooksListResponse: """ API method reference https://api.huntflow.ai/v2/docs#get-/accounts/-account_id-/hooks :param account_id: Organization ID + :param webhook_type: Webhook type. If no value provided, webhooks of all types will be + returned. :return: List of webhooks """ path = f"/accounts/{account_id}/hooks" - response = await self._api.request("GET", path) + params = {} + if webhook_type: + params["webhook_type"] = webhook_type.value + response = await self._api.request("GET", path, params=params) return WebhooksListResponse.model_validate(response.json()) async def create(self, account_id: int, data: WebhookRequest) -> WebhookResponse: diff --git a/huntflow_api_client/models/consts.py b/huntflow_api_client/models/consts.py index 8648a08..cbedcd3 100644 --- a/huntflow_api_client/models/consts.py +++ b/huntflow_api_client/models/consts.py @@ -11,6 +11,11 @@ class WebhookEvent(str, Enum): SURVEY_QUESTIONARY = "SURVEY-QUESTIONARY" +class WebhookType(str, Enum): + USER = "USER" + APPLICATION = "APPLICATION" + + class MemberType(str, Enum): owner = "owner" manager = "manager" diff --git a/huntflow_api_client/models/request/webhooks.py b/huntflow_api_client/models/request/webhooks.py index f9226cb..8298a30 100644 --- a/huntflow_api_client/models/request/webhooks.py +++ b/huntflow_api_client/models/request/webhooks.py @@ -3,7 +3,7 @@ from pydantic import Field from huntflow_api_client.models.common import JsonRequestModel -from huntflow_api_client.models.consts import WebhookEvent +from huntflow_api_client.models.consts import WebhookEvent, WebhookType class WebhookRequest(JsonRequestModel): @@ -11,3 +11,4 @@ class WebhookRequest(JsonRequestModel): url: str = Field(..., description="Webhook URL") active: bool = Field(..., description="Webhook activity flag") webhook_events: List[WebhookEvent] = Field(..., description="List of webhook events") + type: WebhookType = Field(default=WebhookType.USER, description="Webhook type") diff --git a/huntflow_api_client/models/response/webhooks.py b/huntflow_api_client/models/response/webhooks.py index f21e96d..7806d74 100644 --- a/huntflow_api_client/models/response/webhooks.py +++ b/huntflow_api_client/models/response/webhooks.py @@ -3,7 +3,7 @@ from pydantic import AnyHttpUrl, BaseModel, Field, PositiveInt -from huntflow_api_client.models.consts import WebhookEvent +from huntflow_api_client.models.consts import WebhookEvent, WebhookType class WebhookResponse(BaseModel): @@ -13,6 +13,7 @@ class WebhookResponse(BaseModel): created: datetime = Field(..., description="Date and time of creating a webhook") active: bool = Field(..., description="Webhook activity flag") webhook_events: List[WebhookEvent] = Field(..., description="List of webhook events") + type: WebhookType = Field(..., description="Webhook type") class WebhooksListResponse(BaseModel): diff --git a/pyproject.toml b/pyproject.toml index e25370a..526e67a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "huntflow-api-client" -version = "2.4.0" +version = "2.5.0" description = "Huntflow API Client for Python" authors = [ {name = "Developers huntflow", email = "developer@huntflow.ru"},