mirror of
https://github.com/Skyvern-AI/skyvern.git
synced 2025-09-04 19:50:37 +00:00
243 lines
7.8 KiB
Python
243 lines
7.8 KiB
Python
# 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 ..core.pydantic_utilities import parse_obj_as
|
|
from ..errors.unprocessable_entity_error import UnprocessableEntityError
|
|
from ..types.http_validation_error import HttpValidationError
|
|
from json.decoder import JSONDecodeError
|
|
from ..core.api_error import ApiError
|
|
from ..core.client_wrapper import AsyncClientWrapper
|
|
|
|
|
|
class ServerClient:
|
|
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
self._client_wrapper = client_wrapper
|
|
|
|
def webhook(
|
|
self,
|
|
*,
|
|
skyvern_signature: typing.Optional[str] = None,
|
|
skyvern_timestamp: typing.Optional[str] = None,
|
|
request_options: typing.Optional[RequestOptions] = None,
|
|
) -> typing.Optional[typing.Any]:
|
|
"""
|
|
Parameters
|
|
----------
|
|
skyvern_signature : typing.Optional[str]
|
|
|
|
skyvern_timestamp : typing.Optional[str]
|
|
|
|
request_options : typing.Optional[RequestOptions]
|
|
Request-specific configuration.
|
|
|
|
Returns
|
|
-------
|
|
typing.Optional[typing.Any]
|
|
Successful Response
|
|
|
|
Examples
|
|
--------
|
|
from skyverndocs import Skyvern
|
|
|
|
client = Skyvern()
|
|
client.server.webhook()
|
|
"""
|
|
_response = self._client_wrapper.httpx_client.request(
|
|
"api/v1/webhook",
|
|
method="POST",
|
|
headers={
|
|
"x-skyvern-signature": str(skyvern_signature) if skyvern_signature is not None else None,
|
|
"x-skyvern-timestamp": str(skyvern_timestamp) if skyvern_timestamp is not None else None,
|
|
},
|
|
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(
|
|
HttpValidationError,
|
|
parse_obj_as(
|
|
type_=HttpValidationError, # 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 check_status(self, *, request_options: typing.Optional[RequestOptions] = None) -> typing.Optional[typing.Any]:
|
|
"""
|
|
Check if the server is running.
|
|
|
|
Parameters
|
|
----------
|
|
request_options : typing.Optional[RequestOptions]
|
|
Request-specific configuration.
|
|
|
|
Returns
|
|
-------
|
|
typing.Optional[typing.Any]
|
|
Successful Response
|
|
|
|
Examples
|
|
--------
|
|
from skyverndocs import Skyvern
|
|
|
|
client = Skyvern()
|
|
client.server.check_status()
|
|
"""
|
|
_response = self._client_wrapper.httpx_client.request(
|
|
"api/v1/heartbeat",
|
|
method="GET",
|
|
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(),
|
|
),
|
|
)
|
|
_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 AsyncServerClient:
|
|
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
self._client_wrapper = client_wrapper
|
|
|
|
async def webhook(
|
|
self,
|
|
*,
|
|
skyvern_signature: typing.Optional[str] = None,
|
|
skyvern_timestamp: typing.Optional[str] = None,
|
|
request_options: typing.Optional[RequestOptions] = None,
|
|
) -> typing.Optional[typing.Any]:
|
|
"""
|
|
Parameters
|
|
----------
|
|
skyvern_signature : typing.Optional[str]
|
|
|
|
skyvern_timestamp : typing.Optional[str]
|
|
|
|
request_options : typing.Optional[RequestOptions]
|
|
Request-specific configuration.
|
|
|
|
Returns
|
|
-------
|
|
typing.Optional[typing.Any]
|
|
Successful Response
|
|
|
|
Examples
|
|
--------
|
|
import asyncio
|
|
|
|
from skyverndocs import AsyncSkyvern
|
|
|
|
client = AsyncSkyvern()
|
|
|
|
|
|
async def main() -> None:
|
|
await client.server.webhook()
|
|
|
|
|
|
asyncio.run(main())
|
|
"""
|
|
_response = await self._client_wrapper.httpx_client.request(
|
|
"api/v1/webhook",
|
|
method="POST",
|
|
headers={
|
|
"x-skyvern-signature": str(skyvern_signature) if skyvern_signature is not None else None,
|
|
"x-skyvern-timestamp": str(skyvern_timestamp) if skyvern_timestamp is not None else None,
|
|
},
|
|
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(
|
|
HttpValidationError,
|
|
parse_obj_as(
|
|
type_=HttpValidationError, # 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 check_status(
|
|
self, *, request_options: typing.Optional[RequestOptions] = None
|
|
) -> typing.Optional[typing.Any]:
|
|
"""
|
|
Check if the server is running.
|
|
|
|
Parameters
|
|
----------
|
|
request_options : typing.Optional[RequestOptions]
|
|
Request-specific configuration.
|
|
|
|
Returns
|
|
-------
|
|
typing.Optional[typing.Any]
|
|
Successful Response
|
|
|
|
Examples
|
|
--------
|
|
import asyncio
|
|
|
|
from skyverndocs import AsyncSkyvern
|
|
|
|
client = AsyncSkyvern()
|
|
|
|
|
|
async def main() -> None:
|
|
await client.server.check_status()
|
|
|
|
|
|
asyncio.run(main())
|
|
"""
|
|
_response = await self._client_wrapper.httpx_client.request(
|
|
"api/v1/heartbeat",
|
|
method="GET",
|
|
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(),
|
|
),
|
|
)
|
|
_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)
|