|
| 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 NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven |
| 8 | +from ..._compat import cached_property |
| 9 | +from ..._resource import SyncAPIResource, AsyncAPIResource |
| 10 | +from ..._response import ( |
| 11 | + to_raw_response_wrapper, |
| 12 | + to_streamed_response_wrapper, |
| 13 | + async_to_raw_response_wrapper, |
| 14 | + async_to_streamed_response_wrapper, |
| 15 | +) |
| 16 | +from ..._base_client import make_request_options |
| 17 | +from ...types.execution import Execution |
| 18 | + |
| 19 | +__all__ = ["StatusResource", "AsyncStatusResource"] |
| 20 | + |
| 21 | + |
| 22 | +class StatusResource(SyncAPIResource): |
| 23 | + @cached_property |
| 24 | + def with_raw_response(self) -> StatusResourceWithRawResponse: |
| 25 | + """ |
| 26 | + This property can be used as a prefix for any HTTP method call to return |
| 27 | + the raw response object instead of the parsed content. |
| 28 | +
|
| 29 | + For more information, see https://www.github.com/julep-ai/python-sdk#accessing-raw-response-data-eg-headers |
| 30 | + """ |
| 31 | + return StatusResourceWithRawResponse(self) |
| 32 | + |
| 33 | + @cached_property |
| 34 | + def with_streaming_response(self) -> StatusResourceWithStreamingResponse: |
| 35 | + """ |
| 36 | + An alternative to `.with_raw_response` that doesn't eagerly read the response body. |
| 37 | +
|
| 38 | + For more information, see https://www.github.com/julep-ai/python-sdk#with_streaming_response |
| 39 | + """ |
| 40 | + return StatusResourceWithStreamingResponse(self) |
| 41 | + |
| 42 | + def get( |
| 43 | + self, |
| 44 | + execution_id: str, |
| 45 | + *, |
| 46 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 47 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 48 | + extra_headers: Headers | None = None, |
| 49 | + extra_query: Query | None = None, |
| 50 | + extra_body: Body | None = None, |
| 51 | + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, |
| 52 | + ) -> Execution: |
| 53 | + """ |
| 54 | + Get Execution Details |
| 55 | +
|
| 56 | + Args: |
| 57 | + extra_headers: Send extra headers |
| 58 | +
|
| 59 | + extra_query: Add additional query parameters to the request |
| 60 | +
|
| 61 | + extra_body: Add additional JSON properties to the request |
| 62 | +
|
| 63 | + timeout: Override the client-level default timeout for this request, in seconds |
| 64 | + """ |
| 65 | + if not execution_id: |
| 66 | + raise ValueError(f"Expected a non-empty value for `execution_id` but received {execution_id!r}") |
| 67 | + return self._get( |
| 68 | + f"/executions/{execution_id}", |
| 69 | + options=make_request_options( |
| 70 | + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 71 | + ), |
| 72 | + cast_to=Execution, |
| 73 | + ) |
| 74 | + |
| 75 | + def stream( |
| 76 | + self, |
| 77 | + execution_id: str, |
| 78 | + *, |
| 79 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 80 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 81 | + extra_headers: Headers | None = None, |
| 82 | + extra_query: Query | None = None, |
| 83 | + extra_body: Body | None = None, |
| 84 | + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, |
| 85 | + ) -> None: |
| 86 | + """ |
| 87 | + SSE endpoint that streams the status of a given execution_id by polling the |
| 88 | + latest_executions view. |
| 89 | +
|
| 90 | + Args: |
| 91 | + extra_headers: Send extra headers |
| 92 | +
|
| 93 | + extra_query: Add additional query parameters to the request |
| 94 | +
|
| 95 | + extra_body: Add additional JSON properties to the request |
| 96 | +
|
| 97 | + timeout: Override the client-level default timeout for this request, in seconds |
| 98 | + """ |
| 99 | + if not execution_id: |
| 100 | + raise ValueError(f"Expected a non-empty value for `execution_id` but received {execution_id!r}") |
| 101 | + extra_headers = {"Accept": "*/*", **(extra_headers or {})} |
| 102 | + return self._get( |
| 103 | + f"/executions/{execution_id}/status.stream", |
| 104 | + options=make_request_options( |
| 105 | + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 106 | + ), |
| 107 | + cast_to=NoneType, |
| 108 | + ) |
| 109 | + |
| 110 | + |
| 111 | +class AsyncStatusResource(AsyncAPIResource): |
| 112 | + @cached_property |
| 113 | + def with_raw_response(self) -> AsyncStatusResourceWithRawResponse: |
| 114 | + """ |
| 115 | + This property can be used as a prefix for any HTTP method call to return |
| 116 | + the raw response object instead of the parsed content. |
| 117 | +
|
| 118 | + For more information, see https://www.github.com/julep-ai/python-sdk#accessing-raw-response-data-eg-headers |
| 119 | + """ |
| 120 | + return AsyncStatusResourceWithRawResponse(self) |
| 121 | + |
| 122 | + @cached_property |
| 123 | + def with_streaming_response(self) -> AsyncStatusResourceWithStreamingResponse: |
| 124 | + """ |
| 125 | + An alternative to `.with_raw_response` that doesn't eagerly read the response body. |
| 126 | +
|
| 127 | + For more information, see https://www.github.com/julep-ai/python-sdk#with_streaming_response |
| 128 | + """ |
| 129 | + return AsyncStatusResourceWithStreamingResponse(self) |
| 130 | + |
| 131 | + async def get( |
| 132 | + self, |
| 133 | + execution_id: str, |
| 134 | + *, |
| 135 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 136 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 137 | + extra_headers: Headers | None = None, |
| 138 | + extra_query: Query | None = None, |
| 139 | + extra_body: Body | None = None, |
| 140 | + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, |
| 141 | + ) -> Execution: |
| 142 | + """ |
| 143 | + Get Execution Details |
| 144 | +
|
| 145 | + Args: |
| 146 | + extra_headers: Send extra headers |
| 147 | +
|
| 148 | + extra_query: Add additional query parameters to the request |
| 149 | +
|
| 150 | + extra_body: Add additional JSON properties to the request |
| 151 | +
|
| 152 | + timeout: Override the client-level default timeout for this request, in seconds |
| 153 | + """ |
| 154 | + if not execution_id: |
| 155 | + raise ValueError(f"Expected a non-empty value for `execution_id` but received {execution_id!r}") |
| 156 | + return await self._get( |
| 157 | + f"/executions/{execution_id}", |
| 158 | + options=make_request_options( |
| 159 | + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 160 | + ), |
| 161 | + cast_to=Execution, |
| 162 | + ) |
| 163 | + |
| 164 | + async def stream( |
| 165 | + self, |
| 166 | + execution_id: str, |
| 167 | + *, |
| 168 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 169 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 170 | + extra_headers: Headers | None = None, |
| 171 | + extra_query: Query | None = None, |
| 172 | + extra_body: Body | None = None, |
| 173 | + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, |
| 174 | + ) -> None: |
| 175 | + """ |
| 176 | + SSE endpoint that streams the status of a given execution_id by polling the |
| 177 | + latest_executions view. |
| 178 | +
|
| 179 | + Args: |
| 180 | + extra_headers: Send extra headers |
| 181 | +
|
| 182 | + extra_query: Add additional query parameters to the request |
| 183 | +
|
| 184 | + extra_body: Add additional JSON properties to the request |
| 185 | +
|
| 186 | + timeout: Override the client-level default timeout for this request, in seconds |
| 187 | + """ |
| 188 | + if not execution_id: |
| 189 | + raise ValueError(f"Expected a non-empty value for `execution_id` but received {execution_id!r}") |
| 190 | + extra_headers = {"Accept": "*/*", **(extra_headers or {})} |
| 191 | + return await self._get( |
| 192 | + f"/executions/{execution_id}/status.stream", |
| 193 | + options=make_request_options( |
| 194 | + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 195 | + ), |
| 196 | + cast_to=NoneType, |
| 197 | + ) |
| 198 | + |
| 199 | + |
| 200 | +class StatusResourceWithRawResponse: |
| 201 | + def __init__(self, status: StatusResource) -> None: |
| 202 | + self._status = status |
| 203 | + |
| 204 | + self.get = to_raw_response_wrapper( |
| 205 | + status.get, |
| 206 | + ) |
| 207 | + self.stream = to_raw_response_wrapper( |
| 208 | + status.stream, |
| 209 | + ) |
| 210 | + |
| 211 | + |
| 212 | +class AsyncStatusResourceWithRawResponse: |
| 213 | + def __init__(self, status: AsyncStatusResource) -> None: |
| 214 | + self._status = status |
| 215 | + |
| 216 | + self.get = async_to_raw_response_wrapper( |
| 217 | + status.get, |
| 218 | + ) |
| 219 | + self.stream = async_to_raw_response_wrapper( |
| 220 | + status.stream, |
| 221 | + ) |
| 222 | + |
| 223 | + |
| 224 | +class StatusResourceWithStreamingResponse: |
| 225 | + def __init__(self, status: StatusResource) -> None: |
| 226 | + self._status = status |
| 227 | + |
| 228 | + self.get = to_streamed_response_wrapper( |
| 229 | + status.get, |
| 230 | + ) |
| 231 | + self.stream = to_streamed_response_wrapper( |
| 232 | + status.stream, |
| 233 | + ) |
| 234 | + |
| 235 | + |
| 236 | +class AsyncStatusResourceWithStreamingResponse: |
| 237 | + def __init__(self, status: AsyncStatusResource) -> None: |
| 238 | + self._status = status |
| 239 | + |
| 240 | + self.get = async_to_streamed_response_wrapper( |
| 241 | + status.get, |
| 242 | + ) |
| 243 | + self.stream = async_to_streamed_response_wrapper( |
| 244 | + status.stream, |
| 245 | + ) |
0 commit comments