Metadata-Version: 2.5
Name: larrot
Version: 1.0.0
Summary: Larrot repeats Huawei Cloud. Perfectly. — a local Huawei Cloud API simulator (like LocalStack, but for Huawei Cloud)
Project-URL: Homepage, https://github.com/larbi-ishak/Larrot
Author: Larbi Ishak (larbizyo)
License: Apache-2.0
License-File: LICENSE
Keywords: cloud,huawei,larrot,localstack,mock,simulator,testing
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development :: Testing
Requires-Python: >=3.11
Requires-Dist: fastapi>=0.115
Requires-Dist: pydantic>=2.10
Requires-Dist: uvicorn[standard]>=0.32
Provides-Extra: dev
Requires-Dist: httpx>=0.28; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.24; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: ruff>=0.8; extra == 'dev'
Description-Content-Type: text/markdown

<div align="center">

# Larrot 🦜

**Larrot repeats Huawei Cloud. Perfectly.**

*A local Huawei Cloud API simulator — like LocalStack, but for Huawei Cloud.*

[![CI](https://github.com/larbi-ishak/Larrot/actions/workflows/ci.yml/badge.svg)](../../actions)

</div>

---

Larrot is a parrot. Larrot listens to Huawei Cloud and repeats it — every endpoint,
every error envelope, every async job, every quirk we observed in production.
*Yes, even `Ecs.0005 "device is illegal"`.*

**Can your SDK tell the difference? That's the point.**

It runs the REST APIs of Huawei Cloud's international site (`*.myhuaweicloud.com`)
on your machine: 59 services — IAM, ECS, EVS, VPC, EIP, IMS, CBR, RDS, OBS, CCE,
ModelArts + MaaS, and 50 more — on ports 8200/8201.

## Quick start

```bash
# Install
pip install larrot

# Run
larrot-server
# → REST on http://127.0.0.1:8200, OBS on http://127.0.0.1:8201

# Or with Docker
docker compose up

# Or from source
pip install -e .
python -m larrot
```

## CLI

```bash
larrot projects
larrot ecs list
larrot --wait ecs create --image <id> --flavor s6.large.2 --name myvm
larrot --wait ecs stop <server-id>
larrot evs list
larrot cbr vaults
larrot obs buckets
larrot --json ecs list
```

## Wire real SDKs

Point any `@huaweicloud` SDK at the simulator with a custom endpoint:

```python
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkecs.v2 import EcsClient, CreateServersRequest

credentials = BasicCredentials() \
    .with_ak("HWYSIMAK00000001") \
    .with_sk("HWYSIMSK00000001") \
    .with_project_id("06f1c15e6f0010672f86c003006c5f17")

client = EcsClient.newBuilder() \
    .withCredential(credentials) \
    .withEndpoint("http://127.0.0.1:8200") \
    .build()
```

Your existing scripts run **unchanged** — just change the endpoint.

## Services

**59 distinct Huawei Cloud services** across 71 router modules:

| Service | Port | What it covers |
|---|---|---|
| IAM | 8200 | Projects, tokens |
| ECS | 8200 | Servers: lifecycle, attach/detach, state guards, batch ops, flavors |
| EVS | 8200 | Volumes: CRUD, snapshots (detached-only), os-vendor detail, extend |
| VPC | 8200 | VPCs, subnets, ports, peering, network ACLs, route tables |
| EIP | 8200 | Allocate/bind/unbind/release, bandwidths (v2.0) |
| IMS | 8200 | Images: 3 registration routes, Glance v2, whole images |
| CBR | 8200 | Vaults, policies, checkpoints (on-demand backup), backups, restore |
| RDS | 8200 | Database instances, flavors, backups, params, replicas, users, logs |
| OBS | 8201 | Buckets, objects, multipart upload, ListObjects XML |
| ELB / NAT / VPN / DNS | 8200 | Load balancers, NAT gateways, VPN gateways, zones + recordsets |
| CCE / CCI / SWR | 8200 | Kubernetes clusters, serverless pods, container registry |
| DWS / CSS / MRS | 8200 | Data warehouse, Elasticsearch clusters, Hadoop/Spark clusters |
| RDS-family | 8200 | DDS, GaussDB, GeminiDB, DDM, DBSS |
| DCS / DMS / DIS | 8200 | Redis, Kafka/RocketMQ, streaming ingestion |
| ModelArts + MaaS | 8200 | Notebooks, training, model registry, inference services, fine-tuning, OpenAI-compatible chat/embeddings |
| HSS / CFW / DSC / WAF / Anti-DDoS / KMS | 8200 | Host security, cloud firewall, data security, WAF, DDoS, keys |
| CDN | 8200 | Domains, origins, purge/preheat, statistics |
| SMS / OMS / DES | 8200 | Server migration, OBS migration, physical data transfer |
| DC / ER | 8200 | Direct Connect, Enterprise Router (attachments, route tables) |
| CodeArts / ServiceStage / CSE | 8200 | Repos, pipelines, builds; environments/apps/components; microservice engines |
| VOD / IEF | 8200 | Media assets + transcode, edge nodes + deployments |
| DataArts / DLI / AOM / CES / LTS / SMN | 8200 | Data governance, SQL jobs, ops, monitoring, logs, notifications |
| BMS / AS / SFS / TMS / EPS / APIG / IoTDA / BSS | 8200 | Bare metal, auto scaling, file shares, tags, enterprise projects, API gateway, IoT, billing |

## What makes it different from a mock

- **State machines with preconditions** — can't stop a stopped server, can't snapshot an
  in-use volume, can't detach a system disk
- **Async job model** — every mutation returns `job_id`, completes after 1–3s, clients poll
- **Per-region quirk profiles** — tr-west-1 (HCS) behaves differently from ap-southeast-1
- **Exact error codes** — `Ecs.0005 "device is illegal"`, `APIGW.0301`, `SecurityGroupRuleExists`
- **Rate limiting** — rapid calls → 401 `APIGW.0301`, 30s backoff clears it
- **Signature verification** — recomputes SDK-HMAC-SHA256 and OBS v2 signatures (accept-and-check)

## Configuration

| Env var | Default | Meaning |
|---|---|---|
| `SIM_PORT` | 8200 | REST port |
| `SIM_OBS_PORT` | 8201 | OBS port |
| `SIM_PROFILE` | public | Default quirk profile |
| `SIM_AK` / `SIM_SK` | HWYSIMAK… / HWYSIMSK… | Credentials |
| `SIM_RATE_LIMIT` | 100 | Per-AK requests / 10s (0 = disabled) |
| `SIM_RATE_COOLDOWN_MS` | 30000 | Throttle backoff |

## Dashboard

Open `http://127.0.0.1:8200/` for a live dashboard showing resource counts.
Open `http://127.0.0.1:8200/docs` for auto-generated API documentation.

## Testing

```bash
python3 tools/smoke.py        # 23-check smoke suite
python3 -m pytest tests/      # unit tests
```

## License

Apache 2.0 — see [LICENSE](LICENSE)

## Contributing

See [CONTRIBUTING.md](CONTRIBUTING.md)
