Release v1.0.2 (#4175)
This commit is contained in:
committed by
GitHub
parent
2961fdd721
commit
d9610701d3
@@ -12,11 +12,13 @@ from .core.pydantic_utilities import parse_obj_as
|
||||
from .core.request_options import RequestOptions
|
||||
from .core.serialization import convert_and_respect_annotation_metadata
|
||||
from .errors.bad_request_error import BadRequestError
|
||||
from .errors.conflict_error import ConflictError
|
||||
from .errors.forbidden_error import ForbiddenError
|
||||
from .errors.not_found_error import NotFoundError
|
||||
from .errors.unprocessable_entity_error import UnprocessableEntityError
|
||||
from .types.artifact import Artifact
|
||||
from .types.artifact_type import ArtifactType
|
||||
from .types.browser_profile import BrowserProfile
|
||||
from .types.browser_session_response import BrowserSessionResponse
|
||||
from .types.create_credential_request_credential import CreateCredentialRequestCredential
|
||||
from .types.create_script_response import CreateScriptResponse
|
||||
@@ -31,10 +33,12 @@ from .types.script_file_create import ScriptFileCreate
|
||||
from .types.skyvern_forge_sdk_schemas_credentials_credential_type import SkyvernForgeSdkSchemasCredentialsCredentialType
|
||||
from .types.skyvern_schemas_run_blocks_credential_type import SkyvernSchemasRunBlocksCredentialType
|
||||
from .types.task_run_request_data_extraction_schema import TaskRunRequestDataExtractionSchema
|
||||
from .types.task_run_request_proxy_location import TaskRunRequestProxyLocation
|
||||
from .types.task_run_response import TaskRunResponse
|
||||
from .types.totp_code import TotpCode
|
||||
from .types.workflow import Workflow
|
||||
from .types.workflow_create_yaml_request import WorkflowCreateYamlRequest
|
||||
from .types.workflow_run_request_proxy_location import WorkflowRunRequestProxyLocation
|
||||
from .types.workflow_run_response import WorkflowRunResponse
|
||||
from .types.workflow_run_timeline import WorkflowRunTimeline
|
||||
from .types.workflow_status import WorkflowStatus
|
||||
@@ -55,7 +59,7 @@ class RawSkyvern:
|
||||
url: typing.Optional[str] = OMIT,
|
||||
engine: typing.Optional[RunEngine] = OMIT,
|
||||
title: typing.Optional[str] = OMIT,
|
||||
proxy_location: typing.Optional[ProxyLocation] = OMIT,
|
||||
proxy_location: typing.Optional[TaskRunRequestProxyLocation] = OMIT,
|
||||
data_extraction_schema: typing.Optional[TaskRunRequestDataExtractionSchema] = OMIT,
|
||||
error_code_mapping: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT,
|
||||
max_steps: typing.Optional[int] = OMIT,
|
||||
@@ -93,7 +97,7 @@ class RawSkyvern:
|
||||
title : typing.Optional[str]
|
||||
The title for the task
|
||||
|
||||
proxy_location : typing.Optional[ProxyLocation]
|
||||
proxy_location : typing.Optional[TaskRunRequestProxyLocation]
|
||||
|
||||
Geographic Proxy location to route the browser traffic through. This is only available in Skyvern Cloud.
|
||||
|
||||
@@ -117,6 +121,7 @@ class RawSkyvern:
|
||||
- US-FL: Florida
|
||||
- US-WA: Washington
|
||||
- NONE: No proxy
|
||||
Can also be a GeoTarget object for granular city/state targeting: {"country": "US", "subdivision": "CA", "city": "San Francisco"}
|
||||
|
||||
data_extraction_schema : typing.Optional[TaskRunRequestDataExtractionSchema]
|
||||
|
||||
@@ -181,7 +186,9 @@ class RawSkyvern:
|
||||
"url": url,
|
||||
"engine": engine,
|
||||
"title": title,
|
||||
"proxy_location": proxy_location,
|
||||
"proxy_location": convert_and_respect_annotation_metadata(
|
||||
object_=proxy_location, annotation=TaskRunRequestProxyLocation, direction="write"
|
||||
),
|
||||
"data_extraction_schema": convert_and_respect_annotation_metadata(
|
||||
object_=data_extraction_schema, annotation=TaskRunRequestDataExtractionSchema, direction="write"
|
||||
),
|
||||
@@ -251,7 +258,7 @@ class RawSkyvern:
|
||||
user_agent: typing.Optional[str] = None,
|
||||
parameters: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
|
||||
title: typing.Optional[str] = OMIT,
|
||||
proxy_location: typing.Optional[ProxyLocation] = OMIT,
|
||||
proxy_location: typing.Optional[WorkflowRunRequestProxyLocation] = OMIT,
|
||||
webhook_url: typing.Optional[str] = OMIT,
|
||||
totp_url: typing.Optional[str] = OMIT,
|
||||
totp_identifier: typing.Optional[str] = OMIT,
|
||||
@@ -284,7 +291,7 @@ class RawSkyvern:
|
||||
title : typing.Optional[str]
|
||||
The title for this workflow run
|
||||
|
||||
proxy_location : typing.Optional[ProxyLocation]
|
||||
proxy_location : typing.Optional[WorkflowRunRequestProxyLocation]
|
||||
|
||||
Geographic Proxy location to route the browser traffic through. This is only available in Skyvern Cloud.
|
||||
|
||||
@@ -308,6 +315,7 @@ class RawSkyvern:
|
||||
- US-FL: Florida
|
||||
- US-WA: Washington
|
||||
- NONE: No proxy
|
||||
Can also be a GeoTarget object for granular city/state targeting: {"country": "US", "subdivision": "CA", "city": "San Francisco"}
|
||||
|
||||
webhook_url : typing.Optional[str]
|
||||
URL to send workflow status updates to after a run is finished. Refer to https://www.skyvern.com/docs/running-tasks/webhooks-faq for webhook questions.
|
||||
@@ -359,7 +367,9 @@ class RawSkyvern:
|
||||
"workflow_id": workflow_id,
|
||||
"parameters": parameters,
|
||||
"title": title,
|
||||
"proxy_location": proxy_location,
|
||||
"proxy_location": convert_and_respect_annotation_metadata(
|
||||
object_=proxy_location, annotation=WorkflowRunRequestProxyLocation, direction="write"
|
||||
),
|
||||
"webhook_url": webhook_url,
|
||||
"totp_url": totp_url,
|
||||
"totp_identifier": totp_identifier,
|
||||
@@ -1066,6 +1076,270 @@ class RawSkyvern:
|
||||
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
||||
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
||||
|
||||
def list_browser_profiles(
|
||||
self, *, include_deleted: typing.Optional[bool] = None, request_options: typing.Optional[RequestOptions] = None
|
||||
) -> HttpResponse[typing.List[BrowserProfile]]:
|
||||
"""
|
||||
Get all browser profiles for the organization
|
||||
|
||||
Parameters
|
||||
----------
|
||||
include_deleted : typing.Optional[bool]
|
||||
Include deleted browser profiles
|
||||
|
||||
request_options : typing.Optional[RequestOptions]
|
||||
Request-specific configuration.
|
||||
|
||||
Returns
|
||||
-------
|
||||
HttpResponse[typing.List[BrowserProfile]]
|
||||
Successfully retrieved browser profiles
|
||||
"""
|
||||
_response = self._client_wrapper.httpx_client.request(
|
||||
"v1/browser_profiles",
|
||||
method="GET",
|
||||
params={
|
||||
"include_deleted": include_deleted,
|
||||
},
|
||||
request_options=request_options,
|
||||
)
|
||||
try:
|
||||
if 200 <= _response.status_code < 300:
|
||||
_data = typing.cast(
|
||||
typing.List[BrowserProfile],
|
||||
parse_obj_as(
|
||||
type_=typing.List[BrowserProfile], # type: ignore
|
||||
object_=_response.json(),
|
||||
),
|
||||
)
|
||||
return HttpResponse(response=_response, data=_data)
|
||||
if _response.status_code == 422:
|
||||
raise UnprocessableEntityError(
|
||||
headers=dict(_response.headers),
|
||||
body=typing.cast(
|
||||
typing.Optional[typing.Any],
|
||||
parse_obj_as(
|
||||
type_=typing.Optional[typing.Any], # type: ignore
|
||||
object_=_response.json(),
|
||||
),
|
||||
),
|
||||
)
|
||||
_response_json = _response.json()
|
||||
except JSONDecodeError:
|
||||
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
||||
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
||||
|
||||
def create_browser_profile(
|
||||
self,
|
||||
*,
|
||||
name: str,
|
||||
description: typing.Optional[str] = OMIT,
|
||||
browser_session_id: typing.Optional[str] = OMIT,
|
||||
workflow_run_id: typing.Optional[str] = OMIT,
|
||||
request_options: typing.Optional[RequestOptions] = None,
|
||||
) -> HttpResponse[BrowserProfile]:
|
||||
"""
|
||||
Create a browser profile from a persistent browser session or workflow run.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
name : str
|
||||
Name for the browser profile
|
||||
|
||||
description : typing.Optional[str]
|
||||
Optional profile description
|
||||
|
||||
browser_session_id : typing.Optional[str]
|
||||
Persistent browser session to convert into a profile
|
||||
|
||||
workflow_run_id : typing.Optional[str]
|
||||
Workflow run whose persisted session should be captured
|
||||
|
||||
request_options : typing.Optional[RequestOptions]
|
||||
Request-specific configuration.
|
||||
|
||||
Returns
|
||||
-------
|
||||
HttpResponse[BrowserProfile]
|
||||
Successfully created browser profile
|
||||
"""
|
||||
_response = self._client_wrapper.httpx_client.request(
|
||||
"v1/browser_profiles",
|
||||
method="POST",
|
||||
json={
|
||||
"name": name,
|
||||
"description": description,
|
||||
"browser_session_id": browser_session_id,
|
||||
"workflow_run_id": workflow_run_id,
|
||||
},
|
||||
headers={
|
||||
"content-type": "application/json",
|
||||
},
|
||||
request_options=request_options,
|
||||
omit=OMIT,
|
||||
)
|
||||
try:
|
||||
if 200 <= _response.status_code < 300:
|
||||
_data = typing.cast(
|
||||
BrowserProfile,
|
||||
parse_obj_as(
|
||||
type_=BrowserProfile, # type: ignore
|
||||
object_=_response.json(),
|
||||
),
|
||||
)
|
||||
return HttpResponse(response=_response, data=_data)
|
||||
if _response.status_code == 400:
|
||||
raise BadRequestError(
|
||||
headers=dict(_response.headers),
|
||||
body=typing.cast(
|
||||
typing.Optional[typing.Any],
|
||||
parse_obj_as(
|
||||
type_=typing.Optional[typing.Any], # type: ignore
|
||||
object_=_response.json(),
|
||||
),
|
||||
),
|
||||
)
|
||||
if _response.status_code == 409:
|
||||
raise ConflictError(
|
||||
headers=dict(_response.headers),
|
||||
body=typing.cast(
|
||||
typing.Optional[typing.Any],
|
||||
parse_obj_as(
|
||||
type_=typing.Optional[typing.Any], # type: ignore
|
||||
object_=_response.json(),
|
||||
),
|
||||
),
|
||||
)
|
||||
if _response.status_code == 422:
|
||||
raise UnprocessableEntityError(
|
||||
headers=dict(_response.headers),
|
||||
body=typing.cast(
|
||||
typing.Optional[typing.Any],
|
||||
parse_obj_as(
|
||||
type_=typing.Optional[typing.Any], # type: ignore
|
||||
object_=_response.json(),
|
||||
),
|
||||
),
|
||||
)
|
||||
_response_json = _response.json()
|
||||
except JSONDecodeError:
|
||||
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
||||
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
||||
|
||||
def get_browser_profile(
|
||||
self, profile_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
||||
) -> HttpResponse[BrowserProfile]:
|
||||
"""
|
||||
Get a specific browser profile by ID
|
||||
|
||||
Parameters
|
||||
----------
|
||||
profile_id : str
|
||||
The ID of the browser profile. browser_profile_id starts with `bp_`
|
||||
|
||||
request_options : typing.Optional[RequestOptions]
|
||||
Request-specific configuration.
|
||||
|
||||
Returns
|
||||
-------
|
||||
HttpResponse[BrowserProfile]
|
||||
Successfully retrieved browser profile
|
||||
"""
|
||||
_response = self._client_wrapper.httpx_client.request(
|
||||
f"v1/browser_profiles/{jsonable_encoder(profile_id)}",
|
||||
method="GET",
|
||||
request_options=request_options,
|
||||
)
|
||||
try:
|
||||
if 200 <= _response.status_code < 300:
|
||||
_data = typing.cast(
|
||||
BrowserProfile,
|
||||
parse_obj_as(
|
||||
type_=BrowserProfile, # type: ignore
|
||||
object_=_response.json(),
|
||||
),
|
||||
)
|
||||
return HttpResponse(response=_response, data=_data)
|
||||
if _response.status_code == 404:
|
||||
raise NotFoundError(
|
||||
headers=dict(_response.headers),
|
||||
body=typing.cast(
|
||||
typing.Optional[typing.Any],
|
||||
parse_obj_as(
|
||||
type_=typing.Optional[typing.Any], # type: ignore
|
||||
object_=_response.json(),
|
||||
),
|
||||
),
|
||||
)
|
||||
if _response.status_code == 422:
|
||||
raise UnprocessableEntityError(
|
||||
headers=dict(_response.headers),
|
||||
body=typing.cast(
|
||||
typing.Optional[typing.Any],
|
||||
parse_obj_as(
|
||||
type_=typing.Optional[typing.Any], # type: ignore
|
||||
object_=_response.json(),
|
||||
),
|
||||
),
|
||||
)
|
||||
_response_json = _response.json()
|
||||
except JSONDecodeError:
|
||||
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
||||
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
||||
|
||||
def delete_browser_profile(
|
||||
self, profile_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
||||
) -> HttpResponse[None]:
|
||||
"""
|
||||
Delete a browser profile (soft delete)
|
||||
|
||||
Parameters
|
||||
----------
|
||||
profile_id : str
|
||||
The ID of the browser profile to delete. browser_profile_id starts with `bp_`
|
||||
|
||||
request_options : typing.Optional[RequestOptions]
|
||||
Request-specific configuration.
|
||||
|
||||
Returns
|
||||
-------
|
||||
HttpResponse[None]
|
||||
"""
|
||||
_response = self._client_wrapper.httpx_client.request(
|
||||
f"v1/browser_profiles/{jsonable_encoder(profile_id)}",
|
||||
method="DELETE",
|
||||
request_options=request_options,
|
||||
)
|
||||
try:
|
||||
if 200 <= _response.status_code < 300:
|
||||
return HttpResponse(response=_response, data=None)
|
||||
if _response.status_code == 404:
|
||||
raise NotFoundError(
|
||||
headers=dict(_response.headers),
|
||||
body=typing.cast(
|
||||
typing.Optional[typing.Any],
|
||||
parse_obj_as(
|
||||
type_=typing.Optional[typing.Any], # type: ignore
|
||||
object_=_response.json(),
|
||||
),
|
||||
),
|
||||
)
|
||||
if _response.status_code == 422:
|
||||
raise UnprocessableEntityError(
|
||||
headers=dict(_response.headers),
|
||||
body=typing.cast(
|
||||
typing.Optional[typing.Any],
|
||||
parse_obj_as(
|
||||
type_=typing.Optional[typing.Any], # type: ignore
|
||||
object_=_response.json(),
|
||||
),
|
||||
),
|
||||
)
|
||||
_response_json = _response.json()
|
||||
except JSONDecodeError:
|
||||
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
||||
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
||||
|
||||
def get_browser_sessions(
|
||||
self, *, request_options: typing.Optional[RequestOptions] = None
|
||||
) -> HttpResponse[typing.List[BrowserSessionResponse]]:
|
||||
@@ -2176,7 +2450,7 @@ class AsyncRawSkyvern:
|
||||
url: typing.Optional[str] = OMIT,
|
||||
engine: typing.Optional[RunEngine] = OMIT,
|
||||
title: typing.Optional[str] = OMIT,
|
||||
proxy_location: typing.Optional[ProxyLocation] = OMIT,
|
||||
proxy_location: typing.Optional[TaskRunRequestProxyLocation] = OMIT,
|
||||
data_extraction_schema: typing.Optional[TaskRunRequestDataExtractionSchema] = OMIT,
|
||||
error_code_mapping: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT,
|
||||
max_steps: typing.Optional[int] = OMIT,
|
||||
@@ -2214,7 +2488,7 @@ class AsyncRawSkyvern:
|
||||
title : typing.Optional[str]
|
||||
The title for the task
|
||||
|
||||
proxy_location : typing.Optional[ProxyLocation]
|
||||
proxy_location : typing.Optional[TaskRunRequestProxyLocation]
|
||||
|
||||
Geographic Proxy location to route the browser traffic through. This is only available in Skyvern Cloud.
|
||||
|
||||
@@ -2238,6 +2512,7 @@ class AsyncRawSkyvern:
|
||||
- US-FL: Florida
|
||||
- US-WA: Washington
|
||||
- NONE: No proxy
|
||||
Can also be a GeoTarget object for granular city/state targeting: {"country": "US", "subdivision": "CA", "city": "San Francisco"}
|
||||
|
||||
data_extraction_schema : typing.Optional[TaskRunRequestDataExtractionSchema]
|
||||
|
||||
@@ -2302,7 +2577,9 @@ class AsyncRawSkyvern:
|
||||
"url": url,
|
||||
"engine": engine,
|
||||
"title": title,
|
||||
"proxy_location": proxy_location,
|
||||
"proxy_location": convert_and_respect_annotation_metadata(
|
||||
object_=proxy_location, annotation=TaskRunRequestProxyLocation, direction="write"
|
||||
),
|
||||
"data_extraction_schema": convert_and_respect_annotation_metadata(
|
||||
object_=data_extraction_schema, annotation=TaskRunRequestDataExtractionSchema, direction="write"
|
||||
),
|
||||
@@ -2372,7 +2649,7 @@ class AsyncRawSkyvern:
|
||||
user_agent: typing.Optional[str] = None,
|
||||
parameters: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
|
||||
title: typing.Optional[str] = OMIT,
|
||||
proxy_location: typing.Optional[ProxyLocation] = OMIT,
|
||||
proxy_location: typing.Optional[WorkflowRunRequestProxyLocation] = OMIT,
|
||||
webhook_url: typing.Optional[str] = OMIT,
|
||||
totp_url: typing.Optional[str] = OMIT,
|
||||
totp_identifier: typing.Optional[str] = OMIT,
|
||||
@@ -2405,7 +2682,7 @@ class AsyncRawSkyvern:
|
||||
title : typing.Optional[str]
|
||||
The title for this workflow run
|
||||
|
||||
proxy_location : typing.Optional[ProxyLocation]
|
||||
proxy_location : typing.Optional[WorkflowRunRequestProxyLocation]
|
||||
|
||||
Geographic Proxy location to route the browser traffic through. This is only available in Skyvern Cloud.
|
||||
|
||||
@@ -2429,6 +2706,7 @@ class AsyncRawSkyvern:
|
||||
- US-FL: Florida
|
||||
- US-WA: Washington
|
||||
- NONE: No proxy
|
||||
Can also be a GeoTarget object for granular city/state targeting: {"country": "US", "subdivision": "CA", "city": "San Francisco"}
|
||||
|
||||
webhook_url : typing.Optional[str]
|
||||
URL to send workflow status updates to after a run is finished. Refer to https://www.skyvern.com/docs/running-tasks/webhooks-faq for webhook questions.
|
||||
@@ -2480,7 +2758,9 @@ class AsyncRawSkyvern:
|
||||
"workflow_id": workflow_id,
|
||||
"parameters": parameters,
|
||||
"title": title,
|
||||
"proxy_location": proxy_location,
|
||||
"proxy_location": convert_and_respect_annotation_metadata(
|
||||
object_=proxy_location, annotation=WorkflowRunRequestProxyLocation, direction="write"
|
||||
),
|
||||
"webhook_url": webhook_url,
|
||||
"totp_url": totp_url,
|
||||
"totp_identifier": totp_identifier,
|
||||
@@ -3187,6 +3467,270 @@ class AsyncRawSkyvern:
|
||||
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
||||
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
||||
|
||||
async def list_browser_profiles(
|
||||
self, *, include_deleted: typing.Optional[bool] = None, request_options: typing.Optional[RequestOptions] = None
|
||||
) -> AsyncHttpResponse[typing.List[BrowserProfile]]:
|
||||
"""
|
||||
Get all browser profiles for the organization
|
||||
|
||||
Parameters
|
||||
----------
|
||||
include_deleted : typing.Optional[bool]
|
||||
Include deleted browser profiles
|
||||
|
||||
request_options : typing.Optional[RequestOptions]
|
||||
Request-specific configuration.
|
||||
|
||||
Returns
|
||||
-------
|
||||
AsyncHttpResponse[typing.List[BrowserProfile]]
|
||||
Successfully retrieved browser profiles
|
||||
"""
|
||||
_response = await self._client_wrapper.httpx_client.request(
|
||||
"v1/browser_profiles",
|
||||
method="GET",
|
||||
params={
|
||||
"include_deleted": include_deleted,
|
||||
},
|
||||
request_options=request_options,
|
||||
)
|
||||
try:
|
||||
if 200 <= _response.status_code < 300:
|
||||
_data = typing.cast(
|
||||
typing.List[BrowserProfile],
|
||||
parse_obj_as(
|
||||
type_=typing.List[BrowserProfile], # type: ignore
|
||||
object_=_response.json(),
|
||||
),
|
||||
)
|
||||
return AsyncHttpResponse(response=_response, data=_data)
|
||||
if _response.status_code == 422:
|
||||
raise UnprocessableEntityError(
|
||||
headers=dict(_response.headers),
|
||||
body=typing.cast(
|
||||
typing.Optional[typing.Any],
|
||||
parse_obj_as(
|
||||
type_=typing.Optional[typing.Any], # type: ignore
|
||||
object_=_response.json(),
|
||||
),
|
||||
),
|
||||
)
|
||||
_response_json = _response.json()
|
||||
except JSONDecodeError:
|
||||
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
||||
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
||||
|
||||
async def create_browser_profile(
|
||||
self,
|
||||
*,
|
||||
name: str,
|
||||
description: typing.Optional[str] = OMIT,
|
||||
browser_session_id: typing.Optional[str] = OMIT,
|
||||
workflow_run_id: typing.Optional[str] = OMIT,
|
||||
request_options: typing.Optional[RequestOptions] = None,
|
||||
) -> AsyncHttpResponse[BrowserProfile]:
|
||||
"""
|
||||
Create a browser profile from a persistent browser session or workflow run.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
name : str
|
||||
Name for the browser profile
|
||||
|
||||
description : typing.Optional[str]
|
||||
Optional profile description
|
||||
|
||||
browser_session_id : typing.Optional[str]
|
||||
Persistent browser session to convert into a profile
|
||||
|
||||
workflow_run_id : typing.Optional[str]
|
||||
Workflow run whose persisted session should be captured
|
||||
|
||||
request_options : typing.Optional[RequestOptions]
|
||||
Request-specific configuration.
|
||||
|
||||
Returns
|
||||
-------
|
||||
AsyncHttpResponse[BrowserProfile]
|
||||
Successfully created browser profile
|
||||
"""
|
||||
_response = await self._client_wrapper.httpx_client.request(
|
||||
"v1/browser_profiles",
|
||||
method="POST",
|
||||
json={
|
||||
"name": name,
|
||||
"description": description,
|
||||
"browser_session_id": browser_session_id,
|
||||
"workflow_run_id": workflow_run_id,
|
||||
},
|
||||
headers={
|
||||
"content-type": "application/json",
|
||||
},
|
||||
request_options=request_options,
|
||||
omit=OMIT,
|
||||
)
|
||||
try:
|
||||
if 200 <= _response.status_code < 300:
|
||||
_data = typing.cast(
|
||||
BrowserProfile,
|
||||
parse_obj_as(
|
||||
type_=BrowserProfile, # type: ignore
|
||||
object_=_response.json(),
|
||||
),
|
||||
)
|
||||
return AsyncHttpResponse(response=_response, data=_data)
|
||||
if _response.status_code == 400:
|
||||
raise BadRequestError(
|
||||
headers=dict(_response.headers),
|
||||
body=typing.cast(
|
||||
typing.Optional[typing.Any],
|
||||
parse_obj_as(
|
||||
type_=typing.Optional[typing.Any], # type: ignore
|
||||
object_=_response.json(),
|
||||
),
|
||||
),
|
||||
)
|
||||
if _response.status_code == 409:
|
||||
raise ConflictError(
|
||||
headers=dict(_response.headers),
|
||||
body=typing.cast(
|
||||
typing.Optional[typing.Any],
|
||||
parse_obj_as(
|
||||
type_=typing.Optional[typing.Any], # type: ignore
|
||||
object_=_response.json(),
|
||||
),
|
||||
),
|
||||
)
|
||||
if _response.status_code == 422:
|
||||
raise UnprocessableEntityError(
|
||||
headers=dict(_response.headers),
|
||||
body=typing.cast(
|
||||
typing.Optional[typing.Any],
|
||||
parse_obj_as(
|
||||
type_=typing.Optional[typing.Any], # type: ignore
|
||||
object_=_response.json(),
|
||||
),
|
||||
),
|
||||
)
|
||||
_response_json = _response.json()
|
||||
except JSONDecodeError:
|
||||
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
||||
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
||||
|
||||
async def get_browser_profile(
|
||||
self, profile_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
||||
) -> AsyncHttpResponse[BrowserProfile]:
|
||||
"""
|
||||
Get a specific browser profile by ID
|
||||
|
||||
Parameters
|
||||
----------
|
||||
profile_id : str
|
||||
The ID of the browser profile. browser_profile_id starts with `bp_`
|
||||
|
||||
request_options : typing.Optional[RequestOptions]
|
||||
Request-specific configuration.
|
||||
|
||||
Returns
|
||||
-------
|
||||
AsyncHttpResponse[BrowserProfile]
|
||||
Successfully retrieved browser profile
|
||||
"""
|
||||
_response = await self._client_wrapper.httpx_client.request(
|
||||
f"v1/browser_profiles/{jsonable_encoder(profile_id)}",
|
||||
method="GET",
|
||||
request_options=request_options,
|
||||
)
|
||||
try:
|
||||
if 200 <= _response.status_code < 300:
|
||||
_data = typing.cast(
|
||||
BrowserProfile,
|
||||
parse_obj_as(
|
||||
type_=BrowserProfile, # type: ignore
|
||||
object_=_response.json(),
|
||||
),
|
||||
)
|
||||
return AsyncHttpResponse(response=_response, data=_data)
|
||||
if _response.status_code == 404:
|
||||
raise NotFoundError(
|
||||
headers=dict(_response.headers),
|
||||
body=typing.cast(
|
||||
typing.Optional[typing.Any],
|
||||
parse_obj_as(
|
||||
type_=typing.Optional[typing.Any], # type: ignore
|
||||
object_=_response.json(),
|
||||
),
|
||||
),
|
||||
)
|
||||
if _response.status_code == 422:
|
||||
raise UnprocessableEntityError(
|
||||
headers=dict(_response.headers),
|
||||
body=typing.cast(
|
||||
typing.Optional[typing.Any],
|
||||
parse_obj_as(
|
||||
type_=typing.Optional[typing.Any], # type: ignore
|
||||
object_=_response.json(),
|
||||
),
|
||||
),
|
||||
)
|
||||
_response_json = _response.json()
|
||||
except JSONDecodeError:
|
||||
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
||||
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
||||
|
||||
async def delete_browser_profile(
|
||||
self, profile_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
||||
) -> AsyncHttpResponse[None]:
|
||||
"""
|
||||
Delete a browser profile (soft delete)
|
||||
|
||||
Parameters
|
||||
----------
|
||||
profile_id : str
|
||||
The ID of the browser profile to delete. browser_profile_id starts with `bp_`
|
||||
|
||||
request_options : typing.Optional[RequestOptions]
|
||||
Request-specific configuration.
|
||||
|
||||
Returns
|
||||
-------
|
||||
AsyncHttpResponse[None]
|
||||
"""
|
||||
_response = await self._client_wrapper.httpx_client.request(
|
||||
f"v1/browser_profiles/{jsonable_encoder(profile_id)}",
|
||||
method="DELETE",
|
||||
request_options=request_options,
|
||||
)
|
||||
try:
|
||||
if 200 <= _response.status_code < 300:
|
||||
return AsyncHttpResponse(response=_response, data=None)
|
||||
if _response.status_code == 404:
|
||||
raise NotFoundError(
|
||||
headers=dict(_response.headers),
|
||||
body=typing.cast(
|
||||
typing.Optional[typing.Any],
|
||||
parse_obj_as(
|
||||
type_=typing.Optional[typing.Any], # type: ignore
|
||||
object_=_response.json(),
|
||||
),
|
||||
),
|
||||
)
|
||||
if _response.status_code == 422:
|
||||
raise UnprocessableEntityError(
|
||||
headers=dict(_response.headers),
|
||||
body=typing.cast(
|
||||
typing.Optional[typing.Any],
|
||||
parse_obj_as(
|
||||
type_=typing.Optional[typing.Any], # type: ignore
|
||||
object_=_response.json(),
|
||||
),
|
||||
),
|
||||
)
|
||||
_response_json = _response.json()
|
||||
except JSONDecodeError:
|
||||
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
||||
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
||||
|
||||
async def get_browser_sessions(
|
||||
self, *, request_options: typing.Optional[RequestOptions] = None
|
||||
) -> AsyncHttpResponse[typing.List[BrowserSessionResponse]]:
|
||||
|
||||
Reference in New Issue
Block a user