syntax = "proto3";

package devvit.data.api.admin.v1alpha;

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

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

message Subscription {
  string id = 1;
  string name = 2;
  string organization_id = 3;
  string description = 4;
  repeated devvit.options.FirehoseEvent events = 5;
  repeated string subreddits = 6;
  repeated devvit.reddit.v2alpha.SubredditRating subreddit_ratings = 7;
  // the number of concurrent connections to the firehose. Most of the time this will be 1
  // but for compliance subscriptions this will be 0 indicating unlimited connections
  int32 concurrent_connections = 8;
  // how far back this subscription should be able to stream from
  google.protobuf.Duration duration = 9;
  // a flag that determines whether this subscription should be used for the compliance endpoint
  // only one subscription should have this flag set to true per organization
  bool compliance = 10;
}

message CreateSubscriptionRequest {
  repeated devvit.options.FirehoseEvent events = 1;
  repeated string subreddits = 2;
  repeated devvit.reddit.v2alpha.SubredditRating subreddit_ratings = 3;
  string organization_id = 4;
  string name = 5;
  string description = 6;
  // the number of concurrent connections to the firehose. Most of the time this will be 1
  // but for compliance subscriptions this will be 0 indicating unlimited connections
  google.protobuf.Duration duration = 8;
  // a flag that determines whether this subscription should be used for the compliance endpoint
  // only one subscription should have this flag set to true per organization
  bool compliance = 9;
}

message CreateSubscriptionResponse {
  Subscription subscription = 1;
}

message GetSubscriptionByIdRequest {
  string subscription_id = 1;
}

message GetSubscriptionByIdResponse {
  Subscription subscription = 1;
}

message GetSubscriptionsByOrganizationNameRequest {
  string organization_name = 1;
}

message GetSubscriptionsByOrganizationNameResponse {
  repeated Subscription subscriptions = 1;
}

message UpdateSubscriptionRequest {
  // Id of the subscription to update
  string subscription_id = 1;
  // New name of the subscription
  optional string name = 2;
  // New description of the subscription
  optional string description = 3;
  // New events. Will overwrite the array of existing events.
  repeated devvit.options.FirehoseEvent events = 4;
  // New subreddits. Will overwrite the array of existing subreddits.
  repeated string subreddits = 5;
  // New subreddit ratings. Will overwrite the array of existing subreddit ratings.
  repeated devvit.reddit.v2alpha.SubredditRating subreddit_ratings = 6;
}

message UpdateSubscriptionResponse {
  Subscription subscription = 1;
}

message DeleteSubscriptionRequest {
  string subscription_id = 1;
}

message DeleteSubscriptionResponse {}
