syntax = "proto3";

package io.stellarproject.heimdall.api.v1;

import "gogoproto/gogo.proto";
import "google/protobuf/empty.proto";

option go_package = "github.com/stellarproject/heimdall/api/v1;v1";

service Heimdall {
        rpc Connect(ConnectRequest) returns (ConnectResponse);
        rpc Routes(RoutesRequest) returns (RoutesResponse);
        rpc CreateRoute(CreateRouteRequest) returns (google.protobuf.Empty);
        rpc DeleteRoute(DeleteRouteRequest) returns (google.protobuf.Empty);
        rpc Nodes(NodesRequest) returns (NodesResponse);
        rpc Peers(PeersRequest) returns (PeersResponse);
}

message Master {
        string id = 1 [(gogoproto.customname) = "ID"];
        string grpc_address = 2 [(gogoproto.customname) = "GRPCAddress"];
        string redis_url = 3 [(gogoproto.customname) = "RedisURL"];
}

message ConnectRequest {
        string id = 1 [(gogoproto.customname) = "ID"];
        string cluster_key = 2;
}

message ConnectResponse {
        Master master = 1;
}

message KeyPair {
        string private_key = 1;
        string public_key = 2;
}

message Node {
        string id = 1 [(gogoproto.customname) = "ID"];
        string addr = 2;
        KeyPair keypair = 3 [(gogoproto.customname) = "KeyPair"];
        string gateway_ip = 4 [(gogoproto.customname) = "GatewayIP"];
        uint64 gateway_port = 5;
}

message NodesRequest {}

message NodesResponse {
        repeated Node nodes = 1;
}

message Peer {
        string id = 1 [(gogoproto.customname) = "ID"];
        KeyPair keypair = 2 [(gogoproto.customname) = "KeyPair"];
        repeated string allowed_ips = 3 [(gogoproto.customname) = "AllowedIPs"];
        string endpoint = 4;
}

message PeersRequest {}

message PeersResponse {
        repeated Peer peers = 1;
}

message Route {
        string node_id = 1 [(gogoproto.customname) = "NodeID"];
        string network = 2;
}

message CreateRouteRequest {
        string node_id = 1 [(gogoproto.customname) = "NodeID"];
        string network = 2;
}

message DeleteRouteRequest {
        string network = 1;
}

message RoutesRequest {}

message RoutesResponse {
        repeated Route routes = 1;
}
