2424from frequenz .api .reporting .v1 .reporting_pb2 import (
2525 ListMicrogridComponentsDataResponse as PBListMicrogridComponentsDataResponse ,
2626)
27+ from frequenz .api .reporting .v1 .reporting_pb2 import (
28+ ResamplingOptions as PBResamplingOptions ,
29+ )
2730from frequenz .api .reporting .v1 .reporting_pb2 import TimeFilter as PBTimeFilter
2831from frequenz .api .reporting .v1 .reporting_pb2_grpc import ReportingStub
2932from frequenz .client .common .metric import Metric
@@ -130,6 +133,7 @@ async def list_single_component_data(
130133 metrics : Metric | list [Metric ],
131134 start_dt : datetime ,
132135 end_dt : datetime ,
136+ resolution : int | None ,
133137 page_size : int = 1000 ,
134138 ) -> AsyncIterator [MetricSample ]:
135139 """Iterate over the data for a single metric.
@@ -140,6 +144,7 @@ async def list_single_component_data(
140144 metrics: The metric name or list of metric names.
141145 start_dt: The start date and time.
142146 end_dt: The end date and time.
147+ resolution: The resampling resolution for the data, represented in seconds.
143148 page_size: The page size.
144149
145150 Yields:
@@ -152,6 +157,7 @@ async def list_single_component_data(
152157 metrics = [metrics ] if isinstance (metrics , Metric ) else metrics ,
153158 start_dt = start_dt ,
154159 end_dt = end_dt ,
160+ resolution = resolution ,
155161 page_size = page_size ,
156162 ):
157163 for entry in page :
@@ -165,6 +171,7 @@ async def list_microgrid_components_data(
165171 metrics : Metric | list [Metric ],
166172 start_dt : datetime ,
167173 end_dt : datetime ,
174+ resolution : int | None ,
168175 page_size : int = 1000 ,
169176 ) -> AsyncIterator [MetricSample ]:
170177 """Iterate over the data for multiple microgrids and components.
@@ -175,6 +182,7 @@ async def list_microgrid_components_data(
175182 metrics: The metric name or list of metric names.
176183 start_dt: The start date and time.
177184 end_dt: The end date and time.
185+ resolution: The resampling resolution for the data, represented in seconds.
178186 page_size: The page size.
179187
180188 Yields:
@@ -190,6 +198,7 @@ async def list_microgrid_components_data(
190198 metrics = [metrics ] if isinstance (metrics , Metric ) else metrics ,
191199 start_dt = start_dt ,
192200 end_dt = end_dt ,
201+ resolution = resolution ,
193202 page_size = page_size ,
194203 ):
195204 for entry in page :
@@ -203,7 +212,8 @@ async def _list_microgrid_components_data_pages(
203212 metrics : list [Metric ],
204213 start_dt : datetime ,
205214 end_dt : datetime ,
206- page_size : int = 1000 ,
215+ resolution : int | None ,
216+ page_size : int ,
207217 ) -> AsyncIterator [ComponentsDataPage ]:
208218 """Iterate over the pages of microgrid components data.
209219
@@ -215,6 +225,7 @@ async def _list_microgrid_components_data_pages(
215225 metrics: A list of metrics.
216226 start_dt: The start date and time.
217227 end_dt: The end date and time.
228+ resolution: The resampling resolution for the data, represented in seconds.
218229 page_size: The page size.
219230
220231 Yields:
@@ -237,6 +248,7 @@ def dt2ts(dt: datetime) -> PBTimestamp:
237248
238249 list_filter = PBListMicrogridComponentsDataRequest .ListFilter (
239250 time_filter = time_filter ,
251+ resampling_options = PBResamplingOptions (resolution = resolution ),
240252 )
241253
242254 metrics_pb = [metric .to_proto () for metric in metrics ]
0 commit comments