update login interface to support wait_for_completion (#3018)
This commit is contained in:
@@ -28,9 +28,9 @@ from .errors.forbidden_error import ForbiddenError
|
||||
import datetime as dt
|
||||
from .types.totp_code import TotpCode
|
||||
from .types.credential_response import CredentialResponse
|
||||
from .types.credential_type import CredentialType
|
||||
from .types.skyvern_forge_sdk_schemas_credentials_credential_type import SkyvernForgeSdkSchemasCredentialsCredentialType
|
||||
from .types.create_credential_request_credential import CreateCredentialRequestCredential
|
||||
from .types.login_request_body import LoginRequestBody
|
||||
from .types.skyvern_schemas_run_blocks_credential_type import SkyvernSchemasRunBlocksCredentialType
|
||||
from .core.client_wrapper import AsyncClientWrapper
|
||||
|
||||
# this is used as the default value for optional parameters
|
||||
@@ -1544,7 +1544,7 @@ class Skyvern:
|
||||
self,
|
||||
*,
|
||||
name: str,
|
||||
credential_type: CredentialType,
|
||||
credential_type: SkyvernForgeSdkSchemasCredentialsCredentialType,
|
||||
credential: CreateCredentialRequestCredential,
|
||||
request_options: typing.Optional[RequestOptions] = None,
|
||||
) -> CredentialResponse:
|
||||
@@ -1556,7 +1556,7 @@ class Skyvern:
|
||||
name : str
|
||||
Name of the credential
|
||||
|
||||
credential_type : CredentialType
|
||||
credential_type : SkyvernForgeSdkSchemasCredentialsCredentialType
|
||||
Type of credential to create
|
||||
|
||||
credential : CreateCredentialRequestCredential
|
||||
@@ -1740,14 +1740,74 @@ class Skyvern:
|
||||
raise ApiError(status_code=_response.status_code, body=_response_json)
|
||||
|
||||
def login(
|
||||
self, *, request: LoginRequestBody, request_options: typing.Optional[RequestOptions] = None
|
||||
self,
|
||||
*,
|
||||
credential_type: SkyvernSchemasRunBlocksCredentialType,
|
||||
url: typing.Optional[str] = OMIT,
|
||||
prompt: typing.Optional[str] = OMIT,
|
||||
webhook_url: typing.Optional[str] = OMIT,
|
||||
proxy_location: typing.Optional[ProxyLocation] = OMIT,
|
||||
totp_identifier: typing.Optional[str] = OMIT,
|
||||
totp_url: typing.Optional[str] = OMIT,
|
||||
browser_session_id: typing.Optional[str] = OMIT,
|
||||
extra_http_headers: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT,
|
||||
max_screenshot_scrolling_times: typing.Optional[int] = OMIT,
|
||||
credential_id: typing.Optional[str] = OMIT,
|
||||
bitwarden_collection_id: typing.Optional[str] = OMIT,
|
||||
bitwarden_item_id: typing.Optional[str] = OMIT,
|
||||
onepassword_vault_id: typing.Optional[str] = OMIT,
|
||||
onepassword_item_id: typing.Optional[str] = OMIT,
|
||||
request_options: typing.Optional[RequestOptions] = None,
|
||||
) -> WorkflowRunResponse:
|
||||
"""
|
||||
Log in to a website using either credential stored in Skyvern, Bitwarden or 1Password
|
||||
|
||||
Parameters
|
||||
----------
|
||||
request : LoginRequestBody
|
||||
credential_type : SkyvernSchemasRunBlocksCredentialType
|
||||
Where to get the credential from
|
||||
|
||||
url : typing.Optional[str]
|
||||
Website url
|
||||
|
||||
prompt : typing.Optional[str]
|
||||
Login instructions. Skyvern has default prompt/instruction for login if this field is not provided.
|
||||
|
||||
webhook_url : typing.Optional[str]
|
||||
Webhook URL to send login status updates
|
||||
|
||||
proxy_location : typing.Optional[ProxyLocation]
|
||||
Proxy location to use
|
||||
|
||||
totp_identifier : typing.Optional[str]
|
||||
Identifier for TOTP (Time-based One-Time Password) if required
|
||||
|
||||
totp_url : typing.Optional[str]
|
||||
TOTP URL to fetch one-time passwords
|
||||
|
||||
browser_session_id : typing.Optional[str]
|
||||
ID of the browser session to use, which is prefixed by `pbs_` e.g. `pbs_123456`
|
||||
|
||||
extra_http_headers : typing.Optional[typing.Dict[str, typing.Optional[str]]]
|
||||
Additional HTTP headers to include in requests
|
||||
|
||||
max_screenshot_scrolling_times : typing.Optional[int]
|
||||
Maximum number of times to scroll for screenshots
|
||||
|
||||
credential_id : typing.Optional[str]
|
||||
ID of the Skyvern credential to use for login.
|
||||
|
||||
bitwarden_collection_id : typing.Optional[str]
|
||||
Bitwarden collection ID. You can find it in the Bitwarden collection URL. e.g. `https://vault.bitwarden.com/vaults/collection_id/items`
|
||||
|
||||
bitwarden_item_id : typing.Optional[str]
|
||||
Bitwarden item ID
|
||||
|
||||
onepassword_vault_id : typing.Optional[str]
|
||||
1Password vault ID
|
||||
|
||||
onepassword_item_id : typing.Optional[str]
|
||||
1Password item ID
|
||||
|
||||
request_options : typing.Optional[RequestOptions]
|
||||
Request-specific configuration.
|
||||
@@ -1759,24 +1819,39 @@ class Skyvern:
|
||||
|
||||
Examples
|
||||
--------
|
||||
from skyvern import LoginRequestBody_Skyvern, Skyvern
|
||||
from skyvern import Skyvern
|
||||
|
||||
client = Skyvern(
|
||||
api_key="YOUR_API_KEY",
|
||||
x_api_key="YOUR_X_API_KEY",
|
||||
)
|
||||
client.login(
|
||||
request=LoginRequestBody_Skyvern(
|
||||
credential_id="credential_id",
|
||||
),
|
||||
credential_type="skyvern",
|
||||
)
|
||||
"""
|
||||
_response = self._client_wrapper.httpx_client.request(
|
||||
"v1/run/tasks/login",
|
||||
method="POST",
|
||||
json=convert_and_respect_annotation_metadata(
|
||||
object_=request, annotation=LoginRequestBody, direction="write"
|
||||
),
|
||||
json={
|
||||
"credential_type": credential_type,
|
||||
"url": url,
|
||||
"prompt": prompt,
|
||||
"webhook_url": webhook_url,
|
||||
"proxy_location": proxy_location,
|
||||
"totp_identifier": totp_identifier,
|
||||
"totp_url": totp_url,
|
||||
"browser_session_id": browser_session_id,
|
||||
"extra_http_headers": extra_http_headers,
|
||||
"max_screenshot_scrolling_times": max_screenshot_scrolling_times,
|
||||
"credential_id": credential_id,
|
||||
"bitwarden_collection_id": bitwarden_collection_id,
|
||||
"bitwarden_item_id": bitwarden_item_id,
|
||||
"onepassword_vault_id": onepassword_vault_id,
|
||||
"onepassword_item_id": onepassword_item_id,
|
||||
},
|
||||
headers={
|
||||
"content-type": "application/json",
|
||||
},
|
||||
request_options=request_options,
|
||||
omit=OMIT,
|
||||
)
|
||||
@@ -3450,7 +3525,7 @@ class AsyncSkyvern:
|
||||
self,
|
||||
*,
|
||||
name: str,
|
||||
credential_type: CredentialType,
|
||||
credential_type: SkyvernForgeSdkSchemasCredentialsCredentialType,
|
||||
credential: CreateCredentialRequestCredential,
|
||||
request_options: typing.Optional[RequestOptions] = None,
|
||||
) -> CredentialResponse:
|
||||
@@ -3462,7 +3537,7 @@ class AsyncSkyvern:
|
||||
name : str
|
||||
Name of the credential
|
||||
|
||||
credential_type : CredentialType
|
||||
credential_type : SkyvernForgeSdkSchemasCredentialsCredentialType
|
||||
Type of credential to create
|
||||
|
||||
credential : CreateCredentialRequestCredential
|
||||
@@ -3672,14 +3747,74 @@ class AsyncSkyvern:
|
||||
raise ApiError(status_code=_response.status_code, body=_response_json)
|
||||
|
||||
async def login(
|
||||
self, *, request: LoginRequestBody, request_options: typing.Optional[RequestOptions] = None
|
||||
self,
|
||||
*,
|
||||
credential_type: SkyvernSchemasRunBlocksCredentialType,
|
||||
url: typing.Optional[str] = OMIT,
|
||||
prompt: typing.Optional[str] = OMIT,
|
||||
webhook_url: typing.Optional[str] = OMIT,
|
||||
proxy_location: typing.Optional[ProxyLocation] = OMIT,
|
||||
totp_identifier: typing.Optional[str] = OMIT,
|
||||
totp_url: typing.Optional[str] = OMIT,
|
||||
browser_session_id: typing.Optional[str] = OMIT,
|
||||
extra_http_headers: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT,
|
||||
max_screenshot_scrolling_times: typing.Optional[int] = OMIT,
|
||||
credential_id: typing.Optional[str] = OMIT,
|
||||
bitwarden_collection_id: typing.Optional[str] = OMIT,
|
||||
bitwarden_item_id: typing.Optional[str] = OMIT,
|
||||
onepassword_vault_id: typing.Optional[str] = OMIT,
|
||||
onepassword_item_id: typing.Optional[str] = OMIT,
|
||||
request_options: typing.Optional[RequestOptions] = None,
|
||||
) -> WorkflowRunResponse:
|
||||
"""
|
||||
Log in to a website using either credential stored in Skyvern, Bitwarden or 1Password
|
||||
|
||||
Parameters
|
||||
----------
|
||||
request : LoginRequestBody
|
||||
credential_type : SkyvernSchemasRunBlocksCredentialType
|
||||
Where to get the credential from
|
||||
|
||||
url : typing.Optional[str]
|
||||
Website url
|
||||
|
||||
prompt : typing.Optional[str]
|
||||
Login instructions. Skyvern has default prompt/instruction for login if this field is not provided.
|
||||
|
||||
webhook_url : typing.Optional[str]
|
||||
Webhook URL to send login status updates
|
||||
|
||||
proxy_location : typing.Optional[ProxyLocation]
|
||||
Proxy location to use
|
||||
|
||||
totp_identifier : typing.Optional[str]
|
||||
Identifier for TOTP (Time-based One-Time Password) if required
|
||||
|
||||
totp_url : typing.Optional[str]
|
||||
TOTP URL to fetch one-time passwords
|
||||
|
||||
browser_session_id : typing.Optional[str]
|
||||
ID of the browser session to use, which is prefixed by `pbs_` e.g. `pbs_123456`
|
||||
|
||||
extra_http_headers : typing.Optional[typing.Dict[str, typing.Optional[str]]]
|
||||
Additional HTTP headers to include in requests
|
||||
|
||||
max_screenshot_scrolling_times : typing.Optional[int]
|
||||
Maximum number of times to scroll for screenshots
|
||||
|
||||
credential_id : typing.Optional[str]
|
||||
ID of the Skyvern credential to use for login.
|
||||
|
||||
bitwarden_collection_id : typing.Optional[str]
|
||||
Bitwarden collection ID. You can find it in the Bitwarden collection URL. e.g. `https://vault.bitwarden.com/vaults/collection_id/items`
|
||||
|
||||
bitwarden_item_id : typing.Optional[str]
|
||||
Bitwarden item ID
|
||||
|
||||
onepassword_vault_id : typing.Optional[str]
|
||||
1Password vault ID
|
||||
|
||||
onepassword_item_id : typing.Optional[str]
|
||||
1Password item ID
|
||||
|
||||
request_options : typing.Optional[RequestOptions]
|
||||
Request-specific configuration.
|
||||
@@ -3693,7 +3828,7 @@ class AsyncSkyvern:
|
||||
--------
|
||||
import asyncio
|
||||
|
||||
from skyvern import AsyncSkyvern, LoginRequestBody_Skyvern
|
||||
from skyvern import AsyncSkyvern
|
||||
|
||||
client = AsyncSkyvern(
|
||||
api_key="YOUR_API_KEY",
|
||||
@@ -3703,9 +3838,7 @@ class AsyncSkyvern:
|
||||
|
||||
async def main() -> None:
|
||||
await client.login(
|
||||
request=LoginRequestBody_Skyvern(
|
||||
credential_id="credential_id",
|
||||
),
|
||||
credential_type="skyvern",
|
||||
)
|
||||
|
||||
|
||||
@@ -3714,9 +3847,26 @@ class AsyncSkyvern:
|
||||
_response = await self._client_wrapper.httpx_client.request(
|
||||
"v1/run/tasks/login",
|
||||
method="POST",
|
||||
json=convert_and_respect_annotation_metadata(
|
||||
object_=request, annotation=LoginRequestBody, direction="write"
|
||||
),
|
||||
json={
|
||||
"credential_type": credential_type,
|
||||
"url": url,
|
||||
"prompt": prompt,
|
||||
"webhook_url": webhook_url,
|
||||
"proxy_location": proxy_location,
|
||||
"totp_identifier": totp_identifier,
|
||||
"totp_url": totp_url,
|
||||
"browser_session_id": browser_session_id,
|
||||
"extra_http_headers": extra_http_headers,
|
||||
"max_screenshot_scrolling_times": max_screenshot_scrolling_times,
|
||||
"credential_id": credential_id,
|
||||
"bitwarden_collection_id": bitwarden_collection_id,
|
||||
"bitwarden_item_id": bitwarden_item_id,
|
||||
"onepassword_vault_id": onepassword_vault_id,
|
||||
"onepassword_item_id": onepassword_item_id,
|
||||
},
|
||||
headers={
|
||||
"content-type": "application/json",
|
||||
},
|
||||
request_options=request_options,
|
||||
omit=OMIT,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user