Browser Profiles API Docs (#4087)
This commit is contained in:
@@ -185,6 +185,12 @@ navigation:
|
|||||||
- GET /v1/browser_sessions/{browser_session_id}
|
- GET /v1/browser_sessions/{browser_session_id}
|
||||||
- POST /v1/browser_sessions/{browser_session_id}/close
|
- POST /v1/browser_sessions/{browser_session_id}/close
|
||||||
- GET /v1/browser_sessions
|
- GET /v1/browser_sessions
|
||||||
|
- section: Browser Profiles
|
||||||
|
contents:
|
||||||
|
- POST /v1/browser_profiles
|
||||||
|
- GET /v1/browser_profiles
|
||||||
|
- GET /v1/browser_profiles/{profile_id}
|
||||||
|
- DELETE /v1/browser_profiles/{profile_id}
|
||||||
- section: Credentials
|
- section: Credentials
|
||||||
contents:
|
contents:
|
||||||
- POST /v1/credentials
|
- POST /v1/credentials
|
||||||
|
|||||||
@@ -12,6 +12,16 @@ from skyvern.exceptions import (
|
|||||||
WorkflowRunNotFound,
|
WorkflowRunNotFound,
|
||||||
)
|
)
|
||||||
from skyvern.forge import app
|
from skyvern.forge import app
|
||||||
|
from skyvern.forge.sdk.routes.code_samples import (
|
||||||
|
CREATE_BROWSER_PROFILE_CODE_SAMPLE_PYTHON,
|
||||||
|
CREATE_BROWSER_PROFILE_CODE_SAMPLE_TS,
|
||||||
|
DELETE_BROWSER_PROFILE_CODE_SAMPLE_PYTHON,
|
||||||
|
DELETE_BROWSER_PROFILE_CODE_SAMPLE_TS,
|
||||||
|
GET_BROWSER_PROFILE_CODE_SAMPLE_PYTHON,
|
||||||
|
GET_BROWSER_PROFILE_CODE_SAMPLE_TS,
|
||||||
|
GET_BROWSER_PROFILES_CODE_SAMPLE_PYTHON,
|
||||||
|
GET_BROWSER_PROFILES_CODE_SAMPLE_TS,
|
||||||
|
)
|
||||||
from skyvern.forge.sdk.routes.routers import base_router
|
from skyvern.forge.sdk.routes.routers import base_router
|
||||||
from skyvern.forge.sdk.schemas.browser_profiles import (
|
from skyvern.forge.sdk.schemas.browser_profiles import (
|
||||||
BrowserProfile,
|
BrowserProfile,
|
||||||
@@ -41,6 +51,23 @@ def _handle_duplicate_profile_name(*, organization_id: str, name: str, exc: Inte
|
|||||||
response_model=BrowserProfile,
|
response_model=BrowserProfile,
|
||||||
tags=["Browser Profiles"],
|
tags=["Browser Profiles"],
|
||||||
summary="Create a browser profile",
|
summary="Create a browser profile",
|
||||||
|
description="Create a browser profile from a persistent browser session or workflow run.",
|
||||||
|
openapi_extra={
|
||||||
|
"x-fern-sdk-method-name": "create_browser_profile",
|
||||||
|
"x-fern-examples": [
|
||||||
|
{
|
||||||
|
"code-samples": [
|
||||||
|
{"sdk": "python", "code": CREATE_BROWSER_PROFILE_CODE_SAMPLE_PYTHON},
|
||||||
|
{"sdk": "typescript", "code": CREATE_BROWSER_PROFILE_CODE_SAMPLE_TS},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
responses={
|
||||||
|
200: {"description": "Successfully created browser profile"},
|
||||||
|
400: {"description": "Invalid request - missing source or source not found"},
|
||||||
|
409: {"description": "Browser profile name already exists"},
|
||||||
|
},
|
||||||
)
|
)
|
||||||
@base_router.post(
|
@base_router.post(
|
||||||
"/browser_profiles/",
|
"/browser_profiles/",
|
||||||
@@ -84,6 +111,20 @@ async def create_browser_profile(
|
|||||||
tags=["Browser Profiles"],
|
tags=["Browser Profiles"],
|
||||||
summary="List browser profiles",
|
summary="List browser profiles",
|
||||||
description="Get all browser profiles for the organization",
|
description="Get all browser profiles for the organization",
|
||||||
|
openapi_extra={
|
||||||
|
"x-fern-sdk-method-name": "list_browser_profiles",
|
||||||
|
"x-fern-examples": [
|
||||||
|
{
|
||||||
|
"code-samples": [
|
||||||
|
{"sdk": "python", "code": GET_BROWSER_PROFILES_CODE_SAMPLE_PYTHON},
|
||||||
|
{"sdk": "typescript", "code": GET_BROWSER_PROFILES_CODE_SAMPLE_TS},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
responses={
|
||||||
|
200: {"description": "Successfully retrieved browser profiles"},
|
||||||
|
},
|
||||||
)
|
)
|
||||||
@base_router.get(
|
@base_router.get(
|
||||||
"/browser_profiles/",
|
"/browser_profiles/",
|
||||||
@@ -125,6 +166,17 @@ async def list_browser_profiles(
|
|||||||
200: {"description": "Successfully retrieved browser profile"},
|
200: {"description": "Successfully retrieved browser profile"},
|
||||||
404: {"description": "Browser profile not found"},
|
404: {"description": "Browser profile not found"},
|
||||||
},
|
},
|
||||||
|
openapi_extra={
|
||||||
|
"x-fern-sdk-method-name": "get_browser_profile",
|
||||||
|
"x-fern-examples": [
|
||||||
|
{
|
||||||
|
"code-samples": [
|
||||||
|
{"sdk": "python", "code": GET_BROWSER_PROFILE_CODE_SAMPLE_PYTHON},
|
||||||
|
{"sdk": "typescript", "code": GET_BROWSER_PROFILE_CODE_SAMPLE_TS},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
)
|
)
|
||||||
@base_router.get(
|
@base_router.get(
|
||||||
"/browser_profiles/{profile_id}/",
|
"/browser_profiles/{profile_id}/",
|
||||||
@@ -178,6 +230,17 @@ async def get_browser_profile(
|
|||||||
204: {"description": "Successfully deleted browser profile"},
|
204: {"description": "Successfully deleted browser profile"},
|
||||||
404: {"description": "Browser profile not found"},
|
404: {"description": "Browser profile not found"},
|
||||||
},
|
},
|
||||||
|
openapi_extra={
|
||||||
|
"x-fern-sdk-method-name": "delete_browser_profile",
|
||||||
|
"x-fern-examples": [
|
||||||
|
{
|
||||||
|
"code-samples": [
|
||||||
|
{"sdk": "python", "code": DELETE_BROWSER_PROFILE_CODE_SAMPLE_PYTHON},
|
||||||
|
{"sdk": "typescript", "code": DELETE_BROWSER_PROFILE_CODE_SAMPLE_TS},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
)
|
)
|
||||||
@base_router.delete(
|
@base_router.delete(
|
||||||
"/browser_profiles/{profile_id}/",
|
"/browser_profiles/{profile_id}/",
|
||||||
|
|||||||
@@ -835,3 +835,73 @@ const skyvern = new SkyvernClient({ apiKey: "YOUR_API_KEY" });
|
|||||||
const browserSessions = await skyvern.getBrowserSessions();
|
const browserSessions = await skyvern.getBrowserSessions();
|
||||||
console.log(browserSessions);
|
console.log(browserSessions);
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# Browser Profiles
|
||||||
|
CREATE_BROWSER_PROFILE_CODE_SAMPLE_PYTHON = """from skyvern import Skyvern
|
||||||
|
|
||||||
|
skyvern = Skyvern(api_key="YOUR_API_KEY")
|
||||||
|
# Create a browser profile from a persistent browser session
|
||||||
|
browser_profile = await skyvern.browser_profiles.create_browser_profile(
|
||||||
|
name="My Profile",
|
||||||
|
browser_session_id="pbs_123",
|
||||||
|
)
|
||||||
|
print(browser_profile)
|
||||||
|
|
||||||
|
# Or create from a workflow run with persist_browser_session=True
|
||||||
|
browser_profile = await skyvern.browser_profiles.create_browser_profile(
|
||||||
|
name="My Profile",
|
||||||
|
workflow_run_id="wr_123",
|
||||||
|
)
|
||||||
|
print(browser_profile)
|
||||||
|
"""
|
||||||
|
CREATE_BROWSER_PROFILE_CODE_SAMPLE_TS = """import { SkyvernClient } from "@skyvern/client";
|
||||||
|
|
||||||
|
const skyvern = new SkyvernClient({ apiKey: "YOUR_API_KEY" });
|
||||||
|
// Create a browser profile from a persistent browser session
|
||||||
|
const browserProfile = await skyvern.browserProfiles.createBrowserProfile({
|
||||||
|
name: "My Profile",
|
||||||
|
browser_session_id: "pbs_123",
|
||||||
|
});
|
||||||
|
console.log(browserProfile);
|
||||||
|
|
||||||
|
// Or create from a workflow run with persist_browser_session=True
|
||||||
|
const browserProfile2 = await skyvern.browserProfiles.createBrowserProfile({
|
||||||
|
name: "My Profile",
|
||||||
|
workflow_run_id: "wr_123",
|
||||||
|
});
|
||||||
|
console.log(browserProfile2);
|
||||||
|
"""
|
||||||
|
GET_BROWSER_PROFILES_CODE_SAMPLE_PYTHON = """from skyvern import Skyvern
|
||||||
|
|
||||||
|
skyvern = Skyvern(api_key="YOUR_API_KEY")
|
||||||
|
browser_profiles = await skyvern.browser_profiles.list_browser_profiles()
|
||||||
|
print(browser_profiles)
|
||||||
|
"""
|
||||||
|
GET_BROWSER_PROFILES_CODE_SAMPLE_TS = """import { SkyvernClient } from "@skyvern/client";
|
||||||
|
|
||||||
|
const skyvern = new SkyvernClient({ apiKey: "YOUR_API_KEY" });
|
||||||
|
const browserProfiles = await skyvern.browserProfiles.listBrowserProfiles();
|
||||||
|
console.log(browserProfiles);
|
||||||
|
"""
|
||||||
|
GET_BROWSER_PROFILE_CODE_SAMPLE_PYTHON = """from skyvern import Skyvern
|
||||||
|
|
||||||
|
skyvern = Skyvern(api_key="YOUR_API_KEY")
|
||||||
|
browser_profile = await skyvern.browser_profiles.get_browser_profile("bp_123")
|
||||||
|
print(browser_profile)
|
||||||
|
"""
|
||||||
|
GET_BROWSER_PROFILE_CODE_SAMPLE_TS = """import { SkyvernClient } from "@skyvern/client";
|
||||||
|
|
||||||
|
const skyvern = new SkyvernClient({ apiKey: "YOUR_API_KEY" });
|
||||||
|
const browserProfile = await skyvern.browserProfiles.getBrowserProfile("bp_123");
|
||||||
|
console.log(browserProfile);
|
||||||
|
"""
|
||||||
|
DELETE_BROWSER_PROFILE_CODE_SAMPLE_PYTHON = """from skyvern import Skyvern
|
||||||
|
|
||||||
|
skyvern = Skyvern(api_key="YOUR_API_KEY")
|
||||||
|
await skyvern.browser_profiles.delete_browser_profile("bp_123")
|
||||||
|
"""
|
||||||
|
DELETE_BROWSER_PROFILE_CODE_SAMPLE_TS = """import { SkyvernClient } from "@skyvern/client";
|
||||||
|
|
||||||
|
const skyvern = new SkyvernClient({ apiKey: "YOUR_API_KEY" });
|
||||||
|
await skyvern.browserProfiles.deleteBrowserProfile("bp_123");
|
||||||
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user