// Fleet — An IoT fleet: sites, devices, telemetry and alerts — the MQTT one. // sondahub (https://sondahub.com): served over gRPC-Web and Connect at https://api.sondahub.com/grpc. // Writes are simulated: answered as a real server would, kept only in the x-sondahub-session token you send back. syntax = "proto3"; package sondahub.fleet.v1; import "google/protobuf/struct.proto"; service FleetService { // A page of sites: page, limit, sort, q and filter (field → value, with the REST operator suffixes: price_lt → 20). rpc ListSites(ListSitesRequest) returns (ListSitesResponse); // One site by id. rpc GetSite(GetSiteRequest) returns (Site); // Create a site (simulated, kept in your session token). id and the timestamps are set by the server. rpc CreateSite(Site) returns (Site); // Change the fields set in site (simulated). rpc UpdateSite(UpdateSiteRequest) returns (Site); // Delete one (simulated); answers what was removed. rpc DeleteSite(DeleteSiteRequest) returns (Site); // A page of devices: page, limit, sort, q and filter (field → value, with the REST operator suffixes: price_lt → 20). rpc ListDevices(ListDevicesRequest) returns (ListDevicesResponse); // One device by id. rpc GetDevice(GetDeviceRequest) returns (Device); // Create a device (simulated, kept in your session token). id and the timestamps are set by the server. rpc CreateDevice(Device) returns (Device); // Change the fields set in device (simulated). rpc UpdateDevice(UpdateDeviceRequest) returns (Device); // Delete one (simulated); answers what was removed. rpc DeleteDevice(DeleteDeviceRequest) returns (Device); // A page of readings: page, limit, sort, q and filter (field → value, with the REST operator suffixes: price_lt → 20). rpc ListReadings(ListReadingsRequest) returns (ListReadingsResponse); // One reading by id. rpc GetReading(GetReadingRequest) returns (Reading); // Create a reading (simulated, kept in your session token). id and the timestamps are set by the server. rpc CreateReading(Reading) returns (Reading); // Change the fields set in reading (simulated). rpc UpdateReading(UpdateReadingRequest) returns (Reading); // Delete one (simulated); answers what was removed. rpc DeleteReading(DeleteReadingRequest) returns (Reading); // A page of alerts: page, limit, sort, q and filter (field → value, with the REST operator suffixes: price_lt → 20). rpc ListAlerts(ListAlertsRequest) returns (ListAlertsResponse); // One alert by id. rpc GetAlert(GetAlertRequest) returns (Alert); // Create a alert (simulated, kept in your session token). id and the timestamps are set by the server. rpc CreateAlert(Alert) returns (Alert); // Change the fields set in alert (simulated). rpc UpdateAlert(UpdateAlertRequest) returns (Alert); // Delete one (simulated); answers what was removed. rpc DeleteAlert(DeleteAlertRequest) returns (Alert); // A page of commands: page, limit, sort, q and filter (field → value, with the REST operator suffixes: price_lt → 20). rpc ListCommands(ListCommandsRequest) returns (ListCommandsResponse); // One command by id. rpc GetCommand(GetCommandRequest) returns (Command); // Create a command (simulated, kept in your session token). id and the timestamps are set by the server. rpc CreateCommand(Command) returns (Command); // Change the fields set in command (simulated). rpc UpdateCommand(UpdateCommandRequest) returns (Command); // Delete one (simulated); answers what was removed. rpc DeleteCommand(DeleteCommandRequest) returns (Command); // The API's live activity as a server stream, each topic at its own pace: telemetry (every 2 s), alerts (every ~15 s), devices (every ~10 s). max_events ends the stream (default 10, at most 120). rpc Watch(WatchRequest) returns (stream Event); } message Site { // Assigned by the server. Seed records keep their ids across restarts; records you create continue after the seed. int64 id = 1; // When the record was created (ISO 8601, UTC). optional string created_at = 2; // When the record last changed. optional string updated_at = 3; optional string code = 4; optional string name = 5; optional string kind = 6; google.protobuf.Value address = 7; optional string timezone = 8; optional double lat = 9; optional double lon = 10; optional int64 device_count = 11; optional string status = 12; } message ListSitesRequest { int32 page = 1; int32 limit = 2; string sort = 3; string q = 4; map filter = 5; } message ListSitesResponse { repeated Site data = 1; int32 page = 2; int32 limit = 3; int32 total = 4; int32 pages = 5; } message UpdateSiteRequest { int64 id = 1; Site site = 2; } message GetSiteRequest { int64 id = 1; } message DeleteSiteRequest { int64 id = 1; } message Device { // Assigned by the server. Seed records keep their ids across restarts; records you create continue after the seed. int64 id = 1; // When the record was created (ISO 8601, UTC). optional string created_at = 2; // When the record last changed. optional string updated_at = 3; // Unique. Also the device’s MQTT topic segment. optional string serial = 4; optional string name = 5; optional string type = 6; optional string model = 7; optional int64 site_id = 8; optional string firmware = 9; optional string status = 10; // null for mains-powered devices. optional int64 battery_pct = 11; optional int64 rssi_dbm = 12; optional string ip = 13; optional string mac = 14; google.protobuf.Value tags = 15; google.protobuf.Value config = 16; optional string installed_at = 17; optional string last_seen_at = 18; } message ListDevicesRequest { int32 page = 1; int32 limit = 2; string sort = 3; string q = 4; map filter = 5; } message ListDevicesResponse { repeated Device data = 1; int32 page = 2; int32 limit = 3; int32 total = 4; int32 pages = 5; } message UpdateDeviceRequest { int64 id = 1; Device device = 2; } message GetDeviceRequest { int64 id = 1; } message DeleteDeviceRequest { int64 id = 1; } message Reading { // Assigned by the server. Seed records keep their ids across restarts; records you create continue after the seed. int64 id = 1; // When the record was created (ISO 8601, UTC). optional string created_at = 2; // When the record last changed. optional string updated_at = 3; optional int64 device_id = 4; optional string recorded_at = 5; google.protobuf.Value metrics = 6; optional string quality = 7; } message ListReadingsRequest { int32 page = 1; int32 limit = 2; string sort = 3; string q = 4; map filter = 5; } message ListReadingsResponse { repeated Reading data = 1; int32 page = 2; int32 limit = 3; int32 total = 4; int32 pages = 5; } message UpdateReadingRequest { int64 id = 1; Reading reading = 2; } message GetReadingRequest { int64 id = 1; } message DeleteReadingRequest { int64 id = 1; } message Alert { // Assigned by the server. Seed records keep their ids across restarts; records you create continue after the seed. int64 id = 1; // When the record was created (ISO 8601, UTC). optional string created_at = 2; // When the record last changed. optional string updated_at = 3; optional int64 device_id = 4; optional int64 site_id = 5; optional string severity = 6; optional string kind = 7; optional string message = 8; optional string status = 9; optional string opened_at = 10; optional string acknowledged_at = 11; optional string resolved_at = 12; optional string acknowledged_by = 13; } message ListAlertsRequest { int32 page = 1; int32 limit = 2; string sort = 3; string q = 4; map filter = 5; } message ListAlertsResponse { repeated Alert data = 1; int32 page = 2; int32 limit = 3; int32 total = 4; int32 pages = 5; } message UpdateAlertRequest { int64 id = 1; Alert alert = 2; } message GetAlertRequest { int64 id = 1; } message DeleteAlertRequest { int64 id = 1; } message Command { // Assigned by the server. Seed records keep their ids across restarts; records you create continue after the seed. int64 id = 1; // When the record was created (ISO 8601, UTC). optional string created_at = 2; // When the record last changed. optional string updated_at = 3; optional int64 device_id = 4; optional string action = 5; google.protobuf.Value params = 6; optional string status = 7; optional string issued_by = 8; optional string sent_at = 9; optional string acked_at = 10; google.protobuf.Value result = 11; } message ListCommandsRequest { int32 page = 1; int32 limit = 2; string sort = 3; string q = 4; map filter = 5; } message ListCommandsResponse { repeated Command data = 1; int32 page = 2; int32 limit = 3; int32 total = 4; int32 pages = 5; } message UpdateCommandRequest { int64 id = 1; Command command = 2; } message GetCommandRequest { int64 id = 1; } message DeleteCommandRequest { int64 id = 1; } message WatchRequest { repeated string topics = 1; int32 max_events = 2; } message Event { string topic = 1; string api = 2; string ts = 3; google.protobuf.Struct data = 4; }