syntax = "proto3";

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

import "ocis/messages/store/v0/store.proto";
import "protoc-gen-openapiv2/options/annotations.proto";

option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
  info: {
    title: "ownCloud Infinite Scale store";
    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/extensions/store/";
  };
};

service Store {
	rpc Read(ReadRequest) returns (ReadResponse) {};
	rpc Write(WriteRequest) returns (WriteResponse) {};
	rpc Delete(DeleteRequest) returns (DeleteResponse) {};
	rpc List(ListRequest) returns (stream ListResponse) {};
	rpc Databases(DatabasesRequest) returns (DatabasesResponse) {};
	rpc Tables(TablesRequest) returns (TablesResponse) {};
}

message ReadRequest {
	string key                                 = 1;
	ocis.messages.store.v0.ReadOptions options = 2;
}

message ReadResponse {
	repeated ocis.messages.store.v0.Record records = 1;
}

message WriteRequest {
	ocis.messages.store.v0.Record record        = 1;
	ocis.messages.store.v0.WriteOptions options = 2;
}

message WriteResponse {}

message DeleteRequest {
	string key                                   = 1;
	ocis.messages.store.v0.DeleteOptions options = 2;
}

message DeleteResponse {}

message ListRequest {
	ocis.messages.store.v0.ListOptions options = 1;
}

message ListResponse {
	reserved 1; //repeated Record records = 1;
	repeated string keys = 2;
}

message DatabasesRequest {}

message DatabasesResponse {
	repeated string databases = 1;
}

message TablesRequest {
	string database = 1;
}

message TablesResponse {
	repeated string tables = 1;
}
