v0.1.83 - sdk update (#2379)

This commit is contained in:
Shuchang Zheng
2025-05-18 15:46:11 -07:00
committed by GitHub
parent 3e44a1995d
commit 226ef99738
6 changed files with 1342 additions and 1192 deletions

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +1,6 @@
[tool.poetry] [tool.poetry]
name = "skyvern" name = "skyvern"
version = "0.1.82" version = "0.1.83"
description = "" description = ""
authors = ["Skyvern AI <info@skyvern.com>"] authors = ["Skyvern AI <info@skyvern.com>"]
readme = "README.md" readme = "README.md"

View File

@@ -2,22 +2,22 @@
import typing import typing
from ..core.client_wrapper import SyncClientWrapper from ..core.client_wrapper import SyncClientWrapper
from ..core.request_options import RequestOptions
from .types.agent_get_run_response import AgentGetRunResponse
from ..core.jsonable_encoder import jsonable_encoder
from ..core.pydantic_utilities import parse_obj_as
from ..errors.not_found_error import NotFoundError
from ..errors.unprocessable_entity_error import UnprocessableEntityError
from json.decoder import JSONDecodeError
from ..core.api_error import ApiError
from ..types.workflow import Workflow
from ..types.run_engine import RunEngine from ..types.run_engine import RunEngine
from ..types.proxy_location import ProxyLocation from ..types.proxy_location import ProxyLocation
from ..types.task_run_request_data_extraction_schema import TaskRunRequestDataExtractionSchema from ..types.task_run_request_data_extraction_schema import TaskRunRequestDataExtractionSchema
from ..core.request_options import RequestOptions
from ..types.task_run_response import TaskRunResponse from ..types.task_run_response import TaskRunResponse
from ..core.serialization import convert_and_respect_annotation_metadata from ..core.serialization import convert_and_respect_annotation_metadata
from ..core.pydantic_utilities import parse_obj_as
from ..errors.bad_request_error import BadRequestError from ..errors.bad_request_error import BadRequestError
from ..errors.unprocessable_entity_error import UnprocessableEntityError
from json.decoder import JSONDecodeError
from ..core.api_error import ApiError
from ..types.workflow_run_response import WorkflowRunResponse from ..types.workflow_run_response import WorkflowRunResponse
from .types.agent_get_run_response import AgentGetRunResponse
from ..core.jsonable_encoder import jsonable_encoder
from ..errors.not_found_error import NotFoundError
from ..types.workflow import Workflow
from ..core.client_wrapper import AsyncClientWrapper from ..core.client_wrapper import AsyncClientWrapper
# this is used as the default value for optional parameters # this is used as the default value for optional parameters
@@ -28,245 +28,6 @@ class AgentClient:
def __init__(self, *, client_wrapper: SyncClientWrapper): def __init__(self, *, client_wrapper: SyncClientWrapper):
self._client_wrapper = client_wrapper self._client_wrapper = client_wrapper
def get_run(self, run_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> AgentGetRunResponse:
"""
Get a task or a workflow run by id
Parameters
----------
run_id : str
The id of the task run or the workflow run.
request_options : typing.Optional[RequestOptions]
Request-specific configuration.
Returns
-------
AgentGetRunResponse
Successfully got run
Examples
--------
from skyvern import Skyvern
client = Skyvern(
api_key="YOUR_API_KEY",
authorization="YOUR_AUTHORIZATION",
)
client.agent.get_run(
run_id="tsk_123",
)
"""
_response = self._client_wrapper.httpx_client.request(
f"v1/runs/{jsonable_encoder(run_id)}",
method="GET",
request_options=request_options,
)
try:
if 200 <= _response.status_code < 300:
return typing.cast(
AgentGetRunResponse,
parse_obj_as(
type_=AgentGetRunResponse, # type: ignore
object_=_response.json(),
),
)
if _response.status_code == 404:
raise NotFoundError(
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(
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, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json)
def create_workflow(self, *, request_options: typing.Optional[RequestOptions] = None) -> Workflow:
"""
Create a new workflow
Parameters
----------
request_options : typing.Optional[RequestOptions]
Request-specific configuration.
Returns
-------
Workflow
Successfully created workflow
Examples
--------
from skyvern import Skyvern
client = Skyvern(
api_key="YOUR_API_KEY",
authorization="YOUR_AUTHORIZATION",
)
client.agent.create_workflow()
"""
_response = self._client_wrapper.httpx_client.request(
"v1/workflows",
method="POST",
request_options=request_options,
)
try:
if 200 <= _response.status_code < 300:
return typing.cast(
Workflow,
parse_obj_as(
type_=Workflow, # type: ignore
object_=_response.json(),
),
)
if _response.status_code == 422:
raise UnprocessableEntityError(
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, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json)
def update_workflow(self, workflow_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Workflow:
"""
Update a workflow definition
Parameters
----------
workflow_id : str
The ID of the workflow to update. Workflow ID starts with `wpid_`.
request_options : typing.Optional[RequestOptions]
Request-specific configuration.
Returns
-------
Workflow
Successfully updated workflow
Examples
--------
from skyvern import Skyvern
client = Skyvern(
api_key="YOUR_API_KEY",
authorization="YOUR_AUTHORIZATION",
)
client.agent.update_workflow(
workflow_id="wpid_123",
)
"""
_response = self._client_wrapper.httpx_client.request(
f"v1/workflows/{jsonable_encoder(workflow_id)}",
method="POST",
request_options=request_options,
)
try:
if 200 <= _response.status_code < 300:
return typing.cast(
Workflow,
parse_obj_as(
type_=Workflow, # type: ignore
object_=_response.json(),
),
)
if _response.status_code == 422:
raise UnprocessableEntityError(
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, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json)
def delete_workflow(
self, workflow_id: str, *, request_options: typing.Optional[RequestOptions] = None
) -> typing.Optional[typing.Any]:
"""
Delete a workflow
Parameters
----------
workflow_id : str
The ID of the workflow to delete. Workflow ID starts with `wpid_`.
request_options : typing.Optional[RequestOptions]
Request-specific configuration.
Returns
-------
typing.Optional[typing.Any]
Successfully deleted workflow
Examples
--------
from skyvern import Skyvern
client = Skyvern(
api_key="YOUR_API_KEY",
authorization="YOUR_AUTHORIZATION",
)
client.agent.delete_workflow(
workflow_id="wpid_123",
)
"""
_response = self._client_wrapper.httpx_client.request(
f"v1/workflows/{jsonable_encoder(workflow_id)}/delete",
method="POST",
request_options=request_options,
)
try:
if 200 <= _response.status_code < 300:
return 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(
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, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json)
def run_task( def run_task(
self, self,
*, *,
@@ -545,11 +306,79 @@ class AgentClient:
raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json) raise ApiError(status_code=_response.status_code, body=_response_json)
def get_run(self, run_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> AgentGetRunResponse:
"""
Get run information (task run, workflow run)
Parameters
----------
run_id : str
The id of the task run or the workflow run.
request_options : typing.Optional[RequestOptions]
Request-specific configuration.
Returns
-------
AgentGetRunResponse
Successfully got run
Examples
--------
from skyvern import Skyvern
client = Skyvern(
api_key="YOUR_API_KEY",
authorization="YOUR_AUTHORIZATION",
)
client.agent.get_run(
run_id="tsk_123",
)
"""
_response = self._client_wrapper.httpx_client.request(
f"v1/runs/{jsonable_encoder(run_id)}",
method="GET",
request_options=request_options,
)
try:
if 200 <= _response.status_code < 300:
return typing.cast(
AgentGetRunResponse,
parse_obj_as(
type_=AgentGetRunResponse, # type: ignore
object_=_response.json(),
),
)
if _response.status_code == 404:
raise NotFoundError(
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(
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, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json)
def cancel_run( def cancel_run(
self, run_id: str, *, request_options: typing.Optional[RequestOptions] = None self, run_id: str, *, request_options: typing.Optional[RequestOptions] = None
) -> typing.Optional[typing.Any]: ) -> typing.Optional[typing.Any]:
""" """
Cancel a task or workflow run Cancel a run (task or workflow)
Parameters Parameters
---------- ----------
@@ -605,90 +434,7 @@ class AgentClient:
raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json) raise ApiError(status_code=_response.status_code, body=_response_json)
def create_workflow(self, *, request_options: typing.Optional[RequestOptions] = None) -> Workflow:
class AsyncAgentClient:
def __init__(self, *, client_wrapper: AsyncClientWrapper):
self._client_wrapper = client_wrapper
async def get_run(
self, run_id: str, *, request_options: typing.Optional[RequestOptions] = None
) -> AgentGetRunResponse:
"""
Get a task or a workflow run by id
Parameters
----------
run_id : str
The id of the task run or the workflow run.
request_options : typing.Optional[RequestOptions]
Request-specific configuration.
Returns
-------
AgentGetRunResponse
Successfully got run
Examples
--------
import asyncio
from skyvern import AsyncSkyvern
client = AsyncSkyvern(
api_key="YOUR_API_KEY",
authorization="YOUR_AUTHORIZATION",
)
async def main() -> None:
await client.agent.get_run(
run_id="tsk_123",
)
asyncio.run(main())
"""
_response = await self._client_wrapper.httpx_client.request(
f"v1/runs/{jsonable_encoder(run_id)}",
method="GET",
request_options=request_options,
)
try:
if 200 <= _response.status_code < 300:
return typing.cast(
AgentGetRunResponse,
parse_obj_as(
type_=AgentGetRunResponse, # type: ignore
object_=_response.json(),
),
)
if _response.status_code == 404:
raise NotFoundError(
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(
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, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json)
async def create_workflow(self, *, request_options: typing.Optional[RequestOptions] = None) -> Workflow:
""" """
Create a new workflow Create a new workflow
@@ -704,23 +450,15 @@ class AsyncAgentClient:
Examples Examples
-------- --------
import asyncio from skyvern import Skyvern
from skyvern import AsyncSkyvern client = Skyvern(
client = AsyncSkyvern(
api_key="YOUR_API_KEY", api_key="YOUR_API_KEY",
authorization="YOUR_AUTHORIZATION", authorization="YOUR_AUTHORIZATION",
) )
client.agent.create_workflow()
async def main() -> None:
await client.agent.create_workflow()
asyncio.run(main())
""" """
_response = await self._client_wrapper.httpx_client.request( _response = self._client_wrapper.httpx_client.request(
"v1/workflows", "v1/workflows",
method="POST", method="POST",
request_options=request_options, request_options=request_options,
@@ -749,9 +487,7 @@ class AsyncAgentClient:
raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json) raise ApiError(status_code=_response.status_code, body=_response_json)
async def update_workflow( def update_workflow(self, workflow_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Workflow:
self, workflow_id: str, *, request_options: typing.Optional[RequestOptions] = None
) -> Workflow:
""" """
Update a workflow definition Update a workflow definition
@@ -770,25 +506,17 @@ class AsyncAgentClient:
Examples Examples
-------- --------
import asyncio from skyvern import Skyvern
from skyvern import AsyncSkyvern client = Skyvern(
client = AsyncSkyvern(
api_key="YOUR_API_KEY", api_key="YOUR_API_KEY",
authorization="YOUR_AUTHORIZATION", authorization="YOUR_AUTHORIZATION",
) )
client.agent.update_workflow(
workflow_id="wpid_123",
async def main() -> None: )
await client.agent.update_workflow(
workflow_id="wpid_123",
)
asyncio.run(main())
""" """
_response = await self._client_wrapper.httpx_client.request( _response = self._client_wrapper.httpx_client.request(
f"v1/workflows/{jsonable_encoder(workflow_id)}", f"v1/workflows/{jsonable_encoder(workflow_id)}",
method="POST", method="POST",
request_options=request_options, request_options=request_options,
@@ -817,7 +545,7 @@ class AsyncAgentClient:
raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json) raise ApiError(status_code=_response.status_code, body=_response_json)
async def delete_workflow( def delete_workflow(
self, workflow_id: str, *, request_options: typing.Optional[RequestOptions] = None self, workflow_id: str, *, request_options: typing.Optional[RequestOptions] = None
) -> typing.Optional[typing.Any]: ) -> typing.Optional[typing.Any]:
""" """
@@ -838,25 +566,17 @@ class AsyncAgentClient:
Examples Examples
-------- --------
import asyncio from skyvern import Skyvern
from skyvern import AsyncSkyvern client = Skyvern(
client = AsyncSkyvern(
api_key="YOUR_API_KEY", api_key="YOUR_API_KEY",
authorization="YOUR_AUTHORIZATION", authorization="YOUR_AUTHORIZATION",
) )
client.agent.delete_workflow(
workflow_id="wpid_123",
async def main() -> None: )
await client.agent.delete_workflow(
workflow_id="wpid_123",
)
asyncio.run(main())
""" """
_response = await self._client_wrapper.httpx_client.request( _response = self._client_wrapper.httpx_client.request(
f"v1/workflows/{jsonable_encoder(workflow_id)}/delete", f"v1/workflows/{jsonable_encoder(workflow_id)}/delete",
method="POST", method="POST",
request_options=request_options, request_options=request_options,
@@ -885,6 +605,11 @@ class AsyncAgentClient:
raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json) raise ApiError(status_code=_response.status_code, body=_response_json)
class AsyncAgentClient:
def __init__(self, *, client_wrapper: AsyncClientWrapper):
self._client_wrapper = client_wrapper
async def run_task( async def run_task(
self, self,
*, *,
@@ -1179,11 +904,89 @@ class AsyncAgentClient:
raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json) raise ApiError(status_code=_response.status_code, body=_response_json)
async def get_run(
self, run_id: str, *, request_options: typing.Optional[RequestOptions] = None
) -> AgentGetRunResponse:
"""
Get run information (task run, workflow run)
Parameters
----------
run_id : str
The id of the task run or the workflow run.
request_options : typing.Optional[RequestOptions]
Request-specific configuration.
Returns
-------
AgentGetRunResponse
Successfully got run
Examples
--------
import asyncio
from skyvern import AsyncSkyvern
client = AsyncSkyvern(
api_key="YOUR_API_KEY",
authorization="YOUR_AUTHORIZATION",
)
async def main() -> None:
await client.agent.get_run(
run_id="tsk_123",
)
asyncio.run(main())
"""
_response = await self._client_wrapper.httpx_client.request(
f"v1/runs/{jsonable_encoder(run_id)}",
method="GET",
request_options=request_options,
)
try:
if 200 <= _response.status_code < 300:
return typing.cast(
AgentGetRunResponse,
parse_obj_as(
type_=AgentGetRunResponse, # type: ignore
object_=_response.json(),
),
)
if _response.status_code == 404:
raise NotFoundError(
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(
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, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json)
async def cancel_run( async def cancel_run(
self, run_id: str, *, request_options: typing.Optional[RequestOptions] = None self, run_id: str, *, request_options: typing.Optional[RequestOptions] = None
) -> typing.Optional[typing.Any]: ) -> typing.Optional[typing.Any]:
""" """
Cancel a task or workflow run Cancel a run (task or workflow)
Parameters Parameters
---------- ----------
@@ -1246,3 +1049,200 @@ class AsyncAgentClient:
except JSONDecodeError: except JSONDecodeError:
raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json) raise ApiError(status_code=_response.status_code, body=_response_json)
async def create_workflow(self, *, request_options: typing.Optional[RequestOptions] = None) -> Workflow:
"""
Create a new workflow
Parameters
----------
request_options : typing.Optional[RequestOptions]
Request-specific configuration.
Returns
-------
Workflow
Successfully created workflow
Examples
--------
import asyncio
from skyvern import AsyncSkyvern
client = AsyncSkyvern(
api_key="YOUR_API_KEY",
authorization="YOUR_AUTHORIZATION",
)
async def main() -> None:
await client.agent.create_workflow()
asyncio.run(main())
"""
_response = await self._client_wrapper.httpx_client.request(
"v1/workflows",
method="POST",
request_options=request_options,
)
try:
if 200 <= _response.status_code < 300:
return typing.cast(
Workflow,
parse_obj_as(
type_=Workflow, # type: ignore
object_=_response.json(),
),
)
if _response.status_code == 422:
raise UnprocessableEntityError(
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, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json)
async def update_workflow(
self, workflow_id: str, *, request_options: typing.Optional[RequestOptions] = None
) -> Workflow:
"""
Update a workflow definition
Parameters
----------
workflow_id : str
The ID of the workflow to update. Workflow ID starts with `wpid_`.
request_options : typing.Optional[RequestOptions]
Request-specific configuration.
Returns
-------
Workflow
Successfully updated workflow
Examples
--------
import asyncio
from skyvern import AsyncSkyvern
client = AsyncSkyvern(
api_key="YOUR_API_KEY",
authorization="YOUR_AUTHORIZATION",
)
async def main() -> None:
await client.agent.update_workflow(
workflow_id="wpid_123",
)
asyncio.run(main())
"""
_response = await self._client_wrapper.httpx_client.request(
f"v1/workflows/{jsonable_encoder(workflow_id)}",
method="POST",
request_options=request_options,
)
try:
if 200 <= _response.status_code < 300:
return typing.cast(
Workflow,
parse_obj_as(
type_=Workflow, # type: ignore
object_=_response.json(),
),
)
if _response.status_code == 422:
raise UnprocessableEntityError(
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, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json)
async def delete_workflow(
self, workflow_id: str, *, request_options: typing.Optional[RequestOptions] = None
) -> typing.Optional[typing.Any]:
"""
Delete a workflow
Parameters
----------
workflow_id : str
The ID of the workflow to delete. Workflow ID starts with `wpid_`.
request_options : typing.Optional[RequestOptions]
Request-specific configuration.
Returns
-------
typing.Optional[typing.Any]
Successfully deleted workflow
Examples
--------
import asyncio
from skyvern import AsyncSkyvern
client = AsyncSkyvern(
api_key="YOUR_API_KEY",
authorization="YOUR_AUTHORIZATION",
)
async def main() -> None:
await client.agent.delete_workflow(
workflow_id="wpid_123",
)
asyncio.run(main())
"""
_response = await self._client_wrapper.httpx_client.request(
f"v1/workflows/{jsonable_encoder(workflow_id)}/delete",
method="POST",
request_options=request_options,
)
try:
if 200 <= _response.status_code < 300:
return 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(
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, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json)

View File

@@ -4,13 +4,13 @@ import typing
from ..core.client_wrapper import SyncClientWrapper from ..core.client_wrapper import SyncClientWrapper
from ..core.request_options import RequestOptions from ..core.request_options import RequestOptions
from ..types.browser_session_response import BrowserSessionResponse from ..types.browser_session_response import BrowserSessionResponse
from ..core.jsonable_encoder import jsonable_encoder
from ..core.pydantic_utilities import parse_obj_as from ..core.pydantic_utilities import parse_obj_as
from ..errors.forbidden_error import ForbiddenError from ..errors.forbidden_error import ForbiddenError
from ..errors.not_found_error import NotFoundError
from ..errors.unprocessable_entity_error import UnprocessableEntityError from ..errors.unprocessable_entity_error import UnprocessableEntityError
from json.decoder import JSONDecodeError from json.decoder import JSONDecodeError
from ..core.api_error import ApiError from ..core.api_error import ApiError
from ..core.jsonable_encoder import jsonable_encoder
from ..errors.not_found_error import NotFoundError
from ..core.client_wrapper import AsyncClientWrapper from ..core.client_wrapper import AsyncClientWrapper
# this is used as the default value for optional parameters # this is used as the default value for optional parameters
@@ -21,85 +21,6 @@ class BrowserSessionClient:
def __init__(self, *, client_wrapper: SyncClientWrapper): def __init__(self, *, client_wrapper: SyncClientWrapper):
self._client_wrapper = client_wrapper self._client_wrapper = client_wrapper
def get_browser_session(
self, browser_session_id: str, *, request_options: typing.Optional[RequestOptions] = None
) -> BrowserSessionResponse:
"""
Get details about a specific browser session by ID
Parameters
----------
browser_session_id : str
request_options : typing.Optional[RequestOptions]
Request-specific configuration.
Returns
-------
BrowserSessionResponse
Successfully retrieved browser session details
Examples
--------
from skyvern import Skyvern
client = Skyvern(
api_key="YOUR_API_KEY",
authorization="YOUR_AUTHORIZATION",
)
client.browser_session.get_browser_session(
browser_session_id="browser_session_id",
)
"""
_response = self._client_wrapper.httpx_client.request(
f"v1/browser_sessions/{jsonable_encoder(browser_session_id)}",
method="GET",
request_options=request_options,
)
try:
if 200 <= _response.status_code < 300:
return typing.cast(
BrowserSessionResponse,
parse_obj_as(
type_=BrowserSessionResponse, # type: ignore
object_=_response.json(),
),
)
if _response.status_code == 403:
raise ForbiddenError(
typing.cast(
typing.Optional[typing.Any],
parse_obj_as(
type_=typing.Optional[typing.Any], # type: ignore
object_=_response.json(),
),
)
)
if _response.status_code == 404:
raise NotFoundError(
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(
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, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json)
def get_browser_sessions( def get_browser_sessions(
self, *, request_options: typing.Optional[RequestOptions] = None self, *, request_options: typing.Optional[RequestOptions] = None
) -> typing.List[BrowserSessionResponse]: ) -> typing.List[BrowserSessionResponse]:
@@ -249,6 +170,7 @@ class BrowserSessionClient:
Parameters Parameters
---------- ----------
browser_session_id : str browser_session_id : str
The ID of the browser session to close. completed_at will be set when the browser session is closed. browser_session_id starts with `pbs_`
request_options : typing.Optional[RequestOptions] request_options : typing.Optional[RequestOptions]
Request-specific configuration. Request-specific configuration.
@@ -267,7 +189,7 @@ class BrowserSessionClient:
authorization="YOUR_AUTHORIZATION", authorization="YOUR_AUTHORIZATION",
) )
client.browser_session.close_browser_session( client.browser_session.close_browser_session(
browser_session_id="browser_session_id", browser_session_id="pbs_123456",
) )
""" """
_response = self._client_wrapper.httpx_client.request( _response = self._client_wrapper.httpx_client.request(
@@ -309,12 +231,7 @@ class BrowserSessionClient:
raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json) raise ApiError(status_code=_response.status_code, body=_response_json)
def get_browser_session(
class AsyncBrowserSessionClient:
def __init__(self, *, client_wrapper: AsyncClientWrapper):
self._client_wrapper = client_wrapper
async def get_browser_session(
self, browser_session_id: str, *, request_options: typing.Optional[RequestOptions] = None self, browser_session_id: str, *, request_options: typing.Optional[RequestOptions] = None
) -> BrowserSessionResponse: ) -> BrowserSessionResponse:
""" """
@@ -323,6 +240,7 @@ class AsyncBrowserSessionClient:
Parameters Parameters
---------- ----------
browser_session_id : str browser_session_id : str
The ID of the browser session. browser_session_id starts with `pbs_`
request_options : typing.Optional[RequestOptions] request_options : typing.Optional[RequestOptions]
Request-specific configuration. Request-specific configuration.
@@ -334,25 +252,17 @@ class AsyncBrowserSessionClient:
Examples Examples
-------- --------
import asyncio from skyvern import Skyvern
from skyvern import AsyncSkyvern client = Skyvern(
client = AsyncSkyvern(
api_key="YOUR_API_KEY", api_key="YOUR_API_KEY",
authorization="YOUR_AUTHORIZATION", authorization="YOUR_AUTHORIZATION",
) )
client.browser_session.get_browser_session(
browser_session_id="pbs_123456",
async def main() -> None: )
await client.browser_session.get_browser_session(
browser_session_id="browser_session_id",
)
asyncio.run(main())
""" """
_response = await self._client_wrapper.httpx_client.request( _response = self._client_wrapper.httpx_client.request(
f"v1/browser_sessions/{jsonable_encoder(browser_session_id)}", f"v1/browser_sessions/{jsonable_encoder(browser_session_id)}",
method="GET", method="GET",
request_options=request_options, request_options=request_options,
@@ -401,6 +311,11 @@ class AsyncBrowserSessionClient:
raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json) raise ApiError(status_code=_response.status_code, body=_response_json)
class AsyncBrowserSessionClient:
def __init__(self, *, client_wrapper: AsyncClientWrapper):
self._client_wrapper = client_wrapper
async def get_browser_sessions( async def get_browser_sessions(
self, *, request_options: typing.Optional[RequestOptions] = None self, *, request_options: typing.Optional[RequestOptions] = None
) -> typing.List[BrowserSessionResponse]: ) -> typing.List[BrowserSessionResponse]:
@@ -566,6 +481,7 @@ class AsyncBrowserSessionClient:
Parameters Parameters
---------- ----------
browser_session_id : str browser_session_id : str
The ID of the browser session to close. completed_at will be set when the browser session is closed. browser_session_id starts with `pbs_`
request_options : typing.Optional[RequestOptions] request_options : typing.Optional[RequestOptions]
Request-specific configuration. Request-specific configuration.
@@ -589,7 +505,7 @@ class AsyncBrowserSessionClient:
async def main() -> None: async def main() -> None:
await client.browser_session.close_browser_session( await client.browser_session.close_browser_session(
browser_session_id="browser_session_id", browser_session_id="pbs_123456",
) )
@@ -633,3 +549,91 @@ class AsyncBrowserSessionClient:
except JSONDecodeError: except JSONDecodeError:
raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json) raise ApiError(status_code=_response.status_code, body=_response_json)
async def get_browser_session(
self, browser_session_id: str, *, request_options: typing.Optional[RequestOptions] = None
) -> BrowserSessionResponse:
"""
Get details about a specific browser session by ID
Parameters
----------
browser_session_id : str
The ID of the browser session. browser_session_id starts with `pbs_`
request_options : typing.Optional[RequestOptions]
Request-specific configuration.
Returns
-------
BrowserSessionResponse
Successfully retrieved browser session details
Examples
--------
import asyncio
from skyvern import AsyncSkyvern
client = AsyncSkyvern(
api_key="YOUR_API_KEY",
authorization="YOUR_AUTHORIZATION",
)
async def main() -> None:
await client.browser_session.get_browser_session(
browser_session_id="pbs_123456",
)
asyncio.run(main())
"""
_response = await self._client_wrapper.httpx_client.request(
f"v1/browser_sessions/{jsonable_encoder(browser_session_id)}",
method="GET",
request_options=request_options,
)
try:
if 200 <= _response.status_code < 300:
return typing.cast(
BrowserSessionResponse,
parse_obj_as(
type_=BrowserSessionResponse, # type: ignore
object_=_response.json(),
),
)
if _response.status_code == 403:
raise ForbiddenError(
typing.cast(
typing.Optional[typing.Any],
parse_obj_as(
type_=typing.Optional[typing.Any], # type: ignore
object_=_response.json(),
),
)
)
if _response.status_code == 404:
raise NotFoundError(
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(
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, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json)

View File

@@ -37,7 +37,7 @@ class CredentialsClient:
request_options: typing.Optional[RequestOptions] = None, request_options: typing.Optional[RequestOptions] = None,
) -> TotpCode: ) -> TotpCode:
""" """
Forward a TOTP (2FA, MFA) code to Skyvern Forward a TOTP (2FA, MFA) email or sms message containing the code to Skyvern
Parameters Parameters
---------- ----------
@@ -282,6 +282,57 @@ class CredentialsClient:
raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json) raise ApiError(status_code=_response.status_code, body=_response_json)
def delete_credential(self, credential_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
"""
Deletes a specific credential by its ID
Parameters
----------
credential_id : str
The unique identifier of the credential to delete
request_options : typing.Optional[RequestOptions]
Request-specific configuration.
Returns
-------
None
Examples
--------
from skyvern import Skyvern
client = Skyvern(
api_key="YOUR_API_KEY",
authorization="YOUR_AUTHORIZATION",
)
client.credentials.delete_credential(
credential_id="cred_1234567890",
)
"""
_response = self._client_wrapper.httpx_client.request(
f"v1/credentials/{jsonable_encoder(credential_id)}/delete",
method="POST",
request_options=request_options,
)
try:
if 200 <= _response.status_code < 300:
return
if _response.status_code == 422:
raise UnprocessableEntityError(
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, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json)
def get_credential( def get_credential(
self, credential_id: str, *, request_options: typing.Optional[RequestOptions] = None self, credential_id: str, *, request_options: typing.Optional[RequestOptions] = None
) -> CredentialResponse: ) -> CredentialResponse:
@@ -342,57 +393,6 @@ class CredentialsClient:
raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json) raise ApiError(status_code=_response.status_code, body=_response_json)
def delete_credential(self, credential_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
"""
Deletes a specific credential by its ID
Parameters
----------
credential_id : str
The unique identifier of the credential to delete
request_options : typing.Optional[RequestOptions]
Request-specific configuration.
Returns
-------
None
Examples
--------
from skyvern import Skyvern
client = Skyvern(
api_key="YOUR_API_KEY",
authorization="YOUR_AUTHORIZATION",
)
client.credentials.delete_credential(
credential_id="cred_1234567890",
)
"""
_response = self._client_wrapper.httpx_client.request(
f"v1/credentials/{jsonable_encoder(credential_id)}/delete",
method="POST",
request_options=request_options,
)
try:
if 200 <= _response.status_code < 300:
return
if _response.status_code == 422:
raise UnprocessableEntityError(
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, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json)
class AsyncCredentialsClient: class AsyncCredentialsClient:
def __init__(self, *, client_wrapper: AsyncClientWrapper): def __init__(self, *, client_wrapper: AsyncClientWrapper):
@@ -411,7 +411,7 @@ class AsyncCredentialsClient:
request_options: typing.Optional[RequestOptions] = None, request_options: typing.Optional[RequestOptions] = None,
) -> TotpCode: ) -> TotpCode:
""" """
Forward a TOTP (2FA, MFA) code to Skyvern Forward a TOTP (2FA, MFA) email or sms message containing the code to Skyvern
Parameters Parameters
---------- ----------
@@ -680,6 +680,67 @@ class AsyncCredentialsClient:
raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json) raise ApiError(status_code=_response.status_code, body=_response_json)
async def delete_credential(
self, credential_id: str, *, request_options: typing.Optional[RequestOptions] = None
) -> None:
"""
Deletes a specific credential by its ID
Parameters
----------
credential_id : str
The unique identifier of the credential to delete
request_options : typing.Optional[RequestOptions]
Request-specific configuration.
Returns
-------
None
Examples
--------
import asyncio
from skyvern import AsyncSkyvern
client = AsyncSkyvern(
api_key="YOUR_API_KEY",
authorization="YOUR_AUTHORIZATION",
)
async def main() -> None:
await client.credentials.delete_credential(
credential_id="cred_1234567890",
)
asyncio.run(main())
"""
_response = await self._client_wrapper.httpx_client.request(
f"v1/credentials/{jsonable_encoder(credential_id)}/delete",
method="POST",
request_options=request_options,
)
try:
if 200 <= _response.status_code < 300:
return
if _response.status_code == 422:
raise UnprocessableEntityError(
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, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json)
async def get_credential( async def get_credential(
self, credential_id: str, *, request_options: typing.Optional[RequestOptions] = None self, credential_id: str, *, request_options: typing.Optional[RequestOptions] = None
) -> CredentialResponse: ) -> CredentialResponse:
@@ -747,64 +808,3 @@ class AsyncCredentialsClient:
except JSONDecodeError: except JSONDecodeError:
raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json) raise ApiError(status_code=_response.status_code, body=_response_json)
async def delete_credential(
self, credential_id: str, *, request_options: typing.Optional[RequestOptions] = None
) -> None:
"""
Deletes a specific credential by its ID
Parameters
----------
credential_id : str
The unique identifier of the credential to delete
request_options : typing.Optional[RequestOptions]
Request-specific configuration.
Returns
-------
None
Examples
--------
import asyncio
from skyvern import AsyncSkyvern
client = AsyncSkyvern(
api_key="YOUR_API_KEY",
authorization="YOUR_AUTHORIZATION",
)
async def main() -> None:
await client.credentials.delete_credential(
credential_id="cred_1234567890",
)
asyncio.run(main())
"""
_response = await self._client_wrapper.httpx_client.request(
f"v1/credentials/{jsonable_encoder(credential_id)}/delete",
method="POST",
request_options=request_options,
)
try:
if 200 <= _response.status_code < 300:
return
if _response.status_code == 422:
raise UnprocessableEntityError(
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, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json)

View File

@@ -14,7 +14,7 @@ class BrowserSessionResponse(UniversalBaseModel):
browser_session_id: str = pydantic.Field() browser_session_id: str = pydantic.Field()
""" """
Unique identifier for the browser session Unique identifier for the browser session. browser_session_id starts with `pbs_`.
""" """
organization_id: str = pydantic.Field() organization_id: str = pydantic.Field()
@@ -24,17 +24,17 @@ class BrowserSessionResponse(UniversalBaseModel):
runnable_type: typing.Optional[str] = pydantic.Field(default=None) runnable_type: typing.Optional[str] = pydantic.Field(default=None)
""" """
Type of runnable associated with this session (workflow, task etc) Type of the current runnable associated with this session (workflow, task etc)
""" """
runnable_id: typing.Optional[str] = pydantic.Field(default=None) runnable_id: typing.Optional[str] = pydantic.Field(default=None)
""" """
ID of the associated runnable ID of the current runnable
""" """
timeout: typing.Optional[int] = pydantic.Field(default=None) timeout: typing.Optional[int] = pydantic.Field(default=None)
""" """
Timeout in minutes for the session. Timeout is applied after the session is started. Timeout in minutes for the session. Timeout is applied after the session is started. Defaults to 60 minutes.
""" """
started_at: typing.Optional[dt.datetime] = pydantic.Field(default=None) started_at: typing.Optional[dt.datetime] = pydantic.Field(default=None)