syntax = "proto3";

package example.armeria.blog.grpc;
option java_package = "example.armeria.blog.grpc";
option java_multiple_files = true;

import "google/protobuf/empty.proto";

service BlogService {
  rpc CreateBlogPost (CreateBlogPostRequest) returns (BlogPost) {}
  rpc GetBlogPost (GetBlogPostRequest) returns (BlogPost) {}
  rpc ListBlogPosts (ListBlogPostsRequest) returns (ListBlogPostsResponse) {}
  rpc UpdateBlogPost (UpdateBlogPostRequest) returns (BlogPost) {}
  rpc DeleteBlogPost (DeleteBlogPostRequest) returns (google.protobuf.Empty) {}
}

message CreateBlogPostRequest {
  string title = 1;
  string content = 2;
}

message GetBlogPostRequest {
  int32 id = 1;
}

message ListBlogPostsRequest {
  bool descending = 1;
}

message ListBlogPostsResponse {
  repeated BlogPost blogs = 1;
}

message UpdateBlogPostRequest {
  int32 id = 1;
  string title = 2;
  string content = 3;
}

message DeleteBlogPostRequest {
  int32 id = 1;
}

message BlogPost {
  int32 id = 1;
  string title = 2;
  string content = 3;
  int64 createdAt = 4;
  int64 modifiedAt = 5;
}
