-
Notifications
You must be signed in to change notification settings - Fork 164
/
demo_service.proto
220 lines (190 loc) · 7.9 KB
/
demo_service.proto
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
syntax = "proto3";
package example;
import "google/protobuf/empty.proto";
import "options/gorm.proto";
import "google/protobuf/field_mask.proto";
import "atlas/query/v1/collection_operators.proto";
option go_package = "github.com/infobloxopen/protoc-gen-gorm/example/feature_demo;example";
// IntPoint is a basic message type representing a single cartesian point
// that we want to store in a database
message IntPoint {
option (gorm.opts).ormable = true;
uint32 id = 1;
int32 x = 2;
int32 y = 3;
}
// Convention dictates that we have separate Request and Response message types
// for each API call, so that they can be altered later without having to fear
// breaking a contract in any of the other services.
message CreateIntPointRequest {
// Convention dictates that this field be of the given type, and be
// named 'payload' in order to autogenerate the handler
IntPoint payload = 1;
}
message CreateIntPointResponse {
// Convention also requires that the return type be the same and named 'result'
IntPoint result = 1;
}
message ReadIntPointRequest {
// For a read request, the id field is the only to be specified
uint32 id = 1;
infoblox.api.FieldSelection fields = 2;
}
message ReadIntPointResponse {
// Again the type with 'result' name
IntPoint result = 1;
}
message UpdateIntPointRequest {
IntPoint payload = 1;
google.protobuf.FieldMask gerogeri_gegege = 2;
}
message UpdateIntPointResponse {
IntPoint result = 1;
}
message UpdateSetIntPointRequest {
repeated IntPoint objects = 1;
repeated google.protobuf.FieldMask masks = 2;
}
message UpdateSetIntPointResponse {
repeated IntPoint results = 1;
}
message DeleteIntPointRequest {
// Only the id is needed for a delete request
uint32 id = 1;
}
message DeleteIntPointsRequest {
// Only the id is needed for a delete request
repeated uint32 ids = 1;
}
// By convention, on DELETE no response data is given, so either a
// google.protobuf.empty, or an empty struct is sufficient
message DeleteIntPointResponse {
}
message ListIntPointResponse {
// Note repeated field and plural name 'results'
repeated IntPoint results = 1;
infoblox.api.PageInfo page_info = 2;
}
message ListSomethingResponse {
// Note repeated field and plural name 'results'
repeated Something results = 1;
infoblox.api.PageInfo page_info = 2;
}
// A dummy type to demo an rpc that can't be autogenerated
message Something {
option (gorm.opts).ormable = true;
string field = 1;
}
message ListIntPointRequest {
infoblox.api.Filtering filter = 1;
infoblox.api.Sorting order_by = 2;
infoblox.api.FieldSelection fields = 3;
infoblox.api.Pagination paging = 4;
}
service IntPointService {
// This option tells protoc-gen-gorm to generate the calls and stubs
option (gorm.server).autogen = true;
// The convention requires the rpc names have Create/Read/Update/List/Delete
// as a prefix. The type is inferred from the response (except for delete),
// so multiple objects can have CURDL handlers in the same service, provided
// they are given unique suffixes
rpc Create ( CreateIntPointRequest ) returns ( CreateIntPointResponse ) {}
rpc Read ( ReadIntPointRequest ) returns ( ReadIntPointResponse ) {}
rpc Update ( UpdateIntPointRequest ) returns ( UpdateIntPointResponse ) {}
rpc UpdateSet (UpdateSetIntPointRequest) returns ( UpdateSetIntPointResponse) {}
rpc List ( ListIntPointRequest ) returns ( ListIntPointResponse ) {}
rpc ListSomething( google.protobuf.Empty ) returns ( ListSomethingResponse ) {}
rpc Delete ( DeleteIntPointRequest ) returns ( DeleteIntPointResponse ) {
// This option is required because the type/table can't be inferred
// by the return type
option (gorm.method).object_type = "IntPoint";
}
// CustomMethod can't be autogenerated as it matches no conventions, it will
// become a stub
rpc CustomMethod ( google.protobuf.Empty ) returns ( google.protobuf.Empty ) {}
// CreateSomething also doesn't match conventions and will become a stub
rpc CreateSomething ( Something ) returns ( Something ) {}
}
// Test cases that were previously broken
message CreateFooRequest {
bytes payload = 1;
}
message ListFooRequest {
}
service IntPointServiceB {
option (gorm.server).autogen = true;
rpc List ( ListFooRequest ) returns ( ListIntPointResponse ) {}
rpc Create ( CreateFooRequest ) returns ( ListIntPointResponse ) {}
}
service IntPointTxn {
// This option tells protoc-gen-gorm to generate the calls and stubs, and
// the transaction middleware will be used
option (gorm.server) = {autogen: true, txn_middleware: true, with_tracing: true};
// The convention requires the rpc names have Create/Read/Update/List/Delete
// as a prefix. The type is inferred from the response (except for delete),
// so multiple objects can have CURDL handlers in the same service, provided
// they are given unique suffixes
rpc Create ( CreateIntPointRequest ) returns ( CreateIntPointResponse ) {}
rpc Read ( ReadIntPointRequest ) returns ( ReadIntPointResponse ) {}
rpc Update ( UpdateIntPointRequest ) returns ( UpdateIntPointResponse ) {}
rpc List ( ListIntPointRequest ) returns ( ListIntPointResponse ) {}
rpc Delete ( DeleteIntPointRequest ) returns ( DeleteIntPointResponse ) {
// This option is required because the type/table can't be inferred
// by the return type
option (gorm.method).object_type = "int_point";
}
rpc DeleteSet ( DeleteIntPointsRequest ) returns ( DeleteIntPointResponse ) {
// This option is required because the type/table can't be inferred
// by the return type
option (gorm.method).object_type = "int_point";
}
// CustomMethod can't be autogenerated as it matches no conventions, it will
// become a stub
rpc CustomMethod ( google.protobuf.Empty ) returns ( google.protobuf.Empty ) {}
// CreateSomething also doesn't match conventions and will become a stub
rpc CreateSomething ( Something ) returns ( Something ) {}
}
message Circle {
option (gorm.opts).ormable = true;
uint32 r = 1;
}
message ListCircleRequest {
}
message ListCircleResponse {
repeated Circle results = 1;
}
service CircleService {
option (gorm.server).autogen = true;
rpc List ( ListCircleRequest ) returns ( ListCircleResponse ) {}
}
service MultipleMethodsAutoGen {
option (gorm.server).autogen = true;
rpc CreateA ( CreateIntPointRequest ) returns ( CreateIntPointResponse ) {}
rpc CreateB ( CreateIntPointRequest ) returns ( CreateIntPointResponse ) {}
rpc ReadA ( ReadIntPointRequest ) returns ( ReadIntPointResponse ) {}
rpc ReadB ( ReadIntPointRequest ) returns ( ReadIntPointResponse ) {}
rpc UpdateA ( UpdateIntPointRequest ) returns ( UpdateIntPointResponse ) {}
rpc UpdateB ( UpdateIntPointRequest ) returns ( UpdateIntPointResponse ) {}
rpc ListA ( ListIntPointRequest ) returns ( ListIntPointResponse ) {}
rpc ListB ( ListIntPointRequest ) returns ( ListIntPointResponse ) {}
rpc DeleteA ( DeleteIntPointRequest ) returns ( DeleteIntPointResponse ) {
// This option is required because the type/table can't be inferred
// by the return type
option (gorm.method).object_type = "int_point";
}
rpc DeleteB ( DeleteIntPointRequest ) returns ( DeleteIntPointResponse ) {
// This option is required because the type/table can't be inferred
// by the return type
option (gorm.method).object_type = "int_point";
}
rpc DeleteSetA ( DeleteIntPointsRequest ) returns ( DeleteIntPointResponse ) {
// This option is required because the type/table can't be inferred
// by the return type
option (gorm.method).object_type = "int_point";
}
rpc DeleteSetB ( DeleteIntPointsRequest ) returns ( DeleteIntPointResponse ) {
// This option is required because the type/table can't be inferred
// by the return type
option (gorm.method).object_type = "int_point";
}
}