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 (DataKeyResponse) {}

    // 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 {}

// 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;
}

// DataKeyResponse is a simple response
message DataKeyResponse {}

// 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 {
    // The value of the key
    string value = 3;
}