leancpms-cli 0.1.4__tar.gz → 0.1.5__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: leancpms-cli
3
- Version: 0.1.4
3
+ Version: 0.1.5
4
4
  Summary: The cpms command alone: a client of a LeanCPMS instance's JSON API
5
5
  License-Expression: AGPL-3.0-or-later
6
6
  License-File: LICENSE
@@ -23,15 +23,15 @@ depends on httpx, pydantic and PyYAML only.
23
23
 
24
24
  ## Install
25
25
 
26
- With [uv](https://docs.astral.sh/uv/), from PyPI once it is published there:
26
+ With [uv](https://docs.astral.sh/uv/), from PyPI:
27
27
 
28
28
  ```bash
29
29
  uv tool install leancpms-cli
30
30
  cpms --help
31
31
  ```
32
32
 
33
- Until then, from a GitHub release (a tag `cli-v<version>`) or straight
34
- from the repository:
33
+ That needs no access to the repository. With access, also from a GitHub
34
+ release (a tag `cli-v<version>`) or straight from the repository:
35
35
 
36
36
  ```bash
37
37
  gh release download cli-v0.1.4 --repo forsslund/leancpms --pattern '*.whl'
@@ -40,8 +40,8 @@ uv tool install ./leancpms_cli-0.1.4-py3-none-any.whl
40
40
  uv tool install "git+https://github.com/forsslund/leancpms#subdirectory=cli"
41
41
  ```
42
42
 
43
- - The repository is private for now, so both need read access to it on
44
- GitHub; over SSH the URL is
43
+ - The repository is private for now, so these two need read access to it
44
+ on GitHub; over SSH the URL is
45
45
  `git+ssh://git@github.com/forsslund/leancpms#subdirectory=cli`.
46
46
  - It needs Python 3.14. uv downloads it if your machine lacks it.
47
47
  - To get a newer version, run `uv tool upgrade leancpms-cli`. To pin a
@@ -78,6 +78,8 @@ cpms logout # revokes the key on the server and removes the profile
78
78
  The key stops working when you are removed as a member, and so does
79
79
  every key you issued with it. Approve a code only if you just ran
80
80
  `cpms login` yourself: whoever started it gets the key.
81
+ [`docs/users-and-access.md`](../docs/users-and-access.md) explains members, roles and keys in full, with
82
+ several computers, a lost computer, and common tasks.
81
83
 
82
84
  ### Machine keys, for CI and agents
83
85
 
@@ -144,6 +146,12 @@ document that changed on the server since your plan; plan again. Removing
144
146
  anything needs `--prune`. `validate` needs no key, so CI can run it on
145
147
  every pull request; `plan` needs one.
146
148
 
149
+ An outlet's `public_id` is the id in its QR code (`/c/<public_id>`). Leave
150
+ it out and the server makes one up on first apply and keeps it. Once the
151
+ codes are printed, write the ids into the site file
152
+ (`- {connector: 1, key: s1-1, public_id: h7k2m9pq}`): a declared id applies,
153
+ also on a new server, and `plan` warns before an outlet's id changes.
154
+
147
155
  ## In your editor: the JSON Schema
148
156
 
149
157
  The documents have a JSON Schema, so an editor can complete field names
@@ -173,8 +181,9 @@ line, so add it again after an export.
173
181
  The schema checks types, required and unknown fields, allowed values,
174
182
  key spelling, and that amounts are quoted (`"4.70"`, not `4.70`). It does
175
183
  not check anything that spans several fields: a budget above the fuse,
176
- duplicate keys or ocpp ids, a plan naming a missing tariff, or an unknown
177
- time zone. `validate` and `plan` check those.
184
+ duplicate keys, ocpp ids or public ids, a plan naming a missing tariff, or
185
+ an unknown time zone. `validate` and `plan` check those. Only `plan`
186
+ knows whether another outlet on the server already has a public id.
178
187
 
179
188
  ## For agents
180
189
 
@@ -11,15 +11,15 @@ depends on httpx, pydantic and PyYAML only.
11
11
 
12
12
  ## Install
13
13
 
14
- With [uv](https://docs.astral.sh/uv/), from PyPI once it is published there:
14
+ With [uv](https://docs.astral.sh/uv/), from PyPI:
15
15
 
16
16
  ```bash
17
17
  uv tool install leancpms-cli
18
18
  cpms --help
19
19
  ```
20
20
 
21
- Until then, from a GitHub release (a tag `cli-v<version>`) or straight
22
- from the repository:
21
+ That needs no access to the repository. With access, also from a GitHub
22
+ release (a tag `cli-v<version>`) or straight from the repository:
23
23
 
24
24
  ```bash
25
25
  gh release download cli-v0.1.4 --repo forsslund/leancpms --pattern '*.whl'
@@ -28,8 +28,8 @@ uv tool install ./leancpms_cli-0.1.4-py3-none-any.whl
28
28
  uv tool install "git+https://github.com/forsslund/leancpms#subdirectory=cli"
29
29
  ```
30
30
 
31
- - The repository is private for now, so both need read access to it on
32
- GitHub; over SSH the URL is
31
+ - The repository is private for now, so these two need read access to it
32
+ on GitHub; over SSH the URL is
33
33
  `git+ssh://git@github.com/forsslund/leancpms#subdirectory=cli`.
34
34
  - It needs Python 3.14. uv downloads it if your machine lacks it.
35
35
  - To get a newer version, run `uv tool upgrade leancpms-cli`. To pin a
@@ -66,6 +66,8 @@ cpms logout # revokes the key on the server and removes the profile
66
66
  The key stops working when you are removed as a member, and so does
67
67
  every key you issued with it. Approve a code only if you just ran
68
68
  `cpms login` yourself: whoever started it gets the key.
69
+ [`docs/users-and-access.md`](../docs/users-and-access.md) explains members, roles and keys in full, with
70
+ several computers, a lost computer, and common tasks.
69
71
 
70
72
  ### Machine keys, for CI and agents
71
73
 
@@ -132,6 +134,12 @@ document that changed on the server since your plan; plan again. Removing
132
134
  anything needs `--prune`. `validate` needs no key, so CI can run it on
133
135
  every pull request; `plan` needs one.
134
136
 
137
+ An outlet's `public_id` is the id in its QR code (`/c/<public_id>`). Leave
138
+ it out and the server makes one up on first apply and keeps it. Once the
139
+ codes are printed, write the ids into the site file
140
+ (`- {connector: 1, key: s1-1, public_id: h7k2m9pq}`): a declared id applies,
141
+ also on a new server, and `plan` warns before an outlet's id changes.
142
+
135
143
  ## In your editor: the JSON Schema
136
144
 
137
145
  The documents have a JSON Schema, so an editor can complete field names
@@ -161,8 +169,9 @@ line, so add it again after an export.
161
169
  The schema checks types, required and unknown fields, allowed values,
162
170
  key spelling, and that amounts are quoted (`"4.70"`, not `4.70`). It does
163
171
  not check anything that spans several fields: a budget above the fuse,
164
- duplicate keys or ocpp ids, a plan naming a missing tariff, or an unknown
165
- time zone. `validate` and `plan` check those.
172
+ duplicate keys, ocpp ids or public ids, a plan naming a missing tariff, or
173
+ an unknown time zone. `validate` and `plan` check those. Only `plan`
174
+ knows whether another outlet on the server already has a public id.
166
175
 
167
176
  ## For agents
168
177
 
@@ -70,6 +70,12 @@ def _not_reserved(value: str) -> str:
70
70
 
71
71
 
72
72
  OrganizationKey = Annotated[Key, AfterValidator(_not_reserved)]
73
+
74
+ # An outlet's public id, the last part of its QR code's URL (/c/<public_id>). The server generates
75
+ # one from this alphabet (no 0, 1, i, l or o, which read alike) unless the site document declares it.
76
+ PUBLIC_ID_ALPHABET = "23456789abcdefghjkmnpqrstuvwxyz"
77
+ PUBLIC_ID_LENGTH = 8
78
+ PublicId = Annotated[str, StringConstraints(pattern=rf"^[{PUBLIC_ID_ALPHABET}]{{{PUBLIC_ID_LENGTH}}}$")]
73
79
  Rate = Annotated[Decimal, BeforeValidator(_no_float), Field(ge=0, le=1), _DECIMAL_TEXT]
74
80
 
75
81
 
@@ -344,6 +350,11 @@ class Outlet(Strict):
344
350
  plug: Literal["type2_socket", "type2_cable"] | None = None
345
351
  phases: Literal[1, 3] | None = None
346
352
  evse_id: Annotated[str, StringConstraints(max_length=48)] | None = None # overrides the derived eMI3 id
353
+ # The id in the printed QR code, a physical fact once printed. Left out, the server generates one
354
+ # on first apply and keeps it; declared, it applies, also over one generated before.
355
+ public_id: PublicId | None = Field(default=None, description=(
356
+ f"the id in the outlet's printed QR code (/c/<public_id>): {PUBLIC_ID_LENGTH} characters from "
357
+ f"{PUBLIC_ID_ALPHABET}; left out, the server generates one on first apply and keeps it"))
347
358
 
348
359
 
349
360
  class ChargePoint(Strict):
@@ -415,7 +426,9 @@ class Site(Strict):
415
426
  cps = [cp for fg in self.fuse_groups for cp in fg.charge_points]
416
427
  _unique(cps, "key", "charge point")
417
428
  _unique(cps, "ocpp_id", "ocpp_id")
418
- _unique([o for cp in cps for o in cp.outlets], "key", "outlet")
429
+ outlets = [o for cp in cps for o in cp.outlets]
430
+ _unique(outlets, "key", "outlet")
431
+ _unique([o for o in outlets if o.public_id], "public_id", "public_id")
419
432
  return self
420
433
 
421
434
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "leancpms-cli"
3
- version = "0.1.4"
3
+ version = "0.1.5"
4
4
  description = "The cpms command alone: a client of a LeanCPMS instance's JSON API"
5
5
  readme = "README.md"
6
6
  license = "AGPL-3.0-or-later"
File without changes
File without changes