Skip to content

Update dataStorage proto file in order to add some more rpc calls #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
326 changes: 326 additions & 0 deletions protos/data_storage/storage.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,326 @@
syntax = "proto3";

package data_storage;


// Interface exported by the server.
service DataStorage {
// A simple RPC used for registering new users.
// username is obtained from input and the result will be
// successful if the username isn't already taken.
// username shouldn't contain whitespace or *, ?, $, ', ", etc characters.
// In case of the failure the rpc call is aborted and a proper message is shown to user.
rpc RegisterUser (RegisterUserRequest) returns (RegisterUserResponse);

// A simple RPC used for removing old users.
// successful if the username is already registered.
// In case of failure a proper message will be returned.
// In case of the failure the rpc call is aborted and a proper message is shown to user.
rpc DeregisterUser(DeregisterUserRequest) returns (DeregisterUserResponse);

// A simple RPC used for setting the volume limit
// for a specified username.
// Request will be failed if the username doesn't exist or
// the requested volume is less than the used volume of the user.
// In case of the failure the rpc call is aborted and a proper message is shown to user.
rpc SetVolume (SetVolumeRequest) returns (SetVolumeResponse);

// A simple RPC used for getting the amount of used, total and remaing
// volume for the specified username.
// request will fail if the username isn't registered.
// In case of the failure the rpc call is aborted and a proper message is shown to user.
rpc GetVolumeReport (GetVolumeRequest) returns (GetVolumeResponse);

// A simple RPC used for creating a new folder in the specified path
// for the spcified useranme
// fails if:
// - username isn't registered
// - the path can't be reached(missing folder between the path)
// - the destination folder contains a folder with the same name.
// - the folder name is recycleBin and the path is /username
// if successful a boolean and the new path for folder is returened.
// In case of the failure the rpc call is aborted and a proper message is shown to user.
rpc CreateFolder (CreateFolderRequest) returns (CreateFolderResponse);

// A simple RPC used for deleting a content in the specified path
// for the specified username.
// fails if:
// - username isn't registered
// - the specified path doesn't exist
// - the specified folder is not empty.
// - the user doesn't have access to this path
// - the user tries to remove recycleBin or base folder
// if succesful, a true boolean is returened.
// NOTE that the removed file or folder will be stored in recycleBin.
// In case of the failure the rpc call is aborted and a proper message is shown to user.
rpc Remove (RemoveRequest) returns (RemoveResponse);

// A simple RPC used for deleting a content in the specified path
// for the specified username.
// fails if:
// - username isn't registered
// - the specified path doesn't exist
// - the user doesn't have access to this path
// - the user tries to remove recycleBin or base folder
// if succesful, a true boolean is returened.
// NOTE that the different between Remove and ForceRemove is that
// ForceRemove can remove the folder with other contents in it and
// the removed folder will be in recycleBin with its contents as
// structured as before.
// In case of the failure the rpc call is aborted and a proper message is shown to user.
rpc ForceRemove (ForceRemoveRequest) returns (ForceRemoveResponse);

// A simple RPC used for emptying the recycleBin folder
// for the specified username.
// fails if username isn't registered.
// if successful, a true boolean will be returned.
// In case of the failure the rpc call is aborted and a proper message is shown to user.
rpc EmptyRecycleBin (EmptyRecycleBinRequest) returns (EmptyRecycleBinResponse);

// A simple RPC used for browsing the data of the specified username.
// obtains the base path and username from the input and
// returns the list of files and folders created in the base path.
// fails if the username or the base path are not correct.
// In case of the failure the rpc call is aborted and a proper message is shown to user.
rpc BrowseData (BrowseDataRequest) returns (BrowseDataResponse);

// A simple RPC used for check if a specified folder or file is uploaded
// for the specified user.
// fails if:
// - the user is not registered.
// if successful the path of the file or folder is returned
// and if the content doesn't exist in the user's filesystem,
// an empty path will be returned.
// In case of the failure the rpc call is aborted and a proper message is shown to user.
rpc Search (SearchRequest) returns (SearchResponse);

// A simple RPC used for getting the report of the general disk usage of the system..
// no input is required.
// result contains the status of the system.
// In case of the failure the rpc call is aborted and a proper message is shown to user.
rpc GetSystemicReport (GetSystemicReportRequest) returns (GetSystemicReportResponse);

// A simple rpc used for copying a path from a source to a destination.
// fails if:
// - the username isn't registered prior to the action.
// - the source or destination path doesn't exist in the user's filesystem.
// - the username doesn't have access to the source or destination path.
// - there isn't enough space for the copying action to be completed.
// - the destination path basename is a file.
// - source and destination paths point at the same place.
// - a content with same name exists in the destination path.
// In case of the failure the rpc call is aborted and a proper message is shown to user.
rpc Copy (CopyRequest) returns (CopyResponse);

// A simple rpc used for cutting a path from a source and pasting it to a destination.
// fails if:
// - the username isn't registered prior to the action.
// - the source or destination path doesn't exist in the user's filesystem.
// - the username doesn't have access to the source or destination path.
// - there isn't enough space for the copying action to be completed.
// - the destination path basename is a file.
// - source and destination paths point at the same place.
// - a content with same name exists in the destination path.
// In case of the failure the rpc call is aborted and a proper message is shown to user.
rpc Cut (CutRequest) returns (CutResponse);

// A simple rpc used for the size of the specified paths in bytes.
// fails if:
// - the username isn't registered.
// - the spcified path doesn't exists.
// In case of the failure the rpc call is aborted and a proper message is shown to user.
rpc GetPathSize(GetPathSizeRequest) returns (GetPathSizeResponse);

// A simple rpc used for getting the userTree.
// user tree is a string which resembles the structure of the filesystem
// for the specified user.
// fails if:
// - the username isn't registered.
// In case of the failure the rpc call is aborted and a proper message is shown to user.
rpc GetUserTree(GetUserTreeRequest) returns (GetUserTreeResponse);

// A server-to-client RPC, used for downloading the specified file.
// The following content should be provided for data download.
// - username
// - path
// - file_name
// - extension
// A byte stream which contains the file will be returned if all the above
// information is correctly specified.
// In case of the failure the rpc call is aborted and a proper message is shown to user.
rpc DownloadFile (DownloadFileRequest) returns (stream DownloadFileResponse);

// A client-to-server RPC, used for uploading the input data into the system.
// obtains file metadata and chunk_bytes from input stream and returns
// the path in which the data is stored (virtual path of the user).
// In case of the failure the rpc call is aborted and a proper message is shown to user.
rpc UploadFile (stream UploadFileRequest) returns (UploadFileResponse);
}


message RegisterUserRequest {
string username = 1;
int64 initial_volume = 2;
}

message RegisterUserResponse {
string registered_username = 1;
}

message DeregisterUserRequest{
string username = 1;
}

message DeregisterUserResponse{
string deregistered_username = 1;
}

message SetVolumeRequest {
string username = 1;
int64 new_volume = 2;
}

message SetVolumeResponse {
string newly_set_volume = 1;
}

message GetVolumeRequest {
string username = 1;
}

message VolumeReport {
int64 total_allocated_volume = 1;
int64 total_used_volume = 2;
int64 remaining_volume = 3;
}

message GetVolumeResponse {
VolumeReport volume_report = 1;
}

message CreateFolderRequest {
string username = 1;
string folder_name = 2;
string path = 3;
}

message CreateFolderResponse {
string path = 1;
}

message RemoveRequest {
string username = 1;
string path = 2;
}

message RemoveResponse {
string removed_path = 1;
}

message ForceRemoveRequest {
string username = 1;
string path = 2;
}

message ForceRemoveResponse {
string force_removed_path = 1;
}

message EmptyRecycleBinRequest {
string username = 1;
}

message EmptyRecycleBinResponse {
int64 total_used_volume = 1;
}

message BrowseDataRequest {
string username = 1;
string path = 2;
}

message BrowseDataResponse {
repeated string contents = 1;
}

message SearchRequest {
string username = 1;
string content = 2;
}

message SearchResponse {
string path = 1;
string content_type = 2;
}

message GetSystemicReportRequest {}

message GetSystemicReportResponse {
int64 number_of_users = 1;
VolumeReport volume_report = 2;
}

message MetaData {
string username = 1;
string path = 2;
string filename = 3;
string extension = 4;
int64 file_size = 5;
}

message CopyRequest {
string username = 1;
string source_path = 2;
string destination_path = 3;
}

message CopyResponse {
int64 new_usded_volume = 1;
}

message CutRequest {
string username = 1;
string source_path = 2;
string destination_path = 3;
}

message CutResponse {
int64 new_used_volume = 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

مگه با کات و پیست حجم عوض می‌شه؟

}

message GetPathSizeRequest {
string username = 1;
string path = 2;
}

message GetPathSizeResponse {
int64 size_in_bytes = 1;
}

message GetUserTreeRequest {
string username = 1;
}

message GetUserTreeResponse {
string user_tree = 1;
}

message DownloadFileRequest {
string username = 1;
string path = 2;
}

message DownloadFileResponse {
bytes chunk_data = 1;
}

message UploadFileRequest {
oneof request {
MetaData metadata = 1;
bytes chunk_data = 2;
}
}

message UploadFileResponse {
string path = 1;
}
8 changes: 7 additions & 1 deletion protos/stubs/stubs_configs.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"_comment": {
"notice": "Allowed ports for services are 50051-50999. update next_port if you want to add more services",
"next_port": 50054
"next_port": 50055
},

"services": [
Expand All @@ -22,6 +22,12 @@
"proto_file_path": "protos/platform_management/wallet_server.proto",
"host": "0.0.0.0",
"port": 50053
},
{
"name": "DataStorage",
"proto_file_path": "protos/data_storage/storage.proto",
"host": "0.0.0.0",
"port": 50054
}
]
}