Skip to main content

Client for Leap Workflows API

Project description

leap-workflows-python-sdk

The Leap Workflows API allows developers to run workflows, fetch workflow runs, and provide other utility functions related to workflow runs. Please use the X-Api-Key for authenticated requests.

PyPI GitHub last commit README.md More Info

Table of Contents

Requirements

Python >=3.7

Installing

pip install leap-workflows-python-sdk==1.0.1

Getting Started

from pprint import pprint
from leap_workflows import Leap, ApiException

leap = Leap(
    api_key="YOUR_API_KEY",
)

try:
    # Get a workflow run
    get_workflow_run_response = leap.workflow_runs.get_workflow_run(
        workflow_run_id="rnp_x3p27VQk6MyJfLe",
    )
    pprint(get_workflow_run_response.body)
    pprint(get_workflow_run_response.body["id"])
    pprint(get_workflow_run_response.body["version_id"])
    pprint(get_workflow_run_response.body["status"])
    pprint(get_workflow_run_response.body["created_at"])
    pprint(get_workflow_run_response.body["started_at"])
    pprint(get_workflow_run_response.body["ended_at"])
    pprint(get_workflow_run_response.body["workflow_id"])
    pprint(get_workflow_run_response.body["error"])
    pprint(get_workflow_run_response.body["input"])
    pprint(get_workflow_run_response.body["output"])
    pprint(get_workflow_run_response.headers)
    pprint(get_workflow_run_response.status)
    pprint(get_workflow_run_response.round_trip_time)
except ApiException as e:
    print("Exception when calling WorkflowRunsApi.get_workflow_run: %s\n" % e)
    pprint(e.body)
    pprint(e.headers)
    pprint(e.status)
    pprint(e.reason)
    pprint(e.round_trip_time)

Async

async support is available by prepending a to any method.

import asyncio
from pprint import pprint
from leap_workflows import Leap, ApiException

leap = Leap(
    api_key="YOUR_API_KEY",
)


async def main():
    try:
        # Get a workflow run
        get_workflow_run_response = await leap.workflow_runs.aget_workflow_run(
            workflow_run_id="rnp_x3p27VQk6MyJfLe",
        )
        pprint(get_workflow_run_response.body)
        pprint(get_workflow_run_response.body["id"])
        pprint(get_workflow_run_response.body["version_id"])
        pprint(get_workflow_run_response.body["status"])
        pprint(get_workflow_run_response.body["created_at"])
        pprint(get_workflow_run_response.body["started_at"])
        pprint(get_workflow_run_response.body["ended_at"])
        pprint(get_workflow_run_response.body["workflow_id"])
        pprint(get_workflow_run_response.body["error"])
        pprint(get_workflow_run_response.body["input"])
        pprint(get_workflow_run_response.body["output"])
        pprint(get_workflow_run_response.headers)
        pprint(get_workflow_run_response.status)
        pprint(get_workflow_run_response.round_trip_time)
    except ApiException as e:
        print("Exception when calling WorkflowRunsApi.get_workflow_run: %s\n" % e)
        pprint(e.body)
        pprint(e.headers)
        pprint(e.status)
        pprint(e.reason)
        pprint(e.round_trip_time)


asyncio.run(main())

Reference

leap.workflow_runs.get_workflow_run

This endpoint retrieves the details of a specific workflow run using its workflow_run_id.

🛠️ Usage

get_workflow_run_response = leap.workflow_runs.get_workflow_run(
    workflow_run_id="rnp_x3p27VQk6MyJfLe",
)

⚙️ Parameters

workflow_run_id: str

The ID of the workflow run to retrieve.

🔄 Return

WorkflowRunEntity

🌐 Endpoint

/v1/runs/{workflow_run_id} get

🔙 Back to Table of Contents


leap.workflow_runs.workflow

This endpoint lets the user run a specified workflow with the provided workflow definition.

🛠️ Usage

workflow_response = leap.workflow_runs.workflow(
    workflow_id="wkf_i3F5UjpZ2Vg",
    webhook_url="https://myapp.com/webhook",
    input={
        "first_name": "Sam",
        "last_name": "Altman",
    },
)

⚙️ Parameters

workflow_id: str

The ID of the workflow to be run.

webhook_url: str

The URL to which the workflow results should be sent to on completion.

input: RunWorkflowDtoInput

⚙️ Request Body

RunWorkflowDto

🔄 Return

WorkflowRunEntity

🌐 Endpoint

/v1/runs post

🔙 Back to Table of Contents


Author

This Python package is automatically generated by Konfig

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

leap_workflows_python_sdk-1.0.1.tar.gz (51.2 kB view hashes)

Uploaded Source

Built Distribution

leap_workflows_python_sdk-1.0.1-py3-none-any.whl (75.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page