Metadata-Version: 2.4
Name: pulice
Version: 0.1.0
Summary: A framework for managing infrastructure-as-code components via Pulumi with tenant isolation, async execution, and pluggable backends.
Author: mk.fshr
License-Expression: MIT
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: License :: OSI Approved :: MIT License
Requires-Dist: pulumi>=3.215.0
Requires-Dist: pydantic>=2.12.5
Requires-Dist: typer>=0.21.1
Requires-Dist: textual>=3.0.0 ; extra == 'admin'
Requires-Dist: textual-serve>=1.1.0 ; extra == 'admin'
Requires-Dist: fastapi>=0.115.0 ; extra == 'api'
Requires-Dist: uvicorn[standard]>=0.30.0 ; extra == 'api'
Requires-Dist: huey>=2.5.0 ; extra == 'api'
Requires-Dist: pulumi-aws>=7.15.0 ; extra == 'aws'
Requires-Dist: celery[redis]>=5.4.0 ; extra == 'celery'
Requires-Python: >=3.13
Provides-Extra: admin
Provides-Extra: api
Provides-Extra: aws
Provides-Extra: celery
Description-Content-Type: text/markdown

# Pulice

A Python framework for managing infrastructure-as-code components via [Pulumi](https://www.pulumi.com/) with tenant isolation, async execution, and pluggable backends.

## Features

- **Component model** — Define cloud resources as `ManagedComponent` subclasses with Pydantic-validated inputs
- **Tenant isolation** — Named boundaries ensure stacks belonging to different environments never collide
- **9 lifecycle operations** — create, read, update, delete, refresh, list, status, export, import
- **CLI + HTTP API** — Synchronous CLI for interactive use; async FastAPI server for automation
- **Pluggable task backends** — Huey (SQLite, zero-dep) or Celery (Redis, distributed)
- **Passphrase-protected stacks** — scrypt-hashed passphrases validated before any Pulumi call
- **Advisory locking** — Prevents concurrent mutating operations on the same stack
- **Provider-agnostic** — Works with any Pulumi provider (AWS, GCP, Azure, Kubernetes, etc.)

## Installation

```bash
pip install pulice
```

With optional extras:

```bash
pip install pulice[api]      # FastAPI server + Huey worker
pip install pulice[celery]   # Celery backend for distributed deployments
pip install pulice[aws]      # AWS provider
```

## Quick Start

Define a component:

```python
from pulice import ComponentArgs, ManagedComponent
from pydantic import Field
import pulumi
import pulumi_aws as aws

class BucketArgs(ComponentArgs):
    region: str = Field(description="AWS region")

class Bucket(ManagedComponent):
    args_model = BucketArgs

    def __init__(self, name: str, args: BucketArgs, opts=None, **kwargs):
        super().__init__("pulice:aws:Bucket", name, {}, opts)
        aws.s3.BucketV2(f"{name}-bucket", opts=pulumi.ResourceOptions(parent=self))
```

Register and run:

```python
from typer import Typer
from pulice import PuliceCLI

app = Typer()
cli = PuliceCLI(app)
cli.register_component(Bucket, name="bucket")

if __name__ == "__main__":
    cli()
```

Use it:

```bash
pulice tenant create --name dev
pulice bucket create --name my-data --region eu-west-1 --tenant dev --passphrase secret
pulice bucket list --tenant dev
pulice bucket delete --stack-reference <ref> --tenant dev --passphrase secret
```

## HTTP API

```bash
pip install pulice[api]
uvicorn pulice.api:create_api --factory --host 0.0.0.0 --port 8000
huey_consumer pulice.worker.huey -w 2 -k process
```

Submit operations asynchronously:

```bash
curl -X POST http://localhost:8000/stacks/operations \
  -H "Content-Type: application/json" \
  -d '{"component_class": "myapp.Bucket", "operation": "create", "tenant": "dev", "passphrase": "secret", "args": {"name": "my-data", "region": "eu-west-1"}}'
```

## Documentation

Full documentation is available at the [project site](https://your-org.github.io/pulice/) or can be built locally:

```bash
pip install pulice[docs]
zensical serve
```

## License

[MIT](LICENSE) — Mike Fischer and Dani Vela Calderón
