Metadata-Version: 2.4
Name: orchepy-client
Version: 0.1.0
Summary: Python client for Orchepy - A lightweight, domain-agnostic event orchestrator
Project-URL: Homepage, https://github.com/derivia/orchepy-python
Project-URL: Repository, https://github.com/derivia/orchepy-python
Project-URL: Documentation, https://github.com/derivia/orchepy-python#readme
Project-URL: Bug Tracker, https://github.com/derivia/orchepy-python/issues
Author-email: Lorran Soares <contato.lorransoares@gmail.com>
License: MIT
License-File: LICENSE
Keywords: automation,kanban,orchepy,orchestration,workflow
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Office/Business :: Groupware
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.11
Requires-Dist: httpx>=0.27.0
Requires-Dist: pydantic>=2.0.0
Provides-Extra: dev
Requires-Dist: mypy>=1.8.0; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
Requires-Dist: pytest-cov>=5.0.0; extra == 'dev'
Requires-Dist: pytest>=8.0.0; extra == 'dev'
Requires-Dist: ruff>=0.3.0; extra == 'dev'
Description-Content-Type: text/markdown

# Orchepy Python Client

A Python client library for [Orchepy](https://github.com/derivia/orchepy) - A lightweight, domain-agnostic event orchestrator for workflow automation.

## Features

- 🚀 Async-first - Built on `httpx` for high-performance async operations
- 🔒 Type-safe - Full type hints and Pydantic models
- 📦 Simple API - Clean, intuitive interface matching Orchepy's REST API
- 🎯 Lightweight - Minimal dependencies

## Installation

```bash
pip install orchepy-client
```

## Quick Start

```python
import asyncio
from orchepy_client import OrchepyClient

async def main():
    client = OrchepyClient(base_url="http://localhost:3296")

    # Create a workflow
    workflow = await client.create_workflow(
        name="Sales Pipeline",
        phases=["Lead", "Qualified", "Proposal", "Closed"],
        initial_phase="Lead",
    )

    # Create a case
    case = await client.create_case(
        workflow_id=workflow["id"],
        data={
            "customer": "Acme Corp",
            "value": 50000,
            "contact": "john@acme.com"
        }
    )

    # Move case to next phase
    await client.move_case(
        case_id=case["id"],
        to_phase="Qualified",
        reason="Customer showed interest"
    )

    # Update case data
    await client.update_case_data(
        case_id=case["id"],
        data={"value": 75000}
    )

    # Get case info
    case_info = await client.get_case(case["id"])
    print(f"Case is now in phase: {case_info['current_phase']}")

asyncio.run(main())
```

## API Reference

### Client Initialization

```python
from orchepy_client import OrchepyClient

client = OrchepyClient(
    base_url="http://localhost:3296",
    timeout=10.0  # optional, defaults to 10.0 seconds
)
```

### Workflows

```python
# Create workflow
workflow = await client.create_workflow(
    name="My Workflow",
    phases=["Phase 1", "Phase 2"],
    initial_phase="Phase 1",
    active=True,
    webhook_url="https://example.com/webhook"  # optional
)

# Get workflow
workflow = await client.get_workflow(workflow_id)

# List workflows
workflows = await client.list_workflows()
```

### Cases

```python
# Create case
case = await client.create_case(
    workflow_id="workflow-uuid",
    data={"field": "value"},
    metadata={"source": "api"}  # optional
)

# Get case
case = await client.get_case(case_id)

# List cases
cases = await client.list_cases(
    workflow_id="workflow-uuid",  # optional
    current_phase="Phase 1",      # optional
    status="active"                # optional
)

# Move case
await client.move_case(
    case_id="case-uuid",
    to_phase="Phase 2",
    reason="Moving forward",      # optional
    triggered_by="user-123"       # optional
)

# Update case data
await client.update_case_data(
    case_id="case-uuid",
    data={"new_field": "new_value"}
)

# Get case history
history = await client.get_case_history(case_id)
```

### Error Handling

```python
from orchepy_client import OrchepyClientError

try:
    case = await client.get_case("invalid-id")
except OrchepyClientError as e:
    print(f"Error: {e}")
```

## License

[MIT](./LICENSE)
