Skip to content

Commit

Permalink
feat(tui): prepared API for TUI
Browse files Browse the repository at this point in the history
  • Loading branch information
Wittano committed May 13, 2024
1 parent f4b4432 commit 10fc24b
Show file tree
Hide file tree
Showing 6 changed files with 219 additions and 0 deletions.
35 changes: 35 additions & 0 deletions protobuf/admin.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
syntax = "proto3";

import "google/protobuf/empty.proto";
import "protobuf/request.proto";
package komputer;

enum Privileges {
AUDIO = 0;
JOKE = 1;
FEATURE_MANAGEMENT = 2;
}

message AdminRegistration {
string name = 1;
oneof auth_method {
string password = 2;
string public_key = 3;
}
string guildID = 4;
repeated Privileges privileges = 5;
}

message AdminData {
bytes object_id = 1;
string name = 2;
string guildID = 3;
repeated Privileges privileges = 4;
}

service AdminService {
rpc List(Pagination) returns (stream AdminData);
rpc New(AdminRegistration) returns (ObjectID);
rpc Update(AdminRegistration) returns (AdminData);
rpc Remove(ObjectID) returns (google.protobuf.Empty);
}
40 changes: 40 additions & 0 deletions protobuf/audio.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
syntax = "proto3";

import "google/protobuf/empty.proto";
import "protobuf/request.proto";
package komputer;

enum FileFormat {
MP3 = 0;
MP4 = 1;
}

message AudioInfo {
string name = 1;
FileFormat type = 2;
}

message Audio {
AudioInfo info = 1;
bytes file = 2;
}

message File {
bytes content = 1;
uint64 size = 2;
}

message UploadAudioResponse {
bytes uuid = 1;
uint32 size = 2;
}

service AudioService {
rpc List(komputer.Pagination) returns (stream AudioInfo);
rpc Add(stream Audio) returns (UploadAudioResponse);
rpc Remove(NameOrIdRequest) returns (google.protobuf.Empty);
}

service AudioFileService {
rpc Download(FindById) returns (stream File);
}
44 changes: 44 additions & 0 deletions protobuf/joke.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
syntax = "proto3";

import "google/protobuf/empty.proto";
import "protobuf/request.proto";
package komputer;

enum Type {
SINGLE = 0;
TWO_PART = 1;
}

enum Category {
PROGRAMMING = 0;
MISC = 1;
DARK = 2;
YOMAMA = 3;
Any = 4;
}

message Joke {
bytes id = 1;
string answer = 2;
optional string question = 3;
Type type = 4;
Category category = 5;
string guild_id = 6;
}

message JokeID {
oneof id {
uint64 api_id = 1;
bytes object_id = 2;
}
}

message DatabaseObjectID {
bytes object_id = 1;
}

service JokeService {
rpc Find(komputer.FindById) returns (Joke);
rpc Add(Joke) returns (JokeID);
rpc Remove(DatabaseObjectID) returns (google.protobuf.Empty);
}
36 changes: 36 additions & 0 deletions protobuf/logs.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
syntax = "proto3";

import "google/protobuf/empty.proto";
import "google/protobuf/timestamp.proto";
package komputer;

enum Level {
INFO = 0;
DEBUG = 1;
WARN = 2;
ERROR = 3;
}

message Log {
bytes msg = 1;
optional Level level = 2;
}

message LogDateRange {
google.protobuf.Timestamp from = 1;
google.protobuf.Timestamp to = 2;
}

message LogData {
bytes data = 1;
uint32 size = 2;
}

service StreamLogsService {
rpc Get(google.protobuf.Empty) returns (stream Log);
}

service LogManager {
rpc CleanUp(LogDateRange) returns (google.protobuf.Empty);
rpc Download(LogDateRange) returns (stream LogData);
}
30 changes: 30 additions & 0 deletions protobuf/options.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
syntax = "proto3";

package komputer;

enum Features {
JOKE_DEV = 0;
HUMOR_API = 1;
DATABASE = 2;
}

message DatabaseConfig {
string uri = 1;
}

message HumorAPIConfig {
string api_key = 1;
}

message FeatureStatus {
Features option = 1;
bool value = 2;
oneof config {
DatabaseConfig database = 3;
HumorAPIConfig humor_api = 4;
}
}

service ConfigService {
rpc Update(FeatureStatus) returns (FeatureStatus);
}
34 changes: 34 additions & 0 deletions protobuf/request.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
syntax = "proto3";

import "google/protobuf/empty.proto";
package komputer;

message Pagination {
uint32 page = 1;
uint32 size = 2;
}

message FindById {
oneof identity {
uint64 id = 1;
bytes uuid = 2;
}
optional Pagination page = 4;
}

message UUID {
bytes uuid = 1;
}

message ObjectID {
bytes object_id = 1;
}

message NameOrIdRequest {
oneof query {
uint64 id = 1;
bytes uuid = 2;
string name = 3;
}
optional Pagination page = 4;
}

0 comments on commit 10fc24b

Please sign in to comment.