group workflows interfaces - create_workflow, update_workflow, delete_workflow (#2405)
This commit is contained in:
@@ -235,7 +235,7 @@ from .types import (
|
||||
WorkflowStatus,
|
||||
)
|
||||
from .errors import BadRequestError, ForbiddenError, NotFoundError, UnprocessableEntityError
|
||||
from . import agent, browser_session, credentials
|
||||
from . import agent, browser_session, credentials, workflows
|
||||
from .agent import (
|
||||
AgentGetRunResponse,
|
||||
AgentGetRunResponse_AnthropicCua,
|
||||
@@ -500,4 +500,5 @@ __all__ = [
|
||||
"agent",
|
||||
"browser_session",
|
||||
"credentials",
|
||||
"workflows",
|
||||
]
|
||||
|
||||
@@ -434,59 +434,6 @@ class AgentClient:
|
||||
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
|
||||
@@ -545,66 +492,6 @@ class AgentClient:
|
||||
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)
|
||||
|
||||
|
||||
class AsyncAgentClient:
|
||||
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
||||
@@ -1050,67 +937,6 @@ class AsyncAgentClient:
|
||||
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
|
||||
|
||||
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:
|
||||
@@ -1178,71 +1004,3 @@ class AsyncAgentClient:
|
||||
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)
|
||||
|
||||
@@ -5,10 +5,12 @@ from .environment import SkyvernEnvironment
|
||||
import httpx
|
||||
from .core.client_wrapper import SyncClientWrapper
|
||||
from .agent.client import AgentClient
|
||||
from .workflows.client import WorkflowsClient
|
||||
from .browser_session.client import BrowserSessionClient
|
||||
from .credentials.client import CredentialsClient
|
||||
from .core.client_wrapper import AsyncClientWrapper
|
||||
from .agent.client import AsyncAgentClient
|
||||
from .workflows.client import AsyncWorkflowsClient
|
||||
from .browser_session.client import AsyncBrowserSessionClient
|
||||
from .credentials.client import AsyncCredentialsClient
|
||||
|
||||
@@ -76,6 +78,7 @@ class Skyvern:
|
||||
timeout=_defaulted_timeout,
|
||||
)
|
||||
self.agent = AgentClient(client_wrapper=self._client_wrapper)
|
||||
self.workflows = WorkflowsClient(client_wrapper=self._client_wrapper)
|
||||
self.browser_session = BrowserSessionClient(client_wrapper=self._client_wrapper)
|
||||
self.credentials = CredentialsClient(client_wrapper=self._client_wrapper)
|
||||
|
||||
@@ -143,6 +146,7 @@ class AsyncSkyvern:
|
||||
timeout=_defaulted_timeout,
|
||||
)
|
||||
self.agent = AsyncAgentClient(client_wrapper=self._client_wrapper)
|
||||
self.workflows = AsyncWorkflowsClient(client_wrapper=self._client_wrapper)
|
||||
self.browser_session = AsyncBrowserSessionClient(client_wrapper=self._client_wrapper)
|
||||
self.credentials = AsyncCredentialsClient(client_wrapper=self._client_wrapper)
|
||||
|
||||
|
||||
2
skyvern/client/workflows/__init__.py
Normal file
2
skyvern/client/workflows/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
# This file was auto-generated by Fern from our API Definition.
|
||||
|
||||
264
skyvern/client/workflows/client.py
Normal file
264
skyvern/client/workflows/client.py
Normal file
@@ -0,0 +1,264 @@
|
||||
# This file was auto-generated by Fern from our API Definition.
|
||||
|
||||
from ..core.client_wrapper import SyncClientWrapper
|
||||
import typing
|
||||
from ..core.request_options import RequestOptions
|
||||
from ..types.workflow import Workflow
|
||||
from ..core.pydantic_utilities import parse_obj_as
|
||||
from ..errors.unprocessable_entity_error import UnprocessableEntityError
|
||||
from json.decoder import JSONDecodeError
|
||||
from ..core.api_error import ApiError
|
||||
from ..core.jsonable_encoder import jsonable_encoder
|
||||
from ..core.client_wrapper import AsyncClientWrapper
|
||||
|
||||
|
||||
class WorkflowsClient:
|
||||
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
||||
self._client_wrapper = client_wrapper
|
||||
|
||||
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.workflows.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 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.workflows.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)
|
||||
|
||||
|
||||
class AsyncWorkflowsClient:
|
||||
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
||||
self._client_wrapper = client_wrapper
|
||||
|
||||
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.workflows.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 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.workflows.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)
|
||||
Reference in New Issue
Block a user