|
| 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 | + to_raw_response_wrapper, |
| 13 | + to_streamed_response_wrapper, |
| 14 | + async_to_raw_response_wrapper, |
| 15 | + async_to_streamed_response_wrapper, |
| 16 | +) |
| 17 | +from ...._base_client import make_request_options |
| 18 | +from ....types.sessions.recording.download_list_response import DownloadListResponse |
| 19 | +from ....types.sessions.recording.download_create_response import DownloadCreateResponse |
| 20 | + |
| 21 | +__all__ = ["DownloadsResource", "AsyncDownloadsResource"] |
| 22 | + |
| 23 | + |
| 24 | +class DownloadsResource(SyncAPIResource): |
| 25 | + @cached_property |
| 26 | + def with_raw_response(self) -> DownloadsResourceWithRawResponse: |
| 27 | + """ |
| 28 | + This property can be used as a prefix for any HTTP method call to return |
| 29 | + the raw response object instead of the parsed content. |
| 30 | +
|
| 31 | + For more information, see https://www.github.com/browserbase/sdk-python#accessing-raw-response-data-eg-headers |
| 32 | + """ |
| 33 | + return DownloadsResourceWithRawResponse(self) |
| 34 | + |
| 35 | + @cached_property |
| 36 | + def with_streaming_response(self) -> DownloadsResourceWithStreamingResponse: |
| 37 | + """ |
| 38 | + An alternative to `.with_raw_response` that doesn't eagerly read the response body. |
| 39 | +
|
| 40 | + For more information, see https://www.github.com/browserbase/sdk-python#with_streaming_response |
| 41 | + """ |
| 42 | + return DownloadsResourceWithStreamingResponse(self) |
| 43 | + |
| 44 | + def create( |
| 45 | + self, |
| 46 | + id: str, |
| 47 | + *, |
| 48 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 49 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 50 | + extra_headers: Headers | None = None, |
| 51 | + extra_query: Query | None = None, |
| 52 | + extra_body: Body | None = None, |
| 53 | + timeout: float | httpx.Timeout | None | NotGiven = not_given, |
| 54 | + ) -> DownloadCreateResponse: |
| 55 | + """Requests one downloadable MP4 per recorded page of a session. |
| 56 | +
|
| 57 | + Assembly runs |
| 58 | + asynchronously and every page returns as `PENDING`. Re-posting re-enqueues all |
| 59 | + pages and retries any that failed. Poll the GET endpoint for per-page status |
| 60 | + and, on standard (non-BYOS) projects, download URLs. |
| 61 | +
|
| 62 | + Args: |
| 63 | + extra_headers: Send extra headers |
| 64 | +
|
| 65 | + extra_query: Add additional query parameters to the request |
| 66 | +
|
| 67 | + extra_body: Add additional JSON properties to the request |
| 68 | +
|
| 69 | + timeout: Override the client-level default timeout for this request, in seconds |
| 70 | + """ |
| 71 | + if not id: |
| 72 | + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") |
| 73 | + return self._post( |
| 74 | + path_template("/v1/sessions/{id}/recording/downloads", id=id), |
| 75 | + options=make_request_options( |
| 76 | + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 77 | + ), |
| 78 | + cast_to=DownloadCreateResponse, |
| 79 | + ) |
| 80 | + |
| 81 | + def list( |
| 82 | + self, |
| 83 | + id: str, |
| 84 | + *, |
| 85 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 86 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 87 | + extra_headers: Headers | None = None, |
| 88 | + extra_query: Query | None = None, |
| 89 | + extra_body: Body | None = None, |
| 90 | + timeout: float | httpx.Timeout | None | NotGiven = not_given, |
| 91 | + ) -> DownloadListResponse: |
| 92 | + """ |
| 93 | + Returns the per-page download status for a session, with a short-lived signed |
| 94 | + URL for each completed page on standard (non-BYOS) projects. |
| 95 | +
|
| 96 | + Args: |
| 97 | + extra_headers: Send extra headers |
| 98 | +
|
| 99 | + extra_query: Add additional query parameters to the request |
| 100 | +
|
| 101 | + extra_body: Add additional JSON properties to the request |
| 102 | +
|
| 103 | + timeout: Override the client-level default timeout for this request, in seconds |
| 104 | + """ |
| 105 | + if not id: |
| 106 | + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") |
| 107 | + return self._get( |
| 108 | + path_template("/v1/sessions/{id}/recording/downloads", id=id), |
| 109 | + options=make_request_options( |
| 110 | + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 111 | + ), |
| 112 | + cast_to=DownloadListResponse, |
| 113 | + ) |
| 114 | + |
| 115 | + |
| 116 | +class AsyncDownloadsResource(AsyncAPIResource): |
| 117 | + @cached_property |
| 118 | + def with_raw_response(self) -> AsyncDownloadsResourceWithRawResponse: |
| 119 | + """ |
| 120 | + This property can be used as a prefix for any HTTP method call to return |
| 121 | + the raw response object instead of the parsed content. |
| 122 | +
|
| 123 | + For more information, see https://www.github.com/browserbase/sdk-python#accessing-raw-response-data-eg-headers |
| 124 | + """ |
| 125 | + return AsyncDownloadsResourceWithRawResponse(self) |
| 126 | + |
| 127 | + @cached_property |
| 128 | + def with_streaming_response(self) -> AsyncDownloadsResourceWithStreamingResponse: |
| 129 | + """ |
| 130 | + An alternative to `.with_raw_response` that doesn't eagerly read the response body. |
| 131 | +
|
| 132 | + For more information, see https://www.github.com/browserbase/sdk-python#with_streaming_response |
| 133 | + """ |
| 134 | + return AsyncDownloadsResourceWithStreamingResponse(self) |
| 135 | + |
| 136 | + async def create( |
| 137 | + self, |
| 138 | + id: str, |
| 139 | + *, |
| 140 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 141 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 142 | + extra_headers: Headers | None = None, |
| 143 | + extra_query: Query | None = None, |
| 144 | + extra_body: Body | None = None, |
| 145 | + timeout: float | httpx.Timeout | None | NotGiven = not_given, |
| 146 | + ) -> DownloadCreateResponse: |
| 147 | + """Requests one downloadable MP4 per recorded page of a session. |
| 148 | +
|
| 149 | + Assembly runs |
| 150 | + asynchronously and every page returns as `PENDING`. Re-posting re-enqueues all |
| 151 | + pages and retries any that failed. Poll the GET endpoint for per-page status |
| 152 | + and, on standard (non-BYOS) projects, download URLs. |
| 153 | +
|
| 154 | + Args: |
| 155 | + extra_headers: Send extra headers |
| 156 | +
|
| 157 | + extra_query: Add additional query parameters to the request |
| 158 | +
|
| 159 | + extra_body: Add additional JSON properties to the request |
| 160 | +
|
| 161 | + timeout: Override the client-level default timeout for this request, in seconds |
| 162 | + """ |
| 163 | + if not id: |
| 164 | + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") |
| 165 | + return await self._post( |
| 166 | + path_template("/v1/sessions/{id}/recording/downloads", id=id), |
| 167 | + options=make_request_options( |
| 168 | + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 169 | + ), |
| 170 | + cast_to=DownloadCreateResponse, |
| 171 | + ) |
| 172 | + |
| 173 | + async def list( |
| 174 | + self, |
| 175 | + id: str, |
| 176 | + *, |
| 177 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 178 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 179 | + extra_headers: Headers | None = None, |
| 180 | + extra_query: Query | None = None, |
| 181 | + extra_body: Body | None = None, |
| 182 | + timeout: float | httpx.Timeout | None | NotGiven = not_given, |
| 183 | + ) -> DownloadListResponse: |
| 184 | + """ |
| 185 | + Returns the per-page download status for a session, with a short-lived signed |
| 186 | + URL for each completed page on standard (non-BYOS) projects. |
| 187 | +
|
| 188 | + Args: |
| 189 | + extra_headers: Send extra headers |
| 190 | +
|
| 191 | + extra_query: Add additional query parameters to the request |
| 192 | +
|
| 193 | + extra_body: Add additional JSON properties to the request |
| 194 | +
|
| 195 | + timeout: Override the client-level default timeout for this request, in seconds |
| 196 | + """ |
| 197 | + if not id: |
| 198 | + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") |
| 199 | + return await self._get( |
| 200 | + path_template("/v1/sessions/{id}/recording/downloads", id=id), |
| 201 | + options=make_request_options( |
| 202 | + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 203 | + ), |
| 204 | + cast_to=DownloadListResponse, |
| 205 | + ) |
| 206 | + |
| 207 | + |
| 208 | +class DownloadsResourceWithRawResponse: |
| 209 | + def __init__(self, downloads: DownloadsResource) -> None: |
| 210 | + self._downloads = downloads |
| 211 | + |
| 212 | + self.create = to_raw_response_wrapper( |
| 213 | + downloads.create, |
| 214 | + ) |
| 215 | + self.list = to_raw_response_wrapper( |
| 216 | + downloads.list, |
| 217 | + ) |
| 218 | + |
| 219 | + |
| 220 | +class AsyncDownloadsResourceWithRawResponse: |
| 221 | + def __init__(self, downloads: AsyncDownloadsResource) -> None: |
| 222 | + self._downloads = downloads |
| 223 | + |
| 224 | + self.create = async_to_raw_response_wrapper( |
| 225 | + downloads.create, |
| 226 | + ) |
| 227 | + self.list = async_to_raw_response_wrapper( |
| 228 | + downloads.list, |
| 229 | + ) |
| 230 | + |
| 231 | + |
| 232 | +class DownloadsResourceWithStreamingResponse: |
| 233 | + def __init__(self, downloads: DownloadsResource) -> None: |
| 234 | + self._downloads = downloads |
| 235 | + |
| 236 | + self.create = to_streamed_response_wrapper( |
| 237 | + downloads.create, |
| 238 | + ) |
| 239 | + self.list = to_streamed_response_wrapper( |
| 240 | + downloads.list, |
| 241 | + ) |
| 242 | + |
| 243 | + |
| 244 | +class AsyncDownloadsResourceWithStreamingResponse: |
| 245 | + def __init__(self, downloads: AsyncDownloadsResource) -> None: |
| 246 | + self._downloads = downloads |
| 247 | + |
| 248 | + self.create = async_to_streamed_response_wrapper( |
| 249 | + downloads.create, |
| 250 | + ) |
| 251 | + self.list = async_to_streamed_response_wrapper( |
| 252 | + downloads.list, |
| 253 | + ) |
0 commit comments