# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations from typing_extensions import Literal import httpx from ..types import custom_storage_credential_create_params, custom_storage_credential_update_params from .._types import Body, Query, Headers, NoneType, NotGiven, not_given from .._utils import path_template, maybe_transform, async_maybe_transform from .._compat import cached_property from .._resource import SyncAPIResource, AsyncAPIResource from .._response import ( to_raw_response_wrapper, to_streamed_response_wrapper, async_to_raw_response_wrapper, async_to_streamed_response_wrapper, ) from .._base_client import make_request_options from ..types.credentials_response import CredentialsResponse __all__ = ["CustomStorageCredentialsResource", "AsyncCustomStorageCredentialsResource"] class CustomStorageCredentialsResource(SyncAPIResource): """Call Recordings operations.""" @cached_property def with_raw_response(self) -> CustomStorageCredentialsResourceWithRawResponse: """ This property can be used as a prefix for any HTTP method call to return the raw response object instead of the parsed content. For more information, see https://www.github.com/team-telnyx/telnyx-python#accessing-raw-response-data-eg-headers """ return CustomStorageCredentialsResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> CustomStorageCredentialsResourceWithStreamingResponse: """ An alternative to `.with_raw_response` that doesn't eagerly read the response body. For more information, see https://www.github.com/team-telnyx/telnyx-python#with_streaming_response """ return CustomStorageCredentialsResourceWithStreamingResponse(self) def create( self, connection_id: str, *, backend: Literal["gcs", "s3", "s3-generic", "azure"], configuration: custom_storage_credential_create_params.Configuration, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> CredentialsResponse: """ Creates a custom storage credentials configuration. Args: extra_headers: Send extra headers extra_query: Add additional query parameters to the request extra_body: Add additional JSON properties to the request timeout: Override the client-level default timeout for this request, in seconds """ if not connection_id: raise ValueError(f"Expected a non-empty value for `connection_id` but received {connection_id!r}") return self._post( path_template("/custom_storage_credentials/{connection_id}", connection_id=connection_id), body=maybe_transform( { "backend": backend, "configuration": configuration, }, custom_storage_credential_create_params.CustomStorageCredentialCreateParams, ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), cast_to=CredentialsResponse, ) def retrieve( self, connection_id: str, *, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> CredentialsResponse: """ Returns the information about custom storage credentials. Args: extra_headers: Send extra headers extra_query: Add additional query parameters to the request extra_body: Add additional JSON properties to the request timeout: Override the client-level default timeout for this request, in seconds """ if not connection_id: raise ValueError(f"Expected a non-empty value for `connection_id` but received {connection_id!r}") return self._get( path_template("/custom_storage_credentials/{connection_id}", connection_id=connection_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), cast_to=CredentialsResponse, ) def update( self, connection_id: str, *, backend: Literal["gcs", "s3", "s3-generic", "azure"], configuration: custom_storage_credential_update_params.Configuration, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> CredentialsResponse: """ Updates a stored custom credentials configuration. Args: extra_headers: Send extra headers extra_query: Add additional query parameters to the request extra_body: Add additional JSON properties to the request timeout: Override the client-level default timeout for this request, in seconds """ if not connection_id: raise ValueError(f"Expected a non-empty value for `connection_id` but received {connection_id!r}") return self._put( path_template("/custom_storage_credentials/{connection_id}", connection_id=connection_id), body=maybe_transform( { "backend": backend, "configuration": configuration, }, custom_storage_credential_update_params.CustomStorageCredentialUpdateParams, ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), cast_to=CredentialsResponse, ) def delete( self, connection_id: str, *, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ Deletes a stored custom credentials configuration. Args: extra_headers: Send extra headers extra_query: Add additional query parameters to the request extra_body: Add additional JSON properties to the request timeout: Override the client-level default timeout for this request, in seconds """ if not connection_id: raise ValueError(f"Expected a non-empty value for `connection_id` but received {connection_id!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return self._delete( path_template("/custom_storage_credentials/{connection_id}", connection_id=connection_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), cast_to=NoneType, ) class AsyncCustomStorageCredentialsResource(AsyncAPIResource): """Call Recordings operations.""" @cached_property def with_raw_response(self) -> AsyncCustomStorageCredentialsResourceWithRawResponse: """ This property can be used as a prefix for any HTTP method call to return the raw response object instead of the parsed content. For more information, see https://www.github.com/team-telnyx/telnyx-python#accessing-raw-response-data-eg-headers """ return AsyncCustomStorageCredentialsResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> AsyncCustomStorageCredentialsResourceWithStreamingResponse: """ An alternative to `.with_raw_response` that doesn't eagerly read the response body. For more information, see https://www.github.com/team-telnyx/telnyx-python#with_streaming_response """ return AsyncCustomStorageCredentialsResourceWithStreamingResponse(self) async def create( self, connection_id: str, *, backend: Literal["gcs", "s3", "s3-generic", "azure"], configuration: custom_storage_credential_create_params.Configuration, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> CredentialsResponse: """ Creates a custom storage credentials configuration. Args: extra_headers: Send extra headers extra_query: Add additional query parameters to the request extra_body: Add additional JSON properties to the request timeout: Override the client-level default timeout for this request, in seconds """ if not connection_id: raise ValueError(f"Expected a non-empty value for `connection_id` but received {connection_id!r}") return await self._post( path_template("/custom_storage_credentials/{connection_id}", connection_id=connection_id), body=await async_maybe_transform( { "backend": backend, "configuration": configuration, }, custom_storage_credential_create_params.CustomStorageCredentialCreateParams, ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), cast_to=CredentialsResponse, ) async def retrieve( self, connection_id: str, *, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> CredentialsResponse: """ Returns the information about custom storage credentials. Args: extra_headers: Send extra headers extra_query: Add additional query parameters to the request extra_body: Add additional JSON properties to the request timeout: Override the client-level default timeout for this request, in seconds """ if not connection_id: raise ValueError(f"Expected a non-empty value for `connection_id` but received {connection_id!r}") return await self._get( path_template("/custom_storage_credentials/{connection_id}", connection_id=connection_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), cast_to=CredentialsResponse, ) async def update( self, connection_id: str, *, backend: Literal["gcs", "s3", "s3-generic", "azure"], configuration: custom_storage_credential_update_params.Configuration, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> CredentialsResponse: """ Updates a stored custom credentials configuration. Args: extra_headers: Send extra headers extra_query: Add additional query parameters to the request extra_body: Add additional JSON properties to the request timeout: Override the client-level default timeout for this request, in seconds """ if not connection_id: raise ValueError(f"Expected a non-empty value for `connection_id` but received {connection_id!r}") return await self._put( path_template("/custom_storage_credentials/{connection_id}", connection_id=connection_id), body=await async_maybe_transform( { "backend": backend, "configuration": configuration, }, custom_storage_credential_update_params.CustomStorageCredentialUpdateParams, ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), cast_to=CredentialsResponse, ) async def delete( self, connection_id: str, *, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ Deletes a stored custom credentials configuration. Args: extra_headers: Send extra headers extra_query: Add additional query parameters to the request extra_body: Add additional JSON properties to the request timeout: Override the client-level default timeout for this request, in seconds """ if not connection_id: raise ValueError(f"Expected a non-empty value for `connection_id` but received {connection_id!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return await self._delete( path_template("/custom_storage_credentials/{connection_id}", connection_id=connection_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), cast_to=NoneType, ) class CustomStorageCredentialsResourceWithRawResponse: def __init__(self, custom_storage_credentials: CustomStorageCredentialsResource) -> None: self._custom_storage_credentials = custom_storage_credentials self.create = to_raw_response_wrapper( custom_storage_credentials.create, ) self.retrieve = to_raw_response_wrapper( custom_storage_credentials.retrieve, ) self.update = to_raw_response_wrapper( custom_storage_credentials.update, ) self.delete = to_raw_response_wrapper( custom_storage_credentials.delete, ) class AsyncCustomStorageCredentialsResourceWithRawResponse: def __init__(self, custom_storage_credentials: AsyncCustomStorageCredentialsResource) -> None: self._custom_storage_credentials = custom_storage_credentials self.create = async_to_raw_response_wrapper( custom_storage_credentials.create, ) self.retrieve = async_to_raw_response_wrapper( custom_storage_credentials.retrieve, ) self.update = async_to_raw_response_wrapper( custom_storage_credentials.update, ) self.delete = async_to_raw_response_wrapper( custom_storage_credentials.delete, ) class CustomStorageCredentialsResourceWithStreamingResponse: def __init__(self, custom_storage_credentials: CustomStorageCredentialsResource) -> None: self._custom_storage_credentials = custom_storage_credentials self.create = to_streamed_response_wrapper( custom_storage_credentials.create, ) self.retrieve = to_streamed_response_wrapper( custom_storage_credentials.retrieve, ) self.update = to_streamed_response_wrapper( custom_storage_credentials.update, ) self.delete = to_streamed_response_wrapper( custom_storage_credentials.delete, ) class AsyncCustomStorageCredentialsResourceWithStreamingResponse: def __init__(self, custom_storage_credentials: AsyncCustomStorageCredentialsResource) -> None: self._custom_storage_credentials = custom_storage_credentials self.create = async_to_streamed_response_wrapper( custom_storage_credentials.create, ) self.retrieve = async_to_streamed_response_wrapper( custom_storage_credentials.retrieve, ) self.update = async_to_streamed_response_wrapper( custom_storage_credentials.update, ) self.delete = async_to_streamed_response_wrapper( custom_storage_credentials.delete, )