syntax = "proto3";

option go_package = "github.com/opencord/device-management-interface/v3/go/dmi";
package dmi;

import "dmi/commons.proto";

// Protos for modeling a software image and it's status

message ImageVersion {
    string image_name = 1;
    string version = 2;
}

message ImageInformation {
    ImageVersion image = 1;
    // Script used by the device specific managers to install the image.
    // Script must be included in the object downloaded from the image_url
    string image_install_script = 2;
    // Location of the image and installation script, authentication (user/pass) if any should be in the url string
    // The image_url would contain the protocol, credentials, the IP address/DNS of the server and the path of the file
    // e.g. sftp://download_user:download_pass@192.168.0.1:22/images/image1
    string image_url = 3;
    // SHA-256 sum of the image (sha256sum on Linux)
    string sha256sum = 5;
}

message ImageStatus {
    enum ImageState {
        UNDEFINED_STATE = 0;
        COPYING_IMAGE = 1;
        INSTALLING_IMAGE = 2;
        COMMITTING_IMAGE = 3;
        REBOOTING_DEVICE = 4;
        UPGRADE_COMPLETE = 5;
        UPGRADE_FAILED = 6;
        ACTIVATION_COMPLETE = 7;
        ACTIVATION_FAILED = 8;
    }

    enum Reason {
        UNDEFINED_REASON = 0;
        ERROR_IN_REQUEST = 1;
        INTERNAL_ERROR = 2;
        DEVICE_IN_WRONG_STATE = 3;
        INVALID_IMAGE = 4;
        WRONG_IMAGE_CHECKSUM = 5;
        OPERATION_ALREADY_IN_PROGRESS = 6;
        UNKNOWN_DEVICE = 7;
        // The DM implementations should have retry mechanisms (timeout values dependant on specific implementations)
        // and even after those if the operation cannot be completed/reached then return error with reason as DEVICE_NOT_REACHABLE
        DEVICE_NOT_REACHABLE = 8;
    }

    Status status  = 1;
    Reason reason = 2;
    ImageState state = 3;
    // description contains more information about the current state of the procedure and is device dependant
    string description = 4;
}
