// 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.api.v1;

import "google/api/annotations.proto";
import "protoc-gen-swagger/options/annotations.proto";

option (grpc.gateway.protoc_gen_swagger.options.openapiv2_swagger) = {
    info: {
	title: "BBSim API";
	version: "1.0";
    };
    schemes: HTTP;
    consumes: "application/json";
    produces: "application/json";
    responses: {
	key: "404";
	value: {
	    description: "Returned when the resource does not exist.";
	    schema: {
		    json_schema: {
		      type: STRING;
		}
	    }
	}
    }
};

// OLT information
message OLTInfo {
    int64   olt_id = 1;
    string  olt_serial = 2;
    string  olt_ip = 3;
    string  olt_state = 4;
    string  olt_vendor = 5;
}

// ONU information
message ONUInfo {
    uint32 onu_id = 1;
    uint32 pon_port_id = 2;
    // ONU serial number
    string onu_serial = 3;
    // ONU oper state
    string oper_state = 4;
    // ONU internal state
    string onu_state = 5;
}

// Bulk ONU operations
message ONUs {
    repeated ONUInfo onus = 1;
}

message ONURequest {
    ONUInfo onu = 1;
    ONUs onus_batch = 2;
}

// Port information
message PortInfo {
    string port_type = 1;
    uint32 port_id = 2;
    int32  pon_port_max_onus = 3;
    uint32 pon_port_active_onus = 4;
    string port_state = 5;
    string alarm_state = 6;
}

// Bulk port information
message Ports {
    repeated PortInfo ports = 1;
}

// BBSim status
message OLTStatusResponse {
    OLTInfo olt = 1;
    repeated PortInfo ports = 2;
}

// BBSim response message
message BBSimResponse {
    string status_msg = 1;
}

// ONU alarm request
message ONUAlarmRequest {
    // ONU serial number
    string onu_serial = 1; 
    // Alarm types are:
    //   "signaldegrade"
    //   "lossofomcichannel"
    //   "lossofploam"
    string alarm_type = 2;
    // "on"/"off" indicates raised or cleared alarm 
    string status = 3;                 }

// OLT alarm request
message OLTAlarmRequest {
    uint32 port_id = 1;
    string port_type = 2;
    string status = 3;
}

// Device action
message DeviceAction {
    string device_type = 1;             // ONU or OLT
    string device_serial_number = 2;    // Device serial number
    string device_action = 3;           // soft or hard reboot
}

message Empty {}

service BBSimService {

    // Get current status of OLT
    rpc OLTStatus(Empty) returns (OLTStatusResponse) {
        option (google.api.http) = {
            get : "/v1/olt"
            additional_bindings {get : "/v1/olt/status"}
        };
    }

    // Get status of a PON/NNI port
    rpc PortStatus(PortInfo) returns (Ports) {
        option (google.api.http) = {
            get : "/v1/olt/ports/{port_type}"
        };
    }

    // Get status of all or specific ONUs
    rpc ONUStatus(ONURequest) returns (ONUs) {
        option (google.api.http) = {
            get : "/v1/olt/onus"
            additional_bindings { get : "/v1/olt/ports/{onu.pon_port_id}/onus" }
            additional_bindings { get : "/v1/olt/onus/{onu.onu_serial}" }
        };
    }

    // Single/bulk activate ONU(s) for specific PON port(s)
    rpc ONUActivate(ONURequest) returns (BBSimResponse) {
        option (google.api.http) = {
            post : "/v1/olt/onus"
            body: "onus_batch"
            additional_bindings { post : "/v1/olt/ports/{onu.pon_port_id}/onus" }
            additional_bindings { post : "/v1/olt/ports/{onu.pon_port_id}/onus/{onu.onu_serial}" }
        };
    }
    
    // Deactivate ONU(s) for specific PON port(s) specified by  
    // a given onu_serial, onu_id, or pon_port_id
    rpc ONUDeactivate(ONURequest) returns (BBSimResponse) {
        option (google.api.http) = {
            delete : "/v1/olt/onus"
            body: "onus_batch"
            additional_bindings { delete: "/v1/olt/onus/{onu.onu_serial}" }
            additional_bindings { delete: "/v1/olt/ports/{onu.pon_port_id}/onus" }
            additional_bindings { delete: "/v1/olt/ports/{onu.pon_port_id}/onus/{onu.onu_id}" }
        };
    }

    // Generate ONU related alarms
    rpc GenerateONUAlarm(ONUAlarmRequest) returns (BBSimResponse) {
        option (google.api.http) = {
            post : "/v1/olt/onus/{onu_serial}/alarms/{alarm_type}/{status}"
        };
    }

    // Generate OLT related alarms
    rpc GenerateOLTAlarm(OLTAlarmRequest) returns (BBSimResponse) {
        option (google.api.http) = {
            post : "/v1/olt/ports/{port_type}/{port_id}/alarms/los/{status}"
        };
    }

    // Perform actions on OLT/ONU devices (e.g. reboot)
    rpc PerformDeviceAction(DeviceAction) returns (BBSimResponse) {
        option (google.api.http) = {
            patch: "/v1/{device_type}/reboot"
            additional_bindings { patch : "/v1/olt/{device_type}/{device_serial_number}/reboot/{device_action}"}
        };
    }
}
