Skip to content

Commit

Permalink
Add pagination
Browse files Browse the repository at this point in the history
This commit introduces pagination to the ´GetHistoricalWeatherForecast´ RPC.
It uses the ´PaginationInfo´ and ´PaginationParams´ from the
frequenz-api-common repository.

Signed-off-by: TalweSingh <[email protected]>
  • Loading branch information
TalweSingh committed Nov 21, 2023
1 parent 0b9cd16 commit c163e41
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions proto/frequenz/api/weather/weather.proto
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ syntax = "proto3";

package frequenz.api.weatherforecast.v1;

import "frequenz/api/common/location.proto";
import "frequenz/api/common/v1/location.proto";
import "frequenz/api/common/v1/pagination/pagination_info.proto";
import "frequenz/api/common/v1/pagination/pagination_params.proto";
import "google/protobuf/timestamp.proto";


Expand Down Expand Up @@ -74,9 +76,9 @@ enum ForecastFeature {
// and time period, with designated features.
message GetHistoricalWeatherForecastRequest {
// The locations for which the forecast is being requested.
// The maximum number of locations that can be requested is 50. If the
// he maximum number of locations that can be requested is 50. If the
// request exceeds this limit, the API will respond with an error.
repeated frequenz.api.common.location.Location locations = 1;
repeated frequenz.api.common.v1.location.Location locations = 1;

// List of required features. If none are specified, all available features
// will be returned.
Expand All @@ -90,9 +92,10 @@ message GetHistoricalWeatherForecastRequest {
// period.
google.protobuf.Timestamp end_ts = 4;

// Specifies the maximum number of forecasts to be returned in a single
// response.
int32 page_size = 5;
// The parameters define the 'page_size' and the 'page_token'. An inital
// query of a request will omit the 'page_token'. Subsequent queries of the
// same request must include the 'page_token' from the previous response.
optional PaginationParams pagination_params = 5;
}

// The `ReceiveLiveWeatherForecastRequest` message defines parameters for
Expand All @@ -102,7 +105,7 @@ message ReceiveLiveWeatherForecastRequest {
// The locations for which the forecast is being requested.
// The maximum number of locations that can be requested is 50. If the
// request exceeds this limit, the API will respond with an error.
repeated frequenz.api.common.location.Location locations = 1;
repeated frequenz.api.common.v1.location.Location locations = 1;

// List of required features. If none are specified, all available features
// will be streamed.
Expand Down Expand Up @@ -138,7 +141,7 @@ message LocationForecast {
repeated Forecasts forecasts = 1;

// The location for which the weather data is returned.
frequenz.api.common.location.Location location = 2;
frequenz.api.common.v1.location.Location location = 2;

// The UTC timestamp indicating when the forecast was originally created.
google.protobuf.Timestamp creation_ts = 3;
Expand All @@ -148,6 +151,11 @@ message LocationForecast {
// corresponding to a requested location.
message GetHistoricalWeatherForecastResponse {
repeated LocationForecast location_forecasts = 1;

// The pagination_info contains the number of 'total_items' in the response
// and the 'next_page_token' for the subsequent query of the request. It is
// omitted in the last response.
optional PaginationInfo pagination_info = 2;
}

// The message encapsulates a collection of live weather forecasts, each
Expand Down

0 comments on commit c163e41

Please sign in to comment.