syntax = "proto3";

package gmqtt.admin.api;
option go_package = ".;admin";

import "google/api/annotations.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/timestamp.proto";

message ListClientRequest {
  uint32 page_size = 1;
  uint32 page = 2;
}

message ListClientResponse {
  repeated Client clients = 1;
  uint32 total_count = 2;
}

message GetClientRequest {
  string client_id = 1;
}

message GetClientResponse {
  Client client = 1;
}


message DeleteClientRequest {
  string client_id = 1;
  bool clean_session = 2;
}

message Client {
  string client_id = 1;
  string username = 2;
  int32 keep_alive = 3;
  int32 version = 4;
  string remote_addr = 5;
  string local_addr = 6;
  google.protobuf.Timestamp connected_at = 7;
  google.protobuf.Timestamp disconnected_at = 8;
  uint32 session_expiry = 9;
  uint32 max_inflight = 10;
  uint32 inflight_len = 11;
  uint32 max_queue = 12;
  uint32 queue_len = 13;
  uint32 subscriptions_current = 14;
  uint32 subscriptions_total = 15;
  uint64 packets_received_bytes = 16;
  uint64 packets_received_nums = 17;
  uint64 packets_send_bytes = 18;
  uint64 packets_send_nums = 19;
  uint64 message_dropped = 20;
}


service ClientService {
  // List clients
  rpc List (ListClientRequest) returns (ListClientResponse){
    option (google.api.http) = {
      get: "/v1/clients"
    };
  }
  // Get the client for given client id.
  // Return NotFound error when client not found.
  rpc Get (GetClientRequest) returns (GetClientResponse){
    option (google.api.http) = {
      get: "/v1/clients/{client_id}"
    };
  }
  // Disconnect the client for given client id.
  rpc Delete (DeleteClientRequest) returns (google.protobuf.Empty) {
    option (google.api.http) = {
      delete: "/v1/clients/{client_id}"
    };
  }
}
