/**
 * Messages used in communication between servers and within server.
 * @author Mateusz Paciorek
 * @copyright (C) 2016 ACK CYFRONET AGH
 * @copyright This software is released under the MIT license cited in
 * 'LICENSE.txt'
 */

syntax = "proto2";
package one.clproto;

import "common_messages.proto";

// Generic provider request
message ProviderRequest {
    required bytes context_guid = 1;

    oneof provider_request { // list of all provider requests
        GetParent get_parent = 6;
        GetAcl get_acl = 7;
        SetAcl set_acl = 8;
        RemoveAcl remove_acl = 9;
        GetTransferEncoding get_transfer_encoding = 10;
        SetTransferEncoding set_transfer_encoding = 11;
        GetCdmiCompletionStatus get_cdmi_completion_status = 12;
        SetCdmiCompletionStatus set_cdmi_completion_status = 13;
        GetMimetype get_mimetype = 14;
        SetMimetype set_mimetype = 15;
        GetFilePath get_file_path = 16;
        GetFileDistribution get_file_distribution = 18;
        ReplicateFile replicate_file = 19;
        ReadMetadata read_metadata = 20;
        WriteMetadata write_metadata = 21;
        CheckPerms check_perms = 22;
        CreateShare create_share = 23;
        RemoveShare remove_share = 24;
        RemoveMetadata remove_metadata = 25;
        InvalidateFileReplica invalidate_file_replica = 26;
    }
}

message GetParent {
}

message Acl {
    required bytes value = 1;
}

message GetAcl {
}

message SetAcl {
    required Acl acl = 1;
}

message RemoveAcl {
}

message GetTransferEncoding {
}

message SetTransferEncoding {
    required bytes value = 1;
}

message GetCdmiCompletionStatus {
}

message SetCdmiCompletionStatus {
    required bytes value = 1;
}

message GetMimetype {
}

message SetMimetype {
    required bytes value = 2;
}

message GetFilePath {
}

message GetFileDistribution {
}

message ReplicateFile {
    required bytes provider_id = 1;
    optional FileBlock block = 2;
}

message Metadata {
    required bytes type = 1;
    required bytes value = 2;
}

message ReadMetadata {
    required bytes type = 1;
    repeated bytes names = 2;
    optional bool inherited = 3 [default = false];
}

message WriteMetadata {
    required Metadata metadata = 1;
    repeated bytes names = 2;
}

message CheckPerms {
    required OpenFlag flag = 1;
}

message CreateShare {
    required bytes name = 1;
}

message RemoveShare {
}

message RemoveMetadata {
    required bytes type = 1;
}

// Generic provider response
message ProviderResponse {
    required Status status = 1;

    oneof provider_response { // list of all provider responses
        TransferEncoding transfer_encoding = 4;
        CdmiCompletionStatus cdmi_completion_status = 5;
        Mimetype mimetype = 6;
        Acl acl = 7;
        Dir dir = 8;
        FilePath file_path = 9;
        FileDistribution file_distribution = 10;
        Metadata metadata = 11;
        Share share = 12;
    }
}

message TransferEncoding {
    required bytes value = 1;
}

message CdmiCompletionStatus {
    required bytes value = 1;
}

message Mimetype {
    required bytes value = 1;
}

message FilePath {
    required bytes value = 1;
}

message ProviderFileDistribution {
    required bytes provider_id = 1;
    repeated FileBlock blocks = 2;
}

message FileDistribution {
    repeated ProviderFileDistribution provider_file_distributions = 1;
}

message Share {
    required bytes share_id = 1;
    required bytes share_file_uuid = 2;
}

message InvalidateFileReplica {
    required bytes provider_id = 1;
    optional bytes migration_provider_id = 2;
}
