From 226ef99738c83e024f52f34d5cbd2f9095fb7c94 Mon Sep 17 00:00:00 2001 From: Shuchang Zheng Date: Sun, 18 May 2025 15:46:11 -0700 Subject: [PATCH] v0.1.83 - sdk update (#2379) --- fern/openapi/skyvern_openapi.json | 1330 +++++++++-------- pyproject.toml | 2 +- skyvern/client/agent/client.py | 756 +++++----- skyvern/client/browser_session/client.py | 210 +-- skyvern/client/credentials/client.py | 228 +-- .../client/types/browser_session_response.py | 8 +- 6 files changed, 1342 insertions(+), 1192 deletions(-) diff --git a/fern/openapi/skyvern_openapi.json b/fern/openapi/skyvern_openapi.json index 9fcf193b..ab6cf95d 100644 --- a/fern/openapi/skyvern_openapi.json +++ b/fern/openapi/skyvern_openapi.json @@ -6,13 +6,253 @@ "version": "1.0.0" }, "paths": { + "/v1/run/tasks": { + "post": { + "tags": [ + "Agent" + ], + "summary": "Run a task", + "description": "Run a task", + "operationId": "run_task_v1_run_tasks_post", + "parameters": [ + { + "name": "x-api-key", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "X-Api-Key" + } + }, + { + "name": "x-user-agent", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "X-User-Agent" + } + }, + { + "name": "authorization", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Authorization" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/TaskRunRequest" + } + } + } + }, + "responses": { + "200": { + "description": "Successfully run task", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/TaskRunResponse" + } + } + } + }, + "400": { + "description": "Invalid agent engine" + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + }, + "x-fern-sdk-group-name": "agent", + "x-fern-sdk-method-name": "run_task", + "x-fern-examples": [ + { + "code-samples": [ + { + "sdk": "python", + "code": "from skyvern import Skyvern\n\nskyvern = Skyvern(api_key=\"your_api_key\")\nawait skyvern.run_task(prompt=\"What's the top post on hackernews?\")\n" + } + ] + } + ] + } + }, + "/v1/run/workflows": { + "post": { + "tags": [ + "Agent" + ], + "summary": "Run a workflow", + "description": "Run a workflow", + "operationId": "run_workflow_v1_run_workflows_post", + "parameters": [ + { + "name": "template", + "in": "query", + "required": false, + "schema": { + "type": "boolean", + "default": false, + "title": "Template" + } + }, + { + "name": "x-api-key", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "X-Api-Key" + } + }, + { + "name": "x-max-steps-override", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "title": "X-Max-Steps-Override" + } + }, + { + "name": "x-user-agent", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "X-User-Agent" + } + }, + { + "name": "authorization", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Authorization" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/WorkflowRunRequest" + } + } + } + }, + "responses": { + "200": { + "description": "Successfully run workflow", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/WorkflowRunResponse" + } + } + } + }, + "400": { + "description": "Invalid workflow run request" + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + }, + "x-fern-sdk-group-name": "agent", + "x-fern-sdk-method-name": "run_workflow", + "x-fern-examples": [ + { + "code-samples": [ + { + "sdk": "python", + "code": "from skyvern import Skyvern\n\nskyvern = Skyvern(api_key=\"your_api_key\")\nawait skyvern.agent.run_workflow(workflow_id=\"wpid_123\", parameters={\"parameter1\": \"value1\", \"parameter2\": \"value2\"})\n" + } + ] + } + ] + } + }, "/v1/runs/{run_id}": { "get": { "tags": [ "Agent" ], "summary": "Get a task or a workflow run by id", - "description": "Get a task or a workflow run by id", + "description": "Get run information (task run, workflow run)", "operationId": "get_run_v1_runs__run_id__get", "parameters": [ { @@ -114,7 +354,96 @@ "code-samples": [ { "sdk": "python", - "code": "from skyvern import Skyvern\n\nclient = Skyvern(api_key=\"your_api_key\")\nrun = await client.get_run(run_id=\"tsk_123\")\nprint(run)\n" + "code": "from skyvern import Skyvern\n\nskyvern = Skyvern(api_key=\"your_api_key\")\nrun = await skyvern.get_run(run_id=\"tsk_v2_123\")\nprint(run)\n" + } + ] + } + ] + } + }, + "/v1/runs/{run_id}/cancel": { + "post": { + "tags": [ + "Agent" + ], + "summary": "Cancel a task or workflow run", + "description": "Cancel a run (task or workflow)", + "operationId": "cancel_run_v1_runs__run_id__cancel_post", + "parameters": [ + { + "name": "run_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "description": "The id of the task run or the workflow run to cancel.", + "title": "Run Id" + }, + "description": "The id of the task run or the workflow run to cancel." + }, + { + "name": "x-api-key", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "X-Api-Key" + } + }, + { + "name": "authorization", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Authorization" + } + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + }, + "x-fern-sdk-group-name": "agent", + "x-fern-sdk-method-name": "cancel_run", + "x-fern-examples": [ + { + "code-samples": [ + { + "sdk": "python", + "code": "from skyvern import Skyvern\n\nskyvern = Skyvern(api_key=\"your_api_key\")\nawait skyvern.cancel_run(run_id=\"tsk_v2_123\")\n" } ] } @@ -179,7 +508,17 @@ } }, "x-fern-sdk-group-name": "agent", - "x-fern-sdk-method-name": "create_workflow" + "x-fern-sdk-method-name": "create_workflow", + "x-fern-examples": [ + { + "code-samples": [ + { + "sdk": "curl", + "code": "curl -X POST https://api.skyvern.com/v1/workflows --header 'x-api-key: {{x-api-key}}' --header 'Content-Type: application/x-yaml' --data-raw 'title: Invoice Downloading Demo (Jun 13)\ndescription: \u003E-\n Login to the website, download all the invoices after a date, email the\n invoices\nworkflow_definition:\n parameters:\n - key: website_url\n parameter_type: workflow\n workflow_parameter_type: string\n - key: credentials\n parameter_type: bitwarden_login_credential\n bitwarden_client_id_aws_secret_key: SECRET\n bitwarden_client_secret_aws_secret_key: SECRET\n bitwarden_master_password_aws_secret_key: SECRET\n bitwarden_collection_id: SECRET\n url_parameter_key: website_url\n - key: invoice_retrieval_start_date\n parameter_type: workflow\n workflow_parameter_type: string\n - key: smtp_host\n parameter_type: aws_secret\n aws_key: SKYVERN_SMTP_HOST_AWS_SES\n - key: smtp_port\n parameter_type: aws_secret\n aws_key: SKYVERN_SMTP_PORT_AWS_SES\n - key: smtp_username\n parameter_type: aws_secret\n aws_key: SKYVERN_SMTP_USERNAME_SES\n - key: smtp_password\n parameter_type: aws_secret\n aws_key: SKYVERN_SMTP_PASSWORD_SES\n - parameter_type: context\n key: order_history_url\n source_parameter_key: get_order_history_page_url_and_qualifying_order_ids_output\n - parameter_type: context\n key: order_ids\n source_parameter_key: get_order_history_page_url_and_qualifying_order_ids_output\n - parameter_type: context\n key: order_id\n source_parameter_key: order_ids\n blocks:\n - block_type: task\n label: login\n parameter_keys:\n - credentials\n url: website_url\n navigation_goal: \u003E-\n If you're not on the login page, navigate to login page and login using the credentials given, and then navigate to the personal account page. First, take actions on promotional popups or cookie prompts that could prevent taking other action on the web page. Then, try to login and navigate to the personal account page. If you fail to login to find the login page or can't login after several trials, terminate. If you're on the personal account page, consider the goal is completed.\n error_code_mapping:\n stuck_with_popups: terminate and return this error if you can't close popups after several tries and can't take the necessary actions on the website because there is a blocking popup on the page\n failed_to_login: terminate and return this error if you fail logging in to the page\n - block_type: task\n label: get_order_history_page_url_and_qualifying_order_ids\n parameter_keys:\n - invoice_retrieval_start_date\n navigation_goal: Find the order history page. If there is no orders after given start date, terminate.\n data_extraction_goal: \u003E-\n You need to extract the order history page url by looking at the current\n page you're on. You need to extract contact emails you see on the page. You also need to extract the order ids for orders that\n happened on or after invoice_retrieval_start_date. Make sure to filter\n only the orders that happened on or after invoice_retrieval_start_date. You need to compare each order's date with the invoice_download_start_date. You can only include an order in the output if the order's date is after or the same as the invoice_download_start_date.\n While comparing dates, first compare year, then month, then day. invoice_retrieval_start_date\n is in YYYY-MM-DD format. The dates on the websites may be in different formats, compare accordingly and compare year, date, and month.\n error_code_mapping:\n failed_to_find_order_history_page: return this error if you can't find the order history page on the website\n no_orders_found_after_start_date: return this error if there are no orders after the specified invoice_download_start_date\n data_schema:\n type: object\n properties:\n order_history_url:\n type: url\n description: \u003E-\n The exact URL of the order history page. Do not make any\n assumptions. Return the URL that's passed along in this context.\n contact_emails:\n type: array\n items:\n type: string\n description: Contact email for the ecommerce website you're on. If you can't find any return null\n date_comparison_scratchpad:\n type: string\n description: \u003E-\n You are supposed to filter the orders that happened on or after the invoice_download_start_date. Think through how you will approach this task step-by-step here. Consider these before starting the comparison:\n - What format is the order date in? How can you parse it into a structured format?\n - What is the correct way to compare two dates?\n - How will you compare the order dates to the invoice_download_start_date? \n \n Write out your thought process before filling out the order_ids field below. Remember, the original date may be in any format, so parse it carefully! The invoice_download_start_date will be an exact date you can directly compare against in the format YYYY-MM-DD.\n order_ids:\n type: array\n items:\n type: object\n properties:\n order_date:\n type: iso-8601-date-string\n order_id:\n type: string\n description: \u003E-\n Return a list of order id strings. Do not return order ids of\n orders that happened before the specified\n invoice_retrieval_start_date\n - block_type: for_loop\n label: iterate_over_order_ids\n loop_over_parameter_key: order_ids\n continue_on_failure: true\n loop_blocks:\n - block_type: task\n label: download_invoice_for_order\n complete_on_download: true\n continue_on_failure: true\n parameter_keys:\n - order_id\n url: order_history_url\n navigation_goal: Download the invoice of the order with the given order ID. Make sure to download the invoice for the given order id. If the element tree doesn't have a matching order id, check the screenshots. Complete if you have successfully downloaded the invoice according to action history, if you were able to download it, you'll see download_triggered=True for the last step. If you don't see a way to download an invoice, navigate to the order page if possible. If there's no way to download an invoice terminate. If the text suggests printing, you can assume you can download it. Return click action with download=True if you want to trigger a download.\n error_code_mapping:\n not_possible_to_download_invoice: return this error if the website doesn't allow downloading/viewing invoices\n cant_solve_captcha: return this error if captcha isn't solved after multiple retries\n - block_type: upload_to_s3\n label: upload_downloaded_files_to_s3\n path: SKYVERN_DOWNLOAD_DIRECTORY\n - block_type: send_email\n label: send_email\n smtp_host_secret_parameter_key: smtp_host\n smtp_port_secret_parameter_key: smtp_port\n smtp_username_secret_parameter_key: smtp_username\n smtp_password_secret_parameter_key: smtp_password\n sender: hello@skyvern.com\n recipients:\n - founders@skyvern.com\n subject: Skyvern - Downloaded Invoices Demo\n body: website_url\n file_attachments:\n - SKYVERN_DOWNLOAD_DIRECTORY\n'\n" + } + ] + } + ] } }, "/v1/workflows/{workflow_id}": { @@ -2545,7 +2884,17 @@ "required": true }, "x-fern-sdk-group-name": "agent", - "x-fern-sdk-method-name": "update_workflow" + "x-fern-sdk-method-name": "update_workflow", + "x-fern-examples": [ + { + "code-samples": [ + { + "sdk": "curl", + "code": "curl -X POST https://api.skyvern.com/v1/workflows/wpid_123 --header 'x-api-key: {{x-api-key}}' --header 'Content-Type: application/x-yaml' --data-raw 'title: Invoice Downloading Demo (Jun 13)\ndescription: \u003E-\n Login to the website, download all the invoices after a date, email the\n invoices\nworkflow_definition:\n parameters:\n - key: website_url\n parameter_type: workflow\n workflow_parameter_type: string\n - key: credentials\n parameter_type: bitwarden_login_credential\n bitwarden_client_id_aws_secret_key: SECRET\n bitwarden_client_secret_aws_secret_key: SECRET\n bitwarden_master_password_aws_secret_key: SECRET\n bitwarden_collection_id: SECRET\n url_parameter_key: website_url\n - key: invoice_retrieval_start_date\n parameter_type: workflow\n workflow_parameter_type: string\n - key: smtp_host\n parameter_type: aws_secret\n aws_key: SKYVERN_SMTP_HOST_AWS_SES\n - key: smtp_port\n parameter_type: aws_secret\n aws_key: SKYVERN_SMTP_PORT_AWS_SES\n - key: smtp_username\n parameter_type: aws_secret\n aws_key: SKYVERN_SMTP_USERNAME_SES\n - key: smtp_password\n parameter_type: aws_secret\n aws_key: SKYVERN_SMTP_PASSWORD_SES\n - parameter_type: context\n key: order_history_url\n source_parameter_key: get_order_history_page_url_and_qualifying_order_ids_output\n - parameter_type: context\n key: order_ids\n source_parameter_key: get_order_history_page_url_and_qualifying_order_ids_output\n - parameter_type: context\n key: order_id\n source_parameter_key: order_ids\n blocks:\n - block_type: task\n label: login\n parameter_keys:\n - credentials\n url: website_url\n navigation_goal: \u003E-\n If you're not on the login page, navigate to login page and login using the credentials given, and then navigate to the personal account page. First, take actions on promotional popups or cookie prompts that could prevent taking other action on the web page. Then, try to login and navigate to the personal account page. If you fail to login to find the login page or can't login after several trials, terminate. If you're on the personal account page, consider the goal is completed.\n error_code_mapping:\n stuck_with_popups: terminate and return this error if you can't close popups after several tries and can't take the necessary actions on the website because there is a blocking popup on the page\n failed_to_login: terminate and return this error if you fail logging in to the page\n - block_type: task\n label: get_order_history_page_url_and_qualifying_order_ids\n parameter_keys:\n - invoice_retrieval_start_date\n navigation_goal: Find the order history page. If there is no orders after given start date, terminate.\n data_extraction_goal: \u003E-\n You need to extract the order history page url by looking at the current\n page you're on. You need to extract contact emails you see on the page. You also need to extract the order ids for orders that\n happened on or after invoice_retrieval_start_date. Make sure to filter\n only the orders that happened on or after invoice_retrieval_start_date. You need to compare each order's date with the invoice_download_start_date. You can only include an order in the output if the order's date is after or the same as the invoice_download_start_date.\n While comparing dates, first compare year, then month, then day. invoice_retrieval_start_date\n is in YYYY-MM-DD format. The dates on the websites may be in different formats, compare accordingly and compare year, date, and month.\n error_code_mapping:\n failed_to_find_order_history_page: return this error if you can't find the order history page on the website\n no_orders_found_after_start_date: return this error if there are no orders after the specified invoice_download_start_date\n data_schema:\n type: object\n properties:\n order_history_url:\n type: url\n description: \u003E-\n The exact URL of the order history page. Do not make any\n assumptions. Return the URL that's passed along in this context.\n contact_emails:\n type: array\n items:\n type: string\n description: Contact email for the ecommerce website you're on. If you can't find any return null\n date_comparison_scratchpad:\n type: string\n description: \u003E-\n You are supposed to filter the orders that happened on or after the invoice_download_start_date. Think through how you will approach this task step-by-step here. Consider these before starting the comparison:\n - What format is the order date in? How can you parse it into a structured format?\n - What is the correct way to compare two dates?\n - How will you compare the order dates to the invoice_download_start_date? \n \n Write out your thought process before filling out the order_ids field below. Remember, the original date may be in any format, so parse it carefully! The invoice_download_start_date will be an exact date you can directly compare against in the format YYYY-MM-DD.\n order_ids:\n type: array\n items:\n type: object\n properties:\n order_date:\n type: iso-8601-date-string\n order_id:\n type: string\n description: \u003E-\n Return a list of order id strings. Do not return order ids of\n orders that happened before the specified\n invoice_retrieval_start_date\n - block_type: for_loop\n label: iterate_over_order_ids\n loop_over_parameter_key: order_ids\n continue_on_failure: true\n loop_blocks:\n - block_type: task\n label: download_invoice_for_order\n complete_on_download: true\n continue_on_failure: true\n parameter_keys:\n - order_id\n url: order_history_url\n navigation_goal: Download the invoice of the order with the given order ID. Make sure to download the invoice for the given order id. If the element tree doesn't have a matching order id, check the screenshots. Complete if you have successfully downloaded the invoice according to action history, if you were able to download it, you'll see download_triggered=True for the last step. If you don't see a way to download an invoice, navigate to the order page if possible. If there's no way to download an invoice terminate. If the text suggests printing, you can assume you can download it. Return click action with download=True if you want to trigger a download.\n error_code_mapping:\n not_possible_to_download_invoice: return this error if the website doesn't allow downloading/viewing invoices\n cant_solve_captcha: return this error if captcha isn't solved after multiple retries\n - block_type: upload_to_s3\n label: upload_downloaded_files_to_s3\n path: SKYVERN_DOWNLOAD_DIRECTORY\n - block_type: send_email\n label: send_email\n smtp_host_secret_parameter_key: smtp_host\n smtp_port_secret_parameter_key: smtp_port\n smtp_username_secret_parameter_key: smtp_username\n smtp_password_secret_parameter_key: smtp_password\n sender: hello@skyvern.com\n recipients:\n - founders@skyvern.com\n subject: Skyvern - Downloaded Invoices Demo\n body: website_url\n file_attachments:\n - SKYVERN_DOWNLOAD_DIRECTORY\n'\n" + } + ] + } + ] } }, "/v1/workflows/{workflow_id}/delete": { @@ -2627,485 +2976,20 @@ } }, "x-fern-sdk-group-name": "agent", - "x-fern-sdk-method-name": "delete_workflow" - } - }, - "/v1/run/tasks": { - "post": { - "tags": [ - "Agent" - ], - "summary": "Run a task", - "description": "Run a task", - "operationId": "run_task_v1_run_tasks_post", - "parameters": [ - { - "name": "x-api-key", - "in": "header", - "required": false, - "schema": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "title": "X-Api-Key" - } - }, - { - "name": "x-user-agent", - "in": "header", - "required": false, - "schema": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "title": "X-User-Agent" - } - }, - { - "name": "authorization", - "in": "header", - "required": false, - "schema": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "title": "Authorization" - } - } - ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TaskRunRequest" - } - } - } - }, - "responses": { - "200": { - "description": "Successfully run task", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TaskRunResponse" - } - } - } - }, - "400": { - "description": "Invalid agent engine" - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/HTTPValidationError" - } - } - } - } - }, - "x-fern-sdk-group-name": "agent", - "x-fern-sdk-method-name": "run_task", + "x-fern-sdk-method-name": "delete_workflow", "x-fern-examples": [ { "code-samples": [ { "sdk": "python", - "code": "from skyvern import Skyvern\n\nclient = Skyvern(api_key=\"your_api_key\")\nawait client.run_task(prompt=\"What's the top post on hackernews?\")\n" + "code": "from skyvern import Skyvern\n\nskyvern = Skyvern(api_key=\"your_api_key\")\nawait skyvern.agent.delete_workflow(workflow_id=\"wpid_123\")\n" } ] } ] } }, - "/v1/run/workflows": { - "post": { - "tags": [ - "Agent" - ], - "summary": "Run a workflow", - "description": "Run a workflow", - "operationId": "run_workflow_v1_run_workflows_post", - "parameters": [ - { - "name": "template", - "in": "query", - "required": false, - "schema": { - "type": "boolean", - "default": false, - "title": "Template" - } - }, - { - "name": "x-api-key", - "in": "header", - "required": false, - "schema": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "title": "X-Api-Key" - } - }, - { - "name": "x-max-steps-override", - "in": "header", - "required": false, - "schema": { - "anyOf": [ - { - "type": "integer" - }, - { - "type": "null" - } - ], - "title": "X-Max-Steps-Override" - } - }, - { - "name": "x-user-agent", - "in": "header", - "required": false, - "schema": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "title": "X-User-Agent" - } - }, - { - "name": "authorization", - "in": "header", - "required": false, - "schema": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "title": "Authorization" - } - } - ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/WorkflowRunRequest" - } - } - } - }, - "responses": { - "200": { - "description": "Successfully run workflow", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/WorkflowRunResponse" - } - } - } - }, - "400": { - "description": "Invalid workflow run request" - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/HTTPValidationError" - } - } - } - } - }, - "x-fern-sdk-group-name": "agent", - "x-fern-sdk-method-name": "run_workflow", - "x-fern-examples": [ - { - "code-samples": [ - { - "sdk": "python", - "code": "from skyvern import Skyvern\n\nclient = Skyvern(api_key=\"your_api_key\")\nawait client.agent.run_workflow(workflow_id=\"wpid_123\", parameters={\"parameter1\": \"value1\", \"parameter2\": \"value2\"})\n" - } - ] - } - ] - } - }, - "/v1/runs/{run_id}/cancel": { - "post": { - "tags": [ - "Agent" - ], - "summary": "Cancel a task or workflow run", - "description": "Cancel a task or workflow run", - "operationId": "cancel_run_v1_runs__run_id__cancel_post", - "parameters": [ - { - "name": "run_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "The id of the task run or the workflow run to cancel.", - "title": "Run Id" - }, - "description": "The id of the task run or the workflow run to cancel." - }, - { - "name": "x-api-key", - "in": "header", - "required": false, - "schema": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "title": "X-Api-Key" - } - }, - { - "name": "authorization", - "in": "header", - "required": false, - "schema": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "title": "Authorization" - } - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - - } - } - } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/HTTPValidationError" - } - } - } - } - }, - "x-fern-sdk-group-name": "agent", - "x-fern-sdk-method-name": "cancel_run" - } - }, - "/v1/browser_sessions/{browser_session_id}": { - "get": { - "tags": [ - "Browser Sessions" - ], - "summary": "Get browser session details", - "description": "Get details about a specific browser session by ID", - "operationId": "get_browser_session_v1_browser_sessions__browser_session_id__get", - "parameters": [ - { - "name": "browser_session_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "title": "Browser Session Id" - } - }, - { - "name": "x-api-key", - "in": "header", - "required": false, - "schema": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "title": "X-Api-Key" - } - }, - { - "name": "authorization", - "in": "header", - "required": false, - "schema": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "title": "Authorization" - } - } - ], - "responses": { - "200": { - "description": "Successfully retrieved browser session details", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/BrowserSessionResponse" - } - } - } - }, - "404": { - "description": "Browser session not found" - }, - "403": { - "description": "Unauthorized - Invalid or missing authentication" - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/HTTPValidationError" - } - } - } - } - }, - "x-fern-sdk-group-name": "browser_session", - "x-fern-sdk-method-name": "get_browser_session" - } - }, "/v1/browser_sessions": { - "get": { - "tags": [ - "Browser Sessions" - ], - "summary": "Get all active browser sessions", - "description": "Get all active browser sessions for the organization", - "operationId": "get_browser_sessions_v1_browser_sessions_get", - "parameters": [ - { - "name": "x-api-key", - "in": "header", - "required": false, - "schema": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "title": "X-Api-Key" - } - }, - { - "name": "authorization", - "in": "header", - "required": false, - "schema": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "title": "Authorization" - } - } - ], - "responses": { - "200": { - "description": "Successfully retrieved all active browser sessions", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/BrowserSessionResponse" - }, - "title": "Response Get Browser Sessions V1 Browser Sessions Get" - } - } - } - }, - "403": { - "description": "Unauthorized - Invalid or missing authentication" - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/HTTPValidationError" - } - } - } - } - }, - "x-fern-sdk-group-name": "browser_session", - "x-fern-sdk-method-name": "get_browser_sessions" - }, "post": { "tags": [ "Browser Sessions" @@ -3183,7 +3067,100 @@ } }, "x-fern-sdk-group-name": "browser_session", - "x-fern-sdk-method-name": "create_browser_session" + "x-fern-sdk-method-name": "create_browser_session", + "x-fern-examples": [ + { + "code-samples": [ + { + "sdk": "python", + "code": "from skyvern import Skyvern\n\nskyvern = Skyvern(api_key=\"your_api_key\")\nbrowser_session = await skyvern.browser_sessions.create_browser_session(timeout=60)\nprint(browser_session)\n" + } + ] + } + ] + }, + "get": { + "tags": [ + "Browser Sessions" + ], + "summary": "Get all active browser sessions", + "description": "Get all active browser sessions for the organization", + "operationId": "get_browser_sessions_v1_browser_sessions_get", + "parameters": [ + { + "name": "x-api-key", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "X-Api-Key" + } + }, + { + "name": "authorization", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Authorization" + } + } + ], + "responses": { + "200": { + "description": "Successfully retrieved all active browser sessions", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/BrowserSessionResponse" + }, + "title": "Response Get Browser Sessions V1 Browser Sessions Get" + } + } + } + }, + "403": { + "description": "Unauthorized - Invalid or missing authentication" + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + }, + "x-fern-sdk-group-name": "browser_session", + "x-fern-sdk-method-name": "get_browser_sessions", + "x-fern-examples": [ + { + "code-samples": [ + { + "sdk": "python", + "code": "from skyvern import Skyvern\n\nskyvern = Skyvern(api_key=\"your_api_key\")\nbrowser_sessions = await skyvern.browser_sessions.get_browser_sessions()\nprint(browser_sessions)\n" + } + ] + } + ] } }, "/v1/browser_sessions/{browser_session_id}/close": { @@ -3201,8 +3178,13 @@ "required": true, "schema": { "type": "string", + "description": "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_`", + "examples": [ + "pbs_123456" + ], "title": "Browser Session Id" - } + }, + "description": "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_`" }, { "name": "x-api-key", @@ -3263,7 +3245,115 @@ } }, "x-fern-sdk-group-name": "browser_session", - "x-fern-sdk-method-name": "close_browser_session" + "x-fern-sdk-method-name": "close_browser_session", + "x-fern-examples": [ + { + "code-samples": [ + { + "sdk": "python", + "code": "from skyvern import Skyvern\n\nskyvern = Skyvern(api_key=\"your_api_key\")\nawait skyvern.browser_sessions.close_browser_session(browser_session_id=\"pbs_123\")\n" + } + ] + } + ] + } + }, + "/v1/browser_sessions/{browser_session_id}": { + "get": { + "tags": [ + "Browser Sessions" + ], + "summary": "Get browser session details", + "description": "Get details about a specific browser session by ID", + "operationId": "get_browser_session_v1_browser_sessions__browser_session_id__get", + "parameters": [ + { + "name": "browser_session_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "description": "The ID of the browser session. browser_session_id starts with `pbs_`", + "examples": [ + "pbs_123456" + ], + "title": "Browser Session Id" + }, + "description": "The ID of the browser session. browser_session_id starts with `pbs_`" + }, + { + "name": "x-api-key", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "X-Api-Key" + } + }, + { + "name": "authorization", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Authorization" + } + } + ], + "responses": { + "200": { + "description": "Successfully retrieved browser session details", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/BrowserSessionResponse" + } + } + } + }, + "404": { + "description": "Browser session not found" + }, + "403": { + "description": "Unauthorized - Invalid or missing authentication" + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + }, + "x-fern-sdk-group-name": "browser_session", + "x-fern-sdk-method-name": "get_browser_session", + "x-fern-examples": [ + { + "code-samples": [ + { + "sdk": "python", + "code": "from skyvern import Skyvern\n\nskyvern = Skyvern(api_key=\"your_api_key\")\nbrowser_session = await skyvern.browser_sessions.get_browser_session(browser_session_id=\"pbs_123\")\nprint(browser_session)\n" + } + ] + } + ] } }, "/v1/credentials/totp": { @@ -3271,8 +3361,8 @@ "tags": [ "Credentials" ], - "summary": "Forward TOTP (2FA, MFA) code to Skyvern", - "description": "Forward a TOTP (2FA, MFA) code to Skyvern", + "summary": "Send TOTP (2FA, MFA) code to Skyvern", + "description": "Forward a TOTP (2FA, MFA) email or sms message containing the code to Skyvern", "operationId": "send_totp_code_v1_credentials_totp_post", "parameters": [ { @@ -3345,6 +3435,109 @@ } }, "/v1/credentials": { + "post": { + "tags": [ + "Credentials" + ], + "summary": "Create credential", + "description": "Creates a new credential for the current organization", + "operationId": "create_credential_v1_credentials_post", + "parameters": [ + { + "name": "x-api-key", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "X-Api-Key" + } + }, + { + "name": "authorization", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Authorization" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateCredentialRequest", + "description": "The credential data to create", + "openapi_extra": { + "x-fern-sdk-parameter-name": "data" + } + }, + "example": { + "name": "My Credential", + "credential_type": "PASSWORD", + "credential": { + "username": "user@example.com", + "password": "securepassword123", + "totp": "JBSWY3DPEHPK3PXP" + } + } + } + } + }, + "responses": { + "201": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CredentialResponse" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + }, + "x-fern-sdk-group-name": "credentials", + "x-fern-sdk-method-name": "create_credential", + "x-fern-examples": [ + { + "code-samples": [ + { + "sdk": "python", + "code": "from skyvern import Skyvern\n\nskyvern = Skyvern(api_key=\"your_api_key\")\nawait skyvern.credentials.create_credential(\n name=\"Amazon Login\",\n credential_type=\"password\",\n credential={\"username\": \"user@example.com\", \"password\": \"myamazonpassword\"},\n)\n" + }, + { + "sdk": "python", + "code": "from skyvern import Skyvern\n\nskyvern = Skyvern(api_key=\"your_api_key\")\nawait skyvern.credentials.create_credential(\n name=\"Amazon Login\",\n credential_type=\"credit_card\",\n credential={\n \"card_number\": \"4242424242424242\",\n \"card_cvv\": \"424\",\n \"card_exp_month\": \"12\",\n \"card_exp_year\": \"2028\",\n \"card_brand\": \"visa\",\n \"card_holder_name\": \"John Doe\",\n },\n)\n" + } + ] + } + ] + }, "get": { "tags": [ "Credentials" @@ -3447,16 +3640,43 @@ } }, "x-fern-sdk-group-name": "credentials", - "x-fern-sdk-method-name": "get_credentials" - }, + "x-fern-sdk-method-name": "get_credentials", + "x-fern-examples": [ + { + "code-samples": [ + { + "sdk": "python", + "code": "from skyvern import Skyvern\n\nskyvern = Skyvern(api_key=\"your_api_key\")\ncredentials = await skyvern.credentials.get_credentials()\nprint(credentials)\n" + } + ] + } + ] + } + }, + "/v1/credentials/{credential_id}/delete": { "post": { "tags": [ "Credentials" ], - "summary": "Create credential", - "description": "Creates a new credential for the current organization", - "operationId": "create_credential_v1_credentials_post", + "summary": "Delete credential", + "description": "Deletes a specific credential by its ID", + "operationId": "delete_credential_v1_credentials__credential_id__delete_post", "parameters": [ + { + "name": "credential_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "description": "The unique identifier of the credential to delete", + "openapi_extra": { + "x-fern-sdk-parameter-name": "credential_id" + }, + "title": "Credential Id" + }, + "description": "The unique identifier of the credential to delete", + "example": "cred_1234567890" + }, { "name": "x-api-key", "in": "header", @@ -3490,39 +3710,9 @@ } } ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/CreateCredentialRequest", - "description": "The credential data to create", - "openapi_extra": { - "x-fern-sdk-parameter-name": "data" - } - }, - "example": { - "name": "My Credential", - "credential_type": "PASSWORD", - "credential": { - "username": "user@example.com", - "password": "securepassword123", - "totp": "JBSWY3DPEHPK3PXP" - } - } - } - } - }, "responses": { - "201": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/CredentialResponse" - } - } - } + "204": { + "description": "Successful Response" }, "422": { "description": "Validation Error", @@ -3536,7 +3726,17 @@ } }, "x-fern-sdk-group-name": "credentials", - "x-fern-sdk-method-name": "create_credential" + "x-fern-sdk-method-name": "delete_credential", + "x-fern-examples": [ + { + "code-samples": [ + { + "sdk": "python", + "code": "from skyvern import Skyvern\n\nskyvern = Skyvern(api_key=\"your_api_key\")\nawait skyvern.credentials.delete_credential(credential_id=\"cred_123\")\n" + } + ] + } + ] } }, "/v1/credentials/{credential_id}": { @@ -3619,83 +3819,17 @@ } }, "x-fern-sdk-group-name": "credentials", - "x-fern-sdk-method-name": "get_credential" - } - }, - "/v1/credentials/{credential_id}/delete": { - "post": { - "tags": [ - "Credentials" - ], - "summary": "Delete credential", - "description": "Deletes a specific credential by its ID", - "operationId": "delete_credential_v1_credentials__credential_id__delete_post", - "parameters": [ + "x-fern-sdk-method-name": "get_credential", + "x-fern-examples": [ { - "name": "credential_id", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "The unique identifier of the credential to delete", - "openapi_extra": { - "x-fern-sdk-parameter-name": "credential_id" - }, - "title": "Credential Id" - }, - "description": "The unique identifier of the credential to delete", - "example": "cred_1234567890" - }, - { - "name": "x-api-key", - "in": "header", - "required": false, - "schema": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "title": "X-Api-Key" - } - }, - { - "name": "authorization", - "in": "header", - "required": false, - "schema": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "title": "Authorization" - } - } - ], - "responses": { - "204": { - "description": "Successful Response" - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/HTTPValidationError" - } + "code-samples": [ + { + "sdk": "python", + "code": "from skyvern import Skyvern\n\nskyvern = Skyvern(api_key=\"your_api_key\")\ncredential = await skyvern.credentials.get_credential(credential_id=\"cred_123\")\nprint(credential)\n" } - } + ] } - }, - "x-fern-sdk-group-name": "credentials", - "x-fern-sdk-method-name": "delete_credential" + ] } } }, @@ -4317,7 +4451,10 @@ "browser_session_id": { "type": "string", "title": "Browser Session Id", - "description": "Unique identifier for the browser session" + "description": "Unique identifier for the browser session. browser_session_id starts with `pbs_`.", + "examples": [ + "pbs_123456" + ] }, "organization_id": { "type": "string", @@ -4334,7 +4471,11 @@ } ], "title": "Runnable Type", - "description": "Type of runnable associated with this session (workflow, task etc)" + "description": "Type of the current runnable associated with this session (workflow, task etc)", + "examples": [ + "task", + "workflow_run" + ] }, "runnable_id": { "anyOf": [ @@ -4346,7 +4487,11 @@ } ], "title": "Runnable Id", - "description": "ID of the associated runnable" + "description": "ID of the current runnable", + "examples": [ + "tsk_123456", + "wr_123456" + ] }, "timeout": { "anyOf": [ @@ -4358,7 +4503,8 @@ } ], "title": "Timeout", - "description": "Timeout in minutes for the session. Timeout is applied after the session is started." + "description": "Timeout in minutes for the session. Timeout is applied after the session is started. Defaults to 60 minutes.", + "examples": [60, 120] }, "started_at": { "anyOf": [ diff --git a/pyproject.toml b/pyproject.toml index 2b5b4240..1269fbd0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "skyvern" -version = "0.1.82" +version = "0.1.83" description = "" authors = ["Skyvern AI "] readme = "README.md" diff --git a/skyvern/client/agent/client.py b/skyvern/client/agent/client.py index a6c660c1..09e138e1 100644 --- a/skyvern/client/agent/client.py +++ b/skyvern/client/agent/client.py @@ -2,22 +2,22 @@ import typing 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.proxy_location import ProxyLocation from ..types.task_run_request_data_extraction_schema import TaskRunRequestDataExtractionSchema +from ..core.request_options import RequestOptions from ..types.task_run_response import TaskRunResponse 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.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.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 # this is used as the default value for optional parameters @@ -28,245 +28,6 @@ class AgentClient: def __init__(self, *, client_wrapper: SyncClientWrapper): 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( 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_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( self, run_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> typing.Optional[typing.Any]: """ - Cancel a task or workflow run + Cancel a run (task or workflow) 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_json) - -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: + def create_workflow(self, *, request_options: typing.Optional[RequestOptions] = None) -> Workflow: """ Create a new workflow @@ -704,23 +450,15 @@ class AsyncAgentClient: Examples -------- - import asyncio + from skyvern import Skyvern - from skyvern import AsyncSkyvern - - client = AsyncSkyvern( + client = Skyvern( api_key="YOUR_API_KEY", authorization="YOUR_AUTHORIZATION", ) - - - async def main() -> None: - await client.agent.create_workflow() - - - asyncio.run(main()) + client.agent.create_workflow() """ - _response = await self._client_wrapper.httpx_client.request( + _response = self._client_wrapper.httpx_client.request( "v1/workflows", method="POST", 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_json) - async def update_workflow( - self, workflow_id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> Workflow: + def update_workflow(self, workflow_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Workflow: """ Update a workflow definition @@ -770,25 +506,17 @@ class AsyncAgentClient: Examples -------- - import asyncio + from skyvern import Skyvern - from skyvern import AsyncSkyvern - - client = AsyncSkyvern( + client = Skyvern( api_key="YOUR_API_KEY", authorization="YOUR_AUTHORIZATION", ) - - - async def main() -> None: - await client.agent.update_workflow( - workflow_id="wpid_123", - ) - - - asyncio.run(main()) + client.agent.update_workflow( + workflow_id="wpid_123", + ) """ - _response = await self._client_wrapper.httpx_client.request( + _response = self._client_wrapper.httpx_client.request( f"v1/workflows/{jsonable_encoder(workflow_id)}", method="POST", 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_json) - async def delete_workflow( + def delete_workflow( self, workflow_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> typing.Optional[typing.Any]: """ @@ -838,25 +566,17 @@ class AsyncAgentClient: Examples -------- - import asyncio + from skyvern import Skyvern - from skyvern import AsyncSkyvern - - client = AsyncSkyvern( + client = Skyvern( api_key="YOUR_API_KEY", authorization="YOUR_AUTHORIZATION", ) - - - async def main() -> None: - await client.agent.delete_workflow( - workflow_id="wpid_123", - ) - - - asyncio.run(main()) + client.agent.delete_workflow( + workflow_id="wpid_123", + ) """ - _response = await self._client_wrapper.httpx_client.request( + _response = self._client_wrapper.httpx_client.request( f"v1/workflows/{jsonable_encoder(workflow_id)}/delete", method="POST", 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_json) + +class AsyncAgentClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + async def run_task( 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_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( self, run_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> typing.Optional[typing.Any]: """ - Cancel a task or workflow run + Cancel a run (task or workflow) Parameters ---------- @@ -1246,3 +1049,200 @@ 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 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) diff --git a/skyvern/client/browser_session/client.py b/skyvern/client/browser_session/client.py index a52544d4..05ae2115 100644 --- a/skyvern/client/browser_session/client.py +++ b/skyvern/client/browser_session/client.py @@ -4,13 +4,13 @@ import typing from ..core.client_wrapper import SyncClientWrapper from ..core.request_options import RequestOptions from ..types.browser_session_response import BrowserSessionResponse -from ..core.jsonable_encoder import jsonable_encoder from ..core.pydantic_utilities import parse_obj_as from ..errors.forbidden_error import ForbiddenError -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 ..core.jsonable_encoder import jsonable_encoder +from ..errors.not_found_error import NotFoundError from ..core.client_wrapper import AsyncClientWrapper # this is used as the default value for optional parameters @@ -21,85 +21,6 @@ class BrowserSessionClient: def __init__(self, *, client_wrapper: SyncClientWrapper): 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( self, *, request_options: typing.Optional[RequestOptions] = None ) -> typing.List[BrowserSessionResponse]: @@ -249,6 +170,7 @@ class BrowserSessionClient: Parameters ---------- 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-specific configuration. @@ -267,7 +189,7 @@ class BrowserSessionClient: authorization="YOUR_AUTHORIZATION", ) client.browser_session.close_browser_session( - browser_session_id="browser_session_id", + browser_session_id="pbs_123456", ) """ _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_json) - -class AsyncBrowserSessionClient: - def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._client_wrapper = client_wrapper - - async def get_browser_session( + def get_browser_session( self, browser_session_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> BrowserSessionResponse: """ @@ -323,6 +240,7 @@ class AsyncBrowserSessionClient: 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. @@ -334,25 +252,17 @@ class AsyncBrowserSessionClient: Examples -------- - import asyncio + from skyvern import Skyvern - from skyvern import AsyncSkyvern - - client = AsyncSkyvern( + client = Skyvern( api_key="YOUR_API_KEY", authorization="YOUR_AUTHORIZATION", ) - - - async def main() -> None: - await client.browser_session.get_browser_session( - browser_session_id="browser_session_id", - ) - - - asyncio.run(main()) + client.browser_session.get_browser_session( + browser_session_id="pbs_123456", + ) """ - _response = await self._client_wrapper.httpx_client.request( + _response = self._client_wrapper.httpx_client.request( f"v1/browser_sessions/{jsonable_encoder(browser_session_id)}", method="GET", 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_json) + +class AsyncBrowserSessionClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + async def get_browser_sessions( self, *, request_options: typing.Optional[RequestOptions] = None ) -> typing.List[BrowserSessionResponse]: @@ -566,6 +481,7 @@ class AsyncBrowserSessionClient: Parameters ---------- 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-specific configuration. @@ -589,7 +505,7 @@ class AsyncBrowserSessionClient: async def main() -> None: 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: raise ApiError(status_code=_response.status_code, body=_response.text) 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) diff --git a/skyvern/client/credentials/client.py b/skyvern/client/credentials/client.py index 0747482b..c5a61c8e 100644 --- a/skyvern/client/credentials/client.py +++ b/skyvern/client/credentials/client.py @@ -37,7 +37,7 @@ class CredentialsClient: request_options: typing.Optional[RequestOptions] = None, ) -> TotpCode: """ - Forward a TOTP (2FA, MFA) code to Skyvern + Forward a TOTP (2FA, MFA) email or sms message containing the code to Skyvern 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_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( self, credential_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> 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_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: def __init__(self, *, client_wrapper: AsyncClientWrapper): @@ -411,7 +411,7 @@ class AsyncCredentialsClient: request_options: typing.Optional[RequestOptions] = None, ) -> TotpCode: """ - Forward a TOTP (2FA, MFA) code to Skyvern + Forward a TOTP (2FA, MFA) email or sms message containing the code to Skyvern 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_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( self, credential_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> CredentialResponse: @@ -747,64 +808,3 @@ class AsyncCredentialsClient: 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_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) diff --git a/skyvern/client/types/browser_session_response.py b/skyvern/client/types/browser_session_response.py index 36e6fccc..5fab3b5d 100644 --- a/skyvern/client/types/browser_session_response.py +++ b/skyvern/client/types/browser_session_response.py @@ -14,7 +14,7 @@ class BrowserSessionResponse(UniversalBaseModel): 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() @@ -24,17 +24,17 @@ class BrowserSessionResponse(UniversalBaseModel): 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) """ - ID of the associated runnable + ID of the current runnable """ 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)