From 0b2d84959245cdbcf7505e49dc906363bea8795e Mon Sep 17 00:00:00 2001 From: Andrew Scott Date: Wed, 27 Jul 2022 03:09:11 -0400 Subject: [PATCH 1/2] Update comments --- server/location.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/location.go b/server/location.go index ee7efb7..f5d6ea8 100644 --- a/server/location.go +++ b/server/location.go @@ -29,8 +29,8 @@ func (s *Server) Location(ctx context.Context, in *pb.RequestLocation) (*pb.Send } // Used internally to fetch precise locations -// Receives gRPC requests (interface) and the location (string) -// Returns the latitude (float32) and longitude (float32) for a given location +// Receives the city name and the server's API key +// Returns the latitude and longitude for the given location func getLocation(city string, key string) (float32, float32) { url := "http://api.openweathermap.org/geo/1.0/direct?q=" From 9126d0ff13989dd7ee9d1abd3125d54ed698baa9 Mon Sep 17 00:00:00 2001 From: Andrew Scott Date: Thu, 28 Jul 2022 01:27:11 -0400 Subject: [PATCH 2/2] Organize and document .proto files, no changes to request formats --- proto/current.proto | 21 -------------- proto/extended.proto | 22 -------------- proto/location.proto | 35 ++++++++++++++++------ proto/location_types.proto | 15 ---------- proto/service.proto | 3 +- proto/units.proto | 12 -------- proto/weather.proto | 59 ++++++++++++++++++++++++++++++++++++++ 7 files changed, 87 insertions(+), 80 deletions(-) delete mode 100644 proto/current.proto delete mode 100644 proto/extended.proto delete mode 100644 proto/location_types.proto delete mode 100644 proto/units.proto create mode 100644 proto/weather.proto diff --git a/proto/current.proto b/proto/current.proto deleted file mode 100644 index 560c122..0000000 --- a/proto/current.proto +++ /dev/null @@ -1,21 +0,0 @@ -syntax = "proto3"; - -package weather; - -option go_package = "codeberg.org/andcscott/OpenWeatherMap-gRPC-API/proto"; - -//import "location_types.proto"; -//import "units.proto" - -message RequestCurrent { - //LocationType location_type = 1; NOT IMPLEMENTED YET - //Units units = 2; NOT IMPLEMENTED YET - string city = 1; - // optional string zip_code = 2; NOT IMPLEMENTED YET - // optional string state = 2; // US Only / NOT IMPLEMENTED YET - // optional string country = 3; // Must be an ISO 3166 code / NOT IMPLEMENTED YET -} - -message SendCurrent { - string payload = 1; -} diff --git a/proto/extended.proto b/proto/extended.proto deleted file mode 100644 index 1005d2a..0000000 --- a/proto/extended.proto +++ /dev/null @@ -1,22 +0,0 @@ -syntax = "proto3"; - -package weather; - -option go_package = "codeberg.org/andcscott/OpenWeatherMap-gRPC-API/proto"; - -//import "location_types.proto"; -//import "units.proto" - -message RequestExtended { - //LocationType location_type = 1; NOT IMPLEMENTED YET - //Units units = 2; NOT IMPLEMENTED YET - string city = 1; - // optional string zip_code = 2; NOT IMPLEMENTED YET - // optional string state = 2; // US Only / NOT IMPLEMENTED YET - // optional string country = 3; // Must be ISO 3166 code / NOT IMPLEMENTED YET - uint32 days = 2; -} - -message SendExtended { - string payload = 1; -} diff --git a/proto/location.proto b/proto/location.proto index fa2cd8b..991d732 100644 --- a/proto/location.proto +++ b/proto/location.proto @@ -4,18 +4,37 @@ package weather; option go_package = "codeberg.org/andcscott/OpenWeatherMap-gRPC-API/proto"; -//import "location_types.proto"; //import "units.proto" -message RequestLocation { - //LocationType location_type = 1; NOT IMPLEMENTED YET - //Units units = 2; NOT IMPLEMENTED YET - string city = 1; - // optional string zip_code = 2; NOT IMPLEMENTED YET - // optional string state = 2; // US Only / NOT IMPLEMENTED YET - // optional string country = 3; // Must be an ISO 3166 code / NOT IMPLEMENTED YET +// Sub-message used by Current & Extended 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 +enum LocationType { + LOCATION_TYPE_UNSPECIFIED = 0; + LOCATION_CITY = 1; + LOCATION_ZIP = 2; + LOCATION_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 + */ +message RequestLocation { + // LocationType location_type = 1; + string city = 1; + // optional string zip_code = 2; +} + +// Response to RequestLocation message SendLocation { float latitude = 1; float longitude = 2; diff --git a/proto/location_types.proto b/proto/location_types.proto deleted file mode 100644 index a558257..0000000 --- a/proto/location_types.proto +++ /dev/null @@ -1,15 +0,0 @@ -syntax = "proto3"; - -package weather; - -option go_package = "codeberg.org/andcscott/OpenWeatherMap-gRPC-API/proto"; - -enum LocationType { - LOCATION_TYPE_UNSPECIFIED = 0; - LOCATION_CITY = 1; - LOCATION_ZIP = 2; - LOCATION_COORDS = 3; - LOCATION_CITY_STATE = 4; - LOCATION_CITY_COUNTRY = 5; - LOCATION_ZIP_COUNTRY = 6; -} diff --git a/proto/service.proto b/proto/service.proto index 8cef041..f66c80f 100644 --- a/proto/service.proto +++ b/proto/service.proto @@ -4,8 +4,7 @@ package weather; option go_package = "codeberg.org/andcscott/OpenWeatherMap-gRPC-API/proto"; -import "current.proto"; -import "extended.proto"; +import "weather.proto"; import "location.proto"; service WeatherService { diff --git a/proto/units.proto b/proto/units.proto deleted file mode 100644 index 5a62d99..0000000 --- a/proto/units.proto +++ /dev/null @@ -1,12 +0,0 @@ -syntax = "proto3"; - -package weather; - -option go_package = "codeberg.org/andcscott/OpenWeatherMap-gRPC-API/proto"; - -enum Units { - UNITS_UNSPECIFIED = 0; - UNITS_STANDARD = 1; - UNITS_METRIC = 2; - UNITS_IMPERIAL = 3; -} diff --git a/proto/weather.proto b/proto/weather.proto new file mode 100644 index 0000000..e8f3282 --- /dev/null +++ b/proto/weather.proto @@ -0,0 +1,59 @@ +syntax = "proto3"; + +package weather; + +option go_package = "codeberg.org/andcscott/OpenWeatherMap-gRPC-API/proto"; + +//import "location.proto" + +// Sub-message used by Current & Extended to specify preferred units +enum Units { + UNITS_UNSPECIFIED = 0; + UNITS_STANDARD = 1; + UNITS_METRIC = 2; + UNITS_IMPERIAL = 3; +} + +/* 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 + */ +message RequestCurrent { + // LocationType location_type = 1; + // Units units = 2; + string city = 1; + // optional string zip_code = 2; + // Coordinates coordinates = 2; +} + +// Response to RequestCurrent +message SendCurrent { + string payload = 1; +} + +/* 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 + * days {uint32} - number of days to fetch, max 16 + */ +message RequestExtended { + // LocationType location_type = 1; + // Units units = 2; + string city = 1; + // optional string zip_code = 2; + // Coordinates coordinates = 3; + uint32 days = 2; +} + +// Response to RequestExtended +message SendExtended { + string payload = 1; +}