syntax = "proto3";

package devvit.dev_portal;

import "devvit/dev_portal/app/app.proto";
import "devvit/dev_portal/curated_game/curated_game.proto";
import "devvit/dev_portal/fetch_domain/fetch_domain.proto";
import "devvit/dev_portal/fetch_domain_request/fetch_domain_request.proto";
import "devvit/dev_portal/installation/installation.proto";
import "devvit/dev_portal/modmail_template/modmail_template.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/devportal";

service AdminInstallation {
  rpc Upgrade(installation.InstallationUpgradeRequest) returns (installation.FullInstallationInfo);
  rpc UpgradeMany(installation.InstallationUpgradeManyRequest) returns (installation.InstallationUpgradeManyResponse);
}

// Service used for reading and updating fetch domain requests from the Admin Portal.
// A FetchDomainRequest is a request to add or remove a domain from a list. Domains can added to a app-specific list, or to a global list (allowlist or denylist).
// Apps that request a domain will have a FetchDomainRequest with status PENDING. An Admin can approve or deny the request via AdminPortal. Approved domains are added to the app's allowlist.
service AdminFetchDomainRequest {
  // Retrieves a page of fetch domain requests with status PENDING.
  rpc GetPending(fetch_domain_request.GetPendingRequest) returns (fetch_domain_request.GetResponse);
  // Returns the number of fetch domain requests with status PENDING.
  rpc GetPendingRequestsCount(google.protobuf.Empty) returns (google.protobuf.Int32Value);
  // Updates the status of a fetch domain request for a given app.
  rpc UpdateStatusForApp(fetch_domain_request.UpdateStatusForAppRequest) returns (google.protobuf.Empty);
  // Retrieves a page of fetch domain requests for the specified global list type.
  rpc GetFetchDomainRequestsWithGlobalListType(fetch_domain_request.GetFetchDomainRequestsWithGlobalListTypeRequest) returns (fetch_domain_request.GetResponse);
}

// Service used for reading, adding, and removing fetch domains from the Admin Portal.
// A FetchDomain is a domain that has either been approved or denied for use.
// FetchDomains can be used by specific app(s), or globally. Global FetchDomains have a global status of ALLOWED or DENIED, while app-level FetchDomains have status UNDECIDED.
service AdminFetchDomain {
  // Retrieves a page of fetch domains with the specified global status.
  rpc GetFetchDomainsWithStatus(fetch_domain.GetFetchDomainsWithStatusRequest) returns (fetch_domain.GetFetchDomainsResponse);
  // Adds a list of domains to a global list (allowlist or denylist).
  rpc AddGlobalDomains(fetch_domain.AddGlobalDomainsRequest) returns (google.protobuf.Empty);
  // Removes a domain from a global list.
  rpc RemoveGlobalDomain(fetch_domain.RemoveGlobalDomainRequest) returns (google.protobuf.Empty);
}

// Service used for reading and updating app information from the Admin Portal.
service AdminApp {
  // Retrieves an app by slug with its fetch domain info.
  rpc GetAppBySlugWithDomainInfo(app.GetAppBySlugWithDomainInfoRequest) returns (app.AppWithDomainInfo);
  // Retrieves a page of apps with their fetch domain info.
  rpc GetAppsWithDomainInfo(app.GetAppsWithDomainInfoRequest) returns (app.GetAppsWithDomainInfoResponse);
  // Adds domains to an app's allowedDomains list.
  rpc AddDomainsToApp(app.AddDomainsToAppRequest) returns (google.protobuf.Empty);
  // Removes a domain from an app's allowedDomains list.
  rpc RemoveDomainFromApp(app.RemoveDomainFromAppRequest) returns (google.protobuf.Empty);
}

// Service used for reading and mutating curated games in the Admin Portal.
service AdminCuratedGame {
  // Lists curated game entries, optionally filtered by curation type.
  rpc ListGames(curated_game.ListCuratedGamesRequest) returns (curated_game.ListCuratedGamesResponse);
  // Adds an app to a curated game list.
  rpc AddGame(curated_game.AddCuratedGameRequest) returns (curated_game.AddCuratedGameResponse);
  // Updates rank for an app in the curated games list.
  rpc UpdateGameRank(curated_game.UpdateCuratedGameRankRequest) returns (curated_game.UpdateCuratedGameRankResponse);
  // Removes an app from the curated games list.
  rpc RemoveGame(curated_game.RemoveCuratedGameRequest) returns (google.protobuf.Empty);
}

// Service for managing modmail templates used in app review.
service AdminModmailTemplate {
  // Lists all modmail templates and the global header/footer config.
  rpc List(modmail_template.ListModmailTemplatesRequest) returns (modmail_template.ListModmailTemplatesResponse);
  // Creates a new modmail template.
  rpc Create(modmail_template.CreateModmailTemplateRequest) returns (modmail_template.ModmailTemplate);
  // Updates an existing modmail template.
  rpc Update(modmail_template.UpdateModmailTemplateRequest) returns (modmail_template.ModmailTemplate);
  // Deletes a modmail template.
  rpc Delete(modmail_template.DeleteModmailTemplateRequest) returns (google.protobuf.Empty);
  // Dissolves or deletes a group of templates.
  rpc DeleteGroup(modmail_template.DeleteModmailTemplateGroupRequest) returns (google.protobuf.Empty);
  // Reorders templates by specifying the desired ID order.
  rpc Reorder(modmail_template.ReorderModmailTemplatesRequest) returns (google.protobuf.Empty);
  // Retrieves the global modmail header/footer config.
  rpc GetConfig(modmail_template.GetModmailConfigRequest) returns (modmail_template.ModmailConfig);
  // Updates the global modmail header/footer config.
  rpc UpdateConfig(modmail_template.UpdateModmailConfigRequest) returns (modmail_template.ModmailConfig);
}
