Minor updates to proto definitions for location enum and oneof

This commit is contained in:
Andrew Scott 2022-09-01 02:05:33 -04:00
parent 6adee3e31b
commit bcbe199848
Signed by: a
GPG key ID: 3EB62D0BBB8DB381
3 changed files with 27 additions and 31 deletions

View file

@ -4,32 +4,38 @@ package weather;
option go_package = "codeberg.org/andcscott/OpenWeatherMap-gRPC-API/proto";
// Sub-message used by Current & Extended for exact coordinates
// Sub-message for exact coordinates
message Coordinates {
float latitude = 1;
float longitude = 2;
}
// Used by Location, Current, and Extended to help the API find info for the
// correct location. If unspecified, an attept is still made but results may
// be inaccurate
// Sub-message to specify location
message OneOfLocation {
oneof location_id {
string city = 1;
string zip_code = 2;
Coordinates coords = 3;
}
}
// Used to help the API find info for the correct location. If unspecified, an
// attept is still made but results may be inaccurate.
enum LocationType {
LOCATION_TYPE_UNSPECIFIED = 0;
LOCATION_CITY = 1;
LOCATION_ZIP = 2;
LOCATION_COORDS = 3;
LOCATION_TYPE_CITY = 1;
LOCATION_TYPE_ZIP_CODE = 2;
LOCATION_TYPE_COORDS = 3;
}
/* Get the latitude and longitude for a given location
* Commented parameters in the message definition are not implemeneted yet
* location_type {enum} - name or value
* city {string} - case insensitive, spaces and punctuation allowed
* zip_code {string} - non-numeric values permitted
* location_type {LocationType} - name or value of the desired LocationType enum
* location {OneOfLocation} - city name, zip code, or coordinates
*/
message RequestLocation {
LocationType location_type = 1;
optional string city = 2;
optional string zip_code = 3;
OneOfLocation location = 2;
}
// Response to RequestLocation

View file

@ -9,6 +9,6 @@ import "location.proto";
service WeatherService {
rpc Current(RequestCurrent) returns (SendCurrent);
rpc Extended(RequestFiveDay) returns (SendFiveDay);
rpc FiveDay(RequestFiveDay) returns (SendFiveDay);
rpc Location(RequestLocation) returns (SendLocation);
}

View file

@ -15,19 +15,14 @@ enum Units {
}
/* Get the current forecast for a given location
* Commented parameters in the message definition are not implemeneted yet
* location_type {enum} - name or value
* units {enum} - name or value
* city {string} - case insensitive, spaces and punctuation allowed
* zip_code {string} - non-numeric values permitted
* coordinates {Coordinates} - Coordinates message with latitude and longitude
* location_type {LocationType} - name or value of the desired LocationType enum
* units {Units} - name or value of the desired Units enum
* location {OneOfLocation} - city name, zip code, or coordinates
*/
message RequestCurrent {
LocationType location_type = 1;
Units units = 2;
optional string city = 3;
optional string zip_code = 4;
optional Coordinates coordinates = 5;
OneOfLocation location = 3;
}
// Response to RequestCurrent
@ -36,19 +31,14 @@ message SendCurrent {
}
/* Get the extended forecast for a given location up to 16 days in the future
* Commented parameters in the message definition are not implemeneted yet
* location_type {enum} - name or value
* units {enum} - name or value
* city {string} - case insensitive, spaces and punctuation allowed
* zip_code {string} - non-numeric values permitted
* coordinates {Coordinates} - Coordinates message with latitude and longitude
* location_type {LocationType} - name or value of the desired LocationType enum
* units {Units} - name or value of the desired Units enum
* location {OneOfLocation} - city name, zip code, or coordinates
*/
message RequestFiveDay {
LocationType location_type = 1;
Units units = 2;
optional string city = 3;
optional string zip_code = 4;
optional Coordinates coordinates = 5;
OneOfLocation location = 3;
}
// Response to RequestExtended