syntax = "proto3";

package forest.v1;

message Environment {
  string id = 1;
  string organisation = 2;
  string name = 3;
  optional string description = 4;
  int32 sort_order = 5;
  string created_at = 6;
}

message CreateEnvironmentRequest {
  string organisation = 1;
  string name = 2;
  optional string description = 3;
  int32 sort_order = 4;
}
message CreateEnvironmentResponse {
  Environment environment = 1;
}

message GetEnvironmentRequest {
  oneof identifier {
    string id = 1;
    EnvironmentLookup lookup = 2;
  }
}

message EnvironmentLookup {
  string organisation = 1;
  string name = 2;
}

message GetEnvironmentResponse {
  Environment environment = 1;
}

message ListEnvironmentsRequest {
  string organisation = 1;
}
message ListEnvironmentsResponse {
  repeated Environment environments = 1;
}

message UpdateEnvironmentRequest {
  string id = 1;
  optional string description = 2;
  optional int32 sort_order = 3;
}
message UpdateEnvironmentResponse {
  Environment environment = 1;
}

message DeleteEnvironmentRequest {
  string id = 1;
}
message DeleteEnvironmentResponse {}

service EnvironmentService {
  rpc CreateEnvironment(CreateEnvironmentRequest) returns (CreateEnvironmentResponse);
  rpc GetEnvironment(GetEnvironmentRequest) returns (GetEnvironmentResponse);
  rpc ListEnvironments(ListEnvironmentsRequest) returns (ListEnvironmentsResponse);
  rpc UpdateEnvironment(UpdateEnvironmentRequest) returns (UpdateEnvironmentResponse);
  rpc DeleteEnvironment(DeleteEnvironmentRequest) returns (DeleteEnvironmentResponse);
}
