anchorbrowser 0.1.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 +100 -0
- anchorbrowser/_base_client.py +1995 -0
- anchorbrowser/_client.py +440 -0
- anchorbrowser/_compat.py +219 -0
- anchorbrowser/_constants.py +14 -0
- anchorbrowser/_exceptions.py +108 -0
- anchorbrowser/_files.py +123 -0
- anchorbrowser/_models.py +829 -0
- anchorbrowser/_qs.py +150 -0
- anchorbrowser/_resource.py +43 -0
- anchorbrowser/_response.py +832 -0
- anchorbrowser/_streaming.py +333 -0
- anchorbrowser/_types.py +219 -0
- anchorbrowser/_utils/__init__.py +57 -0
- anchorbrowser/_utils/_logs.py +25 -0
- anchorbrowser/_utils/_proxy.py +65 -0
- anchorbrowser/_utils/_reflection.py +42 -0
- anchorbrowser/_utils/_resources_proxy.py +24 -0
- anchorbrowser/_utils/_streams.py +12 -0
- anchorbrowser/_utils/_sync.py +86 -0
- anchorbrowser/_utils/_transform.py +447 -0
- anchorbrowser/_utils/_typing.py +151 -0
- anchorbrowser/_utils/_utils.py +422 -0
- anchorbrowser/_version.py +4 -0
- anchorbrowser/lib/.keep +4 -0
- anchorbrowser/lib/agent.py +69 -0
- anchorbrowser/lib/browser.py +186 -0
- anchorbrowser/py.typed +0 -0
- anchorbrowser/resources/__init__.py +61 -0
- anchorbrowser/resources/agent.py +305 -0
- anchorbrowser/resources/browser.py +152 -0
- anchorbrowser/resources/extensions.py +412 -0
- anchorbrowser/resources/profiles.py +553 -0
- anchorbrowser/resources/sessions/__init__.py +89 -0
- anchorbrowser/resources/sessions/all.py +192 -0
- anchorbrowser/resources/sessions/clipboard.py +252 -0
- anchorbrowser/resources/sessions/keyboard.py +298 -0
- anchorbrowser/resources/sessions/mouse.py +651 -0
- anchorbrowser/resources/sessions/recordings/__init__.py +33 -0
- anchorbrowser/resources/sessions/recordings/primary.py +176 -0
- anchorbrowser/resources/sessions/recordings/recordings.py +357 -0
- anchorbrowser/resources/sessions/sessions.py +1122 -0
- anchorbrowser/resources/tools.py +529 -0
- anchorbrowser/types/__init__.py +32 -0
- anchorbrowser/types/extension_delete_response.py +12 -0
- anchorbrowser/types/extension_list_response.py +31 -0
- anchorbrowser/types/extension_manifest.py +28 -0
- anchorbrowser/types/extension_retrieve_response.py +27 -0
- anchorbrowser/types/extension_upload_params.py +17 -0
- anchorbrowser/types/extension_upload_response.py +31 -0
- anchorbrowser/types/profile_create_params.py +31 -0
- anchorbrowser/types/profile_list_response.py +43 -0
- anchorbrowser/types/profile_retrieve_response.py +36 -0
- anchorbrowser/types/profile_update_params.py +27 -0
- anchorbrowser/types/session_copy_response.py +12 -0
- anchorbrowser/types/session_create_params.py +196 -0
- anchorbrowser/types/session_create_response.py +22 -0
- anchorbrowser/types/session_drag_and_drop_params.py +26 -0
- anchorbrowser/types/session_drag_and_drop_response.py +11 -0
- anchorbrowser/types/session_goto_params.py +12 -0
- anchorbrowser/types/session_goto_response.py +11 -0
- anchorbrowser/types/session_paste_params.py +12 -0
- anchorbrowser/types/session_paste_response.py +11 -0
- anchorbrowser/types/session_retrieve_downloads_response.py +51 -0
- anchorbrowser/types/session_scroll_params.py +26 -0
- anchorbrowser/types/session_scroll_response.py +11 -0
- anchorbrowser/types/sessions/__init__.py +25 -0
- anchorbrowser/types/sessions/all_status_response.py +30 -0
- anchorbrowser/types/sessions/clipboard_get_response.py +16 -0
- anchorbrowser/types/sessions/clipboard_set_params.py +12 -0
- anchorbrowser/types/sessions/clipboard_set_response.py +11 -0
- anchorbrowser/types/sessions/keyboard_shortcut_params.py +18 -0
- anchorbrowser/types/sessions/keyboard_shortcut_response.py +11 -0
- anchorbrowser/types/sessions/keyboard_type_params.py +15 -0
- anchorbrowser/types/sessions/keyboard_type_response.py +11 -0
- anchorbrowser/types/sessions/mouse_click_params.py +18 -0
- anchorbrowser/types/sessions/mouse_click_response.py +11 -0
- anchorbrowser/types/sessions/mouse_double_click_params.py +18 -0
- anchorbrowser/types/sessions/mouse_double_click_response.py +11 -0
- anchorbrowser/types/sessions/mouse_down_params.py +18 -0
- anchorbrowser/types/sessions/mouse_down_response.py +11 -0
- anchorbrowser/types/sessions/mouse_move_params.py +15 -0
- anchorbrowser/types/sessions/mouse_move_response.py +11 -0
- anchorbrowser/types/sessions/mouse_up_params.py +18 -0
- anchorbrowser/types/sessions/mouse_up_response.py +11 -0
- anchorbrowser/types/sessions/recording_list_response.py +46 -0
- anchorbrowser/types/sessions/recording_pause_response.py +12 -0
- anchorbrowser/types/sessions/recording_resume_response.py +12 -0
- anchorbrowser/types/sessions/recordings/__init__.py +3 -0
- anchorbrowser/types/shared/__init__.py +3 -0
- anchorbrowser/types/shared/success_response.py +15 -0
- anchorbrowser/types/tool_fetch_webpage_params.py +26 -0
- anchorbrowser/types/tool_fetch_webpage_response.py +7 -0
- anchorbrowser/types/tool_perform_web_task_params.py +30 -0
- anchorbrowser/types/tool_perform_web_task_response.py +16 -0
- anchorbrowser/types/tool_screenshot_webpage_params.py +48 -0
- anchorbrowser-0.1.0.dist-info/METADATA +449 -0
- anchorbrowser-0.1.0.dist-info/RECORD +100 -0
- anchorbrowser-0.1.0.dist-info/WHEEL +4 -0
- anchorbrowser-0.1.0.dist-info/licenses/LICENSE +201 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from contextlib import _GeneratorContextManager, _AsyncGeneratorContextManager
|
|
4
|
+
|
|
5
|
+
from playwright.sync_api import Browser
|
|
6
|
+
from playwright.async_api import Browser as AsyncBrowser
|
|
7
|
+
|
|
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 ..lib.browser import (
|
|
17
|
+
get_playwright_chromium_from_cdp_url,
|
|
18
|
+
get_async_playwright_chromium_from_cdp_url,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
__all__ = ["BrowserResource", "AsyncBrowserResource"]
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class BrowserResource(SyncAPIResource):
|
|
25
|
+
@cached_property
|
|
26
|
+
def with_raw_response(self) -> BrowserResourceWithRawResponse:
|
|
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/anchorbrowser/AnchorBrowser-SDK-Python#accessing-raw-response-data-eg-headers
|
|
32
|
+
"""
|
|
33
|
+
return BrowserResourceWithRawResponse(self)
|
|
34
|
+
|
|
35
|
+
@cached_property
|
|
36
|
+
def with_streaming_response(self) -> BrowserResourceWithStreamingResponse:
|
|
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/anchorbrowser/AnchorBrowser-SDK-Python#with_streaming_response
|
|
41
|
+
"""
|
|
42
|
+
return BrowserResourceWithStreamingResponse(self)
|
|
43
|
+
|
|
44
|
+
def connect(self, session_id: str) -> _GeneratorContextManager[Browser]:
|
|
45
|
+
"""Connect to a browser session.
|
|
46
|
+
|
|
47
|
+
Args:
|
|
48
|
+
session_id (str): The ID of the session to connect to.
|
|
49
|
+
|
|
50
|
+
Returns:
|
|
51
|
+
BrowserContext: a context manager that can be used to interact with the browser(playwright)
|
|
52
|
+
"""
|
|
53
|
+
return get_playwright_chromium_from_cdp_url(str(self._client.base_url), session_id, self._client.api_key)
|
|
54
|
+
|
|
55
|
+
def create(self) -> _GeneratorContextManager[Browser]:
|
|
56
|
+
session = self._client.sessions.create()
|
|
57
|
+
if not session.data or not session.data.id:
|
|
58
|
+
raise ValueError("Failed to create session")
|
|
59
|
+
return get_playwright_chromium_from_cdp_url(str(self._client.base_url), session.data.id, self._client.api_key)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class AsyncBrowserResource(AsyncAPIResource):
|
|
63
|
+
@cached_property
|
|
64
|
+
def with_raw_response(self) -> AsyncBrowserResourceWithRawResponse:
|
|
65
|
+
"""
|
|
66
|
+
This property can be used as a prefix for any HTTP method call to return
|
|
67
|
+
the raw response object instead of the parsed content.
|
|
68
|
+
|
|
69
|
+
For more information, see https://www.github.com/anchorbrowser/AnchorBrowser-SDK-Python#accessing-raw-response-data-eg-headers
|
|
70
|
+
"""
|
|
71
|
+
return AsyncBrowserResourceWithRawResponse(self)
|
|
72
|
+
|
|
73
|
+
@cached_property
|
|
74
|
+
def with_streaming_response(self) -> AsyncBrowserResourceWithStreamingResponse:
|
|
75
|
+
"""
|
|
76
|
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
|
77
|
+
|
|
78
|
+
For more information, see https://www.github.com/anchorbrowser/AnchorBrowser-SDK-Python#with_streaming_response
|
|
79
|
+
"""
|
|
80
|
+
return AsyncBrowserResourceWithStreamingResponse(self)
|
|
81
|
+
|
|
82
|
+
async def connect(self, session_id: str) -> _AsyncGeneratorContextManager[AsyncBrowser]:
|
|
83
|
+
"""Connect to a browser session.
|
|
84
|
+
|
|
85
|
+
Args:
|
|
86
|
+
session_id (str): The ID of the session to connect to.
|
|
87
|
+
|
|
88
|
+
Returns:
|
|
89
|
+
BrowserContext: a context manager that can be used to interact with the browser(playwright)
|
|
90
|
+
"""
|
|
91
|
+
return get_async_playwright_chromium_from_cdp_url(str(self._client.base_url), session_id, self._client.api_key)
|
|
92
|
+
|
|
93
|
+
async def create(self) -> _AsyncGeneratorContextManager[AsyncBrowser]:
|
|
94
|
+
"""Create a new browser session.
|
|
95
|
+
|
|
96
|
+
Returns:
|
|
97
|
+
BrowserContext: a context manager that can be used to interact with the browser(playwright)
|
|
98
|
+
"""
|
|
99
|
+
session = await self._client.sessions.create()
|
|
100
|
+
if not session.data or not session.data.id:
|
|
101
|
+
raise ValueError("Failed to create session")
|
|
102
|
+
return get_async_playwright_chromium_from_cdp_url(
|
|
103
|
+
str(self._client.base_url), session.data.id, self._client.api_key
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
class BrowserResourceWithRawResponse:
|
|
108
|
+
def __init__(self, browser: BrowserResource) -> None:
|
|
109
|
+
self._browser = browser
|
|
110
|
+
|
|
111
|
+
self.connect = to_raw_response_wrapper(
|
|
112
|
+
browser.connect,
|
|
113
|
+
)
|
|
114
|
+
self.create = to_raw_response_wrapper(
|
|
115
|
+
browser.create,
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
class AsyncBrowserResourceWithRawResponse:
|
|
120
|
+
def __init__(self, browser: AsyncBrowserResource) -> None:
|
|
121
|
+
self._browser = browser
|
|
122
|
+
|
|
123
|
+
self.connect = async_to_raw_response_wrapper(
|
|
124
|
+
browser.connect,
|
|
125
|
+
)
|
|
126
|
+
self.create = async_to_raw_response_wrapper(
|
|
127
|
+
browser.create,
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
class BrowserResourceWithStreamingResponse:
|
|
132
|
+
def __init__(self, browser: BrowserResource) -> None:
|
|
133
|
+
self._browser = browser
|
|
134
|
+
|
|
135
|
+
self.connect = to_streamed_response_wrapper(
|
|
136
|
+
browser.connect,
|
|
137
|
+
)
|
|
138
|
+
self.create = to_streamed_response_wrapper(
|
|
139
|
+
browser.create,
|
|
140
|
+
)
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
class AsyncBrowserResourceWithStreamingResponse:
|
|
144
|
+
def __init__(self, browser: AsyncBrowserResource) -> None:
|
|
145
|
+
self._browser = browser
|
|
146
|
+
|
|
147
|
+
self.connect = async_to_streamed_response_wrapper(
|
|
148
|
+
browser.connect,
|
|
149
|
+
)
|
|
150
|
+
self.create = async_to_streamed_response_wrapper(
|
|
151
|
+
browser.create,
|
|
152
|
+
)
|
|
@@ -0,0 +1,412 @@
|
|
|
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 Mapping, cast
|
|
6
|
+
|
|
7
|
+
import httpx
|
|
8
|
+
|
|
9
|
+
from ..types import extension_upload_params
|
|
10
|
+
from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven, FileTypes
|
|
11
|
+
from .._utils import extract_files, maybe_transform, deepcopy_minimal, 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.extension_list_response import ExtensionListResponse
|
|
22
|
+
from ..types.extension_delete_response import ExtensionDeleteResponse
|
|
23
|
+
from ..types.extension_upload_response import ExtensionUploadResponse
|
|
24
|
+
from ..types.extension_retrieve_response import ExtensionRetrieveResponse
|
|
25
|
+
|
|
26
|
+
__all__ = ["ExtensionsResource", "AsyncExtensionsResource"]
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class ExtensionsResource(SyncAPIResource):
|
|
30
|
+
@cached_property
|
|
31
|
+
def with_raw_response(self) -> ExtensionsResourceWithRawResponse:
|
|
32
|
+
"""
|
|
33
|
+
This property can be used as a prefix for any HTTP method call to return
|
|
34
|
+
the raw response object instead of the parsed content.
|
|
35
|
+
|
|
36
|
+
For more information, see https://www.github.com/anchorbrowser/AnchorBrowser-SDK-Python#accessing-raw-response-data-eg-headers
|
|
37
|
+
"""
|
|
38
|
+
return ExtensionsResourceWithRawResponse(self)
|
|
39
|
+
|
|
40
|
+
@cached_property
|
|
41
|
+
def with_streaming_response(self) -> ExtensionsResourceWithStreamingResponse:
|
|
42
|
+
"""
|
|
43
|
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
|
44
|
+
|
|
45
|
+
For more information, see https://www.github.com/anchorbrowser/AnchorBrowser-SDK-Python#with_streaming_response
|
|
46
|
+
"""
|
|
47
|
+
return ExtensionsResourceWithStreamingResponse(self)
|
|
48
|
+
|
|
49
|
+
def retrieve(
|
|
50
|
+
self,
|
|
51
|
+
id: str,
|
|
52
|
+
*,
|
|
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
|
+
) -> ExtensionRetrieveResponse:
|
|
60
|
+
"""
|
|
61
|
+
Get details of a specific extension by its ID
|
|
62
|
+
|
|
63
|
+
Args:
|
|
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 id:
|
|
73
|
+
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
|
|
74
|
+
return self._get(
|
|
75
|
+
f"/v1/extensions/{id}",
|
|
76
|
+
options=make_request_options(
|
|
77
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
78
|
+
),
|
|
79
|
+
cast_to=ExtensionRetrieveResponse,
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
def list(
|
|
83
|
+
self,
|
|
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
|
+
) -> ExtensionListResponse:
|
|
92
|
+
"""Get all extensions for the authenticated user"""
|
|
93
|
+
return self._get(
|
|
94
|
+
"/v1/extensions",
|
|
95
|
+
options=make_request_options(
|
|
96
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
97
|
+
),
|
|
98
|
+
cast_to=ExtensionListResponse,
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
def delete(
|
|
102
|
+
self,
|
|
103
|
+
id: str,
|
|
104
|
+
*,
|
|
105
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
106
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
107
|
+
extra_headers: Headers | None = None,
|
|
108
|
+
extra_query: Query | None = None,
|
|
109
|
+
extra_body: Body | None = None,
|
|
110
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
111
|
+
) -> ExtensionDeleteResponse:
|
|
112
|
+
"""
|
|
113
|
+
Delete an extension and remove it from storage
|
|
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 id:
|
|
125
|
+
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
|
|
126
|
+
return self._delete(
|
|
127
|
+
f"/v1/extensions/{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=ExtensionDeleteResponse,
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
def upload(
|
|
135
|
+
self,
|
|
136
|
+
*,
|
|
137
|
+
file: FileTypes,
|
|
138
|
+
name: str,
|
|
139
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
140
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
141
|
+
extra_headers: Headers | None = None,
|
|
142
|
+
extra_query: Query | None = None,
|
|
143
|
+
extra_body: Body | None = None,
|
|
144
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
145
|
+
) -> ExtensionUploadResponse:
|
|
146
|
+
"""Upload a new browser extension as a ZIP file.
|
|
147
|
+
|
|
148
|
+
The extension will be validated
|
|
149
|
+
and stored for use in browser sessions.
|
|
150
|
+
|
|
151
|
+
Args:
|
|
152
|
+
file: ZIP file containing the browser extension
|
|
153
|
+
|
|
154
|
+
name: User-friendly name for the extension (1-255 characters)
|
|
155
|
+
|
|
156
|
+
extra_headers: Send extra headers
|
|
157
|
+
|
|
158
|
+
extra_query: Add additional query parameters to the request
|
|
159
|
+
|
|
160
|
+
extra_body: Add additional JSON properties to the request
|
|
161
|
+
|
|
162
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
163
|
+
"""
|
|
164
|
+
body = deepcopy_minimal(
|
|
165
|
+
{
|
|
166
|
+
"file": file,
|
|
167
|
+
"name": name,
|
|
168
|
+
}
|
|
169
|
+
)
|
|
170
|
+
files = extract_files(cast(Mapping[str, object], body), paths=[["file"]])
|
|
171
|
+
# It should be noted that the actual Content-Type header that will be
|
|
172
|
+
# sent to the server will contain a `boundary` parameter, e.g.
|
|
173
|
+
# multipart/form-data; boundary=---abc--
|
|
174
|
+
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
|
|
175
|
+
return self._post(
|
|
176
|
+
"/v1/extensions",
|
|
177
|
+
body=maybe_transform(body, extension_upload_params.ExtensionUploadParams),
|
|
178
|
+
files=files,
|
|
179
|
+
options=make_request_options(
|
|
180
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
181
|
+
),
|
|
182
|
+
cast_to=ExtensionUploadResponse,
|
|
183
|
+
)
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
class AsyncExtensionsResource(AsyncAPIResource):
|
|
187
|
+
@cached_property
|
|
188
|
+
def with_raw_response(self) -> AsyncExtensionsResourceWithRawResponse:
|
|
189
|
+
"""
|
|
190
|
+
This property can be used as a prefix for any HTTP method call to return
|
|
191
|
+
the raw response object instead of the parsed content.
|
|
192
|
+
|
|
193
|
+
For more information, see https://www.github.com/anchorbrowser/AnchorBrowser-SDK-Python#accessing-raw-response-data-eg-headers
|
|
194
|
+
"""
|
|
195
|
+
return AsyncExtensionsResourceWithRawResponse(self)
|
|
196
|
+
|
|
197
|
+
@cached_property
|
|
198
|
+
def with_streaming_response(self) -> AsyncExtensionsResourceWithStreamingResponse:
|
|
199
|
+
"""
|
|
200
|
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
|
201
|
+
|
|
202
|
+
For more information, see https://www.github.com/anchorbrowser/AnchorBrowser-SDK-Python#with_streaming_response
|
|
203
|
+
"""
|
|
204
|
+
return AsyncExtensionsResourceWithStreamingResponse(self)
|
|
205
|
+
|
|
206
|
+
async def retrieve(
|
|
207
|
+
self,
|
|
208
|
+
id: str,
|
|
209
|
+
*,
|
|
210
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
211
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
212
|
+
extra_headers: Headers | None = None,
|
|
213
|
+
extra_query: Query | None = None,
|
|
214
|
+
extra_body: Body | None = None,
|
|
215
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
216
|
+
) -> ExtensionRetrieveResponse:
|
|
217
|
+
"""
|
|
218
|
+
Get details of a specific extension by its ID
|
|
219
|
+
|
|
220
|
+
Args:
|
|
221
|
+
extra_headers: Send extra headers
|
|
222
|
+
|
|
223
|
+
extra_query: Add additional query parameters to the request
|
|
224
|
+
|
|
225
|
+
extra_body: Add additional JSON properties to the request
|
|
226
|
+
|
|
227
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
228
|
+
"""
|
|
229
|
+
if not id:
|
|
230
|
+
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
|
|
231
|
+
return await self._get(
|
|
232
|
+
f"/v1/extensions/{id}",
|
|
233
|
+
options=make_request_options(
|
|
234
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
235
|
+
),
|
|
236
|
+
cast_to=ExtensionRetrieveResponse,
|
|
237
|
+
)
|
|
238
|
+
|
|
239
|
+
async def list(
|
|
240
|
+
self,
|
|
241
|
+
*,
|
|
242
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
243
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
244
|
+
extra_headers: Headers | None = None,
|
|
245
|
+
extra_query: Query | None = None,
|
|
246
|
+
extra_body: Body | None = None,
|
|
247
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
248
|
+
) -> ExtensionListResponse:
|
|
249
|
+
"""Get all extensions for the authenticated user"""
|
|
250
|
+
return await self._get(
|
|
251
|
+
"/v1/extensions",
|
|
252
|
+
options=make_request_options(
|
|
253
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
254
|
+
),
|
|
255
|
+
cast_to=ExtensionListResponse,
|
|
256
|
+
)
|
|
257
|
+
|
|
258
|
+
async def delete(
|
|
259
|
+
self,
|
|
260
|
+
id: str,
|
|
261
|
+
*,
|
|
262
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
263
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
264
|
+
extra_headers: Headers | None = None,
|
|
265
|
+
extra_query: Query | None = None,
|
|
266
|
+
extra_body: Body | None = None,
|
|
267
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
268
|
+
) -> ExtensionDeleteResponse:
|
|
269
|
+
"""
|
|
270
|
+
Delete an extension and remove it from storage
|
|
271
|
+
|
|
272
|
+
Args:
|
|
273
|
+
extra_headers: Send extra headers
|
|
274
|
+
|
|
275
|
+
extra_query: Add additional query parameters to the request
|
|
276
|
+
|
|
277
|
+
extra_body: Add additional JSON properties to the request
|
|
278
|
+
|
|
279
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
280
|
+
"""
|
|
281
|
+
if not id:
|
|
282
|
+
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
|
|
283
|
+
return await self._delete(
|
|
284
|
+
f"/v1/extensions/{id}",
|
|
285
|
+
options=make_request_options(
|
|
286
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
287
|
+
),
|
|
288
|
+
cast_to=ExtensionDeleteResponse,
|
|
289
|
+
)
|
|
290
|
+
|
|
291
|
+
async def upload(
|
|
292
|
+
self,
|
|
293
|
+
*,
|
|
294
|
+
file: FileTypes,
|
|
295
|
+
name: str,
|
|
296
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
297
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
298
|
+
extra_headers: Headers | None = None,
|
|
299
|
+
extra_query: Query | None = None,
|
|
300
|
+
extra_body: Body | None = None,
|
|
301
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
302
|
+
) -> ExtensionUploadResponse:
|
|
303
|
+
"""Upload a new browser extension as a ZIP file.
|
|
304
|
+
|
|
305
|
+
The extension will be validated
|
|
306
|
+
and stored for use in browser sessions.
|
|
307
|
+
|
|
308
|
+
Args:
|
|
309
|
+
file: ZIP file containing the browser extension
|
|
310
|
+
|
|
311
|
+
name: User-friendly name for the extension (1-255 characters)
|
|
312
|
+
|
|
313
|
+
extra_headers: Send extra headers
|
|
314
|
+
|
|
315
|
+
extra_query: Add additional query parameters to the request
|
|
316
|
+
|
|
317
|
+
extra_body: Add additional JSON properties to the request
|
|
318
|
+
|
|
319
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
320
|
+
"""
|
|
321
|
+
body = deepcopy_minimal(
|
|
322
|
+
{
|
|
323
|
+
"file": file,
|
|
324
|
+
"name": name,
|
|
325
|
+
}
|
|
326
|
+
)
|
|
327
|
+
files = extract_files(cast(Mapping[str, object], body), paths=[["file"]])
|
|
328
|
+
# It should be noted that the actual Content-Type header that will be
|
|
329
|
+
# sent to the server will contain a `boundary` parameter, e.g.
|
|
330
|
+
# multipart/form-data; boundary=---abc--
|
|
331
|
+
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
|
|
332
|
+
return await self._post(
|
|
333
|
+
"/v1/extensions",
|
|
334
|
+
body=await async_maybe_transform(body, extension_upload_params.ExtensionUploadParams),
|
|
335
|
+
files=files,
|
|
336
|
+
options=make_request_options(
|
|
337
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
338
|
+
),
|
|
339
|
+
cast_to=ExtensionUploadResponse,
|
|
340
|
+
)
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
class ExtensionsResourceWithRawResponse:
|
|
344
|
+
def __init__(self, extensions: ExtensionsResource) -> None:
|
|
345
|
+
self._extensions = extensions
|
|
346
|
+
|
|
347
|
+
self.retrieve = to_raw_response_wrapper(
|
|
348
|
+
extensions.retrieve,
|
|
349
|
+
)
|
|
350
|
+
self.list = to_raw_response_wrapper(
|
|
351
|
+
extensions.list,
|
|
352
|
+
)
|
|
353
|
+
self.delete = to_raw_response_wrapper(
|
|
354
|
+
extensions.delete,
|
|
355
|
+
)
|
|
356
|
+
self.upload = to_raw_response_wrapper(
|
|
357
|
+
extensions.upload,
|
|
358
|
+
)
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
class AsyncExtensionsResourceWithRawResponse:
|
|
362
|
+
def __init__(self, extensions: AsyncExtensionsResource) -> None:
|
|
363
|
+
self._extensions = extensions
|
|
364
|
+
|
|
365
|
+
self.retrieve = async_to_raw_response_wrapper(
|
|
366
|
+
extensions.retrieve,
|
|
367
|
+
)
|
|
368
|
+
self.list = async_to_raw_response_wrapper(
|
|
369
|
+
extensions.list,
|
|
370
|
+
)
|
|
371
|
+
self.delete = async_to_raw_response_wrapper(
|
|
372
|
+
extensions.delete,
|
|
373
|
+
)
|
|
374
|
+
self.upload = async_to_raw_response_wrapper(
|
|
375
|
+
extensions.upload,
|
|
376
|
+
)
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
class ExtensionsResourceWithStreamingResponse:
|
|
380
|
+
def __init__(self, extensions: ExtensionsResource) -> None:
|
|
381
|
+
self._extensions = extensions
|
|
382
|
+
|
|
383
|
+
self.retrieve = to_streamed_response_wrapper(
|
|
384
|
+
extensions.retrieve,
|
|
385
|
+
)
|
|
386
|
+
self.list = to_streamed_response_wrapper(
|
|
387
|
+
extensions.list,
|
|
388
|
+
)
|
|
389
|
+
self.delete = to_streamed_response_wrapper(
|
|
390
|
+
extensions.delete,
|
|
391
|
+
)
|
|
392
|
+
self.upload = to_streamed_response_wrapper(
|
|
393
|
+
extensions.upload,
|
|
394
|
+
)
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
class AsyncExtensionsResourceWithStreamingResponse:
|
|
398
|
+
def __init__(self, extensions: AsyncExtensionsResource) -> None:
|
|
399
|
+
self._extensions = extensions
|
|
400
|
+
|
|
401
|
+
self.retrieve = async_to_streamed_response_wrapper(
|
|
402
|
+
extensions.retrieve,
|
|
403
|
+
)
|
|
404
|
+
self.list = async_to_streamed_response_wrapper(
|
|
405
|
+
extensions.list,
|
|
406
|
+
)
|
|
407
|
+
self.delete = async_to_streamed_response_wrapper(
|
|
408
|
+
extensions.delete,
|
|
409
|
+
)
|
|
410
|
+
self.upload = async_to_streamed_response_wrapper(
|
|
411
|
+
extensions.upload,
|
|
412
|
+
)
|