138 lines
2.7 KiB
Protocol Buffer
138 lines
2.7 KiB
Protocol Buffer
syntax = "proto3";
|
|
package ezshare;
|
|
|
|
import "google/protobuf/timestamp.proto";
|
|
|
|
option go_package = "gitea.benny.dog/torjus/ezshare/pb";
|
|
|
|
/////////////////////
|
|
// Common messages //
|
|
/////////////////////
|
|
message Empty {}
|
|
|
|
////////////////////////
|
|
// FILE RELATED STUFF //
|
|
////////////////////////
|
|
message File {
|
|
string file_id = 1;
|
|
bytes data = 2;
|
|
|
|
message Metadata {
|
|
google.protobuf.Timestamp uploaded_on = 1;
|
|
google.protobuf.Timestamp expires_on = 2;
|
|
string original_filename = 3;
|
|
};
|
|
|
|
Metadata metadata = 3;
|
|
};
|
|
|
|
|
|
// Service messages
|
|
// Upload
|
|
message UploadFileRequest {
|
|
bytes data = 1;
|
|
string original_filename = 2;
|
|
google.protobuf.Timestamp expires_on = 3;
|
|
}
|
|
message UploadFileResponse {
|
|
string id = 1;
|
|
string file_url = 2;
|
|
}
|
|
|
|
// Get
|
|
message GetFileRequest {
|
|
string id = 1;
|
|
}
|
|
message GetFileResponse {
|
|
File file = 1;
|
|
}
|
|
|
|
// Delete
|
|
message DeleteFileRequest {
|
|
string id = 1;
|
|
}
|
|
message DeleteFileResponse {
|
|
}
|
|
|
|
// List
|
|
message ListFilesRequest {}
|
|
message ListFilesResponse {
|
|
message ListFileInfo {
|
|
string file_id = 1;
|
|
File.Metadata metadata = 2;
|
|
}
|
|
repeated ListFileInfo files = 1;
|
|
}
|
|
|
|
service FileService {
|
|
rpc UploadFile(UploadFileRequest) returns (UploadFileResponse) {}
|
|
rpc GetFile(GetFileRequest) returns (GetFileResponse) {}
|
|
rpc DeleteFile(DeleteFileRequest) returns (DeleteFileResponse) {}
|
|
rpc ListFiles(ListFilesRequest) returns (ListFilesResponse) {}
|
|
}
|
|
|
|
////////////////////////
|
|
// USER RELATED STUFF //
|
|
////////////////////////
|
|
message User {
|
|
string id = 1;
|
|
string username = 2;
|
|
bytes hashed_password = 3;
|
|
enum Role {
|
|
UNKNOWN = 0;
|
|
VIEWONLY = 1;
|
|
USER = 2;
|
|
ADMIN = 3;
|
|
UNAPPROVED = 4;
|
|
}
|
|
Role user_role = 4;
|
|
bool active = 5;
|
|
}
|
|
|
|
// Register
|
|
message RegisterUserRequest {
|
|
string username = 1;
|
|
string password = 2;
|
|
}
|
|
message RegisterUserResponse {
|
|
string id = 1;
|
|
string token = 2;
|
|
}
|
|
|
|
// Login
|
|
message LoginUserRequest {
|
|
string username = 1;
|
|
string password = 2;
|
|
}
|
|
message LoginUserResponse {
|
|
bytes client_cert = 1;
|
|
bytes client_key = 2;
|
|
}
|
|
|
|
// List
|
|
message ListUsersRequest {
|
|
}
|
|
message ListUsersResponse {
|
|
repeated User users = 1;
|
|
}
|
|
|
|
// Approve
|
|
message ApproveUserRequest {
|
|
string user_id = 1;
|
|
}
|
|
|
|
|
|
// Change password
|
|
message ChangePasswordRequest {
|
|
string old_password = 1;
|
|
string new_password = 2;
|
|
}
|
|
|
|
service UserService {
|
|
rpc Register(RegisterUserRequest) returns (RegisterUserResponse) {}
|
|
rpc Login(LoginUserRequest) returns (LoginUserResponse) {}
|
|
rpc List(ListUsersRequest) returns (ListUsersResponse) {}
|
|
rpc Approve(ApproveUserRequest) returns (Empty) {}
|
|
rpc ChangePassword(ChangePasswordRequest) returns (Empty) {}
|
|
}
|