syntax = "proto3";

package v1;

option go_package = "github.com/kubernetes-csi/csi-proxy/client/api/disk/v1";

service Disk {
    // ListDiskLocations returns locations <Adapter, Bus, Target, LUN ID> of all
    // disk devices enumerated by the host.
    rpc ListDiskLocations(ListDiskLocationsRequest) returns (ListDiskLocationsResponse) {}

    // PartitionDisk initializes and partitions a disk device with the GPT partition style
    // (if the disk has not been partitioned already) and returns the resulting volume device ID.
    rpc PartitionDisk(PartitionDiskRequest) returns (PartitionDiskResponse) {}

    // Rescan refreshes the host's storage cache.
    rpc Rescan(RescanRequest) returns (RescanResponse) {}

    // ListDiskIDs returns a map of DiskID objects where the key is the disk number.
    rpc ListDiskIDs(ListDiskIDsRequest) returns (ListDiskIDsResponse) {}

    // GetDiskStats returns the stats of a disk (currently it returns the disk size).
    rpc GetDiskStats(GetDiskStatsRequest) returns (GetDiskStatsResponse) {}

    // SetDiskState sets the offline/online state of a disk.
    rpc SetDiskState(SetDiskStateRequest) returns (SetDiskStateResponse) {}

    // GetDiskState gets the offline/online state of a disk.
    rpc GetDiskState(GetDiskStateRequest) returns (GetDiskStateResponse) {}
}

message ListDiskLocationsRequest {
    // Intentionally empty.
}

message DiskLocation {
    string Adapter = 1;
    string Bus = 2;
    string Target = 3;
    string LUNID = 4;
}

message ListDiskLocationsResponse {
    // Map of disk number and <adapter, bus, target, lun ID> associated with each disk device.
    map <uint32, DiskLocation> disk_locations = 1;
}

message PartitionDiskRequest {
    // Disk device number of the disk to partition.
    uint32 disk_number = 1;
}

message PartitionDiskResponse {
    // Intentionally empty.
}

message RescanRequest {
    // Intentionally empty.
}

message RescanResponse {
    // Intentionally empty.
}

message ListDiskIDsRequest {
    // Intentionally empty.
}

message DiskIDs {
    // The disk page83 id.
    string page83 = 1;
    // The disk serial number.
    string serial_number = 2;
}

message ListDiskIDsResponse {
    // Map of disk numbers and disk identifiers associated with each disk device.
    map <uint32, DiskIDs> diskIDs = 1;  // the case is intentional for protoc to generate the field as DiskIDs
}

message GetDiskStatsRequest {
    // Disk device number of the disk to get the stats from.
    uint32 disk_number = 1;
}

message GetDiskStatsResponse {
    // Total size of the volume.
    int64 total_bytes = 1;
}

message SetDiskStateRequest {
    // Disk device number of the disk.
    uint32 disk_number = 1;

    // Online state to set for the disk. true for online, false for offline.
    bool is_online = 2;
}

message SetDiskStateResponse {
    // Intentionally empty.
}

message GetDiskStateRequest {
    // Disk device number of the disk.
    uint32 disk_number = 1;
}

message GetDiskStateResponse {
    // Online state of the disk. true for online, false for offline.
    bool is_online = 1;
}
