// Copyright 2025 MOIA GmbH

syntax = "proto3";

package moia.fleet.operatingarea.v1beta1;

option go_package = "./operatingarea_v1beta1";
option java_multiple_files = false;
option java_outer_classname = "OperatingAreaServiceV1Beta1";
option java_package = "io.moia.protos.fleet.operatingarea.v1beta1";

// This service provides methods to query the MOIA operating areas.
service OperatingAreaService {
  // List all operating areas.
  rpc ListOperatingAreas(ListOperatingAreasRequest) returns (ListOperatingAreasResponse);
  // Get a specific operating area by its ID.
  rpc GetOperatingArea(GetOperatingAreaRequest) returns (GetOperatingAreaResponse);
  // Update an existing operating area.
  rpc UpdateOperatingArea(UpdateOperatingAreaRequest) returns (UpdateOperatingAreaResponse);
}

// An operating area defines a geographical area where MOIA vehicles are allowed to operate.
message OperatingArea {
  // Unique identifier for the operating area as UUIDv4.
  string id = 1;
  // Human readable name for display purposes.
  string name = 2;
  // Geometry as a GeoJSON MultiPolygon object.
  string geometry = 3;
  // Region identifier the operating area belongs to.
  string region_id = 4;
}

// Request message for GetOperatingArea.
message GetOperatingAreaRequest {
  // Unique identifier for the operating area as UUIDv4.
  string id = 1;
}

// Response message for GetOperatingArea.
message GetOperatingAreaResponse {
  // The requested operating area.
  OperatingArea operating_area = 1;
}

// Response message for ListOperatingAreas.
message ListOperatingAreasResponse {
  // All operating areas.
  repeated OperatingArea operating_areas = 1;
  // A token, which can be sent as `page_token` to retrieve the next page.
  // If this field is omitted, there are no subsequent pages.
  optional string next_page_token = 2;
}

// Request message for ListOperatingAreas.
message ListOperatingAreasRequest {
  // The maximum number of operating areas to return (default 50).
  optional int32 page_size = 1;
  // A page token, received from a previous `ListOperatingAreasRequest` call.
  // Provide this to retrieve the subsequent page.
  optional string page_token = 2;
}

// Request message for UpdateOperatingArea
message UpdateOperatingAreaRequest {
  // The operating area with updated information.
  // Only `name` and `geometry` fields may be changed.
  OperatingArea operating_area = 1;
}

// Response message for UpdateOperatingArea
message UpdateOperatingAreaResponse {
  // The updated operating area.
  OperatingArea operating_area = 1;
}
