/*
 * Top-level Voltha API definition
 *
 * For details, see individual definition files.
 */

syntax = "proto3";

option go_package = "github.com/opencord/voltha-protos/v3/go/voltha";

package voltha;

import "google/api/annotations.proto";
import "google/protobuf/empty.proto";

import public "voltha_protos/meta.proto";
import public "voltha_protos/common.proto";
import public "voltha_protos/health.proto";
import public "voltha_protos/logical_device.proto";
import public "voltha_protos/device.proto";
import public "voltha_protos/adapter.proto";
import public "voltha_protos/openflow_13.proto";

import "voltha_protos/omci_mib_db.proto";
import "voltha_protos/omci_alarm_db.proto";

option java_package = "org.opencord.voltha";
option java_outer_classname = "VolthaProtos";
option csharp_namespace = "Opencord.Voltha.Voltha";

message DeviceGroup {

    string id = 1 [(access) = READ_ONLY];

    repeated LogicalDevice logical_devices = 2 [(child_node) = {key: "id"}];

    repeated Device devices = 3 [(child_node) = {key: "id"}];
}

message DeviceGroups {
    repeated DeviceGroup items = 1;
}


message EventFilterRuleKey {

    enum EventFilterRuleType {
        filter_all = 0;
        category = 1;
        sub_category = 2;
        kpi_event_type = 3;
        config_event_type = 4;
        device_event_type = 5;
    }
}

message EventFilterRule {
    EventFilterRuleKey.EventFilterRuleType key = 1;
    string value = 2;
}
message EventFilter {
    string id = 1 [(access) = READ_ONLY];
    bool enable = 2;
    string device_id = 3;
    string event_type = 4;
    repeated EventFilterRule rules = 5;
}

message EventFilters {
    repeated EventFilter filters = 1;
}

// CoreInstance represents a core instance.  It is data held in memory when a core
// is running.  This data is not persistent.
message CoreInstance {

    string instance_id = 1  [(access) = READ_ONLY];

    HealthStatus health = 2 [(child_node) = {}];

}

message CoreInstances {
    repeated CoreInstance items = 1;
}

message OmciTestRequest {
    string id = 1;
    string uuid = 2;
}

message TestResponse{
    enum TestResponseResult  {
        SUCCESS = 0;
        FAILURE = 1;
    }
    TestResponseResult result = 1;
}

// Voltha represents the Voltha cluster data.  Each Core instance will hold a subset of
// the entire cluster. However, some items (e.g. adapters) will be held by all cores
// for better performance
message Voltha {

    string version = 1 [(access) = READ_ONLY];

    repeated Adapter adapters = 2 [(child_node) = {key: "id"}];

    repeated LogicalDevice logical_devices = 3 [(child_node) = {key: "id"}];

    repeated Device devices = 4 [(child_node) = {key: "id"}];

    repeated DeviceType device_types = 5 [(child_node) = {key: "id"}];

    repeated DeviceGroup device_groups = 6 [(child_node) = {key: "id"}];

    repeated EventFilter event_filters = 7 [(child_node) = {key: "id"}];

    repeated
        omci.MibDeviceData omci_mib_database = 28
        [(child_node) = {key: "device_id"}];

    repeated
        omci.AlarmDeviceData omci_alarm_database = 29
        [(child_node) = {key: "device_id"}];
}

// Device Self Test Response
message SelfTestResponse {

	enum SelfTestResult  {
	    SUCCESS = 0;
	    FAILURE = 1;
	    NOT_SUPPORTED = 2;
	    UNKNOWN_ERROR = 3;
    }
    SelfTestResult result = 1;
}

message OfAgentSubscriber {
    // ID of ofagent instance
    string ofagent_id = 1;

    // ID of voltha instance to which the ofagent is subscribed
    string voltha_id = 2;
}

// Identifies a membership group a Core belongs to
message Membership {
    //  Group name
    string group_name = 1;

    // Unique ID of a container within that group
    string id = 2;
}

// Additional information required to process flow at device adapters
message FlowMetadata {
    // Meters associated with flow-update to adapter
    repeated openflow_13.ofp_meter_config meters = 1;
}

/*
 * Voltha APIs
 *
 */
service VolthaService {

    // Get the membership group of a Voltha Core
    rpc GetMembership(google.protobuf.Empty) returns(Membership) {
        option (google.api.http) = {
            get: "/api/v1/membership"
        };
    }

    // Set the membership group of a Voltha Core
    rpc UpdateMembership(Membership) returns(google.protobuf.Empty) {
        option (google.api.http) = {
            post: "/api/v1/membership"
            body: "*"
        };
    }

    // Get high level information on the Voltha cluster
    rpc GetVoltha(google.protobuf.Empty) returns(Voltha) {
        option (google.api.http) = {
            get: "/api/v1"
        };
    }

    // List all Voltha cluster core instances
    rpc ListCoreInstances(google.protobuf.Empty) returns(CoreInstances) {
        option (google.api.http) = {
            get: "/api/v1/instances"
        };
    }

    // Get details on a Voltha cluster instance
    rpc GetCoreInstance(common.ID) returns(CoreInstance) {
        option (google.api.http) = {
            get: "/api/v1/instances/{id}"
        };
    }

    // List all active adapters (plugins) in the Voltha cluster
    rpc ListAdapters(google.protobuf.Empty) returns(Adapters) {
        option (google.api.http) = {
            get: "/api/v1/adapters"
        };
    }


    // List all logical devices managed by the Voltha cluster
    rpc ListLogicalDevices(google.protobuf.Empty) returns(LogicalDevices) {
        option (google.api.http) = {
            get: "/api/v1/logical_devices"
        };
    }

    // Get additional information on a given logical device
    rpc GetLogicalDevice(common.ID) returns(LogicalDevice) {
        option (google.api.http) = {
            get: "/api/v1/logical_devices/{id}"
        };
    }

    // List ports of a logical device
    rpc ListLogicalDevicePorts(common.ID) returns(LogicalPorts) {
        option (google.api.http) = {
            get: "/api/v1/logical_devices/{id}/ports"
        };
    }

    // Gets a logical device port
    rpc GetLogicalDevicePort(LogicalPortId) returns(LogicalPort) {
        option (google.api.http) = {
            get: "/api/v1/logical_devices/{id}/ports/{port_id}"
        };
    }

    // Enables a logical device port
    rpc EnableLogicalDevicePort(LogicalPortId) returns(google.protobuf.Empty) {
        option (google.api.http) = {
            post: "/api/v1/logical_devices/{id}/ports/{port_id}/enable"
        };
    }

    // Disables a logical device port
    rpc DisableLogicalDevicePort(LogicalPortId) returns(google.protobuf.Empty) {
        option (google.api.http) = {
            post: "/api/v1/logical_devices/{id}/ports/{port_id}/disable"
        };
    }

    // List all flows of a logical device
    rpc ListLogicalDeviceFlows(common.ID) returns(openflow_13.Flows) {
        option (google.api.http) = {
            get: "/api/v1/logical_devices/{id}/flows"
        };
    }

    // Update flow table for logical device
    rpc UpdateLogicalDeviceFlowTable(openflow_13.FlowTableUpdate)
            returns(google.protobuf.Empty) {
        option (google.api.http) = {
            post: "/api/v1/logical_devices/{id}/flows"
            body: "*"
        };
    }

    // Update meter table for logical device
    rpc UpdateLogicalDeviceMeterTable(openflow_13.MeterModUpdate)
            returns(google.protobuf.Empty) {
        option (google.api.http) = {
            post: "/api/v1/logical_devices/{id}/meters"
            body: "*"
        };
    }

    // List all meters of a logical device
    rpc ListLogicalDeviceMeters(common.ID) returns (openflow_13.Meters) {
        option (google.api.http) = {
            get: "/api/v1/logical_devices/{id}/meters"
        };
    }

    // List all flow groups of a logical device
    rpc ListLogicalDeviceFlowGroups(common.ID) returns(openflow_13.FlowGroups) {
        option (google.api.http) = {
            get: "/api/v1/logical_devices/{id}/flow_groups"
        };
    }

    // Update group table for device
    rpc UpdateLogicalDeviceFlowGroupTable(openflow_13.FlowGroupTableUpdate)
            returns(google.protobuf.Empty) {
        option (google.api.http) = {
            post: "/api/v1/logical_devices/{id}/flow_groups"
            body: "*"
        };
    }

    // List all physical devices controlled by the Voltha cluster
    rpc ListDevices(google.protobuf.Empty) returns(Devices) {
        option (google.api.http) = {
            get: "/api/v1/devices"
        };
    }

    // List all physical devices IDs controlled by the Voltha cluster
    rpc ListDeviceIds(google.protobuf.Empty) returns(common.IDs) {
        option (google.api.http) = {
            get: "/api/v1/deviceids"
        };
    }

    // Request to a voltha Core to reconcile a set of devices based on their IDs
    rpc ReconcileDevices(common.IDs) returns(google.protobuf.Empty) {
        option (google.api.http) = {
            post: "/api/v1/deviceids"
            body: "*"
        };
    }

    // Get more information on a given physical device
    rpc GetDevice(common.ID) returns(Device) {
        option (google.api.http) = {
            get: "/api/v1/devices/{id}"
        };
    }

    // Pre-provision a new physical device
    rpc CreateDevice(Device) returns(Device) {
        option (google.api.http) = {
            post: "/api/v1/devices"
            body: "*"
        };
    }

    // Enable a device.  If the device was in pre-provisioned state then it
    // will transition to ENABLED state.  If it was is DISABLED state then it
    // will transition to ENABLED state as well.
    rpc EnableDevice(common.ID) returns(google.protobuf.Empty) {
        option (google.api.http) = {
            post: "/api/v1/devices/{id}/enable"
        };
    }

    // Disable a device
    rpc DisableDevice(common.ID) returns(google.protobuf.Empty) {
        option (google.api.http) = {
            post: "/api/v1/devices/{id}/disable"
        };
    }

    // Reboot a device
    rpc RebootDevice(common.ID) returns(google.protobuf.Empty) {
        option (google.api.http) = {
            post: "/api/v1/devices/{id}/reboot"
        };
    }

    // Delete a device
    rpc DeleteDevice(common.ID) returns(google.protobuf.Empty) {
        option (google.api.http) = {
            delete: "/api/v1/devices/{id}/delete"
        };
    }

    // Request an image download to the standby partition
    // of a device.
    // Note that the call is expected to be non-blocking.
    rpc DownloadImage(ImageDownload) returns(common.OperationResp) {
        option (google.api.http) = {
            post: "/api/v1/devices/{id}/image_downloads/{name}"
            body: "*"
        };
    }

    // Get image download status on a device
    // The request retrieves progress on device and updates db record
    rpc GetImageDownloadStatus(ImageDownload) returns(ImageDownload) {
        option (google.api.http) = {
            get: "/api/v1/devices/{id}/image_downloads/{name}/status"
        };
    }

    // Get image download db record
    rpc GetImageDownload(ImageDownload) returns(ImageDownload) {
        option (google.api.http) = {
            get: "/api/v1/devices/{id}/image_downloads/{name}"
        };
    }

    // List image download db records for a given device
    rpc ListImageDownloads(common.ID) returns(ImageDownloads) {
        option (google.api.http) = {
            get: "/api/v1/devices/{id}/image_downloads"
        };
    }

    // Cancel an existing image download process on a device
    rpc CancelImageDownload(ImageDownload) returns(common.OperationResp) {
        option (google.api.http) = {
            delete: "/api/v1/devices/{id}/image_downloads/{name}"
        };
    }

    // Activate the specified image at a standby partition
    // to active partition.
    // Depending on the device implementation, this call
    // may or may not cause device reboot.
    // If no reboot, then a reboot is required to make the
    // activated image running on device
    // Note that the call is expected to be non-blocking.
    rpc ActivateImageUpdate(ImageDownload) returns(common.OperationResp) {
        option (google.api.http) = {
            post: "/api/v1/devices/{id}/image_downloads/{name}/image_update"
            body: "*"
        };
    }

    // Revert the specified image at standby partition
    // to active partition, and revert to previous image
    // Depending on the device implementation, this call
    // may or may not cause device reboot.
    // If no reboot, then a reboot is required to make the
    // previous image running on device
    // Note that the call is expected to be non-blocking.
    rpc RevertImageUpdate(ImageDownload) returns(common.OperationResp) {
        option (google.api.http) = {
            post: "/api/v1/devices/{id}/image_downloads/{name}/image_revert"
            body: "*"
        };
    }

    // List ports of a device
    rpc ListDevicePorts(common.ID) returns(Ports) {
        option (google.api.http) = {
            get: "/api/v1/devices/{id}/ports"
        };
    }

    // List pm config of a device
    rpc ListDevicePmConfigs(common.ID) returns(PmConfigs) {
        option (google.api.http) = {
            get: "/api/v1/devices/{id}/pm_configs"
        };
    }

    // Update the pm config of a device
    rpc UpdateDevicePmConfigs(voltha.PmConfigs) returns(google.protobuf.Empty) {
        option (google.api.http) = {
            post: "/api/v1/devices/{id}/pm_configs"
            body: "*"
        };
    }

    // List all flows of a device
    rpc ListDeviceFlows(common.ID) returns(openflow_13.Flows) {
        option (google.api.http) = {
            get: "/api/v1/devices/{id}/flows"
        };
    }

    // List all flow groups of a device
    rpc ListDeviceFlowGroups(common.ID) returns(openflow_13.FlowGroups) {
        option (google.api.http) = {
            get: "/api/v1/devices/{id}/flow_groups"
        };
    }

    // List device types known to Voltha
    rpc ListDeviceTypes(google.protobuf.Empty) returns(DeviceTypes) {
        option (google.api.http) = {
            get: "/api/v1/device_types"
        };
    }

    // Get additional information on a device type
    rpc GetDeviceType(common.ID) returns(DeviceType) {
        option (google.api.http) = {
            get: "/api/v1/device_types/{id}"
        };
    }

    // List all device sharding groups
    rpc ListDeviceGroups(google.protobuf.Empty) returns(DeviceGroups) {
        option (google.api.http) = {
            get: "/api/v1/device_groups"
        };
    }

    // Stream control packets to the dataplane
    rpc StreamPacketsOut(stream openflow_13.PacketOut)
        returns(google.protobuf.Empty) {
        // This does not have an HTTP representation
    }

    // Receive control packet stream
    rpc ReceivePacketsIn(google.protobuf.Empty)
        returns(stream openflow_13.PacketIn) {
        // This does not have an HTTP representation
    }

    rpc ReceiveChangeEvents(google.protobuf.Empty)
        returns(stream openflow_13.ChangeEvent) {
        // This does not have an HTTP representation
    }

    // Get additional information on a device group
    rpc GetDeviceGroup(common.ID) returns(DeviceGroup) {
        option (google.api.http) = {
            get: "/api/v1/device_groups/{id}"
        };
    }

    rpc CreateEventFilter(EventFilter) returns(EventFilter) {
        option (google.api.http) = {
            post: "/api/v1/event_filters"
            body: "*"
        };
    }

    // Get all filters present for a device
    rpc GetEventFilter(common.ID) returns(EventFilters) {
        option (google.api.http) = {
            get: "/api/v1/event_filters/{id}"
        };
    }

    rpc UpdateEventFilter(EventFilter) returns(EventFilter) {
        option (google.api.http) = {
            put: "/api/v1/event_filters/{id}"
            body: "*"
        };
    }

    rpc DeleteEventFilter(EventFilter) returns(google.protobuf.Empty) {
        option (google.api.http) = {
            delete: "/api/v1/event_filters/{id}"
        };
    }

    // Get all the filters present
    rpc ListEventFilters(google.protobuf.Empty) returns(EventFilters) {
        option (google.api.http) = {
            get: "/api/v1/event_filters"
        };
    }

    rpc GetImages(common.ID) returns(Images) {
        option (google.api.http) = {
            get: "/api/v1/devices/{id}/images"
        };
    }

    rpc SelfTest(common.ID) returns(SelfTestResponse) {
        option (google.api.http) = {
            post: "/api/v1/devices/{id}/self_test"
        };
    }

    // OpenOMCI MIB information
    rpc GetMibDeviceData(common.ID) returns(omci.MibDeviceData) {
        option (google.api.http) = {
            get: "/api/v1/openomci/{id}/mib"
        };
    }

    // OpenOMCI ALARM information
    rpc GetAlarmDeviceData(common.ID) returns(omci.AlarmDeviceData) {
        option (google.api.http) = {
            get: "/api/v1/openomci/{id}/alarm"
        };
    }

    // Simulate an Alarm
    rpc SimulateAlarm(SimulateAlarmRequest) returns(common.OperationResp) {
        option (google.api.http) = {
            post: "/api/v1/devices/{id}/simulate_larm"
            body: "*"
        };
    }
    rpc Subscribe (OfAgentSubscriber) returns (OfAgentSubscriber) {
    }

    rpc EnablePort(voltha.Port) returns(google.protobuf.Empty) {
        option (google.api.http) = {
            post: "/v1/EnablePort"
            body: "*"
        };
    }
    rpc DisablePort(voltha.Port) returns(google.protobuf.Empty) {
        option (google.api.http) = {
            post: "/v1/DisablePort"
            body: "*"
        };
    }

    // omci start and stop cli implementation
    rpc StartOmciTestAction(OmciTestRequest) returns(TestResponse) {
        option (google.api.http) = {
            post: "/api/v1/start_omci_test"
            body: "*"
        };
    }
}

