syntax = "proto3";

package gosdn.plugin;

import "github.com/openconfig/gnmi/proto/gnmi/gnmi.proto";
import "gosdn/networkelement/networkelement.proto";
option go_package = "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/plugin";

service Plugin {
    rpc Unmarshal(UnmarshalRequest) returns (UnmarshalResponse);
    rpc SetNode(SetNodeRequest) returns (SetNodeResponse);
    rpc GetNode(GetNodeRequest) returns (GetNodeResponse);
    rpc DeleteNode(DeleteNodeRequest) returns (DeleteNodeResponse);
    rpc Model(ModelRequest) returns (ModelResponse);
    rpc Diff(DiffRequest) returns (DiffResponse);
    rpc SchemaTreeGzip(SchemaTreeGzipRequest) returns (stream Payload);
    rpc ValidateChange(ValidateChangeRequest) returns (ValidateChangeResponse);
    rpc PruneConfigFalse(PruneConfigFalseRequest) returns (PruneConfigFalseResponse);
}

message UnmarshalRequest {
    bytes json = 1;
    gnmi.Path path = 2;
    gnmi.TypedValue value = 3;
}

message UnmarshalResponse {
    bool valid = 1;
}

message SetNodeRequest {
    gnmi.Path path = 2;
    gnmi.TypedValue value = 3;
}

message SetNodeResponse {
    bool valid = 1;
}

message GetNodeRequest {
    gnmi.Path path = 2;
    bool requestForIntendedState = 3;
}

message GetNodeResponse {
    repeated gnmi.Notification nodes = 1;
}

message DeleteNodeRequest {
    gnmi.Path path = 2;
}

message DeleteNodeResponse {
    bool valid = 1;
}

message ModelRequest {
    bool filterReadOnly = 1;
}

message ModelResponse {
    bytes json = 1; // JSON-encoded text per RFC7951.
}

message DiffRequest {
    bytes original = 1; // JSON-encoded text per RFC7951.
    bytes modified = 2; // JSON-encoded text per RFC7951.
}

message DiffResponse {
    gnmi.Notification notification = 1;
}

message ValidateChangeRequest {
    networkelement.ApiOperation operation = 1;
    gnmi.Path path = 2;
    gnmi.TypedValue value = 3;
}

message ValidateChangeResponse {
    bytes model = 1; // JSON-encoded text per RFC7951.
}

message PruneConfigFalseRequest {
    bytes value = 1; // JSON-encoded text per RFC7951.
}

message PruneConfigFalseResponse {
    bytes model = 1; // JSON-encoded text per RFC7951.
}

message SchemaTreeGzipRequest {
}

message Payload {
  bytes chunk = 1;
}
