|
| 1 | +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
| 2 | + |
| 3 | +from __future__ import annotations |
| 4 | + |
| 5 | +from typing import Type, cast |
| 6 | + |
| 7 | +import httpx |
| 8 | + |
| 9 | +from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven |
| 10 | +from ..._compat import cached_property |
| 11 | +from ..._resource import SyncAPIResource, AsyncAPIResource |
| 12 | +from ..._response import ( |
| 13 | + to_raw_response_wrapper, |
| 14 | + to_streamed_response_wrapper, |
| 15 | + async_to_raw_response_wrapper, |
| 16 | + async_to_streamed_response_wrapper, |
| 17 | +) |
| 18 | +from ..._wrappers import ResultWrapper |
| 19 | +from ..._base_client import make_request_options |
| 20 | +from ...types.ai_gateway.url_get_response import URLGetResponse |
| 21 | + |
| 22 | +__all__ = ["URLsResource", "AsyncURLsResource"] |
| 23 | + |
| 24 | + |
| 25 | +class URLsResource(SyncAPIResource): |
| 26 | + @cached_property |
| 27 | + def with_raw_response(self) -> URLsResourceWithRawResponse: |
| 28 | + """ |
| 29 | + This property can be used as a prefix for any HTTP method call to return |
| 30 | + the raw response object instead of the parsed content. |
| 31 | +
|
| 32 | + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers |
| 33 | + """ |
| 34 | + return URLsResourceWithRawResponse(self) |
| 35 | + |
| 36 | + @cached_property |
| 37 | + def with_streaming_response(self) -> URLsResourceWithStreamingResponse: |
| 38 | + """ |
| 39 | + An alternative to `.with_raw_response` that doesn't eagerly read the response body. |
| 40 | +
|
| 41 | + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response |
| 42 | + """ |
| 43 | + return URLsResourceWithStreamingResponse(self) |
| 44 | + |
| 45 | + def get( |
| 46 | + self, |
| 47 | + provider: str, |
| 48 | + *, |
| 49 | + account_id: str, |
| 50 | + gateway_id: str, |
| 51 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 52 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 53 | + extra_headers: Headers | None = None, |
| 54 | + extra_query: Query | None = None, |
| 55 | + extra_body: Body | None = None, |
| 56 | + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, |
| 57 | + ) -> str: |
| 58 | + """ |
| 59 | + Get Gateway URL |
| 60 | +
|
| 61 | + Args: |
| 62 | + gateway_id: gateway id |
| 63 | +
|
| 64 | + extra_headers: Send extra headers |
| 65 | +
|
| 66 | + extra_query: Add additional query parameters to the request |
| 67 | +
|
| 68 | + extra_body: Add additional JSON properties to the request |
| 69 | +
|
| 70 | + timeout: Override the client-level default timeout for this request, in seconds |
| 71 | + """ |
| 72 | + if not account_id: |
| 73 | + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") |
| 74 | + if not gateway_id: |
| 75 | + raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}") |
| 76 | + if not provider: |
| 77 | + raise ValueError(f"Expected a non-empty value for `provider` but received {provider!r}") |
| 78 | + return self._get( |
| 79 | + f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/url/{provider}", |
| 80 | + options=make_request_options( |
| 81 | + extra_headers=extra_headers, |
| 82 | + extra_query=extra_query, |
| 83 | + extra_body=extra_body, |
| 84 | + timeout=timeout, |
| 85 | + post_parser=ResultWrapper[URLGetResponse]._unwrapper, |
| 86 | + ), |
| 87 | + cast_to=cast(Type[str], ResultWrapper[str]), |
| 88 | + ) |
| 89 | + |
| 90 | + |
| 91 | +class AsyncURLsResource(AsyncAPIResource): |
| 92 | + @cached_property |
| 93 | + def with_raw_response(self) -> AsyncURLsResourceWithRawResponse: |
| 94 | + """ |
| 95 | + This property can be used as a prefix for any HTTP method call to return |
| 96 | + the raw response object instead of the parsed content. |
| 97 | +
|
| 98 | + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers |
| 99 | + """ |
| 100 | + return AsyncURLsResourceWithRawResponse(self) |
| 101 | + |
| 102 | + @cached_property |
| 103 | + def with_streaming_response(self) -> AsyncURLsResourceWithStreamingResponse: |
| 104 | + """ |
| 105 | + An alternative to `.with_raw_response` that doesn't eagerly read the response body. |
| 106 | +
|
| 107 | + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response |
| 108 | + """ |
| 109 | + return AsyncURLsResourceWithStreamingResponse(self) |
| 110 | + |
| 111 | + async def get( |
| 112 | + self, |
| 113 | + provider: str, |
| 114 | + *, |
| 115 | + account_id: str, |
| 116 | + gateway_id: str, |
| 117 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 118 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 119 | + extra_headers: Headers | None = None, |
| 120 | + extra_query: Query | None = None, |
| 121 | + extra_body: Body | None = None, |
| 122 | + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, |
| 123 | + ) -> str: |
| 124 | + """ |
| 125 | + Get Gateway URL |
| 126 | +
|
| 127 | + Args: |
| 128 | + gateway_id: gateway id |
| 129 | +
|
| 130 | + extra_headers: Send extra headers |
| 131 | +
|
| 132 | + extra_query: Add additional query parameters to the request |
| 133 | +
|
| 134 | + extra_body: Add additional JSON properties to the request |
| 135 | +
|
| 136 | + timeout: Override the client-level default timeout for this request, in seconds |
| 137 | + """ |
| 138 | + if not account_id: |
| 139 | + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") |
| 140 | + if not gateway_id: |
| 141 | + raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}") |
| 142 | + if not provider: |
| 143 | + raise ValueError(f"Expected a non-empty value for `provider` but received {provider!r}") |
| 144 | + return await self._get( |
| 145 | + f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/url/{provider}", |
| 146 | + options=make_request_options( |
| 147 | + extra_headers=extra_headers, |
| 148 | + extra_query=extra_query, |
| 149 | + extra_body=extra_body, |
| 150 | + timeout=timeout, |
| 151 | + post_parser=ResultWrapper[URLGetResponse]._unwrapper, |
| 152 | + ), |
| 153 | + cast_to=cast(Type[str], ResultWrapper[str]), |
| 154 | + ) |
| 155 | + |
| 156 | + |
| 157 | +class URLsResourceWithRawResponse: |
| 158 | + def __init__(self, urls: URLsResource) -> None: |
| 159 | + self._urls = urls |
| 160 | + |
| 161 | + self.get = to_raw_response_wrapper( |
| 162 | + urls.get, |
| 163 | + ) |
| 164 | + |
| 165 | + |
| 166 | +class AsyncURLsResourceWithRawResponse: |
| 167 | + def __init__(self, urls: AsyncURLsResource) -> None: |
| 168 | + self._urls = urls |
| 169 | + |
| 170 | + self.get = async_to_raw_response_wrapper( |
| 171 | + urls.get, |
| 172 | + ) |
| 173 | + |
| 174 | + |
| 175 | +class URLsResourceWithStreamingResponse: |
| 176 | + def __init__(self, urls: URLsResource) -> None: |
| 177 | + self._urls = urls |
| 178 | + |
| 179 | + self.get = to_streamed_response_wrapper( |
| 180 | + urls.get, |
| 181 | + ) |
| 182 | + |
| 183 | + |
| 184 | +class AsyncURLsResourceWithStreamingResponse: |
| 185 | + def __init__(self, urls: AsyncURLsResource) -> None: |
| 186 | + self._urls = urls |
| 187 | + |
| 188 | + self.get = async_to_streamed_response_wrapper( |
| 189 | + urls.get, |
| 190 | + ) |
0 commit comments