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