// Copyright (c) 2018 Open Networking Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at:
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";
package bbsim;

// Models

message PONPort {
    int32 ID = 1;
    string OperState = 2;
}

message NNIPort {
    int32 ID = 1;
    string OperState = 2;
}

message Olt {
    int32 ID = 1;
    string SerialNumber = 2;
    string OperState = 3;
    string InternalState = 4;
    repeated NNIPort NNIPorts = 5;
    repeated PONPort PONPorts = 6;
}

message ONU {
    int32 ID = 1;
    string SerialNumber = 2;
    string OperState = 3;
    string InternalState = 4;
    int32 PonPortID = 5;
    int32 STag = 6;
    int32 CTag = 7;
    string HwAddress = 8;
    int32 PortNo = 9;
}

message ONUs {
    repeated ONU items = 1;
}

// Inputs

message ONURequest {
    string SerialNumber = 1;
}

// Utils

message VersionNumber {
    string version = 1;
    string buildTime = 2;
    string commitHash = 3;
    string gitStatus = 4;
}

message LogLevel {
    string level = 1;
    bool caller = 2;
}

message Response {
    int32 status_code = 1;
    string message = 2;
}

message Empty {}

service BBSim {
    rpc Version(Empty) returns (VersionNumber) {}
    rpc GetOlt(Empty) returns (Olt) {}
    rpc GetONUs(Empty) returns (ONUs) {}
    rpc GetONU(ONURequest) returns (ONU) {}
    rpc SetLogLevel(LogLevel) returns (LogLevel) {}
    rpc ShutdownONU (ONURequest) returns (Response) {}
    rpc PoweronONU (ONURequest) returns (Response) {}
    rpc RestartEapol (ONURequest) returns (Response) {}
    rpc RestartDhcp (ONURequest) returns (Response) {}
}