syntax = "proto3";

package ocis.services.search.v0;
	
option go_package = "github.com/owncloud/ocis/protogen/gen/ocis/service/search/v0";

import "ocis/messages/search/v0/search.proto";
import "protoc-gen-openapiv2/options/annotations.proto";
import "google/api/field_behavior.proto";
import "google/api/annotations.proto";
import "google/protobuf/field_mask.proto";

option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
  info: {
    title: "ownCloud Infinite Scale search";
    version: "1.0.0";
    contact: {
      name: "ownCloud GmbH";
      url: "https://github.com/owncloud/ocis";
      email: "support@owncloud.com";
    };
    license: {
      name: "Apache-2.0";
      url: "https://github.com/owncloud/ocis/blob/master/LICENSE";
    };
  };
  schemes: HTTP;
  schemes: HTTPS;
  consumes: "application/json";
  produces: "application/json";
  external_docs: {
    description: "Developer Manual";
    url: "https://owncloud.dev/services/search/";
  };
};

service SearchProvider {
	rpc Search(SearchRequest) returns (SearchResponse) {
    option (google.api.http) = {
        post: "/api/v0/search/search",
        body: "*"
    };
  };
  rpc IndexSpace(IndexSpaceRequest) returns (IndexSpaceResponse) {
    option (google.api.http) = {
        post: "/api/v0/search/index-space",
        body: "*"
    };
  }
}

service IndexProvider {
	rpc Search(SearchIndexRequest) returns (SearchIndexResponse) {
    option (google.api.http) = {
        post: "/api/v0/search/index/search",
        body: "*"
    };
  };
	// rpc Remove(RemoveRequest) returns (RemoveResponse) {};
}

message SearchRequest {
  // Optional. The maximum number of entries to return in the response
  int32 page_size = 1 [(google.api.field_behavior) = OPTIONAL];

  // Optional. A pagination token returned from a previous call to `Get`
  // that indicates from where search should continue
  string page_token = 2 [(google.api.field_behavior) = OPTIONAL];

  string query = 3;
}

message SearchResponse {
  repeated ocis.messages.search.v0.Match matches = 1;

  // Token to retrieve the next page of results, or empty if there are no
  // more results in the list
  string next_page_token = 2;
  int32 total_matches = 3;
}

message SearchIndexRequest {
  // Optional. The maximum number of entries to return in the response
  int32 page_size = 1 [(google.api.field_behavior) = OPTIONAL];

  // Optional. A pagination token returned from a previous call to `Get`
  // that indicates from where search should continue
  string page_token = 2 [(google.api.field_behavior) = OPTIONAL];

	string query = 3;
  ocis.messages.search.v0.Reference ref = 4 [(google.api.field_behavior) = OPTIONAL];
}

message SearchIndexResponse {
  repeated ocis.messages.search.v0.Match matches = 1;

  // Token to retrieve the next page of results, or empty if there are no
  // more results in the list
  string next_page_token = 2;
  int32 total_matches = 3;
}

message IndexSpaceRequest {
  string space_id = 1;
  string user_id = 2;
}

message IndexSpaceResponse {
}