# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations import httpx from ....._types import Body, Query, Headers, NoneType, NotGiven, not_given from ....._utils import path_template 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 __all__ = ["InsightsResource", "AsyncInsightsResource"] class InsightsResource(SyncAPIResource): """Manage historical AI assistant conversations""" @cached_property def with_raw_response(self) -> InsightsResourceWithRawResponse: """ 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 InsightsResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> InsightsResourceWithStreamingResponse: """ 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 InsightsResourceWithStreamingResponse(self) def assign( self, insight_id: str, *, group_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: """ Assigns the specified insight template to the specified insight template group. Args: group_id: The ID of the insight group insight_id: The ID of the insight 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 group_id: raise ValueError(f"Expected a non-empty value for `group_id` but received {group_id!r}") if not insight_id: raise ValueError(f"Expected a non-empty value for `insight_id` but received {insight_id!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return self._post( path_template( "/ai/conversations/insight-groups/{group_id}/insights/{insight_id}/assign", group_id=group_id, insight_id=insight_id, ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), cast_to=NoneType, ) def delete_unassign( self, insight_id: str, *, group_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: """Removes the specified insight template from the specified group. The insight template itself is not deleted. Args: group_id: The ID of the insight group insight_id: The ID of the insight 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 group_id: raise ValueError(f"Expected a non-empty value for `group_id` but received {group_id!r}") if not insight_id: raise ValueError(f"Expected a non-empty value for `insight_id` but received {insight_id!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return self._delete( path_template( "/ai/conversations/insight-groups/{group_id}/insights/{insight_id}/unassign", group_id=group_id, insight_id=insight_id, ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), cast_to=NoneType, ) class AsyncInsightsResource(AsyncAPIResource): """Manage historical AI assistant conversations""" @cached_property def with_raw_response(self) -> AsyncInsightsResourceWithRawResponse: """ 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 AsyncInsightsResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> AsyncInsightsResourceWithStreamingResponse: """ 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 AsyncInsightsResourceWithStreamingResponse(self) async def assign( self, insight_id: str, *, group_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: """ Assigns the specified insight template to the specified insight template group. Args: group_id: The ID of the insight group insight_id: The ID of the insight 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 group_id: raise ValueError(f"Expected a non-empty value for `group_id` but received {group_id!r}") if not insight_id: raise ValueError(f"Expected a non-empty value for `insight_id` but received {insight_id!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return await self._post( path_template( "/ai/conversations/insight-groups/{group_id}/insights/{insight_id}/assign", group_id=group_id, insight_id=insight_id, ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), cast_to=NoneType, ) async def delete_unassign( self, insight_id: str, *, group_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: """Removes the specified insight template from the specified group. The insight template itself is not deleted. Args: group_id: The ID of the insight group insight_id: The ID of the insight 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 group_id: raise ValueError(f"Expected a non-empty value for `group_id` but received {group_id!r}") if not insight_id: raise ValueError(f"Expected a non-empty value for `insight_id` but received {insight_id!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return await self._delete( path_template( "/ai/conversations/insight-groups/{group_id}/insights/{insight_id}/unassign", group_id=group_id, insight_id=insight_id, ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), cast_to=NoneType, ) class InsightsResourceWithRawResponse: def __init__(self, insights: InsightsResource) -> None: self._insights = insights self.assign = to_raw_response_wrapper( insights.assign, ) self.delete_unassign = to_raw_response_wrapper( insights.delete_unassign, ) class AsyncInsightsResourceWithRawResponse: def __init__(self, insights: AsyncInsightsResource) -> None: self._insights = insights self.assign = async_to_raw_response_wrapper( insights.assign, ) self.delete_unassign = async_to_raw_response_wrapper( insights.delete_unassign, ) class InsightsResourceWithStreamingResponse: def __init__(self, insights: InsightsResource) -> None: self._insights = insights self.assign = to_streamed_response_wrapper( insights.assign, ) self.delete_unassign = to_streamed_response_wrapper( insights.delete_unassign, ) class AsyncInsightsResourceWithStreamingResponse: def __init__(self, insights: AsyncInsightsResource) -> None: self._insights = insights self.assign = async_to_streamed_response_wrapper( insights.assign, ) self.delete_unassign = async_to_streamed_response_wrapper( insights.delete_unassign, )