Skip to content

Commit ef31ae5

Browse files
committed
Merge branch 'release/0.7.0'
2 parents 7a416aa + 64d23ca commit ef31ae5

10 files changed

Lines changed: 601 additions & 12 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package s10k.tool.common.util;
2+
3+
import static org.springframework.util.StreamUtils.nonClosing;
4+
import static s10k.tool.common.util.SystemUtils.systemConsoleIsTerminal;
5+
6+
import java.io.IOException;
7+
8+
import com.fasterxml.jackson.databind.ObjectMapper;
9+
10+
/**
11+
* Output helper methods.
12+
*/
13+
public final class OutputUtils {
14+
15+
private OutputUtils() {
16+
// not available
17+
}
18+
19+
/**
20+
* Write a single object as JSON to standard out.
21+
*
22+
* @param objectMapper the object mapper to use
23+
* @param result the object to write
24+
* @throws IOException if any IO error occurs
25+
*/
26+
public static void writeJsonObject(ObjectMapper objectMapper, Object result) throws IOException {
27+
(systemConsoleIsTerminal() ? objectMapper.writerWithDefaultPrettyPrinter() : objectMapper.writer())
28+
.writeValue(nonClosing(System.out), result);
29+
if (systemConsoleIsTerminal()) {
30+
System.out.println();
31+
}
32+
}
33+
}

docs/docs/commands/datum/list.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ s10k datum list [-S] [-stream=streamId[,streamId...]]...
4646
| `-min=` | `--min-date=` | a minimum date to limit results to, like `2020-10-30` or `2020-10-30T12:45` |
4747
| `-max=` | `--max-date=` | a maximum date (exclusive) to limit results to, in same form as `-min` |
4848
| `-local` | `--local-dates` | treat the min/max dates as "node local" dates, instead of UTC (or the local time zone when `-tz` used) |
49-
| `-tz=` | `--time-zone=` | a time zone ID to treat the min/max dates as, instead of the local time zone, like `Pacific/Auckland` or `-05:00` or `UTC` |
49+
| `-tz=` | `--time-zone=` | a time zone ID to treat the min/max dates as instead of the local time zone, like `Pacific/Auckland` or `-05:00` or `UTC` |
5050
| `-recent` | `--most-recent` | show just the most recently available data, within min/max dates if specified |
5151
| `-agg=` | `--aggregation=` | the [aggregation type][aggregation] to return |
5252
| `-pagg=` | `--partial-aggregation=` | a [partial aggregation][partial-aggregation] level to use |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
title: sec-tokens
Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
---
2+
title: create
3+
---
4+
# Sec-Tokens Create
5+
6+
Create a new security token.
7+
8+
## Usage
9+
10+
```
11+
s10k sec-tokens create [-r] -t=<tokenType> [-n=<name>]
12+
[-D=<description>] [-node=nodeId[,nodeId...]]...
13+
[-source=sourceId[,sourceId...]]...
14+
[-N=metaPath[,metaPath...]]...
15+
[-U=metaPath[,metaPath...]]...
16+
[-A=path[,path...]]...
17+
[-exp=<expirationDate>] [-tz=<zone>]
18+
[-mode=<displayMode>]
19+
[-agg=aggregation |
20+
--aggregation=aggregation[,aggregation...]...]
21+
[-loc=precision |
22+
--location-precision=precision[,precision...]...]
23+
```
24+
25+
## Options
26+
27+
<div markdown="1" class="options-explicit-col-widths">
28+
29+
| Option | Long Version | Description |
30+
|:-------|:-------------|:------------|
31+
| `-A=` | `--api-path=` | an API path(s) to restrict access to ([wildcard patterns][wildcard-pats] allowed) |
32+
| `-agg=` | `--min-aggregation=` | a minimum [aggregation][aggregation] to restrict access to |
33+
| | `--aggregation=` | an [aggregation][aggregation] to restrict access to |
34+
| `-D=` | `--description=` | a description for the token |
35+
| `-exp=` | `--expiration-date=` | an expiration date for the token,like `2020-10-30` or `2020-10-30T12:45` |
36+
| `-loc=` | `--min-location-precision=` | a minimum location precision to restrict access to |
37+
| | `--location-precision=` | a location precision to restrict access to |
38+
| `-n=` | `--name=` | a brief name for the token |
39+
| `-N=` | `--node-metadata-path=` | node [metadata paths][metadata-paths] to restrict access to ([wildcard patterns][wildcard-pats] allowed) |
40+
| `-node=` | `--node-id=` | node ID(s) to restrict access to |
41+
| `-r` | `--refresh-allowed` | allow signing keys for the token to be refreshed |
42+
| `-source=` | `--source-id=` | source ID(s) to restrict access to |
43+
| `-t=` | `--type=` | the type of token to create, one of `ReadNodeData` or `User` |
44+
| `-tz=` | `--time-zone=` | a time zone ID to treat expiration date as instead of the local time zone, like `Pacific/Auckland` or `-05:00` or `UTC` |
45+
| `-U=` | `--user-metadata-path=` | user [metadata paths][metadata-paths] to restrict access to ([wildcard patterns][wildcard-pats] allowed) |
46+
| `-mode=` | `--display-mode=` | the format to display the data as, one of `CSV`, `JSON`, or `PRETTY`; defaults to `PRETTY` |
47+
48+
49+
</div>
50+
51+
## Output
52+
53+
The new security token, with its associated secret.
54+
55+
!!! warning
56+
57+
You must copy the **token secret** to a safe place, as SolarNetwork will not show you its value
58+
ever again.
59+
60+
## Examples
61+
62+
Create a basic `ReadNodeData` token with no policy restrictions:
63+
64+
=== "Create basic token"
65+
66+
```sh
67+
s10k sec-tokens create --type ReadNodeData
68+
```
69+
70+
=== "Pretty Output"
71+
72+
```
73+
+----------------------+---------------------------+--------------------------------+---------+--------------+------+-------------+--------+
74+
| Token ID | Token Secret | Created | User ID | Type | Name | Description | Policy |
75+
+----------------------+---------------------------+--------------------------------+---------+--------------+------+-------------+--------+
76+
| ZCv5FUjlTlIQGjigLhSW | i.3R5qMQ-4sKg8uUV0XoxBY5y | 2025-09-29T03:51:32.388051375Z | 123 | ReadNodeData | | | |
77+
+----------------------+---------------------------+--------------------------------+---------+--------------+------+-------------+--------+
78+
```
79+
80+
=== "CSV Output"
81+
82+
```csv
83+
Token ID,Token Secret,Created,User ID,Type,Name,Description,Policy
84+
Lqc8Z_KzpD8.L0_em0Au,QlmQCrZaemdXmUNISggGF7ed,2025-09-29T03:52:13.248686631Z,123,ReadNodeData,,,
85+
```
86+
87+
=== "JSON Output"
88+
89+
```json
90+
{
91+
"id" : "WoRxAChcFZ.x7s2zT5Y6",
92+
"authSecret" : "zcqVddxS0YTr6rzAtSA.Wq.x0tRzZL",
93+
"created" : "2025-09-29 04:13:52.673034405Z",
94+
"userId" : 123,
95+
"status" : "Active",
96+
"type" : "ReadNodeData",
97+
"expired" : false
98+
}
99+
```
100+
101+
Create a `User` token with a name, description, and various policy restrictions:
102+
103+
=== "Create token with policy"
104+
105+
```sh
106+
s10k sec-tokens create --type User --name 'Reporting: region 1' \
107+
--description 'Allow access to region 1 for reporting team.' \
108+
--node-id 100,101 --source-id '/REGION1/**' \
109+
--min-aggregation Hour \
110+
--refresh-allowed
111+
```
112+
113+
=== "Pretty Output"
114+
115+
```
116+
+----------------------+----------------------------+--------------------------------+---------+------+---------------------+----------------------------------------------+------------------------------------+
117+
| Token ID | Token Secret | Created | User ID | Type | Name | Description | Policy |
118+
+----------------------+----------------------------+--------------------------------+---------+------+---------------------+----------------------------------------------+------------------------------------+
119+
| kF67p6g30eUXQICUgzQf | PDX3VpOKmrc58HOOqUOv3HTmv0 | 2025-09-29T04:23:20.302916611Z | 123 | User | Reporting: region 1 | Allow access to region 1 for reporting team. | { |
120+
| | | | | | | | "nodeIds" : [ 100, 101 ], |
121+
| | | | | | | | "sourceIds" : [ "/REGION1/**" ], |
122+
| | | | | | | | "minAggregation" : "Hour", |
123+
| | | | | | | | "refreshAllowed" : true |
124+
| | | | | | | | } |
125+
+----------------------+----------------------------+--------------------------------+---------+------+---------------------+----------------------------------------------+------------------------------------+
126+
```
127+
128+
=== "CSV Output"
129+
130+
```csv
131+
Token ID,Token Secret,Created,User ID,Type,Name,Description,Policy
132+
vWLOCdFTaB8IeF6__bl5,HQyeON_XND0YgkYlMHGz.7qPoYlP,2025-09-29T04:25:03.335116516Z,123,User,Reporting: region 1,Allow access to region 1 for reporting team.,"{
133+
""nodeIds"" : [ 100, 101 ],
134+
""sourceIds"" : [ ""/REGION1/**"" ],
135+
""minAggregation"" : ""Hour"",
136+
""refreshAllowed"" : true
137+
}"
138+
```
139+
140+
=== "JSON Output"
141+
142+
```json
143+
{
144+
"id" : "0a.vDUsIQFDM.pOShkqf",
145+
"authSecret" : "mvBMxQukn1TsvmyjxQb6lWEZyebUWp",
146+
"created" : "2025-09-29 04:25:43.884356539Z",
147+
"userId" : 123,
148+
"name" : "Reporting: region 1",
149+
"description" : "Allow access to region 1 for reporting team.",
150+
"status" : "Active",
151+
"type" : "User",
152+
"expired" : false,
153+
"policy" : {
154+
"nodeIds" : [ 100, 101 ],
155+
"sourceIds" : [ "/REGION1/**" ],
156+
"minAggregation" : "Hour",
157+
"refreshAllowed" : true
158+
}
159+
}
160+
```
161+
162+
163+
[aggregation]: https://github.com/SolarNetwork/solarnetwork/wiki/SolarQuery-API-enumerated-types#aggregation-types
164+
[metadata-paths]: https://github.com/SolarNetwork/solarnetwork/wiki/SolarNet-API-global-objects#metadata-filter-key-paths
165+
[wildcard-pats]: https://github.com/SolarNetwork/solarnetwork/wiki/SolarNet-API-global-objects#wildcard-patterns
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
title: delete
3+
---
4+
# Sec-Tokens Delete
5+
6+
Delete a security token.
7+
8+
## Usage
9+
10+
```
11+
s10k sec-tokens delete -id=tokenId
12+
```
13+
14+
## Options
15+
16+
<div markdown="1" class="options-explicit-col-widths">
17+
18+
| Option | Long Version | Description |
19+
|:-------|:-------------|:------------|
20+
| `-id=` | `--identifier=` | the token ID to delete |
21+
22+
</div>
23+
24+
## Output
25+
26+
A success message.
27+
28+
## Examples
29+
30+
=== "Delete token"
31+
32+
```sh
33+
s10k sec-tokens delete --identifier ZCv5FUjlTlIQGjigLhSW
34+
```
35+
36+
=== "Output"
37+
38+
```
39+
Security token deleted.
40+
```
41+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Sec-Tokens Commands
2+
3+
The `sec-tokens` group of commands deal with SolarNetwork security token related actions.
4+
5+
!!! note
6+
7+
All `sec-tokens` commands require a **User** security token to operate.
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
---
2+
title: list
3+
---
4+
# Sec-Tokens List
5+
6+
List security tokens matching a search filter.
7+
8+
## Usage
9+
10+
```
11+
s10k sec-tokens list [-id=tokenId[,tokenId...]]... [-t=<tokenType>]
12+
[-mode=<displayMode>] [-a | -d]
13+
```
14+
15+
## Options
16+
17+
<div markdown="1" class="options-explicit-col-widths">
18+
19+
| Option | Long Version | Description |
20+
|:-------|:-------------|:------------|
21+
| `-a` | `--active` | show only active tokens |
22+
| `-d` | `--disabled` | show only disabled tokens |
23+
| `-id=` | `--identifier=` | the ID(s) of the tokens to show |
24+
| `-t=` | `--type=` | the type of token to show, one of `ReadNodeData` or `User` |
25+
| `-mode=` | `--display-mode=` | the format to display the data as, one of `CSV`, `JSON`, or `PRETTY`; defaults to `PRETTY` |
26+
27+
</div>
28+
29+
## Output
30+
31+
A listing of security tokens matching the search criteria.
32+
33+
## Examples
34+
35+
List all `ReadNodeData` tokens:
36+
37+
=== "List `ReadNodeData` tokens"
38+
39+
```sh
40+
s10k sec-tokens list --type ReadNodeData
41+
```
42+
43+
=== "Pretty Output"
44+
45+
```
46+
+----------------------+-----------------------------+---------+--------------+----------+----------------+-------------------------------------+------------------------------------------------------+
47+
| Token ID | Created | User ID | Type | Status | Name | Description | Policy |
48+
+----------------------+-----------------------------+---------+--------------+----------+----------------+-------------------------------------+------------------------------------------------------+
49+
| Lqc8Z_KzpD8.L0_em0Au | 2025-09-29T03:52:13.248687Z | 123 | ReadNodeData | Active | | | |
50+
+----------------------+-----------------------------+---------+--------------+----------+----------------+-------------------------------------+------------------------------------------------------+
51+
| zLgbyhRvcMhQ83QRFJqh | 2025-09-29T04:05:46.562370Z | 123 | ReadNodeData | Disabled | Student access | Allow access to school system data. | { |
52+
| | | | | | | | "nodeIds" : [ 100, 101 ], |
53+
| | | | | | | | "sourceIds" : [ "mock/**", "test/**" ], |
54+
| | | | | | | | "minAggregation" : "Hour", |
55+
| | | | | | | | "minLocationPrecision" : "PostalCode", |
56+
| | | | | | | | "nodeMetadataPaths" : [ "/pm/test/**" ], |
57+
| | | | | | | | "userMetadataPaths" : [ "/pm/account/public/**" ], |
58+
| | | | | | | | "notAfter" : 1759143600000, |
59+
| | | | | | | | "refreshAllowed" : true |
60+
| | | | | | | | } |
61+
+----------------------+-----------------------------+---------+--------------+----------+----------------+-------------------------------------+------------------------------------------------------+
62+
```
63+
64+
=== "CSV Output"
65+
66+
```csv
67+
Token ID,Created,User ID,Type,Status,Name,Description,Policy
68+
Lqc8Z_KzpD8.L0_em0Au,2025-09-29T03:52:13.248687Z,123,ReadNodeData,Active,,,
69+
zLgbyhRvcMhQ83QRFJqh,2025-09-29T04:05:46.562370Z,123,ReadNodeData,Disabled,Student access,Allow access to school system data.,"{
70+
""nodeIds"" : [ 100, 101 ],
71+
""sourceIds"" : [ ""mock/**"", ""test/**"" ],
72+
""minAggregation"" : ""Hour"",
73+
""minLocationPrecision"" : ""PostalCode"",
74+
""nodeMetadataPaths"" : [ ""/pm/test/**"" ],
75+
""userMetadataPaths"" : [ ""/pm/account/public/**"" ],
76+
""notAfter"" : 1759143600000,
77+
""refreshAllowed"" : true
78+
}"
79+
```
80+
81+
=== "JSON Output"
82+
83+
```json
84+
[
85+
{
86+
"id" : "Lqc8Z_KzpD8.L0_em0Au",
87+
"created" : "2025-09-29 03:52:13.248687Z",
88+
"userId" : 123,
89+
"status" : "Active",
90+
"type" : "ReadNodeData",
91+
"expired" : false
92+
},
93+
{
94+
"id" : "zLgbyhRvcMhQ83QRFJqh",
95+
"created" : "2025-09-29 04:05:46.56237Z",
96+
"userId" : 123,
97+
"name" : "Student access",
98+
"description" : "Allow access to school system data.",
99+
"status" : "Disabled",
100+
"type" : "ReadNodeData",
101+
"expired" : false,
102+
"policy" : {
103+
"nodeIds" : [ 100, 101 ],
104+
"sourceIds" : [ "mock/**", "test/**" ],
105+
"minAggregation" : "Hour",
106+
"minLocationPrecision" : "PostalCode",
107+
"nodeMetadataPaths" : [ "/pm/test/**" ],
108+
"userMetadataPaths" : [ "/pm/account/public/**" ],
109+
"notAfter" : 1759143600000,
110+
"refreshAllowed" : true
111+
}
112+
}
113+
]
114+
```

0 commit comments

Comments
 (0)