diff --git a/deepgram/__init__.py b/deepgram/__init__.py index c9a67542..aca6f16a 100644 --- a/deepgram/__init__.py +++ b/deepgram/__init__.py @@ -102,10 +102,12 @@ BalancesResponse, ) -# onprem +# selfhosted from .client import ( OnPremClient, AsyncOnPremClient, + SelfHostedClient, + AsyncSelfHostedClient, ) # utilities diff --git a/deepgram/client.py b/deepgram/client.py index 273ebd6c..ce51f167 100644 --- a/deepgram/client.py +++ b/deepgram/client.py @@ -119,6 +119,8 @@ from .clients import ( OnPremClient, AsyncOnPremClient, + SelfHostedClient, + AsyncSelfHostedClient, ) # client errors and options @@ -172,10 +174,10 @@ class DeepgramClient: listen: Returns a ListenClient instance for interacting with Deepgram's transcription services. manage: (Preferred) Returns a Threaded ManageClient instance for managing Deepgram resources. - onprem: (Preferred) Returns an Threaded OnPremClient instance for interacting with Deepgram's on-premises API. + selfhosted: (Preferred) Returns an Threaded SelfHostedClient instance for interacting with Deepgram's on-premises API. asyncmanage: Returns an (Async) ManageClient instance for managing Deepgram resources. - asynconprem: Returns an (Async) OnPremClient instance for interacting with Deepgram's on-premises API. + asyncselfhosted: Returns an (Async) SelfHostedClient instance for interacting with Deepgram's on-premises API. """ _config: DeepgramClientOptions @@ -247,19 +249,35 @@ def asyncmanage(self): """ return self.Version(self._config, "asyncmanage") + # for backwards compatibility @property def onprem(self): """ - Returns an OnPremClient instance for interacting with Deepgram's on-premises API. + Returns an SelfHostedClient instance for interacting with Deepgram's on-premises API. """ - return self.Version(self._config, "onprem") + return self.Version(self._config, "selfhosted") + @property + def selfhosted(self): + """ + Returns an SelfHostedClient instance for interacting with Deepgram's on-premises API. + """ + return self.Version(self._config, "selfhosted") + + # for backwards compatibility @property def asynconprem(self): """ - Returns an AsyncOnPremClient instance for interacting with Deepgram's on-premises API. + Returns an AsyncSelfHostedClient instance for interacting with Deepgram's on-premises API. + """ + return self.Version(self._config, "asyncselfhosted") + + @property + def asyncselfhosted(self): + """ + Returns an AsyncSelfHostedClient instance for interacting with Deepgram's on-premises API. """ - return self.Version(self._config, "asynconprem") + return self.Version(self._config, "asyncselfhosted") # INTERNAL CLASSES class Version: @@ -286,8 +304,8 @@ def __init__(self, config, parent: str): # match self._parent: # case "manage": # return ManageClient(self._config) - # case "onprem": - # return OnPremClient(self._config) + # case "selfhosted": + # return SelfHostedClient(self._config) # case _: # raise DeepgramModuleError("Invalid parent") @@ -322,14 +340,14 @@ def v(self, version: str = ""): parent = "speak" filename = "async_client" classname = "AsyncSpeakClient" - case "onprem": - parent = "onprem" + case "selfhosted": + parent = "selfhosted" filename = "client" - classname = "OnPremClient" - case "asynconprem": - parent = "onprem" + classname = "SelfHostedClient" + case "asyncselfhosted": + parent = "selfhosted" filename = "async_client" - classname = "AsyncOnPremClient" + classname = "AsyncSelfHostedClient" case _: self._logger.error("parent unknown: %s", self._parent) self._logger.debug("Version.v LEAVE") diff --git a/deepgram/clients/__init__.py b/deepgram/clients/__init__.py index b94d9144..f8375143 100644 --- a/deepgram/clients/__init__.py +++ b/deepgram/clients/__init__.py @@ -96,5 +96,10 @@ BalancesResponse, ) -# onprem -from .onprem import OnPremClient, AsyncOnPremClient +# selfhosted +from .selfhosted import ( + OnPremClient, + AsyncOnPremClient, + SelfHostedClient, + AsyncSelfHostedClient, +) diff --git a/deepgram/clients/onprem/__init__.py b/deepgram/clients/selfhosted/__init__.py similarity index 70% rename from deepgram/clients/onprem/__init__.py rename to deepgram/clients/selfhosted/__init__.py index dbe3194d..93cf7d47 100644 --- a/deepgram/clients/onprem/__init__.py +++ b/deepgram/clients/selfhosted/__init__.py @@ -2,6 +2,6 @@ # Use of this source code is governed by a MIT license that can be found in the LICENSE file. # SPDX-License-Identifier: MIT -from .v1.client import OnPremClient -from .v1.async_client import AsyncOnPremClient +from .client import SelfHostedClient, OnPremClient +from .client import AsyncSelfHostedClient, AsyncOnPremClient from ...options import DeepgramClientOptions, ClientOptionsFromEnv diff --git a/deepgram/clients/onprem/client.py b/deepgram/clients/selfhosted/client.py similarity index 50% rename from deepgram/clients/onprem/client.py rename to deepgram/clients/selfhosted/client.py index 06a931f8..1301c641 100644 --- a/deepgram/clients/onprem/client.py +++ b/deepgram/clients/selfhosted/client.py @@ -2,12 +2,14 @@ # Use of this source code is governed by a MIT license that can be found in the LICENSE file. # SPDX-License-Identifier: MIT -from .v1.client import OnPremClient as OnPremClientLatest -from .v1.async_client import AsyncOnPremClient as AsyncOnPremClientLatest +from .v1.client import SelfHostedClient as SelfHostedClientLatest +from .v1.async_client import AsyncSelfHostedClient as AsyncSelfHostedClientLatest # The client.py points to the current supported version in the SDK. # Older versions are supported in the SDK for backwards compatibility. -OnPremClient = OnPremClientLatest -AsyncOnPremClient = AsyncOnPremClientLatest +SelfHostedClient = SelfHostedClientLatest +AsyncSelfHostedClient = AsyncSelfHostedClientLatest +OnPremClient = SelfHostedClientLatest +AsyncOnPremClient = AsyncSelfHostedClientLatest diff --git a/deepgram/clients/onprem/v1/__init__.py b/deepgram/clients/selfhosted/v1/__init__.py similarity index 75% rename from deepgram/clients/onprem/v1/__init__.py rename to deepgram/clients/selfhosted/v1/__init__.py index ffe012d7..4c46a0ad 100644 --- a/deepgram/clients/onprem/v1/__init__.py +++ b/deepgram/clients/selfhosted/v1/__init__.py @@ -2,6 +2,6 @@ # Use of this source code is governed by a MIT license that can be found in the LICENSE file. # SPDX-License-Identifier: MIT -from .client import OnPremClient -from .async_client import AsyncOnPremClient +from .client import SelfHostedClient +from .async_client import AsyncSelfHostedClient from ....options import DeepgramClientOptions, ClientOptionsFromEnv diff --git a/deepgram/clients/onprem/v1/async_client.py b/deepgram/clients/selfhosted/v1/async_client.py similarity index 57% rename from deepgram/clients/onprem/v1/async_client.py rename to deepgram/clients/selfhosted/v1/async_client.py index a177abc3..6b15feaf 100644 --- a/deepgram/clients/onprem/v1/async_client.py +++ b/deepgram/clients/selfhosted/v1/async_client.py @@ -12,7 +12,7 @@ from ...abstract_async_client import AbstractAsyncRestClient -class AsyncOnPremClient(AbstractAsyncRestClient): +class AsyncSelfHostedClient(AbstractAsyncRestClient): """ Client for interacting with Deepgram's on-premises API. @@ -40,14 +40,22 @@ async def list_onprem_credentials( """ List all on-premises distribution credentials for a project. """ - self._logger.debug("OnPremClient.list_onprem_credentials ENTER") - url = f"{self._config.url}/{self._endpoint}/{project_id}/onprem/distribution/credentials" + return self.list_selfhosted_credentials(project_id, timeout) + + async def list_selfhosted_credentials( + self, project_id: str, timeout: Optional[httpx.Timeout] = None + ): + """ + List all on-premises distribution credentials for a project. + """ + self._logger.debug("SelfHostedClient.list_selfhosted_credentials ENTER") + url = f"{self._config.url}/{self._endpoint}/{project_id}/selfhosted/distribution/credentials" self._logger.info("url: %s", url) self._logger.info("project_id: %s", project_id) res = await self.get(url, timeout=timeout) self._logger.verbose("result: %s", res) - self._logger.notice("list_onprem_credentials succeeded") - self._logger.debug("OnPremClient.list_onprem_credentials LEAVE") + self._logger.notice("list_selfhosted_credentials succeeded") + self._logger.debug("SelfHostedClient.list_selfhosted_credentials LEAVE") return res async def get_onprem_credentials( @@ -59,8 +67,21 @@ async def get_onprem_credentials( """ Get a specific on-premises distribution credential for a project. """ - self._logger.debug("OnPremClient.get_onprem_credentials ENTER") - url = f"{self._config.url}/{self._endpoint}/{project_id}/onprem/distribution/credentials/{distribution_credentials_id}" + return self.get_selfhosted_credentials( + project_id, distribution_credentials_id, timeout + ) + + async def get_selfhosted_credentials( + self, + project_id: str, + distribution_credentials_id: str, + timeout: Optional[httpx.Timeout] = None, + ): + """ + Get a specific on-premises distribution credential for a project. + """ + self._logger.debug("SelfHostedClient.get_selfhosted_credentials ENTER") + url = f"{self._config.url}/{self._endpoint}/{project_id}/selfhosted/distribution/credentials/{distribution_credentials_id}" self._logger.info("url: %s", url) self._logger.info("project_id: %s", project_id) self._logger.info( @@ -68,8 +89,8 @@ async def get_onprem_credentials( ) res = await self.get(url, timeout=timeout) self._logger.verbose("result: %s", res) - self._logger.notice("get_onprem_credentials succeeded") - self._logger.debug("OnPremClient.get_onprem_credentials LEAVE") + self._logger.notice("get_selfhosted_credentials succeeded") + self._logger.debug("SelfHostedClient.get_selfhosted_credentials LEAVE") return res async def create_onprem_credentials( @@ -78,15 +99,23 @@ async def create_onprem_credentials( """ Create a new on-premises distribution credential for a project. """ - self._logger.debug("OnPremClient.create_onprem_credentials ENTER") - url = f"{self._config.url}/{self._endpoint}/{project_id}/onprem/distribution/credentials/" + return self.create_onprem_credentials(project_id, options, timeout) + + async def create_selfhosted_credentials( + self, project_id: str, options, timeout: Optional[httpx.Timeout] = None + ): + """ + Create a new on-premises distribution credential for a project. + """ + self._logger.debug("SelfHostedClient.create_selfhosted_credentials ENTER") + url = f"{self._config.url}/{self._endpoint}/{project_id}/selfhosted/distribution/credentials/" self._logger.info("url: %s", url) self._logger.info("project_id: %s", project_id) self._logger.info("options: %s", options) res = await self.post(url, json=options, timeout=timeout) self._logger.verbose("result: %s", res) - self._logger.notice("create_onprem_credentials succeeded") - self._logger.debug("OnPremClient.create_onprem_credentials LEAVE") + self._logger.notice("create_selfhosted_credentials succeeded") + self._logger.debug("SelfHostedClient.create_selfhosted_credentials LEAVE") return res async def delete_onprem_credentials( @@ -98,13 +127,26 @@ async def delete_onprem_credentials( """ Delete an on-premises distribution credential for a project. """ - self._logger.debug("OnPremClient.delete_onprem_credentials ENTER") - url = f"{self._config.url}/{self._endpoint}/{project_id}/onprem/distribution/credentials/{distribution_credentials_id}" + return self.delete_selfhosted_credentials( + project_id, distribution_credentials_id, timeout + ) + + async def delete_selfhosted_credentials( + self, + project_id: str, + distribution_credentials_id: str, + timeout: Optional[httpx.Timeout] = None, + ): + """ + Delete an on-premises distribution credential for a project. + """ + self._logger.debug("SelfHostedClient.delete_selfhosted_credentials ENTER") + url = f"{self._config.url}/{self._endpoint}/{project_id}/selfhosted/distribution/credentials/{distribution_credentials_id}" self._logger.info("url: %s", url) self._logger.info("project_id: %s", project_id) self._logger.info("distrbution_credentials_id: %s", distribution_credentials_id) res = await self.delete(url, timeout=timeout) self._logger.verbose("result: %s", res) - self._logger.notice("delete_onprem_credentials succeeded") - self._logger.debug("OnPremClient.delete_onprem_credentials LEAVE") + self._logger.notice("delete_selfhosted_credentials succeeded") + self._logger.debug("SelfHostedClient.delete_selfhosted_credentials LEAVE") return res diff --git a/deepgram/clients/onprem/v1/client.py b/deepgram/clients/selfhosted/v1/client.py similarity index 57% rename from deepgram/clients/onprem/v1/client.py rename to deepgram/clients/selfhosted/v1/client.py index c60917f3..586d8d36 100644 --- a/deepgram/clients/onprem/v1/client.py +++ b/deepgram/clients/selfhosted/v1/client.py @@ -12,7 +12,7 @@ from ...abstract_sync_client import AbstractSyncRestClient -class OnPremClient(AbstractSyncRestClient): +class SelfHostedClient(AbstractSyncRestClient): """ Client for interacting with Deepgram's on-premises API. @@ -40,14 +40,22 @@ def list_onprem_credentials( """ List all on-premises distribution credentials for a project. """ - self._logger.debug("OnPremClient.list_onprem_credentials ENTER") - url = f"{self._config.url}/{self._endpoint}/{project_id}/onprem/distribution/credentials" + return self.list_selfhosted_credentials(project_id, timeout) + + def list_selfhosted_credentials( + self, project_id: str, timeout: Optional[httpx.Timeout] = None + ): + """ + List all on-premises distribution credentials for a project. + """ + self._logger.debug("SelfHostedClient.list_selfhosted_credentials ENTER") + url = f"{self._config.url}/{self._endpoint}/{project_id}/selfhosted/distribution/credentials" self._logger.info("url: %s", url) self._logger.info("project_id: %s", project_id) res = self.get(url, timeout=timeout) self._logger.verbose("result: %s", res) - self._logger.notice("list_onprem_credentials succeeded") - self._logger.debug("OnPremClient.list_onprem_credentials LEAVE") + self._logger.notice("list_selfhosted_credentials succeeded") + self._logger.debug("SelfHostedClient.list_selfhosted_credentials LEAVE") return res def get_onprem_credentials( @@ -59,8 +67,21 @@ def get_onprem_credentials( """ Get a specific on-premises distribution credential for a project. """ - self._logger.debug("OnPremClient.get_onprem_credentials ENTER") - url = f"{self._config.url}/{self._endpoint}/{project_id}/onprem/distribution/credentials/{distribution_credentials_id}" + return self.get_selfhosted_credentials( + project_id, distribution_credentials_id, timeout + ) + + def get_selfhosted_credentials( + self, + project_id: str, + distribution_credentials_id: str, + timeout: Optional[httpx.Timeout] = None, + ): + """ + Get a specific on-premises distribution credential for a project. + """ + self._logger.debug("SelfHostedClient.get_selfhosted_credentials ENTER") + url = f"{self._config.url}/{self._endpoint}/{project_id}/selfhosted/distribution/credentials/{distribution_credentials_id}" self._logger.info("url: %s", url) self._logger.info("project_id: %s", project_id) self._logger.info( @@ -68,8 +89,8 @@ def get_onprem_credentials( ) res = self.get(url, timeout=timeout) self._logger.verbose("result: %s", res) - self._logger.notice("get_onprem_credentials succeeded") - self._logger.debug("OnPremClient.get_onprem_credentials LEAVE") + self._logger.notice("get_selfhosted_credentials succeeded") + self._logger.debug("SelfHostedClient.get_selfhosted_credentials LEAVE") return res def create_onprem_credentials( @@ -78,15 +99,23 @@ def create_onprem_credentials( """ Create a new on-premises distribution credential for a project. """ - self._logger.debug("OnPremClient.create_onprem_credentials ENTER") - url = f"{self._config.url}/{self._endpoint}/{project_id}/onprem/distribution/credentials/" + return self.create_selfhosted_credentials(project_id, options, timeout) + + def create_selfhosted_credentials( + self, project_id: str, options, timeout: Optional[httpx.Timeout] = None + ): + """ + Create a new on-premises distribution credential for a project. + """ + self._logger.debug("SelfHostedClient.create_selfhosted_credentials ENTER") + url = f"{self._config.url}/{self._endpoint}/{project_id}/selfhosted/distribution/credentials/" self._logger.info("url: %s", url) self._logger.info("project_id: %s", project_id) self._logger.info("options: %s", options) res = self.post(url, json=options, timeout=timeout) self._logger.verbose("result: %s", res) - self._logger.notice("create_onprem_credentials succeeded") - self._logger.debug("OnPremClient.create_onprem_credentials LEAVE") + self._logger.notice("create_selfhosted_credentials succeeded") + self._logger.debug("SelfHostedClient.create_selfhosted_credentials LEAVE") return res def delete_onprem_credentials( @@ -98,13 +127,26 @@ def delete_onprem_credentials( """ Delete an on-premises distribution credential for a project. """ - self._logger.debug("OnPremClient.delete_onprem_credentials ENTER") - url = f"{self._config.url}/{self._endpoint}/{project_id}/onprem/distribution/credentials/{distribution_credentials_id}" + return self.delete_selfhosted_credentials( + project_id, distribution_credentials_id, timeout + ) + + def delete_selfhosted_credentials( + self, + project_id: str, + distribution_credentials_id: str, + timeout: Optional[httpx.Timeout] = None, + ): + """ + Delete an on-premises distribution credential for a project. + """ + self._logger.debug("SelfHostedClient.delete_selfhosted_credentials ENTER") + url = f"{self._config.url}/{self._endpoint}/{project_id}/selfhosted/distribution/credentials/{distribution_credentials_id}" self._logger.info("url: %s", url) self._logger.info("project_id: %s", project_id) self._logger.info("distrbution_credentials_id: %s", distribution_credentials_id) res = self.delete(url, timeout=timeout) self._logger.verbose("result: %s", res) - self._logger.notice("delete_onprem_credentials succeeded") - self._logger.debug("OnPremClient.delete_onprem_credentials LEAVE") + self._logger.notice("delete_selfhosted_credentials succeeded") + self._logger.debug("SelfHostedClient.delete_selfhosted_credentials LEAVE") return res