syntax = "proto3";

option go_package = "github.com/mdiluz/rove/pkg/accounts";

package accounts;

service Accountant {
    // Register should create a new account in the database
    // It will return an error if the account already exists
    rpc Register(RegisterInfo) returns (RegisterResponse) {}

    // AssignValue assigns a key-value pair to an account, or overwrites an existing key
    rpc AssignValue(DataKeyValue) returns (Response) {}

    // GetValue will get the value for a key for an account
    rpc GetValue(DataKey) returns (DataResponse) {}
}

// RegisterInfo contains the information needed to register an account
message RegisterInfo {
    // The name for the account, must be unique
    string name = 1;
}

// RegisterResponse is the response information from registering an account
message RegisterResponse {
    // The error value should only be populated if success is false
    bool success = 1;
    string error = 2;
}

// DataKeyValue represents a simple key value pair to assign to an account
message DataKeyValue {
    // The account to assign the new key value pair to
    string account = 1;
    
    // The key value pair to assign
    string key = 2;
    string value = 3;
}

// Response is a simple response with success and error
message Response {
    // error should only be populated if success is false
    bool success = 1;
    string error = 2;
}

// DataKey describes a simple key value with an account, for fetching
message DataKey {
    // The account to fetch data for
    string account = 1;

    // The key to fetch
    string key = 2;
}

// DataResponse describes a data fetch response
message DataResponse {
    // error should only be populated if success is false
    bool success = 1;
    string error = 2;

    // The value of the key
    string value = 3;
}