proto-gorm.proto 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. syntax = "proto3";
  2. package proto_gorm;
  3. import "google/protobuf/empty.proto";
  4. import "options/gorm.proto";
  5. import "google/protobuf/field_mask.proto";
  6. import "atlas/query/v1/collection_operators.proto";
  7. import "google/api/annotations.proto";
  8. option go_package = "git.alfi.li/gamelang/proto_gorm";
  9. // WSMessage wraps PB Messages with its type for transit
  10. message WSMessage {
  11. string method = 1;
  12. string path = 2;
  13. string streamid = 3;
  14. bytes body = 4;
  15. }
  16. // IntPoint is a basic message type representing a single cartesian point
  17. // that we want to store in a database
  18. message IntPoint {
  19. option (gorm.opts).ormable = true;
  20. uint32 id = 1;
  21. int32 x = 2;
  22. int32 y = 3;
  23. }
  24. // Convention dictates that we have separate Request and Response message types
  25. // for each API call, so that they can be alterred later without having to fear
  26. // breaking a contract in any of the other services.
  27. message CreateIntPointRequest {
  28. // Convention dictates that this field be of the given type, and be
  29. // named 'payload' in order to autogenerate the handler
  30. IntPoint payload = 1;
  31. }
  32. message CreateIntPointResponse {
  33. // Convention also requires that the return type be the same and named 'result'
  34. IntPoint result = 1;
  35. }
  36. message ReadIntPointRequest {
  37. // For a read request, the id field is the only to be specified
  38. uint32 id = 1;
  39. atlas.query.v1.FieldSelection fields = 2;
  40. }
  41. message ReadIntPointResponse {
  42. // Again the type with 'result' name
  43. IntPoint result = 1;
  44. }
  45. message UpdateIntPointRequest {
  46. IntPoint payload = 1;
  47. google.protobuf.FieldMask gerogeri_gegege = 2;
  48. }
  49. message UpdateIntPointResponse {
  50. IntPoint result = 1;
  51. }
  52. message UpdateSetIntPointRequest {
  53. repeated IntPoint objects = 1;
  54. repeated google.protobuf.FieldMask masks = 2;
  55. }
  56. message UpdateSetIntPointResponse {
  57. repeated IntPoint results = 1;
  58. }
  59. message DeleteIntPointRequest {
  60. // Only the id is needed for a delete request
  61. uint32 id = 1;
  62. }
  63. message DeleteIntPointsRequest {
  64. // Only the id is needed for a delete request
  65. repeated uint32 ids = 1;
  66. }
  67. // By convention, on DELETE no response data is given, so either a
  68. // google.protobuf.empty, or an empty struct is sufficient
  69. message DeleteIntPointResponse {
  70. }
  71. //message ListIntPointResponse {
  72. // // Note repeated field and plural name 'results'
  73. // repeated IntPoint results = 1;
  74. // atlas.query.v1.PageInfo page_info = 2;
  75. //}
  76. //
  77. //message ListSomethingResponse {
  78. // // Note repeated field and plural name 'results'
  79. // repeated Something results = 1;
  80. // atlas.query.v1.PageInfo page_info = 2;
  81. //}
  82. //
  83. //
  84. //// A dummy type to demo an rpc that can't be autogenerated
  85. //message Something {
  86. // option (gorm.opts).ormable = true;
  87. // string field = 1;
  88. //}
  89. //
  90. //message ListIntPointRequest {
  91. // atlas.query.v1.Filtering filter = 1;
  92. // atlas.query.v1.Sorting order_by = 2;
  93. // atlas.query.v1.FieldSelection fields = 3;
  94. // atlas.query.v1.Pagination paging = 4;
  95. //}
  96. service IntPointService {
  97. // This option tells protoc-gen-gorm to generate the calls and stubs
  98. option (gorm.server).autogen = true;
  99. // The convention requires the rpc names have Create/Read/Update/List/Delete
  100. // as a prefix. The type is inferred from the response (except for delete),
  101. // so multiple objects can have CURDL handlers in the same service, provided
  102. // they are given unique suffixes
  103. rpc Create ( CreateIntPointRequest ) returns ( CreateIntPointResponse ) {
  104. option (google.api.http) = {
  105. post: "/v1/point"
  106. body: "payload"
  107. };
  108. }
  109. rpc Read ( ReadIntPointRequest ) returns ( ReadIntPointResponse ) {
  110. option (google.api.http) = {
  111. get: "/v1/point/{id}"
  112. };
  113. }
  114. rpc Update ( UpdateIntPointRequest ) returns ( UpdateIntPointResponse ) {
  115. option (google.api.http) = {
  116. patch: "/v1/point/{payload.id}"
  117. body: "payload"
  118. };
  119. }
  120. rpc UpdateSet (UpdateSetIntPointRequest) returns ( UpdateSetIntPointResponse) {}
  121. //rpc List ( ListIntPointRequest ) returns ( ListIntPointResponse ) {
  122. // option (google.api.http) = {
  123. // get: "/v1/point"
  124. // };
  125. //}
  126. //rpc ListSomething( google.protobuf.Empty ) returns ( ListSomethingResponse ) {}
  127. rpc Delete ( DeleteIntPointRequest ) returns ( DeleteIntPointResponse ) {
  128. // This option is required because the type/table can't be inferred
  129. // by the return type
  130. option (gorm.method).object_type = "IntPoint";
  131. option (google.api.http) = {
  132. delete: "/v1/point/{id}"
  133. };
  134. }
  135. // CustomMethod can't be autogenerated as it matches no conventions, it will
  136. // become a stub
  137. //rpc CustomMethod ( google.protobuf.Empty ) returns ( google.protobuf.Empty ) {}
  138. // CreateSomething also doesn't match conventions and will become a stub
  139. //rpc CreateSomething ( Something ) returns ( Something ) {}
  140. }
  141. service IntPointTxn {
  142. // This option tells protoc-gen-gorm to generate the calls and stubs, and
  143. // the transaction middleware will be used
  144. option (gorm.server) = {autogen: true, txn_middleware: true, with_tracing: true};
  145. // The convention requires the rpc names have Create/Read/Update/List/Delete
  146. // as a prefix. The type is inferred from the response (except for delete),
  147. // so multiple objects can have CURDL handlers in the same service, provided
  148. // they are given unique suffixes
  149. rpc Create ( CreateIntPointRequest ) returns ( CreateIntPointResponse ) {}
  150. rpc Read ( ReadIntPointRequest ) returns ( ReadIntPointResponse ) {}
  151. rpc Update ( UpdateIntPointRequest ) returns ( UpdateIntPointResponse ) {}
  152. //rpc List ( ListIntPointRequest ) returns ( ListIntPointResponse ) {}
  153. rpc Delete ( DeleteIntPointRequest ) returns ( DeleteIntPointResponse ) {
  154. // This option is required because the type/table can't be inferred
  155. // by the return type
  156. option (gorm.method).object_type = "int_point";
  157. }
  158. rpc DeleteSet ( DeleteIntPointsRequest ) returns ( DeleteIntPointResponse ) {
  159. // This option is required because the type/table can't be inferred
  160. // by the return type
  161. option (gorm.method).object_type = "int_point";
  162. }
  163. // CustomMethod can't be autogenerated as it matches no conventions, it will
  164. // become a stub
  165. //rpc CustomMethod ( google.protobuf.Empty ) returns ( google.protobuf.Empty ) {}
  166. // CreateSomething also doesn't match conventions and will become a stub
  167. //rpc CreateSomething ( Something ) returns ( Something ) {}
  168. }