|
| 1 | +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
| 2 | + |
| 3 | +from __future__ import annotations |
| 4 | + |
| 5 | +import httpx |
| 6 | + |
| 7 | +from ..types import search_for_route_retrieve_params |
| 8 | +from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven |
| 9 | +from .._utils import ( |
| 10 | + maybe_transform, |
| 11 | + async_maybe_transform, |
| 12 | +) |
| 13 | +from .._compat import cached_property |
| 14 | +from .._resource import SyncAPIResource, AsyncAPIResource |
| 15 | +from .._response import ( |
| 16 | + to_raw_response_wrapper, |
| 17 | + to_streamed_response_wrapper, |
| 18 | + async_to_raw_response_wrapper, |
| 19 | + async_to_streamed_response_wrapper, |
| 20 | +) |
| 21 | +from .._base_client import make_request_options |
| 22 | +from ..types.search_for_route_retrieve_response import SearchForRouteRetrieveResponse |
| 23 | + |
| 24 | +__all__ = ["SearchForRouteResource", "AsyncSearchForRouteResource"] |
| 25 | + |
| 26 | + |
| 27 | +class SearchForRouteResource(SyncAPIResource): |
| 28 | + @cached_property |
| 29 | + def with_raw_response(self) -> SearchForRouteResourceWithRawResponse: |
| 30 | + return SearchForRouteResourceWithRawResponse(self) |
| 31 | + |
| 32 | + @cached_property |
| 33 | + def with_streaming_response(self) -> SearchForRouteResourceWithStreamingResponse: |
| 34 | + return SearchForRouteResourceWithStreamingResponse(self) |
| 35 | + |
| 36 | + def retrieve( |
| 37 | + self, |
| 38 | + *, |
| 39 | + input: str, |
| 40 | + max_count: int | NotGiven = NOT_GIVEN, |
| 41 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 42 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 43 | + extra_headers: Headers | None = None, |
| 44 | + extra_query: Query | None = None, |
| 45 | + extra_body: Body | None = None, |
| 46 | + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, |
| 47 | + ) -> SearchForRouteRetrieveResponse: |
| 48 | + """ |
| 49 | + Search for a route based on its name. |
| 50 | +
|
| 51 | + Args: |
| 52 | + input: The string to search for. |
| 53 | +
|
| 54 | + max_count: The max number of results to return. Defaults to 20. |
| 55 | +
|
| 56 | + extra_headers: Send extra headers |
| 57 | +
|
| 58 | + extra_query: Add additional query parameters to the request |
| 59 | +
|
| 60 | + extra_body: Add additional JSON properties to the request |
| 61 | +
|
| 62 | + timeout: Override the client-level default timeout for this request, in seconds |
| 63 | + """ |
| 64 | + return self._get( |
| 65 | + "/api/where/search/route.json", |
| 66 | + options=make_request_options( |
| 67 | + extra_headers=extra_headers, |
| 68 | + extra_query=extra_query, |
| 69 | + extra_body=extra_body, |
| 70 | + timeout=timeout, |
| 71 | + query=maybe_transform( |
| 72 | + { |
| 73 | + "input": input, |
| 74 | + "max_count": max_count, |
| 75 | + }, |
| 76 | + search_for_route_retrieve_params.SearchForRouteRetrieveParams, |
| 77 | + ), |
| 78 | + ), |
| 79 | + cast_to=SearchForRouteRetrieveResponse, |
| 80 | + ) |
| 81 | + |
| 82 | + |
| 83 | +class AsyncSearchForRouteResource(AsyncAPIResource): |
| 84 | + @cached_property |
| 85 | + def with_raw_response(self) -> AsyncSearchForRouteResourceWithRawResponse: |
| 86 | + return AsyncSearchForRouteResourceWithRawResponse(self) |
| 87 | + |
| 88 | + @cached_property |
| 89 | + def with_streaming_response(self) -> AsyncSearchForRouteResourceWithStreamingResponse: |
| 90 | + return AsyncSearchForRouteResourceWithStreamingResponse(self) |
| 91 | + |
| 92 | + async def retrieve( |
| 93 | + self, |
| 94 | + *, |
| 95 | + input: str, |
| 96 | + max_count: int | NotGiven = NOT_GIVEN, |
| 97 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 98 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 99 | + extra_headers: Headers | None = None, |
| 100 | + extra_query: Query | None = None, |
| 101 | + extra_body: Body | None = None, |
| 102 | + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, |
| 103 | + ) -> SearchForRouteRetrieveResponse: |
| 104 | + """ |
| 105 | + Search for a route based on its name. |
| 106 | +
|
| 107 | + Args: |
| 108 | + input: The string to search for. |
| 109 | +
|
| 110 | + max_count: The max number of results to return. Defaults to 20. |
| 111 | +
|
| 112 | + extra_headers: Send extra headers |
| 113 | +
|
| 114 | + extra_query: Add additional query parameters to the request |
| 115 | +
|
| 116 | + extra_body: Add additional JSON properties to the request |
| 117 | +
|
| 118 | + timeout: Override the client-level default timeout for this request, in seconds |
| 119 | + """ |
| 120 | + return await self._get( |
| 121 | + "/api/where/search/route.json", |
| 122 | + options=make_request_options( |
| 123 | + extra_headers=extra_headers, |
| 124 | + extra_query=extra_query, |
| 125 | + extra_body=extra_body, |
| 126 | + timeout=timeout, |
| 127 | + query=await async_maybe_transform( |
| 128 | + { |
| 129 | + "input": input, |
| 130 | + "max_count": max_count, |
| 131 | + }, |
| 132 | + search_for_route_retrieve_params.SearchForRouteRetrieveParams, |
| 133 | + ), |
| 134 | + ), |
| 135 | + cast_to=SearchForRouteRetrieveResponse, |
| 136 | + ) |
| 137 | + |
| 138 | + |
| 139 | +class SearchForRouteResourceWithRawResponse: |
| 140 | + def __init__(self, search_for_route: SearchForRouteResource) -> None: |
| 141 | + self._search_for_route = search_for_route |
| 142 | + |
| 143 | + self.retrieve = to_raw_response_wrapper( |
| 144 | + search_for_route.retrieve, |
| 145 | + ) |
| 146 | + |
| 147 | + |
| 148 | +class AsyncSearchForRouteResourceWithRawResponse: |
| 149 | + def __init__(self, search_for_route: AsyncSearchForRouteResource) -> None: |
| 150 | + self._search_for_route = search_for_route |
| 151 | + |
| 152 | + self.retrieve = async_to_raw_response_wrapper( |
| 153 | + search_for_route.retrieve, |
| 154 | + ) |
| 155 | + |
| 156 | + |
| 157 | +class SearchForRouteResourceWithStreamingResponse: |
| 158 | + def __init__(self, search_for_route: SearchForRouteResource) -> None: |
| 159 | + self._search_for_route = search_for_route |
| 160 | + |
| 161 | + self.retrieve = to_streamed_response_wrapper( |
| 162 | + search_for_route.retrieve, |
| 163 | + ) |
| 164 | + |
| 165 | + |
| 166 | +class AsyncSearchForRouteResourceWithStreamingResponse: |
| 167 | + def __init__(self, search_for_route: AsyncSearchForRouteResource) -> None: |
| 168 | + self._search_for_route = search_for_route |
| 169 | + |
| 170 | + self.retrieve = async_to_streamed_response_wrapper( |
| 171 | + search_for_route.retrieve, |
| 172 | + ) |
0 commit comments