syntax = "proto3";

package com.wix.media.media_manager.v1;

import "wix/api/validations.proto";
import "wix/api/permissions.proto";
import "wix/api/annotations.proto";
import "google/api/annotations.proto";
import "wix/api/entity.proto";



message RecentSearch {
  // The id of the recent search.
  string recent_search_id = 1 [(.wix.api.maxLength) = 200, (.wix.api.readOnly) = true];
  // The search term.
  string search_text = 2 [(.wix.api.maxLength) = 200, (.wix.api.readOnly) = false];
}

message GetRecentSearchesRequest {
}

message GetRecentSearchesResponse {
  // A list of recent searches.
  repeated RecentSearch recent_searches = 1 [(.wix.api.maxSize) = 100];
}

message BulkDeleteRecentSearchesRequest {
  // The ids of the recent searches to delete.
  repeated string recent_search_ids = 1 [(.wix.api.maxSize) = 10, (.wix.api.minSize) = 1, (.wix.api.maxLength) = 100];
}

message BulkDeleteRecentSearchesResponse {
}

message CreateRecentSearchRequest {
  // The search term.
  string search_text = 1 [(.wix.api.maxLength) = 200, (.wix.api.readOnly) = false];

}

message CreateRecentSearchResponse {
  // A list of recent searches.
  repeated RecentSearch recent_searches = 1 [(.wix.api.maxSize) = 100];
}

service SearchService {
  option (.wix.api.service_maturity) = ALPHA;
  option (.wix.api.service_exposure) = INTERNAL;
  option (.wix.api.service_entity).message = "com.wix.media.media_manager.v1.SearchResult";

  // Return the recent searches
  rpc GetRecentSearches (GetRecentSearchesRequest) returns (GetRecentSearchesResponse) {
    option (google.api.http) = {post: "/v1/search/recent-searches"};
    option (.wix.api.permission).name = "MEDIA.MEDIA_MANAGER_RECENT_SEARCH_READ";
  }

  // Create a recent search
  // flynt-disable missing-permission
  rpc CreateRecentSearch (CreateRecentSearchRequest) returns (CreateRecentSearchResponse) {
    option (google.api.http) = {post: "/v1/search/recent-searches/create"};
    //    option (.wix.api.permission).name = "MEDIA.MEDIA_MANAGER_RECENT_SEARCH_CREATE";
  }

  // Deletes the request recent searches for the site and user <br/>
  // flynt-disable crud-corresponding-emits-validation
  rpc BulkDeleteRecentSearches (BulkDeleteRecentSearchesRequest) returns (BulkDeleteRecentSearchesResponse) {
    option (.wix.api.required) = "BulkDeleteRecentSearchesRequest.recent_search_ids";
    option (google.api.http) = {post: "/v1/bulk/search/recent-searches/delete"};
    option (.wix.api.permission).name = "MEDIA.MEDIA_MANAGER_RECENT_SEARCH_DELETE";
    option (.wix.api.crud) = {
      method: BULK_DELETE
      bulk_delete_options: {
        ids_field: "recent_search_ids"
      }
    };
  }

  //  rpc CreateRecentSearch (CreateRecentSearchRequest) returns (CreateRecentSearchResponse) {
  //    option (google.api.http) = {post: "/v1/search/update-search-history"};
  //    option (.wix.api.permission).name = "MEDIA.MEDIA_MANAGER_RECENT_SEARCH_WRITE";
  //  }

}
