syntax = "proto3";

package com.ql.api;

message EnvItem {
  optional int32 id = 1;
  optional string name = 2;
  optional string value = 3;
  optional string remarks = 4;
  optional int32 status = 5;
  optional int64 position = 6;
}

message GetEnvsRequest { string searchValue = 1; }

message CreateEnvRequest { repeated EnvItem envs = 1; }

message UpdateEnvRequest { EnvItem env = 1; }

message DeleteEnvsRequest { repeated int32 ids = 1; }

message MoveEnvRequest {
  int32 id = 1;
  int32 fromIndex = 2;
  int32 toIndex = 3;
}

message DisableEnvsRequest { repeated int32 ids = 1; }

message EnableEnvsRequest { repeated int32 ids = 1; }

message UpdateEnvNamesRequest {
  repeated int32 ids = 1;
  string name = 2;
}

message GetEnvByIdRequest { int32 id = 1; }

message EnvsResponse {
  int32 code = 1;
  repeated EnvItem data = 2;
  optional string message = 3;
}

message EnvResponse {
  int32 code = 1;
  EnvItem data = 2;
  optional string message = 3;
}

message Response {
  int32 code = 1;
  optional string message = 2;
}

message ExtraScheduleItem { string schedule = 1; }

message CronItem {
  optional int32 id = 1;
  optional string command = 2;
  optional string schedule = 3;
  optional string name = 4;
  repeated string labels = 5;
  optional int32 sub_id = 6;
  repeated ExtraScheduleItem extra_schedules = 7;
  optional string task_before = 8;
  optional string task_after = 9;
  optional int32 status = 10;
  optional string log_path = 11;
  optional int32 pid = 12;
  optional int64 last_running_time = 13;
  optional int64 last_execution_time = 14;
}

message CreateCronRequest {
  string command = 1;
  string schedule = 2;
  optional string name = 3;
  repeated string labels = 4;
  optional int32 sub_id = 5;
  repeated ExtraScheduleItem extra_schedules = 6;
  optional string task_before = 7;
  optional string task_after = 8;
}

message UpdateCronRequest {
  int32 id = 1;
  optional string command = 2;
  optional string schedule = 3;
  optional string name = 4;
  repeated string labels = 5;
  optional int32 sub_id = 6;
  repeated ExtraScheduleItem extra_schedules = 7;
  optional string task_before = 8;
  optional string task_after = 9;
}

message DeleteCronsRequest { repeated int32 ids = 1; }

message GetCronsRequest {
  optional string searchValue = 1;
}

message GetCronByIdRequest { int32 id = 1; }

message EnableCronsRequest { repeated int32 ids = 1; }

message DisableCronsRequest { repeated int32 ids = 1; }

message RunCronsRequest { repeated int32 ids = 1; }

message CronsResponse {
  int32 code = 1;
  repeated CronItem data = 2;
  optional string message = 3;
}

message CronResponse {
  int32 code = 1;
  CronItem data = 2;
  optional string message = 3;
}

message CronDetailRequest { string log_path = 1; }

message CronDetailResponse {
  int32 code = 1;
  CronItem data = 2;
  optional string message = 3;
}

enum NotificationMode {
  gotify = 0;
  goCqHttpBot = 1;
  serverChan = 2;
  pushDeer = 3;
  bark = 4;
  chat = 5;
  telegramBot = 6;
  dingtalkBot = 7;
  weWorkBot = 8;
  weWorkApp = 9;
  aibotk = 10;
  iGot = 11;
  pushPlus = 12;
  wePlusBot = 13;
  email = 14;
  pushMe = 15;
  feishu = 16;
  webhook = 17;
  chronocat = 18;
  ntfy = 19;
  wxPusherBot = 20;
}

message NotificationInfo {
  NotificationMode type = 1;

  optional string gotifyUrl = 2;
  optional string gotifyToken = 3;
  optional int32 gotifyPriority = 4;

  optional string goCqHttpBotUrl = 5;
  optional string goCqHttpBotToken = 6;
  optional string goCqHttpBotQq = 7;

  optional string serverChanKey = 8;

  optional string pushDeerKey = 9;
  optional string pushDeerUrl = 10;

  optional string synologyChatUrl = 11;

  optional string barkPush = 12;
  optional string barkIcon = 13;
  optional string barkSound = 14;
  optional string barkGroup = 15;
  optional string barkLevel = 16;
  optional string barkUrl = 17;
  optional string barkArchive = 18;

  optional string telegramBotToken = 19;
  optional string telegramBotUserId = 20;
  optional string telegramBotProxyHost = 21;
  optional string telegramBotProxyPort = 22;
  optional string telegramBotProxyAuth = 23;
  optional string telegramBotApiHost = 24;

  optional string dingtalkBotToken = 25;
  optional string dingtalkBotSecret = 26;

  optional string weWorkBotKey = 27;
  optional string weWorkOrigin = 28;

  optional string weWorkAppKey = 29;

  optional string aibotkKey = 30;
  optional string aibotkType = 31;
  optional string aibotkName = 32;

  optional string iGotPushKey = 33;

  optional string pushPlusToken = 34;
  optional string pushPlusUser = 35;
  optional string pushPlusTemplate = 36;
  optional string pushplusChannel = 37;
  optional string pushplusWebhook = 38;
  optional string pushplusCallbackUrl = 39;
  optional string pushplusTo = 40;

  optional string wePlusBotToken = 41;
  optional string wePlusBotReceiver = 42;
  optional string wePlusBotVersion = 43;

  optional string emailService = 44;
  optional string emailUser = 45;
  optional string emailPass = 46;
  optional string emailTo = 47;

  optional string pushMeKey = 48;
  optional string pushMeUrl = 49;

  optional string chronocatURL = 50;
  optional string chronocatQQ = 51;
  optional string chronocatToken = 52;

  optional string webhookHeaders = 53;
  optional string webhookBody = 54;
  optional string webhookUrl = 55;
  optional string webhookMethod = 56;
  optional string webhookContentType = 57;

  optional string larkKey = 58;
  optional string larkSecret = 69;

  optional string ntfyUrl = 59;
  optional string ntfyTopic = 60;
  optional string ntfyPriority = 61;
  optional string ntfyToken = 62;
  optional string ntfyUsername = 63;
  optional string ntfyPassword = 64;
  optional string ntfyActions = 65;

  optional string wxPusherBotAppToken = 66;
  optional string wxPusherBotTopicIds = 67;
  optional string wxPusherBotUids = 68;
}

message SystemNotifyRequest {
  string title = 1;
  string content = 2;
  optional NotificationInfo notificationInfo = 3;
}

service Api {
  rpc GetEnvs(GetEnvsRequest) returns (EnvsResponse) {}
  rpc CreateEnv(CreateEnvRequest) returns (EnvsResponse) {}
  rpc UpdateEnv(UpdateEnvRequest) returns (EnvResponse) {}
  rpc DeleteEnvs(DeleteEnvsRequest) returns (Response) {}
  rpc MoveEnv(MoveEnvRequest) returns (EnvResponse) {}
  rpc DisableEnvs(DisableEnvsRequest) returns (Response) {}
  rpc EnableEnvs(EnableEnvsRequest) returns (Response) {}
  rpc UpdateEnvNames(UpdateEnvNamesRequest) returns (Response) {}
  rpc GetEnvById(GetEnvByIdRequest) returns (EnvResponse) {}
  rpc SystemNotify(SystemNotifyRequest) returns (Response) {}
  rpc GetCronDetail(CronDetailRequest) returns (CronDetailResponse) {}
  rpc CreateCron(CreateCronRequest) returns (CronResponse) {}
  rpc UpdateCron(UpdateCronRequest) returns (CronResponse) {}
  rpc DeleteCrons(DeleteCronsRequest) returns (Response) {}
  rpc GetCrons(GetCronsRequest) returns (CronsResponse) {}
  rpc GetCronById(GetCronByIdRequest) returns (CronResponse) {}
  rpc EnableCrons(EnableCronsRequest) returns (Response) {}
  rpc DisableCrons(DisableCronsRequest) returns (Response) {}
  rpc RunCrons(RunCronsRequest) returns (Response) {}
}