Download data/src/elevenlabs/webhooks/client.py from introvoyz045/elevenlabs-python: direct link, hf CLI and curl.
- Browser
- Download file 12.9 kB
-
https://huggingface.co/datasets/introvoyz045/elevenlabs-python/resolve/main/data/src/elevenlabs/webhooks/client.py
- Command line
-
hf download hf://datasets/introvoyz045/elevenlabs-python/data/src/elevenlabs/webhooks/client.py
-
curl -L -o client.py https://huggingface.co/datasets/introvoyz045/elevenlabs-python/resolve/main/data/src/elevenlabs/webhooks/client.py
12.9 kB
| # This file was auto-generated by Fern from our API Definition. | |
| import typing | |
| from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper | |
| from ..core.request_options import RequestOptions | |
| from ..types.delete_workspace_webhook_response_model import DeleteWorkspaceWebhookResponseModel | |
| from ..types.patch_workspace_webhook_response_model import PatchWorkspaceWebhookResponseModel | |
| from ..types.webhook_hmac_settings import WebhookHmacSettings | |
| from ..types.workspace_create_webhook_response_model import WorkspaceCreateWebhookResponseModel | |
| from ..types.workspace_webhook_event_type import WorkspaceWebhookEventType | |
| from ..types.workspace_webhook_list_response_model import WorkspaceWebhookListResponseModel | |
| from .raw_client import AsyncRawWebhooksClient, RawWebhooksClient | |
| # this is used as the default value for optional parameters | |
| OMIT = typing.cast(typing.Any, ...) | |
| class WebhooksClient: | |
| def __init__(self, *, client_wrapper: SyncClientWrapper): | |
| self._raw_client = RawWebhooksClient(client_wrapper=client_wrapper) | |
| def with_raw_response(self) -> RawWebhooksClient: | |
| """ | |
| Retrieves a raw implementation of this client that returns raw responses. | |
| Returns | |
| ------- | |
| RawWebhooksClient | |
| """ | |
| return self._raw_client | |
| def list( | |
| self, *, include_usages: typing.Optional[bool] = None, request_options: typing.Optional[RequestOptions] = None | |
| ) -> WorkspaceWebhookListResponseModel: | |
| """ | |
| List all webhooks for a workspace | |
| Parameters | |
| ---------- | |
| include_usages : typing.Optional[bool] | |
| Whether to include active usages of the webhook, only usable by admins | |
| request_options : typing.Optional[RequestOptions] | |
| Request-specific configuration. | |
| Returns | |
| ------- | |
| WorkspaceWebhookListResponseModel | |
| Successful Response | |
| Examples | |
| -------- | |
| from elevenlabs import ElevenLabs | |
| client = ElevenLabs( | |
| api_key="YOUR_API_KEY", | |
| ) | |
| client.webhooks.list( | |
| include_usages=False, | |
| ) | |
| """ | |
| _response = self._raw_client.list(include_usages=include_usages, request_options=request_options) | |
| return _response.data | |
| def create( | |
| self, *, settings: WebhookHmacSettings, request_options: typing.Optional[RequestOptions] = None | |
| ) -> WorkspaceCreateWebhookResponseModel: | |
| """ | |
| Create a new webhook for the workspace with the specified authentication type. | |
| Parameters | |
| ---------- | |
| settings : WebhookHmacSettings | |
| Webhook settings object containing auth_type and corresponding configuration | |
| request_options : typing.Optional[RequestOptions] | |
| Request-specific configuration. | |
| Returns | |
| ------- | |
| WorkspaceCreateWebhookResponseModel | |
| Successful Response | |
| Examples | |
| -------- | |
| from elevenlabs import ElevenLabs, WebhookHmacSettings | |
| client = ElevenLabs( | |
| api_key="YOUR_API_KEY", | |
| ) | |
| client.webhooks.create( | |
| settings=WebhookHmacSettings( | |
| name="name", | |
| webhook_url="webhook_url", | |
| ), | |
| ) | |
| """ | |
| _response = self._raw_client.create(settings=settings, request_options=request_options) | |
| return _response.data | |
| def delete( | |
| self, webhook_id: str, *, request_options: typing.Optional[RequestOptions] = None | |
| ) -> DeleteWorkspaceWebhookResponseModel: | |
| """ | |
| Delete the specified workspace webhook | |
| Parameters | |
| ---------- | |
| webhook_id : str | |
| The unique ID for the webhook | |
| request_options : typing.Optional[RequestOptions] | |
| Request-specific configuration. | |
| Returns | |
| ------- | |
| DeleteWorkspaceWebhookResponseModel | |
| Successful Response | |
| Examples | |
| -------- | |
| from elevenlabs import ElevenLabs | |
| client = ElevenLabs( | |
| api_key="YOUR_API_KEY", | |
| ) | |
| client.webhooks.delete( | |
| webhook_id="G007vmtq9uWYl7SUW9zGS8GZZa1K", | |
| ) | |
| """ | |
| _response = self._raw_client.delete(webhook_id, request_options=request_options) | |
| return _response.data | |
| def update( | |
| self, | |
| webhook_id: str, | |
| *, | |
| is_disabled: bool, | |
| name: str, | |
| retry_enabled: typing.Optional[bool] = OMIT, | |
| request_headers: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT, | |
| events: typing.Optional[typing.Sequence[WorkspaceWebhookEventType]] = OMIT, | |
| request_options: typing.Optional[RequestOptions] = None, | |
| ) -> PatchWorkspaceWebhookResponseModel: | |
| """ | |
| Update the specified workspace webhook | |
| Parameters | |
| ---------- | |
| webhook_id : str | |
| The unique ID for the webhook | |
| is_disabled : bool | |
| Whether to disable or enable the webhook | |
| name : str | |
| The display name of the webhook (used for display purposes only). | |
| retry_enabled : typing.Optional[bool] | |
| Whether to enable automatic retries for transient failures (5xx, 429, timeout) | |
| request_headers : typing.Optional[typing.Dict[str, typing.Optional[str]]] | |
| A list of request headers to include with the webhook delivery (optional) | |
| events : typing.Optional[typing.Sequence[WorkspaceWebhookEventType]] | |
| The complete set of workspace-level events this webhook should be subscribed to. The webhook is added to the events in the list and removed from any not in the list. Omit to leave the current event subscriptions unchanged. | |
| request_options : typing.Optional[RequestOptions] | |
| Request-specific configuration. | |
| Returns | |
| ------- | |
| PatchWorkspaceWebhookResponseModel | |
| Successful Response | |
| Examples | |
| -------- | |
| from elevenlabs import ElevenLabs | |
| client = ElevenLabs( | |
| api_key="YOUR_API_KEY", | |
| ) | |
| client.webhooks.update( | |
| webhook_id="G007vmtq9uWYl7SUW9zGS8GZZa1K", | |
| is_disabled=True, | |
| name="My Callback Webhook", | |
| ) | |
| """ | |
| _response = self._raw_client.update( | |
| webhook_id, | |
| is_disabled=is_disabled, | |
| name=name, | |
| retry_enabled=retry_enabled, | |
| request_headers=request_headers, | |
| events=events, | |
| request_options=request_options, | |
| ) | |
| return _response.data | |
| class AsyncWebhooksClient: | |
| def __init__(self, *, client_wrapper: AsyncClientWrapper): | |
| self._raw_client = AsyncRawWebhooksClient(client_wrapper=client_wrapper) | |
| def with_raw_response(self) -> AsyncRawWebhooksClient: | |
| """ | |
| Retrieves a raw implementation of this client that returns raw responses. | |
| Returns | |
| ------- | |
| AsyncRawWebhooksClient | |
| """ | |
| return self._raw_client | |
| async def list( | |
| self, *, include_usages: typing.Optional[bool] = None, request_options: typing.Optional[RequestOptions] = None | |
| ) -> WorkspaceWebhookListResponseModel: | |
| """ | |
| List all webhooks for a workspace | |
| Parameters | |
| ---------- | |
| include_usages : typing.Optional[bool] | |
| Whether to include active usages of the webhook, only usable by admins | |
| request_options : typing.Optional[RequestOptions] | |
| Request-specific configuration. | |
| Returns | |
| ------- | |
| WorkspaceWebhookListResponseModel | |
| Successful Response | |
| Examples | |
| -------- | |
| import asyncio | |
| from elevenlabs import AsyncElevenLabs | |
| client = AsyncElevenLabs( | |
| api_key="YOUR_API_KEY", | |
| ) | |
| async def main() -> None: | |
| await client.webhooks.list( | |
| include_usages=False, | |
| ) | |
| asyncio.run(main()) | |
| """ | |
| _response = await self._raw_client.list(include_usages=include_usages, request_options=request_options) | |
| return _response.data | |
| async def create( | |
| self, *, settings: WebhookHmacSettings, request_options: typing.Optional[RequestOptions] = None | |
| ) -> WorkspaceCreateWebhookResponseModel: | |
| """ | |
| Create a new webhook for the workspace with the specified authentication type. | |
| Parameters | |
| ---------- | |
| settings : WebhookHmacSettings | |
| Webhook settings object containing auth_type and corresponding configuration | |
| request_options : typing.Optional[RequestOptions] | |
| Request-specific configuration. | |
| Returns | |
| ------- | |
| WorkspaceCreateWebhookResponseModel | |
| Successful Response | |
| Examples | |
| -------- | |
| import asyncio | |
| from elevenlabs import AsyncElevenLabs, WebhookHmacSettings | |
| client = AsyncElevenLabs( | |
| api_key="YOUR_API_KEY", | |
| ) | |
| async def main() -> None: | |
| await client.webhooks.create( | |
| settings=WebhookHmacSettings( | |
| name="name", | |
| webhook_url="webhook_url", | |
| ), | |
| ) | |
| asyncio.run(main()) | |
| """ | |
| _response = await self._raw_client.create(settings=settings, request_options=request_options) | |
| return _response.data | |
| async def delete( | |
| self, webhook_id: str, *, request_options: typing.Optional[RequestOptions] = None | |
| ) -> DeleteWorkspaceWebhookResponseModel: | |
| """ | |
| Delete the specified workspace webhook | |
| Parameters | |
| ---------- | |
| webhook_id : str | |
| The unique ID for the webhook | |
| request_options : typing.Optional[RequestOptions] | |
| Request-specific configuration. | |
| Returns | |
| ------- | |
| DeleteWorkspaceWebhookResponseModel | |
| Successful Response | |
| Examples | |
| -------- | |
| import asyncio | |
| from elevenlabs import AsyncElevenLabs | |
| client = AsyncElevenLabs( | |
| api_key="YOUR_API_KEY", | |
| ) | |
| async def main() -> None: | |
| await client.webhooks.delete( | |
| webhook_id="G007vmtq9uWYl7SUW9zGS8GZZa1K", | |
| ) | |
| asyncio.run(main()) | |
| """ | |
| _response = await self._raw_client.delete(webhook_id, request_options=request_options) | |
| return _response.data | |
| async def update( | |
| self, | |
| webhook_id: str, | |
| *, | |
| is_disabled: bool, | |
| name: str, | |
| retry_enabled: typing.Optional[bool] = OMIT, | |
| request_headers: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT, | |
| events: typing.Optional[typing.Sequence[WorkspaceWebhookEventType]] = OMIT, | |
| request_options: typing.Optional[RequestOptions] = None, | |
| ) -> PatchWorkspaceWebhookResponseModel: | |
| """ | |
| Update the specified workspace webhook | |
| Parameters | |
| ---------- | |
| webhook_id : str | |
| The unique ID for the webhook | |
| is_disabled : bool | |
| Whether to disable or enable the webhook | |
| name : str | |
| The display name of the webhook (used for display purposes only). | |
| retry_enabled : typing.Optional[bool] | |
| Whether to enable automatic retries for transient failures (5xx, 429, timeout) | |
| request_headers : typing.Optional[typing.Dict[str, typing.Optional[str]]] | |
| A list of request headers to include with the webhook delivery (optional) | |
| events : typing.Optional[typing.Sequence[WorkspaceWebhookEventType]] | |
| The complete set of workspace-level events this webhook should be subscribed to. The webhook is added to the events in the list and removed from any not in the list. Omit to leave the current event subscriptions unchanged. | |
| request_options : typing.Optional[RequestOptions] | |
| Request-specific configuration. | |
| Returns | |
| ------- | |
| PatchWorkspaceWebhookResponseModel | |
| Successful Response | |
| Examples | |
| -------- | |
| import asyncio | |
| from elevenlabs import AsyncElevenLabs | |
| client = AsyncElevenLabs( | |
| api_key="YOUR_API_KEY", | |
| ) | |
| async def main() -> None: | |
| await client.webhooks.update( | |
| webhook_id="G007vmtq9uWYl7SUW9zGS8GZZa1K", | |
| is_disabled=True, | |
| name="My Callback Webhook", | |
| ) | |
| asyncio.run(main()) | |
| """ | |
| _response = await self._raw_client.update( | |
| webhook_id, | |
| is_disabled=is_disabled, | |
| name=name, | |
| retry_enabled=retry_enabled, | |
| request_headers=request_headers, | |
| events=events, | |
| request_options=request_options, | |
| ) | |
| return _response.data | |