ezshare/protos/ezshare.proto

200 lines
4.1 KiB
Protocol Buffer
Raw Normal View History

2021-12-03 22:04:09 +00:00
syntax = "proto3";
package ezshare;
import "google/protobuf/timestamp.proto";
2021-12-05 10:08:09 +00:00
option go_package = "gitea.benny.dog/torjus/ezshare/pb";
/////////////////////
// Common messages //
/////////////////////
message Empty {}
////////////////////////
// FILE RELATED STUFF //
////////////////////////
2021-12-03 22:04:09 +00:00
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;
2021-12-06 19:13:04 +00:00
string passcode = 4;
int64 current_views = 5;
int64 max_views = 6;
2021-12-07 05:51:14 +00:00
string owner = 7;
2021-12-03 22:04:09 +00:00
};
Metadata metadata = 3;
};
// Service messages
// Upload
message UploadFileRequest {
bytes data = 1;
string original_filename = 2;
google.protobuf.Timestamp expires_on = 3;
2021-12-06 19:13:04 +00:00
int64 max_views = 4;
bool with_passcode = 5;
2021-12-03 22:04:09 +00:00
}
message UploadFileResponse {
string id = 1;
string file_url = 2;
}
// Get
message GetFileRequest {
string id = 1;
2021-12-06 19:13:04 +00:00
string passcode = 2;
2021-12-03 22:04:09 +00:00
}
message GetFileResponse {
File file = 1;
}
2021-12-04 10:30:42 +00:00
// 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;
}
2021-12-03 22:04:09 +00:00
service FileService {
rpc UploadFile(UploadFileRequest) returns (UploadFileResponse) {}
rpc GetFile(GetFileRequest) returns (GetFileResponse) {}
2021-12-04 10:30:42 +00:00
rpc DeleteFile(DeleteFileRequest) returns (DeleteFileResponse) {}
rpc ListFiles(ListFilesRequest) returns (ListFilesResponse) {}
2021-12-05 10:08:09 +00:00
}
////////////////////////
// USER RELATED STUFF //
////////////////////////
message User {
string id = 1;
string username = 2;
bytes hashed_password = 3;
enum Role {
2021-12-05 13:55:18 +00:00
UNKNOWN = 0;
2021-12-07 05:51:14 +00:00
UNAPPROVED = 1;
VIEWONLY = 4;
USER = 7;
ADMIN = 10;
2021-12-05 10:08:09 +00:00
}
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 {
2021-12-06 05:08:17 +00:00
string username = 1;
string password = 2;
2021-12-05 10:08:09 +00:00
}
message LoginUserResponse {
2021-12-06 05:08:17 +00:00
bytes client_cert = 1;
bytes client_key = 2;
2021-12-05 10:08:09 +00:00
}
// List
message ListUsersRequest {
}
message ListUsersResponse {
repeated User users = 1;
}
// Approve
message ApproveUserRequest {
string user_id = 1;
}
2021-12-06 05:53:49 +00:00
// Change password
message ChangePasswordRequest {
string old_password = 1;
string new_password = 2;
}
2021-12-05 10:08:09 +00:00
service UserService {
rpc Register(RegisterUserRequest) returns (RegisterUserResponse) {}
rpc Login(LoginUserRequest) returns (LoginUserResponse) {}
rpc List(ListUsersRequest) returns (ListUsersResponse) {}
rpc Approve(ApproveUserRequest) returns (Empty) {}
2021-12-06 05:53:49 +00:00
rpc ChangePassword(ChangePasswordRequest) returns (Empty) {}
2021-12-05 10:08:09 +00:00
}
2021-12-06 18:14:39 +00:00
///////////////////////////////
// Certificate related stuff //
///////////////////////////////
// List
message ListCertificatesResponse {
message CertificateInfo {
string serial = 1;
string owner_id = 2;
string owner_username = 3;
}
repeated CertificateInfo certificates = 1;
}
// Revoke
message RevokeCertificateRequest {
string serial = 1;
}
service CertificateService {
rpc ListCertificates(Empty) returns (ListCertificatesResponse) {}
rpc RevokeCertificate(RevokeCertificateRequest) returns (Empty) {}
2021-12-08 04:42:25 +00:00
}
//////////////////////////
// Binary related stuff //
//////////////////////////
message Binary {
string version = 1;
string arch = 2;
string os = 3;
bytes data = 4;
}
message UploadBinariesRequest {
repeated Binary binaries = 2;
}
message GetBinaryRequest {
string version = 1;
string arch = 2;
string os = 3;
}
message LatestVersionResponse {
string version = 1;
}
service BinaryService {
rpc UploadBinaries(UploadBinariesRequest) returns (Empty) {}
rpc GetBinary(GetBinaryRequest) returns (Binary) {}
rpc GetLatestVersion(Empty) returns (LatestVersionResponse) {}
}