# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, 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.ai.collections import setting_create_params, setting_patch_all_params from ....types.ai.collections.settings_envelope import SettingsEnvelope from ....types.ai.collections.retrieval_settings_param import RetrievalSettingsParam __all__ = ["SettingsResource", "AsyncSettingsResource"] class SettingsResource(SyncAPIResource): """ Create and manage logical collections of your Telnyx data, tune retrieval settings, manage sources, and run collection-scoped semantic search. """ @cached_property def with_raw_response(self) -> SettingsResourceWithRawResponse: """ 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 SettingsResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> SettingsResourceWithStreamingResponse: """ 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 SettingsResourceWithStreamingResponse(self) def create( self, uuid: str, *, retrieval: RetrievalSettingsParam | Omit = omit, # 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, ) -> SettingsEnvelope: """ Replaces the collection's retrieval settings. Args: retrieval: How documents are retrieved when searching the collection. 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 uuid: raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") return self._put( path_template("/ai/collections/{uuid}/settings", uuid=uuid), body=maybe_transform({"retrieval": retrieval}, setting_create_params.SettingCreateParams), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), cast_to=SettingsEnvelope, ) def list( self, uuid: 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, ) -> SettingsEnvelope: """ Returns the retrieval settings for a collection. 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 uuid: raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") return self._get( path_template("/ai/collections/{uuid}/settings", uuid=uuid), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), cast_to=SettingsEnvelope, ) def patch_all( self, uuid: str, *, retrieval: RetrievalSettingsParam | Omit = omit, # 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, ) -> SettingsEnvelope: """ Partially updates the collection's retrieval settings. Args: retrieval: How documents are retrieved when searching the collection. 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 uuid: raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") return self._patch( path_template("/ai/collections/{uuid}/settings", uuid=uuid), body=maybe_transform({"retrieval": retrieval}, setting_patch_all_params.SettingPatchAllParams), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), cast_to=SettingsEnvelope, ) class AsyncSettingsResource(AsyncAPIResource): """ Create and manage logical collections of your Telnyx data, tune retrieval settings, manage sources, and run collection-scoped semantic search. """ @cached_property def with_raw_response(self) -> AsyncSettingsResourceWithRawResponse: """ 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 AsyncSettingsResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> AsyncSettingsResourceWithStreamingResponse: """ 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 AsyncSettingsResourceWithStreamingResponse(self) async def create( self, uuid: str, *, retrieval: RetrievalSettingsParam | Omit = omit, # 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, ) -> SettingsEnvelope: """ Replaces the collection's retrieval settings. Args: retrieval: How documents are retrieved when searching the collection. 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 uuid: raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") return await self._put( path_template("/ai/collections/{uuid}/settings", uuid=uuid), body=await async_maybe_transform({"retrieval": retrieval}, setting_create_params.SettingCreateParams), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), cast_to=SettingsEnvelope, ) async def list( self, uuid: 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, ) -> SettingsEnvelope: """ Returns the retrieval settings for a collection. 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 uuid: raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") return await self._get( path_template("/ai/collections/{uuid}/settings", uuid=uuid), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), cast_to=SettingsEnvelope, ) async def patch_all( self, uuid: str, *, retrieval: RetrievalSettingsParam | Omit = omit, # 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, ) -> SettingsEnvelope: """ Partially updates the collection's retrieval settings. Args: retrieval: How documents are retrieved when searching the collection. 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 uuid: raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") return await self._patch( path_template("/ai/collections/{uuid}/settings", uuid=uuid), body=await async_maybe_transform({"retrieval": retrieval}, setting_patch_all_params.SettingPatchAllParams), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), cast_to=SettingsEnvelope, ) class SettingsResourceWithRawResponse: def __init__(self, settings: SettingsResource) -> None: self._settings = settings self.create = to_raw_response_wrapper( settings.create, ) self.list = to_raw_response_wrapper( settings.list, ) self.patch_all = to_raw_response_wrapper( settings.patch_all, ) class AsyncSettingsResourceWithRawResponse: def __init__(self, settings: AsyncSettingsResource) -> None: self._settings = settings self.create = async_to_raw_response_wrapper( settings.create, ) self.list = async_to_raw_response_wrapper( settings.list, ) self.patch_all = async_to_raw_response_wrapper( settings.patch_all, ) class SettingsResourceWithStreamingResponse: def __init__(self, settings: SettingsResource) -> None: self._settings = settings self.create = to_streamed_response_wrapper( settings.create, ) self.list = to_streamed_response_wrapper( settings.list, ) self.patch_all = to_streamed_response_wrapper( settings.patch_all, ) class AsyncSettingsResourceWithStreamingResponse: def __init__(self, settings: AsyncSettingsResource) -> None: self._settings = settings self.create = async_to_streamed_response_wrapper( settings.create, ) self.list = async_to_streamed_response_wrapper( settings.list, ) self.patch_all = async_to_streamed_response_wrapper( settings.patch_all, )