Bot controller has keys endpoints

This commit is contained in:
2025-08-23 19:52:05 +08:00
parent d9620fd6a4
commit 953bf5d4de
5 changed files with 370 additions and 16 deletions

View File

@@ -308,4 +308,39 @@ public static class Leveling
512000, // Level 13
1024000
];
}
public class ApiKeyReference : ModelBase
{
public Guid Id { get; set; } = Guid.NewGuid();
public string Label { get; set; } = null!;
public Guid AccountId { get; set; }
public Guid SessionId { get; set; }
public string? Key { get; set; }
public ApiKey ToProtoValue()
{
return new ApiKey
{
Id = Id.ToString(),
Label = Label,
AccountId = AccountId.ToString(),
SessionId = SessionId.ToString(),
Key = Key
};
}
public static ApiKeyReference FromProtoValue(ApiKey proto)
{
return new ApiKeyReference
{
Id = Guid.Parse(proto.Id),
AccountId = Guid.Parse(proto.AccountId),
SessionId = Guid.Parse(proto.SessionId),
Label = proto.Label,
Key = proto.Key
};
}
}

View File

@@ -5,6 +5,7 @@ package proto;
option csharp_namespace = "DysonNetwork.Shared.Proto";
import "google/protobuf/timestamp.proto";
import "google/protobuf/wrappers.proto";
import "account.proto";
import "file.proto";
@@ -136,15 +137,41 @@ message DeleteBotAccountResponse {
bool success = 1; // Whether the deletion was successful
}
message ApiKey {
string id = 1;
string label = 2;
string account_id = 3;
string session_id = 4;
google.protobuf.StringValue key = 5;
}
message GetApiKeyRequest {
string id = 1;
}
message ListApiKeyRequest {
string automated_id = 1;
}
message GetApiKeyBatchResponse {
repeated ApiKey data = 1;
}
message DeleteApiKeyResponse {
bool success = 1;
}
// This service should be implemented by the Pass service to handle the creation, update, and deletion of bot accounts
service BotAccountReceiverService {
// Create a new bot account
rpc CreateBotAccount(CreateBotAccountRequest) returns (CreateBotAccountResponse);
// Update an existing bot account
rpc UpdateBotAccount(UpdateBotAccountRequest) returns (UpdateBotAccountResponse);
// Delete a bot account
rpc DeleteBotAccount(DeleteBotAccountRequest) returns (DeleteBotAccountResponse);
rpc GetApiKey(GetApiKeyRequest) returns (ApiKey);
rpc ListApiKey(ListApiKeyRequest) returns (GetApiKeyBatchResponse);
rpc CreateApiKey(ApiKey) returns (ApiKey);
rpc UpdateApiKey(ApiKey) returns (ApiKey);
rpc RotateApiKey(GetApiKeyRequest) returns (ApiKey);
rpc DeleteApiKey(GetApiKeyRequest) returns (DeleteApiKeyResponse);
}