9
9
from pprint import pprint
10
10
from typing import AsyncIterator
11
11
12
+ from frequenz .client .base .authentication import AuthenticationOptions
13
+ from frequenz .client .base .channel import ChannelOptions
14
+ from frequenz .client .base .signing import SigningOptions
12
15
from frequenz .client .common .metric import Metric
13
16
14
17
from frequenz .client .reporting import ReportingApiClient
@@ -85,6 +88,12 @@ def main() -> None:
85
88
help = "API key" ,
86
89
default = None ,
87
90
)
91
+ parser .add_argument (
92
+ "--secret" ,
93
+ type = str ,
94
+ help = "The secret for the reporting service" ,
95
+ default = None ,
96
+ )
88
97
args = parser .parse_args ()
89
98
asyncio .run (
90
99
run (
@@ -99,6 +108,7 @@ def main() -> None:
99
108
service_address = args .url ,
100
109
key = args .key ,
101
110
fmt = args .format ,
111
+ secret = args .secret ,
102
112
)
103
113
)
104
114
@@ -116,6 +126,7 @@ async def run( # noqa: DOC502
116
126
bounds : bool ,
117
127
service_address : str ,
118
128
key : str ,
129
+ secret : str ,
119
130
fmt : str ,
120
131
) -> None :
121
132
"""Test the ReportingApiClient.
@@ -130,13 +141,19 @@ async def run( # noqa: DOC502
130
141
states: include states in the output
131
142
bounds: include bounds in the output
132
143
service_address: service address
133
- key: API key
144
+ key: API key (per customer)
145
+ secret: cryptographic secret of the service (per API)
134
146
fmt: output format
135
147
136
148
Raises:
137
149
ValueError: if output format is invalid
138
150
"""
139
- client = ReportingApiClient (service_address , key )
151
+ auth = AuthenticationOptions (key )
152
+ sign = SigningOptions (secret )
153
+
154
+ channel_options = ChannelOptions (auth = auth , sign = sign )
155
+
156
+ client = ReportingApiClient (service_address , key , channel_defaults = channel_options )
140
157
141
158
metrics = [Metric [mn ] for mn in metric_names ]
142
159
0 commit comments