syntax = "proto3";

package devvit.data.api.v1alpha;

import "devvit/options/options.proto";
import "devvit/reddit/v2alpha/subredditv2.proto";
import "google/protobuf/duration.proto";
import "google/protobuf/timestamp.proto";

option go_package = "github.snooguts.net/reddit/devplatform-api/go/grpc/devvit/data/api/v1alpha";

message DataToken {
  string id = 1;
  string organization_id = 2;
  google.protobuf.Timestamp created_at = 3;
  google.protobuf.Timestamp expires_at = 4;
  bool is_revoked = 5;
}

message DataSubscription {
  string id = 1;
  devvit.options.DataTier tier = 2;
  repeated devvit.options.FirehoseEvent events = 3;
  repeated string subreddits = 4;

  repeated devvit.reddit.v2alpha.SubredditRating subreddit_ratings = 5;
  string organization_id = 6;
  string name = 7;
  optional string description = 8;
  int32 concurrent_connections = 9;
  google.protobuf.Duration duration = 10;
  bool compliance = 11;
}

message Organization {
  string id = 1;
  string name = 2;
  repeated DataSubscription subscriptions = 3;
  repeated DataToken tokens = 4;
  google.protobuf.Timestamp contract_end_date = 5;
}

message DataApiAuthTokenRequest {
  string customer = 1;
  google.protobuf.Duration expires_in = 2;
}

message DataApiAuthTokenResponse {
  string id = 1;
  string token = 2;
  google.protobuf.Timestamp expires_at = 3;
}

// DataApiAuthTokenIssuer is the service that issues auth tokens for the data api
service DataApiAuthTokenIssuer {
  rpc GenerateAuthToken(DataApiAuthTokenRequest) returns (DataApiAuthTokenResponse);
}
