Skip to content

Commit

Permalink
change(greenspace): update service & documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgechato committed Nov 4, 2023
1 parent 8c7d0bf commit 44dfbbf
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions proto/greenspace/api/v1/mobile.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@ import "google/api/annotations.proto";
import "google/protobuf/empty.proto";


// Internal service
service Internal {
// GreenSpaceService is the service that provides all the information for NASA's GreenSpace app.
service GreenSpaceService {
// GetAnimals returns the animals that are in danger in the coast as a stream.
rpc GetAnimals(AnimalsRequest) returns (stream Animal) {};
// GetCoast returns the nearest coast to the user location.
rpc GetCoast(CoastRequest) returns (CoastResponse) {};
// GetLocation returns the location of the user.
rpc GetLocation(LocationRequest) returns (LocationResponse) {};
}

// BFF service
service Bff {
// GetV1 is the BFF endpoint. It returns the location of the user, the nearest coast and the animals in danger.
rpc GetV1(google.protobuf.Empty) returns (V1Response) {
option (google.api.http) = {
get: "/api/v1"
Expand All @@ -28,14 +29,16 @@ service Bff {
message LocationResponse {
float longitude = 1;
float latitude = 2;
// The name of the location. e.g. "San Sebastian"
string name = 3;
}

// LocationRequest the IP of the user is required to get the location.
message LocationRequest {
string ip = 1;
}

// Coast
// Condition, the condition of the water. In house algorithm to define the condition.
enum Condition {
GOOD = 0;
MODERATE = 1;
Expand All @@ -46,29 +49,38 @@ enum Condition {
PROTECTED = 6;
}

// CoastRequest the user location is required to get the nearest coast.
message CoastRequest {
LocationResponse location = 1;
}

// CoastResponse the nearest coast to the user location.
message CoastResponse {
// The name of the coast. e.g. "Playa de la Concha"
string name = 1;
// The condition of the water. e.g. "GOOD"
Condition condition = 2;
// The temperature of the water in Celsius. e.g. 20
float temperature = 3;
// The distance in kilometers to the coast. e.g. 4.1
double distance = 4;
}

// Animals
// Animals the animals that are in danger in the coast.
message Animal {
string name = 1;
bool in_danger = 2;
string description = 3;
}

// AnimalsRequest the user location is required to get the nearest animals living in the coast.
message AnimalsRequest {
LocationResponse location = 1;
}

// BFF
// V1Response the response of the V1 endpoint. It contains the location of the user, the nearest coast and the animals
// in danger. It serves as a wrapper for the other responses. It is used to avoid multiple requests to the API and
// follow the BFF pattern.
message V1Response {
LocationResponse location = 1;
CoastResponse nearest_aquatic_location = 2;
Expand Down

0 comments on commit 44dfbbf

Please sign in to comment.