/**
 * Generic client and server messages.
 * This file should contain all messages that can be sent between the client and
 * the server.
 * @author Krzysztof Trzepla
 * @copyright (C) 2015 ACK CYFRONET AGH
 * @copyright This software is released under the MIT license cited in
 * 'LICENSE.txt'
 */

syntax = "proto2";
package one.clproto;

import "fuse_messages.proto";
import "event_messages.proto";
import "common_messages.proto";
import "stream_messages.proto";
import "handshake_messages.proto";
import "diagnostic_messages.proto";
import "proxyio_messages.proto";
import "dbsync_messages.proto";
import "provider_messages.proto";
import "remote_driver_messages.proto";
import "rtransfer_messages.proto";
// This file is required by Oneprovider for RTransfer
import "gwproto.proto";

// Messages that can be sent by the client to the server.
message ClientMessage {
    optional bytes         message_id     = 1; // should be set when response is
                                               // expected
    optional MessageStream message_stream = 2; // identifies message as part of
                                               // a stream
    oneof message_body { // list of messages that can be sent from
                         // the client to the server
        // handshake_messages.proto
        ClientHandshakeRequest   client_handshake_request          = 3;
        ProviderHandshakeRequest provider_handshake_request        = 4;
        Macaroon                 macaroon                          = 5;

        // common_messages.proto
        Status                      status                         = 6;

        // stream_messages.proto
        MessageStreamReset          message_stream_reset           = 7;
        MessageRequest              message_request                = 8;
        MessageAcknowledgement      message_acknowledgement        = 9;
        EndOfMessageStream          end_of_stream                  = 10;

        // event_messages.proto
        Events                      events                         = 11;
        Subscription                subscription                   = 12;
        SubscriptionCancellation    subscription_cancellation      = 13;
        FlushEvents                 flush_events                   = 14;

        // diagnostic_messages.proto
        Ping                        ping                           = 15;
        GetProtocolVersion          get_protocol_version           = 16;
        GetConfiguration            get_configuration              = 17;

        // fuse_messages.proto
        FuseRequest                 fuse_request                   = 18;

        // proxyio_messages.proto
        ProxyIORequest              proxyio_request                = 19;

        // dbsync_messages.proto
        DBSyncRequest               dbsync_request                 = 20;
        DBSyncMessage               dbsync_message                 = 21;

        // provider_messages.proto
        ProviderRequest             provider_request               = 22;

        // remote_driver_messages.proto
        GetRemoteDocument           get_remote_document            = 23;

        // rtransfer_messages.proto
        GenerateRTransferConnSecret generate_rtransfer_conn_secret = 24;
        GetRTransferNodesIPs        get_rtransfer_nodes_ips        = 27;
    }
    
    optional bytes proxy_session_id                                = 25;
    optional Macaroon proxy_session_macaroon                       = 26;
}

// Messages that can be sent by the server to the client.
message ServerMessage {
    optional bytes         message_id     = 1; // should be set when response is
                                               // expected
    optional MessageStream message_stream = 2; // identifies message as part of
                                               // a stream
    oneof message_body { // list of messages that can be sent from
                         // the server to the client
        // handshake_messages.proto
        HandshakeResponse        handshake_response        = 3;

        // common_messages.proto
        Status                   status                    = 4;

        // stream_messages.proto
        MessageStreamReset       message_stream_reset      = 5;
        MessageRequest           message_request           = 6;
        MessageAcknowledgement   message_acknowledgement   = 7;
        EndOfMessageStream       end_of_stream             = 8;

        // event_messages.proto
        Events                   events                    = 9;
        Subscription             subscription              = 10;
        SubscriptionCancellation subscription_cancellation = 11;

        // diagnostic_messages.proto
        Pong                     pong                      = 12;
        ProtocolVersion          protocol_version          = 13;
        Configuration            configuration             = 14;

        // fuse_messages.proto
        FuseResponse             fuse_response             = 15;

        // proxyio_messages.proto
        ProxyIOResponse          proxyio_response          = 16;

        // provider_messages.proto
        ProviderResponse         provider_response         = 17;

        // remote_driver_messages.proto
        RemoteDocument           remote_document           = 18;

        // heartbeat or unknown error
        ProcessingStatus         processing_status         = 19;

        // rtransfer_messages.proto
        RTransferConnSecret      rtransfer_conn_secret     = 20;
        RTransferNodesIPs        rtransfer_nodes_ips       = 22;
    }

    optional bytes proxy_session_id                        = 21;
}

enum ProcessingCode {
    IN_PROGRESS = 1;
    ERROR       = 2; // unknown error
}

message ProcessingStatus {
    required ProcessingCode code = 1;
}