# QRM

CLI + Python client for interacting with the Qestit QRM.

## Install

```bash
pip install lr-qrm
```

## Quick start

### Login

Interactive login (prompts for username/password):

```bash
qrm login
```

Non-interactive (for CI/CD):

```bash
export QRM_USERNAME="<insert username>"
export QRM_PASSWORD="<insert password>"
qrm login --ci
```

By default, this stores session details at:

```
~/.config/qrm/login.json
```

### Commands

#### Check API health

```bash
qrm status
```

#### Inspect UUT history

```bash
qrm uut status 326115020010F2F1 --start "2026-02-01T00:00:00Z" --stop "2026-02-06T23:59:00Z"
```

By default the command uses `1970-01-01T00:00:00Z` as the start timestamp and lets QRM treat the stop as "now" (omit `--stop`). Pass `--base-url` and `--insecure` to override the stored settings when needed.

#### List production boxes

```bash
qrm box list --stop "2026-02-06T23:59:00Z"
```

If you omit `--start`, the command defaults to the Unix epoch (`1970-01-01T00:00:00Z`). Leave `--stop` out to let QRM use its current time.

#### JSON output

Most commands support a JSON output mode.

```bash
qrm uut status 326115020010F2F1 --output json
```

## Programmatic use

```python
from qrm.config import load_login_state
from qrm.client import QrmClient

state = load_login_state()
client = QrmClient(base_url=str(state.base_url), verify_tls=state.verify_tls)

uut_runs = client.uut_status(
    token=state.token,
    serial_number="326115020010F2F1",
    start_datetime="2026-02-01T00:00:00Z",
    stop_datetime="2026-02-06T23:59:00Z",
    max_results=1000,
)

boxes = client.box_list(
    token=state.token,
    start_datetime="1970-01-01T00:00:00Z",
    stop_datetime="2026-02-06T23:59:00Z",
)
```


## FAQ

- **Where is the config kept?**
  `~/.config/qrm/login.json` (override with `QRM_CONFIG`)

- **How do I run non-interactively?**
  Make sure to give all required arguments. Also pass `--ci` to stop output of sensitive information such as username or passwords.