Metadata-Version: 2.4
Name: tinet-data-foundry-cli
Version: 0.1.3
Summary: Tinet Data Foundry 取数 CLI（catalog / query / schema）
Author: Tinet
License: MIT
Project-URL: Homepage, https://data-foundry.tinetcloud.com
Project-URL: Documentation, https://data-foundry.tinetcloud.com
Keywords: data-foundry,tinet,cli
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Environment :: Console
Requires-Python: >=3.10
Description-Content-Type: text/markdown

# tinet-data-foundry-cli

Tinet Data Foundry 取数 CLI。包名 `tinet-data-foundry-cli`，命令 **`tdf`**（避开系统磁盘命令 `df`）。

鉴权只用环境变量，**不要**把 AccessKey / SecretKey 写入本地文件。需要 Python **≥ 3.10**。

macOS / Linux 用 Terminal（bash / zsh）。Windows 用 **cmd.exe** 跑下面示例（不要用 PowerShell 传 JSON：`export` 不可用，引号也会被剥掉）。

## macOS / Linux

```bash
pip install -U tinet-data-foundry-cli

export DF_ENDPOINT="https://data-foundry-data-api.tinetcloud.com"
export DF_AK="你的_AccessKey"
export DF_SK="你的_SecretKey"

tdf catalog
tdf schema --dataset "DATASET_ID"
tdf query \
  --dataset "DATASET_ID" \
  --fields "id" \
  --filter '{"op":"eq","field":"id","value":"sample"}' \
  --sort '[{"field":"id","direction":"DESC"}]' \
  --page-no 1 \
  --page-size 10
```

若 pip 提示 scripts 目录不在 PATH，把该目录加入 PATH，或用 `python3 -m tinet_data_foundry_cli`。

## Windows（cmd.exe）

```bat
pip install -U tinet-data-foundry-cli

set DF_ENDPOINT=https://data-foundry-data-api.tinetcloud.com
set DF_AK=你的_AccessKey
set DF_SK=你的_SecretKey

tdf catalog
tdf schema --dataset "DATASET_ID"
tdf query --dataset "DATASET_ID" --fields "id" --filter "{\"op\":\"eq\",\"field\":\"id\",\"value\":\"sample\"}" --sort "[{\"field\":\"id\",\"direction\":\"DESC\"}]" --page-no 1 --page-size 10
```

环境变量只对当前 cmd 窗口有效。JSON 参数用 `\"` 转义，整条命令写在一行。

公司代理 / 自签证书导致 `CERTIFICATE_VERIFY_FAILED` 时：

```bash
tdf --insecure catalog
tdf catalog --insecure
```

| 命令 | 接口 |
| --- | --- |
| `tdf catalog` | `GET /data-api/v1/catalog` |
| `tdf query` | `POST /data-api/v1/datasets/{id}/query` |
| `tdf schema` | `GET /data-api/v1/datasets/{id}/schema` |

签名：`canonical = METHOD + "\n" + PATH + "\n" + TIMESTAMP + "\n" + NONCE + "\n" + hex(SHA256(body))`，`X-DF-Signature = Base64(HMAC-SHA256(canonical, SK))`。GET 的 body 为空字节。PATH 不含域名、不含 query。

## 发布到 PyPI

版本号改 `pyproject.toml` 与 `src/tinet_data_foundry_cli/__init__.py`。

```bash
python -m pip install -U build twine
python -m build
python -m twine check dist/*
python -m twine upload --repository testpypi dist/*
python -m twine upload dist/*
```

已发布版本号不可覆盖。
