updated readme
This commit is contained in:
60
README.md
60
README.md
@@ -15,6 +15,8 @@ sed -i \
|
|||||||
.env
|
.env
|
||||||
```
|
```
|
||||||
|
|
||||||
|
You can change `NUM_KEY_CHUNKS` to adjust how many chunks a license key consists of, and `KEY_CHUNK_LENGTH` to change how many characters appear in each chunk. This only changes how *new* keys are generated, so previous keys won't become invalidated.
|
||||||
|
|
||||||
## API Endpoints
|
## API Endpoints
|
||||||
|
|
||||||
All authenticated endpoints expect a `Bearer` token via the `Authorization` header that matches `API_KEY` from `.env`. Unless stated otherwise, responses are JSON.
|
All authenticated endpoints expect a `Bearer` token via the `Authorization` header that matches `API_KEY` from `.env`. Unless stated otherwise, responses are JSON.
|
||||||
@@ -29,3 +31,61 @@ All authenticated endpoints expect a `Bearer` token via the `Authorization` head
|
|||||||
| `POST` | `/license/{license_key}/expiration` | Yes | Sets or clears a license key expiration. | Path: `license_key`; Query: `expiration_date` (ISO 8601 or omit to clear) | `license_key`, `expiration_timestamp` (nullable) |
|
| `POST` | `/license/{license_key}/expiration` | Yes | Sets or clears a license key expiration. | Path: `license_key`; Query: `expiration_date` (ISO 8601 or omit to clear) | `license_key`, `expiration_timestamp` (nullable) |
|
||||||
| `GET` | `/license/export` | Yes | Exports license inventory as CSV ordered by issue time. | – | CSV with `license_key,issue_timestamp,expiration_timestamp,is_active` |
|
| `GET` | `/license/export` | Yes | Exports license inventory as CSV ordered by issue time. | – | CSV with `license_key,issue_timestamp,expiration_timestamp,is_active` |
|
||||||
| `GET` | `/history/export` | Yes | Exports audit history as CSV. | Query: `token` (optional substring filter) | CSV with `action,timestamp` |
|
| `GET` | `/history/export` | Yes | Exports audit history as CSV. | Query: `token` (optional substring filter) | CSV with `action,timestamp` |
|
||||||
|
|
||||||
|
## Usage Examples
|
||||||
|
|
||||||
|
Set your API key once for convenience:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
API_KEY=$(grep API_KEY .env | cut -d'"' -f2)
|
||||||
|
BASE_URL=http://127.0.0.1:8000
|
||||||
|
```
|
||||||
|
|
||||||
|
Create a license with optional metadata:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -X POST "$BASE_URL/license?info=QA+test+license" \
|
||||||
|
-H "Authorization: Bearer $API_KEY"
|
||||||
|
```
|
||||||
|
|
||||||
|
Check whether a license key is valid:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl "$BASE_URL/is_valid?license_key=PUT-LICENSE-HERE"
|
||||||
|
```
|
||||||
|
|
||||||
|
Disable and enable a license:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -X POST "$BASE_URL/license/PUT-LICENSE-HERE/disable" \
|
||||||
|
-H "Authorization: Bearer $API_KEY"
|
||||||
|
|
||||||
|
curl -X POST "$BASE_URL/license/PUT-LICENSE-HERE/enable" \
|
||||||
|
-H "Authorization: Bearer $API_KEY"
|
||||||
|
```
|
||||||
|
|
||||||
|
Update (or clear) the expiration timestamp:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -X POST "$BASE_URL/license/PUT-LICENSE-HERE/expiration" \
|
||||||
|
-H "Authorization: Bearer $API_KEY" \
|
||||||
|
-G --data-urlencode "expiration_date=$(date -u -Idate)T23:59:59Z"
|
||||||
|
|
||||||
|
curl -X POST "$BASE_URL/license/PUT-LICENSE-HERE/expiration" \
|
||||||
|
-H "Authorization: Bearer $API_KEY"
|
||||||
|
```
|
||||||
|
|
||||||
|
Download the license inventory as CSV:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -H "Authorization: Bearer $API_KEY" \
|
||||||
|
"$BASE_URL/license/export" -o license_export.csv
|
||||||
|
```
|
||||||
|
|
||||||
|
Download history entries filtered by a token:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -H "Authorization: Bearer $API_KEY" \
|
||||||
|
"$BASE_URL/history/export?token=PUT-LICENSE-HERE" \
|
||||||
|
-o history_export.csv
|
||||||
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user