anchorbrowser 0.1.0a3__py3-none-any.whl → 0.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- anchorbrowser/__init__.py +3 -1
- anchorbrowser/_base_client.py +16 -13
- anchorbrowser/_client.py +38 -9
- anchorbrowser/_compat.py +48 -48
- anchorbrowser/_files.py +4 -4
- anchorbrowser/_models.py +54 -45
- anchorbrowser/_qs.py +7 -7
- anchorbrowser/_types.py +53 -12
- anchorbrowser/_utils/__init__.py +9 -2
- anchorbrowser/_utils/_compat.py +45 -0
- anchorbrowser/_utils/_datetime_parse.py +136 -0
- anchorbrowser/_utils/_transform.py +13 -3
- anchorbrowser/_utils/_typing.py +6 -1
- anchorbrowser/_utils/_utils.py +4 -5
- anchorbrowser/_version.py +1 -1
- anchorbrowser/lib/browser.py +1 -1
- anchorbrowser/resources/__init__.py +42 -0
- anchorbrowser/resources/batch_sessions.py +288 -0
- anchorbrowser/resources/events.py +270 -0
- anchorbrowser/resources/extensions.py +9 -9
- anchorbrowser/resources/profiles.py +24 -150
- anchorbrowser/resources/sessions/__init__.py +14 -0
- anchorbrowser/resources/sessions/agent/__init__.py +33 -0
- anchorbrowser/resources/sessions/agent/agent.py +273 -0
- anchorbrowser/resources/sessions/agent/files.py +280 -0
- anchorbrowser/resources/sessions/all.py +5 -5
- anchorbrowser/resources/sessions/clipboard.py +5 -5
- anchorbrowser/resources/sessions/keyboard.py +11 -13
- anchorbrowser/resources/sessions/mouse.py +12 -244
- anchorbrowser/resources/sessions/recordings/primary.py +3 -3
- anchorbrowser/resources/sessions/recordings/recordings.py +7 -7
- anchorbrowser/resources/sessions/sessions.py +345 -30
- anchorbrowser/resources/task/__init__.py +33 -0
- anchorbrowser/resources/task/run.py +225 -0
- anchorbrowser/resources/task/task.py +358 -0
- anchorbrowser/resources/tools.py +107 -37
- anchorbrowser/types/__init__.py +14 -1
- anchorbrowser/types/batch_session_create_params.py +487 -0
- anchorbrowser/types/batch_session_create_response.py +27 -0
- anchorbrowser/types/batch_session_retrieve_response.py +90 -0
- anchorbrowser/types/event_signal_params.py +13 -0
- anchorbrowser/types/event_wait_for_params.py +14 -0
- anchorbrowser/types/event_wait_for_response.py +12 -0
- anchorbrowser/types/extension_manifest.py +6 -1
- anchorbrowser/types/profile_create_params.py +3 -6
- anchorbrowser/types/profile_list_response.py +0 -3
- anchorbrowser/types/profile_retrieve_response.py +0 -3
- anchorbrowser/types/session_create_params.py +308 -29
- anchorbrowser/types/session_list_pages_response.py +25 -0
- anchorbrowser/types/session_retrieve_response.py +46 -0
- anchorbrowser/types/session_scroll_params.py +3 -0
- anchorbrowser/types/session_upload_file_params.py +14 -0
- anchorbrowser/types/session_upload_file_response.py +17 -0
- anchorbrowser/types/sessions/__init__.py +0 -4
- anchorbrowser/types/sessions/agent/__init__.py +7 -0
- anchorbrowser/types/sessions/agent/file_list_response.py +32 -0
- anchorbrowser/types/sessions/agent/file_upload_params.py +14 -0
- anchorbrowser/types/sessions/agent/file_upload_response.py +17 -0
- anchorbrowser/types/sessions/keyboard_shortcut_params.py +2 -2
- anchorbrowser/types/sessions/recording_list_response.py +4 -8
- anchorbrowser/types/task/__init__.py +6 -0
- anchorbrowser/types/task/run_execute_params.py +324 -0
- anchorbrowser/types/task/run_execute_response.py +33 -0
- anchorbrowser/types/task_create_params.py +317 -0
- anchorbrowser/types/task_create_response.py +345 -0
- anchorbrowser/types/task_list_params.py +15 -0
- anchorbrowser/types/task_list_response.py +361 -0
- anchorbrowser/types/tool_fetch_webpage_params.py +15 -0
- anchorbrowser/types/tool_perform_web_task_params.py +17 -1
- anchorbrowser/types/tool_perform_web_task_response.py +3 -3
- {anchorbrowser-0.1.0a3.dist-info → anchorbrowser-0.2.0.dist-info}/METADATA +13 -14
- anchorbrowser-0.2.0.dist-info/RECORD +126 -0
- anchorbrowser/types/profile_update_params.py +0 -27
- anchorbrowser/types/sessions/mouse_down_params.py +0 -18
- anchorbrowser/types/sessions/mouse_down_response.py +0 -11
- anchorbrowser/types/sessions/mouse_up_params.py +0 -18
- anchorbrowser/types/sessions/mouse_up_response.py +0 -11
- anchorbrowser-0.1.0a3.dist-info/RECORD +0 -100
- {anchorbrowser-0.1.0a3.dist-info → anchorbrowser-0.2.0.dist-info}/WHEEL +0 -0
- {anchorbrowser-0.1.0a3.dist-info → anchorbrowser-0.2.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -16,18 +16,20 @@ from ._utils import (
|
|
|
16
16
|
lru_cache,
|
|
17
17
|
is_mapping,
|
|
18
18
|
is_iterable,
|
|
19
|
+
is_sequence,
|
|
19
20
|
)
|
|
20
21
|
from .._files import is_base64_file_input
|
|
22
|
+
from ._compat import get_origin, is_typeddict
|
|
21
23
|
from ._typing import (
|
|
22
24
|
is_list_type,
|
|
23
25
|
is_union_type,
|
|
24
26
|
extract_type_arg,
|
|
25
27
|
is_iterable_type,
|
|
26
28
|
is_required_type,
|
|
29
|
+
is_sequence_type,
|
|
27
30
|
is_annotated_type,
|
|
28
31
|
strip_annotated_type,
|
|
29
32
|
)
|
|
30
|
-
from .._compat import get_origin, model_dump, is_typeddict
|
|
31
33
|
|
|
32
34
|
_T = TypeVar("_T")
|
|
33
35
|
|
|
@@ -167,6 +169,8 @@ def _transform_recursive(
|
|
|
167
169
|
|
|
168
170
|
Defaults to the same value as the `annotation` argument.
|
|
169
171
|
"""
|
|
172
|
+
from .._compat import model_dump
|
|
173
|
+
|
|
170
174
|
if inner_type is None:
|
|
171
175
|
inner_type = annotation
|
|
172
176
|
|
|
@@ -184,6 +188,8 @@ def _transform_recursive(
|
|
|
184
188
|
(is_list_type(stripped_type) and is_list(data))
|
|
185
189
|
# Iterable[T]
|
|
186
190
|
or (is_iterable_type(stripped_type) and is_iterable(data) and not isinstance(data, str))
|
|
191
|
+
# Sequence[T]
|
|
192
|
+
or (is_sequence_type(stripped_type) and is_sequence(data) and not isinstance(data, str))
|
|
187
193
|
):
|
|
188
194
|
# dicts are technically iterable, but it is an iterable on the keys of the dict and is not usually
|
|
189
195
|
# intended as an iterable, so we don't transform it.
|
|
@@ -262,7 +268,7 @@ def _transform_typeddict(
|
|
|
262
268
|
annotations = get_type_hints(expected_type, include_extras=True)
|
|
263
269
|
for key, value in data.items():
|
|
264
270
|
if not is_given(value):
|
|
265
|
-
# we don't need to include
|
|
271
|
+
# we don't need to include omitted values here as they'll
|
|
266
272
|
# be stripped out before the request is sent anyway
|
|
267
273
|
continue
|
|
268
274
|
|
|
@@ -329,6 +335,8 @@ async def _async_transform_recursive(
|
|
|
329
335
|
|
|
330
336
|
Defaults to the same value as the `annotation` argument.
|
|
331
337
|
"""
|
|
338
|
+
from .._compat import model_dump
|
|
339
|
+
|
|
332
340
|
if inner_type is None:
|
|
333
341
|
inner_type = annotation
|
|
334
342
|
|
|
@@ -346,6 +354,8 @@ async def _async_transform_recursive(
|
|
|
346
354
|
(is_list_type(stripped_type) and is_list(data))
|
|
347
355
|
# Iterable[T]
|
|
348
356
|
or (is_iterable_type(stripped_type) and is_iterable(data) and not isinstance(data, str))
|
|
357
|
+
# Sequence[T]
|
|
358
|
+
or (is_sequence_type(stripped_type) and is_sequence(data) and not isinstance(data, str))
|
|
349
359
|
):
|
|
350
360
|
# dicts are technically iterable, but it is an iterable on the keys of the dict and is not usually
|
|
351
361
|
# intended as an iterable, so we don't transform it.
|
|
@@ -424,7 +434,7 @@ async def _async_transform_typeddict(
|
|
|
424
434
|
annotations = get_type_hints(expected_type, include_extras=True)
|
|
425
435
|
for key, value in data.items():
|
|
426
436
|
if not is_given(value):
|
|
427
|
-
# we don't need to include
|
|
437
|
+
# we don't need to include omitted values here as they'll
|
|
428
438
|
# be stripped out before the request is sent anyway
|
|
429
439
|
continue
|
|
430
440
|
|
anchorbrowser/_utils/_typing.py
CHANGED
|
@@ -15,7 +15,7 @@ from typing_extensions import (
|
|
|
15
15
|
|
|
16
16
|
from ._utils import lru_cache
|
|
17
17
|
from .._types import InheritsGeneric
|
|
18
|
-
from
|
|
18
|
+
from ._compat import is_union as _is_union
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
def is_annotated_type(typ: type) -> bool:
|
|
@@ -26,6 +26,11 @@ def is_list_type(typ: type) -> bool:
|
|
|
26
26
|
return (get_origin(typ) or typ) == list
|
|
27
27
|
|
|
28
28
|
|
|
29
|
+
def is_sequence_type(typ: type) -> bool:
|
|
30
|
+
origin = get_origin(typ) or typ
|
|
31
|
+
return origin == typing_extensions.Sequence or origin == typing.Sequence or origin == _c_abc.Sequence
|
|
32
|
+
|
|
33
|
+
|
|
29
34
|
def is_iterable_type(typ: type) -> bool:
|
|
30
35
|
"""If the given type is `typing.Iterable[T]`"""
|
|
31
36
|
origin = get_origin(typ) or typ
|
anchorbrowser/_utils/_utils.py
CHANGED
|
@@ -21,8 +21,7 @@ from typing_extensions import TypeGuard
|
|
|
21
21
|
|
|
22
22
|
import sniffio
|
|
23
23
|
|
|
24
|
-
from .._types import NotGiven, FileTypes,
|
|
25
|
-
from .._compat import parse_date as parse_date, parse_datetime as parse_datetime
|
|
24
|
+
from .._types import Omit, NotGiven, FileTypes, HeadersLike
|
|
26
25
|
|
|
27
26
|
_T = TypeVar("_T")
|
|
28
27
|
_TupleT = TypeVar("_TupleT", bound=Tuple[object, ...])
|
|
@@ -64,7 +63,7 @@ def _extract_items(
|
|
|
64
63
|
try:
|
|
65
64
|
key = path[index]
|
|
66
65
|
except IndexError:
|
|
67
|
-
if
|
|
66
|
+
if not is_given(obj):
|
|
68
67
|
# no value was provided - we can safely ignore
|
|
69
68
|
return []
|
|
70
69
|
|
|
@@ -127,8 +126,8 @@ def _extract_items(
|
|
|
127
126
|
return []
|
|
128
127
|
|
|
129
128
|
|
|
130
|
-
def is_given(obj:
|
|
131
|
-
return not isinstance(obj, NotGiven)
|
|
129
|
+
def is_given(obj: _T | NotGiven | Omit) -> TypeGuard[_T]:
|
|
130
|
+
return not isinstance(obj, NotGiven) and not isinstance(obj, Omit)
|
|
132
131
|
|
|
133
132
|
|
|
134
133
|
# Type safe methods for narrowing types with TypeVars.
|
anchorbrowser/_version.py
CHANGED
anchorbrowser/lib/browser.py
CHANGED
|
@@ -53,7 +53,7 @@ def get_cdp_url(api_base_url: str, session_id: str, api_key: str) -> str:
|
|
|
53
53
|
|
|
54
54
|
|
|
55
55
|
def get_agent_ws_url(api_base_url: str, session_id: str) -> str:
|
|
56
|
-
return f"{api_base_url.replace('https://', 'wss://')
|
|
56
|
+
return f"{api_base_url.replace('https://', 'wss://')}/ws?sessionId={session_id}"
|
|
57
57
|
|
|
58
58
|
|
|
59
59
|
def get_ai_service_worker(browser_context: "BrowserContext") -> Optional["Worker"]:
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
|
+
from .task import (
|
|
4
|
+
TaskResource,
|
|
5
|
+
AsyncTaskResource,
|
|
6
|
+
TaskResourceWithRawResponse,
|
|
7
|
+
AsyncTaskResourceWithRawResponse,
|
|
8
|
+
TaskResourceWithStreamingResponse,
|
|
9
|
+
AsyncTaskResourceWithStreamingResponse,
|
|
10
|
+
)
|
|
3
11
|
from .tools import (
|
|
4
12
|
ToolsResource,
|
|
5
13
|
AsyncToolsResource,
|
|
@@ -8,6 +16,14 @@ from .tools import (
|
|
|
8
16
|
ToolsResourceWithStreamingResponse,
|
|
9
17
|
AsyncToolsResourceWithStreamingResponse,
|
|
10
18
|
)
|
|
19
|
+
from .events import (
|
|
20
|
+
EventsResource,
|
|
21
|
+
AsyncEventsResource,
|
|
22
|
+
EventsResourceWithRawResponse,
|
|
23
|
+
AsyncEventsResourceWithRawResponse,
|
|
24
|
+
EventsResourceWithStreamingResponse,
|
|
25
|
+
AsyncEventsResourceWithStreamingResponse,
|
|
26
|
+
)
|
|
11
27
|
from .profiles import (
|
|
12
28
|
ProfilesResource,
|
|
13
29
|
AsyncProfilesResource,
|
|
@@ -32,6 +48,14 @@ from .extensions import (
|
|
|
32
48
|
ExtensionsResourceWithStreamingResponse,
|
|
33
49
|
AsyncExtensionsResourceWithStreamingResponse,
|
|
34
50
|
)
|
|
51
|
+
from .batch_sessions import (
|
|
52
|
+
BatchSessionsResource,
|
|
53
|
+
AsyncBatchSessionsResource,
|
|
54
|
+
BatchSessionsResourceWithRawResponse,
|
|
55
|
+
AsyncBatchSessionsResourceWithRawResponse,
|
|
56
|
+
BatchSessionsResourceWithStreamingResponse,
|
|
57
|
+
AsyncBatchSessionsResourceWithStreamingResponse,
|
|
58
|
+
)
|
|
35
59
|
|
|
36
60
|
__all__ = [
|
|
37
61
|
"ProfilesResource",
|
|
@@ -58,4 +82,22 @@ __all__ = [
|
|
|
58
82
|
"AsyncExtensionsResourceWithRawResponse",
|
|
59
83
|
"ExtensionsResourceWithStreamingResponse",
|
|
60
84
|
"AsyncExtensionsResourceWithStreamingResponse",
|
|
85
|
+
"EventsResource",
|
|
86
|
+
"AsyncEventsResource",
|
|
87
|
+
"EventsResourceWithRawResponse",
|
|
88
|
+
"AsyncEventsResourceWithRawResponse",
|
|
89
|
+
"EventsResourceWithStreamingResponse",
|
|
90
|
+
"AsyncEventsResourceWithStreamingResponse",
|
|
91
|
+
"BatchSessionsResource",
|
|
92
|
+
"AsyncBatchSessionsResource",
|
|
93
|
+
"BatchSessionsResourceWithRawResponse",
|
|
94
|
+
"AsyncBatchSessionsResourceWithRawResponse",
|
|
95
|
+
"BatchSessionsResourceWithStreamingResponse",
|
|
96
|
+
"AsyncBatchSessionsResourceWithStreamingResponse",
|
|
97
|
+
"TaskResource",
|
|
98
|
+
"AsyncTaskResource",
|
|
99
|
+
"TaskResourceWithRawResponse",
|
|
100
|
+
"AsyncTaskResourceWithRawResponse",
|
|
101
|
+
"TaskResourceWithStreamingResponse",
|
|
102
|
+
"AsyncTaskResourceWithStreamingResponse",
|
|
61
103
|
]
|
|
@@ -0,0 +1,288 @@
|
|
|
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 Dict
|
|
6
|
+
|
|
7
|
+
import httpx
|
|
8
|
+
|
|
9
|
+
from ..types import batch_session_create_params
|
|
10
|
+
from .._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
|
|
11
|
+
from .._utils import maybe_transform, async_maybe_transform
|
|
12
|
+
from .._compat import cached_property
|
|
13
|
+
from .._resource import SyncAPIResource, AsyncAPIResource
|
|
14
|
+
from .._response import (
|
|
15
|
+
to_raw_response_wrapper,
|
|
16
|
+
to_streamed_response_wrapper,
|
|
17
|
+
async_to_raw_response_wrapper,
|
|
18
|
+
async_to_streamed_response_wrapper,
|
|
19
|
+
)
|
|
20
|
+
from .._base_client import make_request_options
|
|
21
|
+
from ..types.batch_session_create_response import BatchSessionCreateResponse
|
|
22
|
+
from ..types.batch_session_retrieve_response import BatchSessionRetrieveResponse
|
|
23
|
+
|
|
24
|
+
__all__ = ["BatchSessionsResource", "AsyncBatchSessionsResource"]
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class BatchSessionsResource(SyncAPIResource):
|
|
28
|
+
@cached_property
|
|
29
|
+
def with_raw_response(self) -> BatchSessionsResourceWithRawResponse:
|
|
30
|
+
"""
|
|
31
|
+
This property can be used as a prefix for any HTTP method call to return
|
|
32
|
+
the raw response object instead of the parsed content.
|
|
33
|
+
|
|
34
|
+
For more information, see https://www.github.com/anchorbrowser/AnchorBrowser-SDK-Python#accessing-raw-response-data-eg-headers
|
|
35
|
+
"""
|
|
36
|
+
return BatchSessionsResourceWithRawResponse(self)
|
|
37
|
+
|
|
38
|
+
@cached_property
|
|
39
|
+
def with_streaming_response(self) -> BatchSessionsResourceWithStreamingResponse:
|
|
40
|
+
"""
|
|
41
|
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
|
42
|
+
|
|
43
|
+
For more information, see https://www.github.com/anchorbrowser/AnchorBrowser-SDK-Python#with_streaming_response
|
|
44
|
+
"""
|
|
45
|
+
return BatchSessionsResourceWithStreamingResponse(self)
|
|
46
|
+
|
|
47
|
+
def create(
|
|
48
|
+
self,
|
|
49
|
+
*,
|
|
50
|
+
count: int,
|
|
51
|
+
configuration: batch_session_create_params.Configuration | Omit = omit,
|
|
52
|
+
metadata: Dict[str, object] | Omit = omit,
|
|
53
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
54
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
55
|
+
extra_headers: Headers | None = None,
|
|
56
|
+
extra_query: Query | None = None,
|
|
57
|
+
extra_body: Body | None = None,
|
|
58
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
59
|
+
) -> BatchSessionCreateResponse:
|
|
60
|
+
"""Creates multiple browser sessions in a single batch operation.
|
|
61
|
+
|
|
62
|
+
This endpoint
|
|
63
|
+
allows you to create up to 5,000 browser sessions simultaneously with the same
|
|
64
|
+
configuration.
|
|
65
|
+
|
|
66
|
+
The batch will be processed asynchronously, and you can monitor progress using
|
|
67
|
+
the batch status endpoint.
|
|
68
|
+
|
|
69
|
+
Args:
|
|
70
|
+
count: Number of sessions to create in the batch (1-1000)
|
|
71
|
+
|
|
72
|
+
configuration: Configuration that applies to all sessions in the batch
|
|
73
|
+
|
|
74
|
+
metadata: Optional batch-level metadata for identification and organization
|
|
75
|
+
|
|
76
|
+
extra_headers: Send extra headers
|
|
77
|
+
|
|
78
|
+
extra_query: Add additional query parameters to the request
|
|
79
|
+
|
|
80
|
+
extra_body: Add additional JSON properties to the request
|
|
81
|
+
|
|
82
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
83
|
+
"""
|
|
84
|
+
return self._post(
|
|
85
|
+
"/v1/batch-sessions",
|
|
86
|
+
body=maybe_transform(
|
|
87
|
+
{
|
|
88
|
+
"count": count,
|
|
89
|
+
"configuration": configuration,
|
|
90
|
+
"metadata": metadata,
|
|
91
|
+
},
|
|
92
|
+
batch_session_create_params.BatchSessionCreateParams,
|
|
93
|
+
),
|
|
94
|
+
options=make_request_options(
|
|
95
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
96
|
+
),
|
|
97
|
+
cast_to=BatchSessionCreateResponse,
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
def retrieve(
|
|
101
|
+
self,
|
|
102
|
+
batch_id: str,
|
|
103
|
+
*,
|
|
104
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
105
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
106
|
+
extra_headers: Headers | None = None,
|
|
107
|
+
extra_query: Query | None = None,
|
|
108
|
+
extra_body: Body | None = None,
|
|
109
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
110
|
+
) -> BatchSessionRetrieveResponse:
|
|
111
|
+
"""
|
|
112
|
+
Retrieves detailed status information for a specific batch, including progress,
|
|
113
|
+
individual session details, and any errors that occurred.
|
|
114
|
+
|
|
115
|
+
Args:
|
|
116
|
+
extra_headers: Send extra headers
|
|
117
|
+
|
|
118
|
+
extra_query: Add additional query parameters to the request
|
|
119
|
+
|
|
120
|
+
extra_body: Add additional JSON properties to the request
|
|
121
|
+
|
|
122
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
123
|
+
"""
|
|
124
|
+
if not batch_id:
|
|
125
|
+
raise ValueError(f"Expected a non-empty value for `batch_id` but received {batch_id!r}")
|
|
126
|
+
return self._get(
|
|
127
|
+
f"/v1/batch-sessions/{batch_id}",
|
|
128
|
+
options=make_request_options(
|
|
129
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
130
|
+
),
|
|
131
|
+
cast_to=BatchSessionRetrieveResponse,
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
class AsyncBatchSessionsResource(AsyncAPIResource):
|
|
136
|
+
@cached_property
|
|
137
|
+
def with_raw_response(self) -> AsyncBatchSessionsResourceWithRawResponse:
|
|
138
|
+
"""
|
|
139
|
+
This property can be used as a prefix for any HTTP method call to return
|
|
140
|
+
the raw response object instead of the parsed content.
|
|
141
|
+
|
|
142
|
+
For more information, see https://www.github.com/anchorbrowser/AnchorBrowser-SDK-Python#accessing-raw-response-data-eg-headers
|
|
143
|
+
"""
|
|
144
|
+
return AsyncBatchSessionsResourceWithRawResponse(self)
|
|
145
|
+
|
|
146
|
+
@cached_property
|
|
147
|
+
def with_streaming_response(self) -> AsyncBatchSessionsResourceWithStreamingResponse:
|
|
148
|
+
"""
|
|
149
|
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
|
150
|
+
|
|
151
|
+
For more information, see https://www.github.com/anchorbrowser/AnchorBrowser-SDK-Python#with_streaming_response
|
|
152
|
+
"""
|
|
153
|
+
return AsyncBatchSessionsResourceWithStreamingResponse(self)
|
|
154
|
+
|
|
155
|
+
async def create(
|
|
156
|
+
self,
|
|
157
|
+
*,
|
|
158
|
+
count: int,
|
|
159
|
+
configuration: batch_session_create_params.Configuration | Omit = omit,
|
|
160
|
+
metadata: Dict[str, object] | Omit = omit,
|
|
161
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
162
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
163
|
+
extra_headers: Headers | None = None,
|
|
164
|
+
extra_query: Query | None = None,
|
|
165
|
+
extra_body: Body | None = None,
|
|
166
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
167
|
+
) -> BatchSessionCreateResponse:
|
|
168
|
+
"""Creates multiple browser sessions in a single batch operation.
|
|
169
|
+
|
|
170
|
+
This endpoint
|
|
171
|
+
allows you to create up to 5,000 browser sessions simultaneously with the same
|
|
172
|
+
configuration.
|
|
173
|
+
|
|
174
|
+
The batch will be processed asynchronously, and you can monitor progress using
|
|
175
|
+
the batch status endpoint.
|
|
176
|
+
|
|
177
|
+
Args:
|
|
178
|
+
count: Number of sessions to create in the batch (1-1000)
|
|
179
|
+
|
|
180
|
+
configuration: Configuration that applies to all sessions in the batch
|
|
181
|
+
|
|
182
|
+
metadata: Optional batch-level metadata for identification and organization
|
|
183
|
+
|
|
184
|
+
extra_headers: Send extra headers
|
|
185
|
+
|
|
186
|
+
extra_query: Add additional query parameters to the request
|
|
187
|
+
|
|
188
|
+
extra_body: Add additional JSON properties to the request
|
|
189
|
+
|
|
190
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
191
|
+
"""
|
|
192
|
+
return await self._post(
|
|
193
|
+
"/v1/batch-sessions",
|
|
194
|
+
body=await async_maybe_transform(
|
|
195
|
+
{
|
|
196
|
+
"count": count,
|
|
197
|
+
"configuration": configuration,
|
|
198
|
+
"metadata": metadata,
|
|
199
|
+
},
|
|
200
|
+
batch_session_create_params.BatchSessionCreateParams,
|
|
201
|
+
),
|
|
202
|
+
options=make_request_options(
|
|
203
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
204
|
+
),
|
|
205
|
+
cast_to=BatchSessionCreateResponse,
|
|
206
|
+
)
|
|
207
|
+
|
|
208
|
+
async def retrieve(
|
|
209
|
+
self,
|
|
210
|
+
batch_id: str,
|
|
211
|
+
*,
|
|
212
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
213
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
214
|
+
extra_headers: Headers | None = None,
|
|
215
|
+
extra_query: Query | None = None,
|
|
216
|
+
extra_body: Body | None = None,
|
|
217
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
218
|
+
) -> BatchSessionRetrieveResponse:
|
|
219
|
+
"""
|
|
220
|
+
Retrieves detailed status information for a specific batch, including progress,
|
|
221
|
+
individual session details, and any errors that occurred.
|
|
222
|
+
|
|
223
|
+
Args:
|
|
224
|
+
extra_headers: Send extra headers
|
|
225
|
+
|
|
226
|
+
extra_query: Add additional query parameters to the request
|
|
227
|
+
|
|
228
|
+
extra_body: Add additional JSON properties to the request
|
|
229
|
+
|
|
230
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
231
|
+
"""
|
|
232
|
+
if not batch_id:
|
|
233
|
+
raise ValueError(f"Expected a non-empty value for `batch_id` but received {batch_id!r}")
|
|
234
|
+
return await self._get(
|
|
235
|
+
f"/v1/batch-sessions/{batch_id}",
|
|
236
|
+
options=make_request_options(
|
|
237
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
238
|
+
),
|
|
239
|
+
cast_to=BatchSessionRetrieveResponse,
|
|
240
|
+
)
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
class BatchSessionsResourceWithRawResponse:
|
|
244
|
+
def __init__(self, batch_sessions: BatchSessionsResource) -> None:
|
|
245
|
+
self._batch_sessions = batch_sessions
|
|
246
|
+
|
|
247
|
+
self.create = to_raw_response_wrapper(
|
|
248
|
+
batch_sessions.create,
|
|
249
|
+
)
|
|
250
|
+
self.retrieve = to_raw_response_wrapper(
|
|
251
|
+
batch_sessions.retrieve,
|
|
252
|
+
)
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
class AsyncBatchSessionsResourceWithRawResponse:
|
|
256
|
+
def __init__(self, batch_sessions: AsyncBatchSessionsResource) -> None:
|
|
257
|
+
self._batch_sessions = batch_sessions
|
|
258
|
+
|
|
259
|
+
self.create = async_to_raw_response_wrapper(
|
|
260
|
+
batch_sessions.create,
|
|
261
|
+
)
|
|
262
|
+
self.retrieve = async_to_raw_response_wrapper(
|
|
263
|
+
batch_sessions.retrieve,
|
|
264
|
+
)
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
class BatchSessionsResourceWithStreamingResponse:
|
|
268
|
+
def __init__(self, batch_sessions: BatchSessionsResource) -> None:
|
|
269
|
+
self._batch_sessions = batch_sessions
|
|
270
|
+
|
|
271
|
+
self.create = to_streamed_response_wrapper(
|
|
272
|
+
batch_sessions.create,
|
|
273
|
+
)
|
|
274
|
+
self.retrieve = to_streamed_response_wrapper(
|
|
275
|
+
batch_sessions.retrieve,
|
|
276
|
+
)
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
class AsyncBatchSessionsResourceWithStreamingResponse:
|
|
280
|
+
def __init__(self, batch_sessions: AsyncBatchSessionsResource) -> None:
|
|
281
|
+
self._batch_sessions = batch_sessions
|
|
282
|
+
|
|
283
|
+
self.create = async_to_streamed_response_wrapper(
|
|
284
|
+
batch_sessions.create,
|
|
285
|
+
)
|
|
286
|
+
self.retrieve = async_to_streamed_response_wrapper(
|
|
287
|
+
batch_sessions.retrieve,
|
|
288
|
+
)
|