# 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__ = ["ToolsResource", "AsyncToolsResource"] class ToolsResource(SyncAPIResource): @cached_property def with_raw_response(self) -> ToolsResourceWithRawResponse: """ 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 ToolsResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> ToolsResourceWithStreamingResponse: """ 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 ToolsResourceWithStreamingResponse(self) def create_tool( self, mission_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, ) -> object: """ Adds a new tool to the specified mission, defining an action agents can invoke during runs of this mission. 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 mission_id: raise ValueError(f"Expected a non-empty value for `mission_id` but received {mission_id!r}") return self._post( path_template("/ai/missions/{mission_id}/tools", mission_id=mission_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), cast_to=object, ) def delete_tool( self, tool_id: str, *, mission_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 tool from the mission so agents can no longer invoke it in subsequent runs. 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 mission_id: raise ValueError(f"Expected a non-empty value for `mission_id` but received {mission_id!r}") if not tool_id: raise ValueError(f"Expected a non-empty value for `tool_id` but received {tool_id!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return self._delete( path_template("/ai/missions/{mission_id}/tools/{tool_id}", mission_id=mission_id, tool_id=tool_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), cast_to=NoneType, ) def get_tool( self, tool_id: str, *, mission_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, ) -> object: """ Returns the definition of a single tool configured on the specified mission. 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 mission_id: raise ValueError(f"Expected a non-empty value for `mission_id` but received {mission_id!r}") if not tool_id: raise ValueError(f"Expected a non-empty value for `tool_id` but received {tool_id!r}") return self._get( path_template("/ai/missions/{mission_id}/tools/{tool_id}", mission_id=mission_id, tool_id=tool_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), cast_to=object, ) def list_tools( self, mission_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, ) -> object: """Returns the tools configured on the specified mission. Tools define the actions agents may invoke while executing the mission's runs. 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 mission_id: raise ValueError(f"Expected a non-empty value for `mission_id` but received {mission_id!r}") return self._get( path_template("/ai/missions/{mission_id}/tools", mission_id=mission_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), cast_to=object, ) def update_tool( self, tool_id: str, *, mission_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, ) -> object: """ Replaces the definition of the specified tool on this mission. 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 mission_id: raise ValueError(f"Expected a non-empty value for `mission_id` but received {mission_id!r}") if not tool_id: raise ValueError(f"Expected a non-empty value for `tool_id` but received {tool_id!r}") return self._put( path_template("/ai/missions/{mission_id}/tools/{tool_id}", mission_id=mission_id, tool_id=tool_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), cast_to=object, ) class AsyncToolsResource(AsyncAPIResource): @cached_property def with_raw_response(self) -> AsyncToolsResourceWithRawResponse: """ 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 AsyncToolsResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> AsyncToolsResourceWithStreamingResponse: """ 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 AsyncToolsResourceWithStreamingResponse(self) async def create_tool( self, mission_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, ) -> object: """ Adds a new tool to the specified mission, defining an action agents can invoke during runs of this mission. 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 mission_id: raise ValueError(f"Expected a non-empty value for `mission_id` but received {mission_id!r}") return await self._post( path_template("/ai/missions/{mission_id}/tools", mission_id=mission_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), cast_to=object, ) async def delete_tool( self, tool_id: str, *, mission_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 tool from the mission so agents can no longer invoke it in subsequent runs. 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 mission_id: raise ValueError(f"Expected a non-empty value for `mission_id` but received {mission_id!r}") if not tool_id: raise ValueError(f"Expected a non-empty value for `tool_id` but received {tool_id!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return await self._delete( path_template("/ai/missions/{mission_id}/tools/{tool_id}", mission_id=mission_id, tool_id=tool_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), cast_to=NoneType, ) async def get_tool( self, tool_id: str, *, mission_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, ) -> object: """ Returns the definition of a single tool configured on the specified mission. 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 mission_id: raise ValueError(f"Expected a non-empty value for `mission_id` but received {mission_id!r}") if not tool_id: raise ValueError(f"Expected a non-empty value for `tool_id` but received {tool_id!r}") return await self._get( path_template("/ai/missions/{mission_id}/tools/{tool_id}", mission_id=mission_id, tool_id=tool_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), cast_to=object, ) async def list_tools( self, mission_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, ) -> object: """Returns the tools configured on the specified mission. Tools define the actions agents may invoke while executing the mission's runs. 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 mission_id: raise ValueError(f"Expected a non-empty value for `mission_id` but received {mission_id!r}") return await self._get( path_template("/ai/missions/{mission_id}/tools", mission_id=mission_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), cast_to=object, ) async def update_tool( self, tool_id: str, *, mission_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, ) -> object: """ Replaces the definition of the specified tool on this mission. 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 mission_id: raise ValueError(f"Expected a non-empty value for `mission_id` but received {mission_id!r}") if not tool_id: raise ValueError(f"Expected a non-empty value for `tool_id` but received {tool_id!r}") return await self._put( path_template("/ai/missions/{mission_id}/tools/{tool_id}", mission_id=mission_id, tool_id=tool_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), cast_to=object, ) class ToolsResourceWithRawResponse: def __init__(self, tools: ToolsResource) -> None: self._tools = tools self.create_tool = to_raw_response_wrapper( tools.create_tool, ) self.delete_tool = to_raw_response_wrapper( tools.delete_tool, ) self.get_tool = to_raw_response_wrapper( tools.get_tool, ) self.list_tools = to_raw_response_wrapper( tools.list_tools, ) self.update_tool = to_raw_response_wrapper( tools.update_tool, ) class AsyncToolsResourceWithRawResponse: def __init__(self, tools: AsyncToolsResource) -> None: self._tools = tools self.create_tool = async_to_raw_response_wrapper( tools.create_tool, ) self.delete_tool = async_to_raw_response_wrapper( tools.delete_tool, ) self.get_tool = async_to_raw_response_wrapper( tools.get_tool, ) self.list_tools = async_to_raw_response_wrapper( tools.list_tools, ) self.update_tool = async_to_raw_response_wrapper( tools.update_tool, ) class ToolsResourceWithStreamingResponse: def __init__(self, tools: ToolsResource) -> None: self._tools = tools self.create_tool = to_streamed_response_wrapper( tools.create_tool, ) self.delete_tool = to_streamed_response_wrapper( tools.delete_tool, ) self.get_tool = to_streamed_response_wrapper( tools.get_tool, ) self.list_tools = to_streamed_response_wrapper( tools.list_tools, ) self.update_tool = to_streamed_response_wrapper( tools.update_tool, ) class AsyncToolsResourceWithStreamingResponse: def __init__(self, tools: AsyncToolsResource) -> None: self._tools = tools self.create_tool = async_to_streamed_response_wrapper( tools.create_tool, ) self.delete_tool = async_to_streamed_response_wrapper( tools.delete_tool, ) self.get_tool = async_to_streamed_response_wrapper( tools.get_tool, ) self.list_tools = async_to_streamed_response_wrapper( tools.list_tools, ) self.update_tool = async_to_streamed_response_wrapper( tools.update_tool, )