# Alibaba Cloud Billing Toolkit

This package mirrors the AWS and GCP pipelines to export and analyze Alibaba Cloud billing data stored in BigQuery.

## Export

```bash
python -m alibaba_cloud.main_export --last-week --config alibaba_cloud/config.json
```

Key flags:

- `--start-date/--end-date` – explicit range (YYYY-MM-DD).
- `--days` or `--last-week` – relative range.
- `--env` – filter to environments defined in `config.json`.
- `--account-id` – limit to specific account IDs.
- `--dry-run` – preview data without writing CSVs.

Exports are stored under `alibaba_cloud/alibaba_cloud_billing_exports/<env>/alibaba_cloud_<account>_<YYYY-MM>.csv`.
Set `cloudWebhookUrl` in `config.json` to route all alerts to a single Alibaba Cloud topic；环境内的 webhook 已移除。
From 2025-12-01 onward, the exporter reads `daily_en_` tables and maps English columns into the legacy CSV schema.

## Analysis

```bash
python -m alibaba_cloud.main_analyze --date 2025-02-01 --config alibaba_cloud/config.json --dry-run
```

Key flags:

- `--env` – environment filter (repeatable, use `all` for every environment).
- `--account-id` – limit to particular accounts.
- `--dry-run` – print Feishu payload instead of sending.
- `--no-notify` – skip notifications entirely.
- `--output-json` – dump structured results for automation.

The analyzer reuses the Feishu notification style from the existing pipelines and honours per-environment thresholds defined in `config.json`.
