syntax = "proto3";

package gosdn.topology;

import "google/api/annotations.proto";
import "google/protobuf/descriptor.proto";
import "protoc-gen-openapiv2/options/annotations.proto";

import "gosdn/topology/link.proto";
import "gosdn/topology/route.proto";

option go_package = "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/topology";

service TopologyService {
    rpc AddLink(AddLinkRequest) returns (AddLinkResponse) {
        option (google.api.http) = {
            post: "/topology/create"
            body: "*"
        };
    }

    rpc GetTopology(GetTopologyRequest) returns (GetTopologyResponse) {
        option (google.api.http) = {
            get: "/topology"
        };
    }

    rpc UpdateLink(UpdateLinkRequest) returns (UpdateLinkResponse) {
        option (google.api.http) = {
            post: "/topology/update"
            body: "*"
        };
    }

    rpc DeleteLink(DeleteLinkRequest) returns (DeleteLinkResponse) {
        option (google.api.http) = {
            delete: "/topology/delete"
        };
    }
}

enum Status {
    STATUS_UNSPECIFIED = 0;
    STATUS_OK = 1;
    STATUS_ERROR = 2;
}

message Topology {
    repeated Link links = 1;
}

message AddLinkRequest {
    int64 timestamp = 1;
    Link link = 2;
}

message AddLinkResponse {
    int64 timestamp = 1;
    Status status = 2;
}

message GetTopologyRequest {
    int64 timestamp = 1;
}

message GetTopologyResponse {
    int64 timestamp = 1;
    Status status = 2;
    Topology toplogy = 3;
}

message UpdateLinkRequest {
    int64 timestamp = 1;
    Link link = 2;
}

message UpdateLinkResponse {
    int64 timestamp = 1;
    Status status = 2;
}

message DeleteLinkRequest {
    int64 timestamp = 1;
    string id = 2;
}

message DeleteLinkResponse {
    int64 timestamp = 1;
    Status status = 2;
}
