syntax = "proto3";

package memos.api.v2;

import "google/api/annotations.proto";

option go_package = "gen/api/v2";

service TagService {
  rpc UpsertTag(UpsertTagRequest) returns (UpsertTagResponse) {
    option (google.api.http) = {post: "/api/v2/tags"};
  }
  rpc ListTags(ListTagsRequest) returns (ListTagsResponse) {
    option (google.api.http) = {get: "/api/v2/tags"};
  }
  rpc DeleteTag(DeleteTagRequest) returns (DeleteTagResponse) {
    option (google.api.http) = {delete: "/api/v2/tags"};
  }
  rpc GetTagSuggestions(GetTagSuggestionsRequest) returns (GetTagSuggestionsResponse) {
    option (google.api.http) = {get: "/api/v2/tags/suggestion"};
  }
}

message Tag {
  string name = 1;
  // The creator of tags.
  // Format: users/{username}
  string creator = 2;
}

message UpsertTagRequest {
  string name = 1;
}

message UpsertTagResponse {
  Tag tag = 1;
}

message ListTagsRequest {
  // The creator of tags.
  // Format: users/{username}
  string user = 1;
}

message ListTagsResponse {
  repeated Tag tags = 1;
}

message DeleteTagRequest {
  Tag tag = 1;
}

message DeleteTagResponse {}

message GetTagSuggestionsRequest {
  // The creator of tags.
  // Format: users/{username}
  string user = 1;
}

message GetTagSuggestionsResponse {
  repeated string tags = 1;
}
