lr-serial 0.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- lr_serial-0.4.0/LICENSE +21 -0
- lr_serial-0.4.0/PKG-INFO +273 -0
- lr_serial-0.4.0/README.md +16 -0
- lr_serial-0.4.0/pyproject.toml +60 -0
- lr_serial-0.4.0/setup.cfg +4 -0
- lr_serial-0.4.0/src/README.md +250 -0
- lr_serial-0.4.0/src/lr_serial.egg-info/PKG-INFO +273 -0
- lr_serial-0.4.0/src/lr_serial.egg-info/SOURCES.txt +30 -0
- lr_serial-0.4.0/src/lr_serial.egg-info/dependency_links.txt +1 -0
- lr_serial-0.4.0/src/lr_serial.egg-info/entry_points.txt +2 -0
- lr_serial-0.4.0/src/lr_serial.egg-info/requires.txt +13 -0
- lr_serial-0.4.0/src/lr_serial.egg-info/top_level.txt +1 -0
- lr_serial-0.4.0/src/serial/__init__.py +31 -0
- lr_serial-0.4.0/src/serial/auth_user.py +220 -0
- lr_serial-0.4.0/src/serial/cli.py +315 -0
- lr_serial-0.4.0/src/serial/client.py +81 -0
- lr_serial-0.4.0/src/serial/commands/__init__.py +67 -0
- lr_serial-0.4.0/src/serial/commands/article.py +260 -0
- lr_serial-0.4.0/src/serial/commands/audit.py +144 -0
- lr_serial-0.4.0/src/serial/commands/serial_cmd.py +121 -0
- lr_serial-0.4.0/src/serial/commands/site.py +171 -0
- lr_serial-0.4.0/src/serial/config.py +27 -0
- lr_serial-0.4.0/tests/test_article.py +513 -0
- lr_serial-0.4.0/tests/test_audit.py +212 -0
- lr_serial-0.4.0/tests/test_auth_user.py +347 -0
- lr_serial-0.4.0/tests/test_cli.py +36 -0
- lr_serial-0.4.0/tests/test_cli_list_articles.py +162 -0
- lr_serial-0.4.0/tests/test_cli_login.py +699 -0
- lr_serial-0.4.0/tests/test_cli_status.py +132 -0
- lr_serial-0.4.0/tests/test_helpers.py +100 -0
- lr_serial-0.4.0/tests/test_serial_cmd.py +254 -0
- lr_serial-0.4.0/tests/test_site.py +282 -0
lr_serial-0.4.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 LumenRadio AB
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
lr_serial-0.4.0/PKG-INFO
ADDED
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: lr-serial
|
|
3
|
+
Version: 0.4.0
|
|
4
|
+
Summary: CLI client for interacting with LumenRadio serial generation backend service.
|
|
5
|
+
Author-email: Jonas Estberger <jonas.estberger@lumenradio.com>
|
|
6
|
+
License: MIT License
|
|
7
|
+
Requires-Python: >=3.9
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Requires-Dist: requests>=2.32
|
|
11
|
+
Requires-Dist: typer>=0.12
|
|
12
|
+
Requires-Dist: rich>=13.7
|
|
13
|
+
Requires-Dist: pydantic>=2.8
|
|
14
|
+
Provides-Extra: dev
|
|
15
|
+
Requires-Dist: build>=1.2.1; extra == "dev"
|
|
16
|
+
Requires-Dist: twine>=5.1.1; extra == "dev"
|
|
17
|
+
Requires-Dist: wheel; extra == "dev"
|
|
18
|
+
Requires-Dist: pytest>=8.4.2; extra == "dev"
|
|
19
|
+
Requires-Dist: black>=25.9.0; extra == "dev"
|
|
20
|
+
Requires-Dist: pytest-html; extra == "dev"
|
|
21
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
22
|
+
Dynamic: license-file
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
# lr-serial
|
|
26
|
+
|
|
27
|
+
CLI + Python client for interacting with the LumenRadio Serial Number Generation Service.
|
|
28
|
+
|
|
29
|
+
## Install
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pip install lr-serial
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## CLI Usage
|
|
36
|
+
|
|
37
|
+
### Login Command
|
|
38
|
+
|
|
39
|
+
The `login` command supports two authentication modes:
|
|
40
|
+
|
|
41
|
+
#### User login (default)
|
|
42
|
+
|
|
43
|
+
Opens the system browser for interactive sign-in via OAuth 2.0 Authorization Code + PKCE.
|
|
44
|
+
No client secret required — suitable for human operators.
|
|
45
|
+
|
|
46
|
+
LumenRadio employees can log in with no arguments (client ID and tenant ID are baked in):
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
serial login
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
If the browser does not open automatically the auth URL is printed to the terminal so you
|
|
53
|
+
can paste it manually.
|
|
54
|
+
|
|
55
|
+
#### Machine-to-machine (M2M) login
|
|
56
|
+
|
|
57
|
+
Uses the OAuth 2.0 client credentials grant — suitable for automated pipelines.
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
serial login --mode m2m \
|
|
61
|
+
--client-id <CLIENT_ID> \
|
|
62
|
+
--client-secret <CLIENT_SECRET> \
|
|
63
|
+
--tenant-id <TENANT_ID>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
#### Common options
|
|
67
|
+
|
|
68
|
+
- `--mode [user|m2m]` — authentication mode (default: `user`) [env: SERIAL_AUTH_MODE]
|
|
69
|
+
- `--client-id` — Azure AD application client ID [env: SERIAL_CLIENT_ID]
|
|
70
|
+
- `--client-secret` — client secret, required for `m2m` [env: SERIAL_CLIENT_SECRET]
|
|
71
|
+
- `--tenant-id` — Azure AD tenant ID [env: SERIAL_TENANT_ID]
|
|
72
|
+
- `--token-url` — token endpoint URL override (m2m only) [env: SERIAL_TOKEN_URL]
|
|
73
|
+
- `--scope` — OAuth2 scope override [env: SERIAL_SCOPE]
|
|
74
|
+
- `--config-path` — override the login.json location
|
|
75
|
+
|
|
76
|
+
Stores the bearer token (and refresh token for user logins) in your config directory for
|
|
77
|
+
subsequent CLI commands.
|
|
78
|
+
|
|
79
|
+
### Status Command
|
|
80
|
+
|
|
81
|
+
Check backend reachability and token validity:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
serial status
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Reports:
|
|
88
|
+
- Backend reachable ✓ / unreachable ✗
|
|
89
|
+
- Token valid ✓ / invalid ✗
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## Global Options
|
|
94
|
+
|
|
95
|
+
Most commands support:
|
|
96
|
+
- `--output [rich|json]` — output format (rich table default, json for scripting)
|
|
97
|
+
- `--config-path PATH` — override the login.json location
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## Article Commands
|
|
102
|
+
|
|
103
|
+
### List Articles
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
serial list-articles
|
|
107
|
+
serial list-articles --output json
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Get Article
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
serial article get ARTICLE_NO
|
|
114
|
+
serial article get 710-4130 --output json
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Returns full article details: article number, description, prefix, schema (version, fields, format, regexp), disabled flag.
|
|
118
|
+
|
|
119
|
+
### Create Article
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
serial article create \
|
|
123
|
+
--article PROD-01 \
|
|
124
|
+
--description "Production line 1" \
|
|
125
|
+
--prefix PROD \
|
|
126
|
+
--schema-file schema.json
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
The `--schema-file` must be a JSON file with the ArticleSchema object:
|
|
130
|
+
|
|
131
|
+
```json
|
|
132
|
+
{
|
|
133
|
+
"version": 1,
|
|
134
|
+
"fields": { "site": "string" },
|
|
135
|
+
"format": "{prefix}-{site}-{counter:06d}",
|
|
136
|
+
"regexp": "^[A-Z0-9]+-[A-Z0-9]+-[0-9]{6}$"
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Options:
|
|
141
|
+
- `--article TEXT` — article number (1-32 chars, [A-Za-z0-9-]) [required]
|
|
142
|
+
- `--description TEXT` — human-readable description (1-100 chars) [required]
|
|
143
|
+
- `--prefix TEXT` — serial prefix (1-10 chars, [A-Za-z0-9]) [required]
|
|
144
|
+
- `--schema-file PATH` — path to JSON file containing the ArticleSchema [required]
|
|
145
|
+
- `--disabled / --no-disabled` — create as disabled (default: enabled)
|
|
146
|
+
|
|
147
|
+
### Update Article
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
serial article update ARTICLE_NO --description "New description"
|
|
151
|
+
serial article update ARTICLE_NO --prefix NEWP --disabled
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
At least one option must be provided. Options: `--description`, `--prefix`, `--disabled/--no-disabled`, `--schema-file`.
|
|
155
|
+
|
|
156
|
+
### Delete Article
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
serial article delete ARTICLE_NO
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Idempotent — succeeds even if the article does not exist.
|
|
163
|
+
|
|
164
|
+
### Set Sequence Counter
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
serial article set-sequence ARTICLE_NO SEQUENCE_NO
|
|
168
|
+
serial article set-sequence 710-4130 1000
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
Sets the current counter value (integer ≥ 0) for the article.
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
## Serial Number Commands
|
|
176
|
+
|
|
177
|
+
### Generate Serial Numbers
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
serial generate ARTICLE_NO
|
|
181
|
+
serial generate ARTICLE_NO --quantity 5
|
|
182
|
+
serial generate ARTICLE_NO --field site=Stockholm --field year=2024
|
|
183
|
+
serial generate ARTICLE_NO --quantity 3 --output json
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
Options:
|
|
187
|
+
- `--quantity INT` — number of serials to generate (1-1000, default 1)
|
|
188
|
+
- `--field KEY=VALUE` — extra field value consumed by the article schema (repeatable)
|
|
189
|
+
|
|
190
|
+
### Lookup a Serial Number
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
serial lookup SERIAL_NO
|
|
194
|
+
serial lookup QWDNA010000001 --output json
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
Returns: serial value, article, created_by, created_at.
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
## Site Commands
|
|
202
|
+
|
|
203
|
+
### List Sites
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
serial site list
|
|
207
|
+
serial site list --output json
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### Create Site
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
serial site create --site-no 5 --name "Helsinki"
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
Options:
|
|
217
|
+
- `--site-no INT` — site number (1-99) [required]
|
|
218
|
+
- `--name TEXT` — site name [required]
|
|
219
|
+
|
|
220
|
+
### Update Site
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
serial site update 5 --name "Helsinki" --contact-email ops@example.com
|
|
224
|
+
serial site update 5 --name "Helsinki" --disabled
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
Note: `--name` is required by the API even when only updating other fields.
|
|
228
|
+
|
|
229
|
+
Options:
|
|
230
|
+
- `--name TEXT` — new site name [required]
|
|
231
|
+
- `--client-id TEXT` — associated client ID (or empty to clear)
|
|
232
|
+
- `--contact-email TEXT` — contact email address (or empty to clear)
|
|
233
|
+
- `--disabled / --no-disabled` — enable or disable the site
|
|
234
|
+
|
|
235
|
+
### Delete Site
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
serial site delete 5
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
Idempotent — succeeds even if the site does not exist.
|
|
242
|
+
|
|
243
|
+
---
|
|
244
|
+
|
|
245
|
+
## Audit Commands
|
|
246
|
+
|
|
247
|
+
These commands require the `app.admin.api` scope.
|
|
248
|
+
|
|
249
|
+
### List Audit Entries
|
|
250
|
+
|
|
251
|
+
```bash
|
|
252
|
+
serial audit list
|
|
253
|
+
serial audit list --limit 50 --output json
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
Returns audit entries newest-first: id, touched_table, touched_key, change_type (create/update/delete), changed_by, changed_at.
|
|
257
|
+
|
|
258
|
+
Options:
|
|
259
|
+
- `--limit INT` — max entries to return (1-500, default 100)
|
|
260
|
+
|
|
261
|
+
### Restore an Audit Entry
|
|
262
|
+
|
|
263
|
+
```bash
|
|
264
|
+
serial audit restore AUDIT_ID
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
Undoes the audited change:
|
|
268
|
+
- `create` → deletes the created row
|
|
269
|
+
- `update` → restores previous values
|
|
270
|
+
- `delete` → re-inserts the deleted row
|
|
271
|
+
|
|
272
|
+
If the token lacks the admin scope, the API returns 403 and the CLI will display:
|
|
273
|
+
`Access denied. Ensure your credentials include the admin scope (app.admin.api).`
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# lr-serial
|
|
2
|
+
|
|
3
|
+
<img src="luminance-logo-512px.png" align="right" width="256"/>
|
|
4
|
+
|
|
5
|
+
CLI tooling for LumenRadio engineers to interact with serial number generation backend. The application is implemented with Typer, Rich, Pydantic, and Requests, and is packaged as a standard Python project targeting Python 3.9+.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
- Consistent CLI entry point exposed as `serial`.
|
|
9
|
+
- Ready-to-extend Rich console output pipeline.
|
|
10
|
+
- Secure login workflow that writes bearer tokens to `~/.config/serial/login.json`.
|
|
11
|
+
- Comprehensive pytest test suite with coverage and HTML/JUnit reports suitable for CI.
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## License
|
|
15
|
+
Released under the MIT License. See LICENSE.
|
|
16
|
+
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "lr-serial"
|
|
7
|
+
version = "0.4.0"
|
|
8
|
+
description = "CLI client for interacting with LumenRadio serial generation backend service."
|
|
9
|
+
readme = "src/README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = { text = "MIT License" }
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "Jonas Estberger", email = "jonas.estberger@lumenradio.com" }
|
|
14
|
+
]
|
|
15
|
+
dependencies = [
|
|
16
|
+
"requests>=2.32",
|
|
17
|
+
"typer>=0.12",
|
|
18
|
+
"rich>=13.7",
|
|
19
|
+
"pydantic>=2.8",
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
[project.optional-dependencies]
|
|
23
|
+
dev = [
|
|
24
|
+
"build>=1.2.1",
|
|
25
|
+
"twine>=5.1.1",
|
|
26
|
+
"wheel",
|
|
27
|
+
"pytest>=8.4.2",
|
|
28
|
+
"black>=25.9.0",
|
|
29
|
+
"pytest-html",
|
|
30
|
+
"pytest-cov",
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
[project.scripts]
|
|
34
|
+
serial = "serial.cli:app"
|
|
35
|
+
|
|
36
|
+
[tool.setuptools]
|
|
37
|
+
package-dir = {"" = "src"}
|
|
38
|
+
include-package-data = true
|
|
39
|
+
|
|
40
|
+
[tool.setuptools.packages.find]
|
|
41
|
+
where = ["src"]
|
|
42
|
+
|
|
43
|
+
[tool.pytest.ini_options]
|
|
44
|
+
addopts = "-ra"
|
|
45
|
+
testpaths = ["tests"]
|
|
46
|
+
filterwarnings = ["error"]
|
|
47
|
+
|
|
48
|
+
[tool.coverage.run]
|
|
49
|
+
branch = true
|
|
50
|
+
source = ["src"]
|
|
51
|
+
omit = []
|
|
52
|
+
|
|
53
|
+
[tool.coverage.report]
|
|
54
|
+
fail_under = 90
|
|
55
|
+
show_missing = true
|
|
56
|
+
skip_covered = true
|
|
57
|
+
|
|
58
|
+
[tool.black]
|
|
59
|
+
target-version = ["py39"]
|
|
60
|
+
line-length = 100
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
|
|
2
|
+
# lr-serial
|
|
3
|
+
|
|
4
|
+
CLI + Python client for interacting with the LumenRadio Serial Number Generation Service.
|
|
5
|
+
|
|
6
|
+
## Install
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
pip install lr-serial
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## CLI Usage
|
|
13
|
+
|
|
14
|
+
### Login Command
|
|
15
|
+
|
|
16
|
+
The `login` command supports two authentication modes:
|
|
17
|
+
|
|
18
|
+
#### User login (default)
|
|
19
|
+
|
|
20
|
+
Opens the system browser for interactive sign-in via OAuth 2.0 Authorization Code + PKCE.
|
|
21
|
+
No client secret required — suitable for human operators.
|
|
22
|
+
|
|
23
|
+
LumenRadio employees can log in with no arguments (client ID and tenant ID are baked in):
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
serial login
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
If the browser does not open automatically the auth URL is printed to the terminal so you
|
|
30
|
+
can paste it manually.
|
|
31
|
+
|
|
32
|
+
#### Machine-to-machine (M2M) login
|
|
33
|
+
|
|
34
|
+
Uses the OAuth 2.0 client credentials grant — suitable for automated pipelines.
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
serial login --mode m2m \
|
|
38
|
+
--client-id <CLIENT_ID> \
|
|
39
|
+
--client-secret <CLIENT_SECRET> \
|
|
40
|
+
--tenant-id <TENANT_ID>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
#### Common options
|
|
44
|
+
|
|
45
|
+
- `--mode [user|m2m]` — authentication mode (default: `user`) [env: SERIAL_AUTH_MODE]
|
|
46
|
+
- `--client-id` — Azure AD application client ID [env: SERIAL_CLIENT_ID]
|
|
47
|
+
- `--client-secret` — client secret, required for `m2m` [env: SERIAL_CLIENT_SECRET]
|
|
48
|
+
- `--tenant-id` — Azure AD tenant ID [env: SERIAL_TENANT_ID]
|
|
49
|
+
- `--token-url` — token endpoint URL override (m2m only) [env: SERIAL_TOKEN_URL]
|
|
50
|
+
- `--scope` — OAuth2 scope override [env: SERIAL_SCOPE]
|
|
51
|
+
- `--config-path` — override the login.json location
|
|
52
|
+
|
|
53
|
+
Stores the bearer token (and refresh token for user logins) in your config directory for
|
|
54
|
+
subsequent CLI commands.
|
|
55
|
+
|
|
56
|
+
### Status Command
|
|
57
|
+
|
|
58
|
+
Check backend reachability and token validity:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
serial status
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Reports:
|
|
65
|
+
- Backend reachable ✓ / unreachable ✗
|
|
66
|
+
- Token valid ✓ / invalid ✗
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## Global Options
|
|
71
|
+
|
|
72
|
+
Most commands support:
|
|
73
|
+
- `--output [rich|json]` — output format (rich table default, json for scripting)
|
|
74
|
+
- `--config-path PATH` — override the login.json location
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## Article Commands
|
|
79
|
+
|
|
80
|
+
### List Articles
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
serial list-articles
|
|
84
|
+
serial list-articles --output json
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Get Article
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
serial article get ARTICLE_NO
|
|
91
|
+
serial article get 710-4130 --output json
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Returns full article details: article number, description, prefix, schema (version, fields, format, regexp), disabled flag.
|
|
95
|
+
|
|
96
|
+
### Create Article
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
serial article create \
|
|
100
|
+
--article PROD-01 \
|
|
101
|
+
--description "Production line 1" \
|
|
102
|
+
--prefix PROD \
|
|
103
|
+
--schema-file schema.json
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
The `--schema-file` must be a JSON file with the ArticleSchema object:
|
|
107
|
+
|
|
108
|
+
```json
|
|
109
|
+
{
|
|
110
|
+
"version": 1,
|
|
111
|
+
"fields": { "site": "string" },
|
|
112
|
+
"format": "{prefix}-{site}-{counter:06d}",
|
|
113
|
+
"regexp": "^[A-Z0-9]+-[A-Z0-9]+-[0-9]{6}$"
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Options:
|
|
118
|
+
- `--article TEXT` — article number (1-32 chars, [A-Za-z0-9-]) [required]
|
|
119
|
+
- `--description TEXT` — human-readable description (1-100 chars) [required]
|
|
120
|
+
- `--prefix TEXT` — serial prefix (1-10 chars, [A-Za-z0-9]) [required]
|
|
121
|
+
- `--schema-file PATH` — path to JSON file containing the ArticleSchema [required]
|
|
122
|
+
- `--disabled / --no-disabled` — create as disabled (default: enabled)
|
|
123
|
+
|
|
124
|
+
### Update Article
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
serial article update ARTICLE_NO --description "New description"
|
|
128
|
+
serial article update ARTICLE_NO --prefix NEWP --disabled
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
At least one option must be provided. Options: `--description`, `--prefix`, `--disabled/--no-disabled`, `--schema-file`.
|
|
132
|
+
|
|
133
|
+
### Delete Article
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
serial article delete ARTICLE_NO
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Idempotent — succeeds even if the article does not exist.
|
|
140
|
+
|
|
141
|
+
### Set Sequence Counter
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
serial article set-sequence ARTICLE_NO SEQUENCE_NO
|
|
145
|
+
serial article set-sequence 710-4130 1000
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
Sets the current counter value (integer ≥ 0) for the article.
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## Serial Number Commands
|
|
153
|
+
|
|
154
|
+
### Generate Serial Numbers
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
serial generate ARTICLE_NO
|
|
158
|
+
serial generate ARTICLE_NO --quantity 5
|
|
159
|
+
serial generate ARTICLE_NO --field site=Stockholm --field year=2024
|
|
160
|
+
serial generate ARTICLE_NO --quantity 3 --output json
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
Options:
|
|
164
|
+
- `--quantity INT` — number of serials to generate (1-1000, default 1)
|
|
165
|
+
- `--field KEY=VALUE` — extra field value consumed by the article schema (repeatable)
|
|
166
|
+
|
|
167
|
+
### Lookup a Serial Number
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
serial lookup SERIAL_NO
|
|
171
|
+
serial lookup QWDNA010000001 --output json
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Returns: serial value, article, created_by, created_at.
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## Site Commands
|
|
179
|
+
|
|
180
|
+
### List Sites
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
serial site list
|
|
184
|
+
serial site list --output json
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### Create Site
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
serial site create --site-no 5 --name "Helsinki"
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
Options:
|
|
194
|
+
- `--site-no INT` — site number (1-99) [required]
|
|
195
|
+
- `--name TEXT` — site name [required]
|
|
196
|
+
|
|
197
|
+
### Update Site
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
serial site update 5 --name "Helsinki" --contact-email ops@example.com
|
|
201
|
+
serial site update 5 --name "Helsinki" --disabled
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
Note: `--name` is required by the API even when only updating other fields.
|
|
205
|
+
|
|
206
|
+
Options:
|
|
207
|
+
- `--name TEXT` — new site name [required]
|
|
208
|
+
- `--client-id TEXT` — associated client ID (or empty to clear)
|
|
209
|
+
- `--contact-email TEXT` — contact email address (or empty to clear)
|
|
210
|
+
- `--disabled / --no-disabled` — enable or disable the site
|
|
211
|
+
|
|
212
|
+
### Delete Site
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
serial site delete 5
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
Idempotent — succeeds even if the site does not exist.
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
## Audit Commands
|
|
223
|
+
|
|
224
|
+
These commands require the `app.admin.api` scope.
|
|
225
|
+
|
|
226
|
+
### List Audit Entries
|
|
227
|
+
|
|
228
|
+
```bash
|
|
229
|
+
serial audit list
|
|
230
|
+
serial audit list --limit 50 --output json
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
Returns audit entries newest-first: id, touched_table, touched_key, change_type (create/update/delete), changed_by, changed_at.
|
|
234
|
+
|
|
235
|
+
Options:
|
|
236
|
+
- `--limit INT` — max entries to return (1-500, default 100)
|
|
237
|
+
|
|
238
|
+
### Restore an Audit Entry
|
|
239
|
+
|
|
240
|
+
```bash
|
|
241
|
+
serial audit restore AUDIT_ID
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
Undoes the audited change:
|
|
245
|
+
- `create` → deletes the created row
|
|
246
|
+
- `update` → restores previous values
|
|
247
|
+
- `delete` → re-inserts the deleted row
|
|
248
|
+
|
|
249
|
+
If the token lacks the admin scope, the API returns 403 and the CLI will display:
|
|
250
|
+
`Access denied. Ensure your credentials include the admin scope (app.admin.api).`
|