syntax = "proto3";

package devvit.plugin.redditapi.subreddits;

import "devvit/plugin/redditapi/common/common_msg.proto";
import "devvit/plugin/redditapi/subreddits/subreddits_msg.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/wrappers.proto";

option go_package = "github.snooguts.net/reddit/reddit-devplatform-monorepo/go-common/generated/protos/types/devvit/plugin/redditapi";
option java_package = "com.reddit.devvit.plugin.redditapi.subreddits";

// SUBREDDITS - https://www.reddit.com/dev/api#section_subreddits
service Subreddits {
  // https://www.reddit.com/dev/api#GET_about_\{where\}
  rpc AboutWhere(AboutWhereRequest) returns (devvit.plugin.redditapi.common.Listing) {
    option (devvit.plugin.redditapi.common.api_client_config).method = 'GET';
    option (devvit.plugin.redditapi.common.api_client_config).path = '/r/{subreddit}/about/{where}?after={after}&before={before}&count={count}&limit={limit}&show={show}&user={user}';
    option (devvit.plugin.redditapi.common.api_client_config).use_custom_response_parser = true;
  }

  // https://www.reddit.com/dev/api#POST_api_delete_sr_banner
  rpc DeleteSrBanner(BasicSubredditRequest) returns (devvit.plugin.redditapi.common.JsonStatus) {
    option (devvit.plugin.redditapi.common.api_client_config).method = 'POST';
    option (devvit.plugin.redditapi.common.api_client_config).path = '/r/{subreddit}/api/delete_sr_banner';
  }

  // https://www.reddit.com/dev/api#POST_api_delete_sr_header
  rpc DeleteSrHeader(BasicSubredditRequest) returns (devvit.plugin.redditapi.common.JsonStatus) {
    option (devvit.plugin.redditapi.common.api_client_config).method = 'POST';
    option (devvit.plugin.redditapi.common.api_client_config).path = '/r/{subreddit}/api/delete_sr_header';
  }

  // https://www.reddit.com/dev/api#POST_api_delete_sr_icon
  rpc DeleteSrIcon(BasicSubredditRequest) returns (devvit.plugin.redditapi.common.JsonStatus) {
    option (devvit.plugin.redditapi.common.api_client_config).method = 'POST';
    option (devvit.plugin.redditapi.common.api_client_config).path = '/r/{subreddit}/api/delete_sr_icon';
  }

  // https://www.reddit.com/dev/api#POST_api_delete_sr_img
  rpc DeleteSrImg(DeleteSrImgRequest) returns (devvit.plugin.redditapi.common.JsonStatus) {
    option (devvit.plugin.redditapi.common.api_client_config).method = 'POST';
    option (devvit.plugin.redditapi.common.api_client_config).path = '/r/{subreddit}/api/delete_sr_img';
    option (devvit.plugin.redditapi.common.api_client_config).request_body_type = FORM_SNAKE;
    option (devvit.plugin.redditapi.common.api_client_config).enforce_json = true;
  }

  // https://www.reddit.com/dev/api#POST_api_search_reddit_names
  rpc SearchRedditNames(BasicSearchRequest) returns (SearchRedditNamesResponse) {
    option (devvit.plugin.redditapi.common.api_client_config).method = 'POST';
    option (devvit.plugin.redditapi.common.api_client_config).path = '/api/search_reddit_names';
    option (devvit.plugin.redditapi.common.api_client_config).request_body_type = FORM_SNAKE;
  }

  // https://www.reddit.com/dev/api#POST_api_search_subreddits
  rpc SearchSubreddits(BasicSearchRequest) returns (SearchSubredditsResponse) {
    option (devvit.plugin.redditapi.common.api_client_config).method = 'POST';
    option (devvit.plugin.redditapi.common.api_client_config).path = '/api/search_subreddits';
    option (devvit.plugin.redditapi.common.api_client_config).request_body_type = FORM_SNAKE;
  }

  // https://www.reddit.com/dev/api#POST_api_site_admin
  rpc SiteAdmin(SiteAdminRequest) returns (devvit.plugin.redditapi.common.JsonStatus) {
    option (devvit.plugin.redditapi.common.api_client_config).method = 'POST';
    option (devvit.plugin.redditapi.common.api_client_config).path = '/api/site_admin';
    option (devvit.plugin.redditapi.common.api_client_config).request_body_type = JSON_SNAKE;
    option (devvit.plugin.redditapi.common.api_client_config).enforce_json = true;
  }

  // https://www.reddit.com/dev/api#GET_api_submit_text
  rpc SubmitText(BasicSubredditRequest) returns (SubmitTextResponse) {
    option (devvit.plugin.redditapi.common.api_client_config).method = 'GET';
    option (devvit.plugin.redditapi.common.api_client_config).path = '/r/{subreddit}/api/submit_text';
  }

  // TODO: this seems to return a Listing, not a SubredditAutocompleteResponse.
  // https://www.reddit.com/dev/api#GET_api_subreddit_autocomplete_v2
  rpc SubredditAutocomplete(SubredditAutocompleteRequest) returns (SubredditAutocompleteResponse) {
    option (devvit.plugin.redditapi.common.api_client_config).method = 'GET';
    option (devvit.plugin.redditapi.common.api_client_config).path = '/api/subreddit_autocomplete_v2?include_over_18={include_over_18}&include_profiles={include_profiles}&limit={limit}&query={query}&search_query_id={search_query_id}&typeahead_active={typeahead_active}';
  }

  // https://www.reddit.com/dev/api#POST_api_subreddit_stylesheet
  rpc SubredditStylesheet(SubredditStylesheetRequest) returns (devvit.plugin.redditapi.common.JsonStatus) {
    option (devvit.plugin.redditapi.common.api_client_config).method = 'POST';
    option (devvit.plugin.redditapi.common.api_client_config).path = '/r/{subreddit}/api/subreddit_stylesheet';
    option (devvit.plugin.redditapi.common.api_client_config).request_body_type = FORM_SNAKE;
    option (devvit.plugin.redditapi.common.api_client_config).enforce_json = true;
  }

  // https://www.reddit.com/dev/api#POST_api_subscribe
  rpc Subscribe(SubscribeRequest) returns (google.protobuf.Empty) {
    option (devvit.plugin.redditapi.common.api_client_config).method = 'POST';
    option (devvit.plugin.redditapi.common.api_client_config).path = '/api/subscribe';
    option (devvit.plugin.redditapi.common.api_client_config).request_body_type = FORM_SNAKE;
    option (devvit.plugin.redditapi.common.api_client_config).run_as_user_scopes = SUBSCRIBE_TO_SUBREDDIT;
    option (devvit.plugin.redditapi.common.api_client_config).always_run_as_user = true;
  }

  // https://www.reddit.com/dev/api#POST_api_upload_sr_img
  rpc UploadSrImg(UploadSrImgRequest) returns (UploadSrImgResponse) {
    option (devvit.plugin.redditapi.common.api_client_config).method = 'POST';
    option (devvit.plugin.redditapi.common.api_client_config).path = '/r/{subreddit}/api/upload_sr_img';
    option (devvit.plugin.redditapi.common.api_client_config).request_body_type = FORM_SNAKE;
  }

  // https://www.reddit.com/dev/api#GET_api_v1_\{subreddit\}_post_requirements
  rpc SubredditPostRequirements(BasicSubredditRequest) returns (SubredditPostRequirementsResponse) {
    option (devvit.plugin.redditapi.common.api_client_config).method = 'GET';
    option (devvit.plugin.redditapi.common.api_client_config).path = '/api/v1/{subreddit}/post_requirements';
  }

  // https://www.reddit.com/dev/api#GET_r_\{subreddit\}_about
  rpc SubredditAbout(BasicSubredditRequest) returns (SubredditAboutResponse) {
    option (devvit.plugin.redditapi.common.api_client_config).method = 'GET';
    option (devvit.plugin.redditapi.common.api_client_config).path = '/r/{subreddit}/about?quarantine_optin=1&gated_optin=1';
  }

  // https://www.reddit.com/dev/api#GET_r_\{subreddit\}_about_edit
  rpc SubredditAboutEdit(SubredditAboutEditRequest) returns (SubredditAboutEditResponse) {
    option (devvit.plugin.redditapi.common.api_client_config).method = 'GET';
    option (devvit.plugin.redditapi.common.api_client_config).path = '/r/{subreddit}/about/edit?created={created}&location={location}';
  }

  // https://www.reddit.com/dev/api#GET_r_\{subreddit\}_about_rules
  rpc SubredditAboutRules(BasicSubredditRequest) returns (SubredditAboutRulesResponse) {
    option (devvit.plugin.redditapi.common.api_client_config).method = 'GET';
    option (devvit.plugin.redditapi.common.api_client_config).path = '/r/{subreddit}/about/rules';
  }

  // https://www.reddit.com/dev/api#GET_r_\{subreddit\}_about_traffic
  rpc SubredditAboutTraffic(BasicSubredditRequest) returns (SubredditAboutTrafficResponse) {
    option (devvit.plugin.redditapi.common.api_client_config).method = 'GET';
    option (devvit.plugin.redditapi.common.api_client_config).path = '/r/{subreddit}/about/traffic';
  }

  // https://www.reddit.com/dev/api#GET_sidebar
  rpc Sidebar(BasicSubredditRequest) returns (google.protobuf.StringValue) {
    option (devvit.plugin.redditapi.common.api_client_config).method = 'GET';
    option (devvit.plugin.redditapi.common.api_client_config).path = '/r/{subreddit}/sidebar';
    option (devvit.plugin.redditapi.common.api_client_config).use_custom_response_parser = true;
  }

  // https://www.reddit.com/dev/api#GET_sticky
  rpc Sticky(StickyRequest) returns (StickyResponse) {
    option (devvit.plugin.redditapi.common.api_client_config).method = 'GET';
    option (devvit.plugin.redditapi.common.api_client_config).path = '/r/{subreddit}/sticky?num={num}';
  }

  // https://www.reddit.com/dev/api#GET_subreddits_mine_\{where\}
  rpc SubredditsMineWhere(BasicWhereRequest) returns (devvit.plugin.redditapi.common.Listing) {
    option (devvit.plugin.redditapi.common.api_client_config).method = 'GET';
    option (devvit.plugin.redditapi.common.api_client_config).path = '/subreddits/mine/{where}?after={after}&before={before}&count={count}&limit={limit}&show={show}';
  }

  // https://www.reddit.com/dev/api#GET_subreddits_search
  // Make Wrapped
  rpc SubredditsSearch(SubredditsSearchRequest) returns (SubredditsSearchResponse) {
    option (devvit.plugin.redditapi.common.api_client_config).method = 'GET';
    option (devvit.plugin.redditapi.common.api_client_config).path = '/subreddits/search?after={after}&before={before}&count={count}&limit={limit}&q={q}&search_query_id={search_query_id}&show={show}&show_users={show_users}&sort={sort}&typeahead_active={typeahead_active}';
  }

  // https://www.reddit.com/dev/api#GET_subreddits_\{where\}
  rpc SubredditsWhere(BasicWhereRequest) returns (SubredditsSearchResponse) {
    option (devvit.plugin.redditapi.common.api_client_config).method = 'GET';
    option (devvit.plugin.redditapi.common.api_client_config).path = '/subreddits/{where}?after={after}&before={before}&count={count}&limit={limit}&show={show}';
  }

  // https://www.reddit.com/dev/api#GET_users_search
  rpc UsersSearch(UsersSearchRequest) returns (UserSearchResponse) {
    option (devvit.plugin.redditapi.common.api_client_config).method = 'GET';
    option (devvit.plugin.redditapi.common.api_client_config).path = '/users/search?after={after}&before={before}&count={count}&limit={limit}&q={q}&search_query_id={search_query_id}&show={show}&sort={sort}&typeahead_active={typeahead_active}';
  }

  // https://www.reddit.com/dev/api#GET_users_\{where\}
  rpc UsersWhere(BasicWhereRequest) returns (SubredditsSearchResponse) {
    option (devvit.plugin.redditapi.common.api_client_config).method = 'GET';
    option (devvit.plugin.redditapi.common.api_client_config).path = '/users/{where}?after={after}&before={before}&count={count}&limit={limit}&show={show}';
  }

  // Add a removal reason to a subreddit.
  //
  // POST /api/v1/{subreddit}/removal_reasons
  rpc SubredditAddRemovalReason(SubredditAddRemovalReasonRequest) returns (SubredditAddRemovalReasonResponse) {
    option (devvit.plugin.redditapi.common.api_client_config).method = 'POST';
    option (devvit.plugin.redditapi.common.api_client_config).path = '/api/v1/{subreddit}/removal_reasons';
    option (devvit.plugin.redditapi.common.api_client_config).request_body_type = FORM_SNAKE;
    option (devvit.plugin.redditapi.common.api_client_config).enforce_json = true;
  }

  // Get the list of subreddit's removal reasons.
  //
  // GET /api/v1/{subreddit}/removal_reasons
  rpc SubredditGetRemovalReasons(SubredditGetRemovalReasonsRequest) returns (SubredditGetRemovalReasonsResponse) {
    option (devvit.plugin.redditapi.common.api_client_config).method = 'GET';
    option (devvit.plugin.redditapi.common.api_client_config).path = '/api/v1/{subreddit}/removal_reasons';
  }
  // Get highlighted posts in a subreddit.
  rpc GetHighlightedPosts(GetHighlightedPostsRequest) returns (GetHighlightedPostsResponse);

  // Reorder highlighted posts in a subreddit.
  rpc ReorderHighlightedPosts(ReorderHighlightedPostsRequest) returns (ReorderHighlightedPostsResponse);
}
