syntax = "proto3";

package code.justin.tv.foundation.history;

import "google/protobuf/timestamp.proto";

option go_package = "history";

service History {
  // Dump of all events stored in history service for a user
  rpc RequestReport (RequestReportInput) returns (RequestReportOutput);
  // List of all reports requested
  rpc ListReports (ListReportsInput) returns (ListReportsOutput);
  // Delete all events stored in history service.
  rpc DeleteAudits (DeleteAuditsInput) returns (DeleteAuditsOutput);
  // List of all delete audits requests.
  rpc ListScheduledDeletes (ListScheduledDeletesInput) returns (ListScheduledDeletesOutput);

  // GetUserStats returns how many records would be deleted if delete request was submitted
  rpc GetUserStats(GetUserStatsInput) returns (GetUserStatsOutput);
}

enum Status {
  Unknown = 0;
  Requested = 1;
  Pending = 2;
  Available = 3;
}

message RequestReportInput {
 string user_id = 1;  // twitch user_id
 string requester = 2; // admin panel user requesting the report
}

message RequestReportOutput {
  string user_id = 1;
  Status status = 2;
}

message ListReportsInput {
  string requester = 1; // admin panel user requesting the report
}

message ListReportsOutput {
  repeated ReportInfo items = 1;
}

message ReportInfo {
 string user_id = 1;
 string requester = 2;
 Status status = 3;
 google.protobuf.Timestamp request_time = 4; // RFC 3339 formated timestamp as string.
 string location = 5; // presigned s3 url of the downloadable report
}

message DeleteAuditsInput {
  string user_id = 1;
  string requester = 2;
  google.protobuf.Timestamp  deletion_time = 3; // RFC 3339 formated timestamp as string.
}

message DeleteAuditsOutput {}

message ListScheduledDeletesInput{
  string requester = 1; // admin panel user requesting the list of scheduled deletion
}

message ListScheduledDeletesOutput {
  repeated SechduledDelete items = 1;
}

message SechduledDelete {
  string user_id = 1;
  string requester = 2;
  google.protobuf.Timestamp deletion_time = 3; // RFC 3339 formated timestamp as string.
}

message GetUserStatsInput {
  string user_id = 1;
}

message GetUserStatsOutput {
  int64 recordCount = 1;
}
