protobufjs 4.1.2 → 5.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (188) hide show
  1. package/.travis.yml +3 -1
  2. package/README.md +147 -25
  3. package/bin/pbjs +2 -2
  4. package/bower.json +3 -3
  5. package/cli/pbjs/targets/amd.js +1 -1
  6. package/cli/pbjs/targets/json.js +9 -1
  7. package/cli/pbjs/targets/proto.js +48 -24
  8. package/cli/pbjs/util.js +1 -1
  9. package/cli/pbjs.js +9 -2
  10. package/dist/README.md +10 -10
  11. package/dist/{ProtoBuf-light.js → protobuf-light.js} +207 -152
  12. package/dist/protobuf-light.min.js +94 -0
  13. package/dist/protobuf-light.min.js.gz +0 -0
  14. package/dist/protobuf-light.min.map +8 -0
  15. package/dist/{ProtoBuf.js → protobuf.js} +265 -175
  16. package/dist/protobuf.min.js +116 -0
  17. package/dist/protobuf.min.js.gz +0 -0
  18. package/dist/protobuf.min.map +8 -0
  19. package/docs/ProtoBuf.Builder.Message.html +1473 -967
  20. package/docs/ProtoBuf.Builder.Service.html +266 -197
  21. package/docs/ProtoBuf.Builder.html +758 -542
  22. package/docs/ProtoBuf.DotProto.Parser.html +223 -161
  23. package/docs/ProtoBuf.DotProto.Tokenizer.html +344 -248
  24. package/docs/ProtoBuf.DotProto.html +20 -12
  25. package/docs/ProtoBuf.Element.html +554 -554
  26. package/docs/ProtoBuf.Map.html +158 -123
  27. package/docs/ProtoBuf.Reflect.Element.html +286 -143
  28. package/docs/ProtoBuf.Reflect.Enum.Value.html +329 -228
  29. package/docs/ProtoBuf.Reflect.Enum.html +757 -537
  30. package/docs/ProtoBuf.Reflect.Extension.html +73 -56
  31. package/docs/ProtoBuf.Reflect.Message.ExtensionField.html +1013 -740
  32. package/docs/ProtoBuf.Reflect.Message.Field.html +926 -649
  33. package/docs/ProtoBuf.Reflect.Message.OneOf.html +327 -245
  34. package/docs/ProtoBuf.Reflect.Message.html +919 -652
  35. package/docs/ProtoBuf.Reflect.Namespace.html +648 -447
  36. package/docs/ProtoBuf.Reflect.Service.Method.html +363 -251
  37. package/docs/ProtoBuf.Reflect.Service.RPCMethod.html +545 -397
  38. package/docs/ProtoBuf.Reflect.Service.html +721 -511
  39. package/docs/ProtoBuf.Reflect.T.html +268 -197
  40. package/docs/ProtoBuf.Reflect.html +20 -12
  41. package/docs/ProtoBuf.Util.html +169 -118
  42. package/docs/ProtoBuf.html +840 -628
  43. package/docs/ProtoBuf.js.html +271 -180
  44. package/docs/fonts/OpenSans-Bold-webfont.eot +0 -0
  45. package/docs/fonts/OpenSans-Bold-webfont.svg +1830 -0
  46. package/docs/fonts/OpenSans-Bold-webfont.woff +0 -0
  47. package/docs/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
  48. package/docs/fonts/OpenSans-BoldItalic-webfont.svg +1830 -0
  49. package/docs/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
  50. package/docs/fonts/OpenSans-Italic-webfont.eot +0 -0
  51. package/docs/fonts/OpenSans-Italic-webfont.svg +1830 -0
  52. package/docs/fonts/OpenSans-Italic-webfont.woff +0 -0
  53. package/docs/fonts/OpenSans-Light-webfont.eot +0 -0
  54. package/docs/fonts/OpenSans-Light-webfont.svg +1831 -0
  55. package/docs/fonts/OpenSans-Light-webfont.woff +0 -0
  56. package/docs/fonts/OpenSans-LightItalic-webfont.eot +0 -0
  57. package/docs/fonts/OpenSans-LightItalic-webfont.svg +1835 -0
  58. package/docs/fonts/OpenSans-LightItalic-webfont.woff +0 -0
  59. package/docs/fonts/OpenSans-Regular-webfont.eot +0 -0
  60. package/docs/fonts/OpenSans-Regular-webfont.svg +1831 -0
  61. package/docs/fonts/OpenSans-Regular-webfont.woff +0 -0
  62. package/docs/index.html +7 -5
  63. package/docs/styles/jsdoc-default.css +95 -75
  64. package/docs/styles/prettify-tomorrow.css +1 -1
  65. package/donate.png +0 -0
  66. package/examples/protoify/json.js +123 -123
  67. package/examples/protoify/json.json +123 -123
  68. package/examples/websocket/server.js +4 -4
  69. package/externs/{ProtoBuf.js → protobuf.js} +933 -922
  70. package/index.js +1 -18
  71. package/jsdoc.json +1 -1
  72. package/package.json +11 -11
  73. package/protobuf.png +0 -0
  74. package/scripts/build.js +53 -58
  75. package/src/ProtoBuf/Builder/Message.js +18 -9
  76. package/src/ProtoBuf/Builder/Service.js +3 -0
  77. package/src/ProtoBuf/Builder.js +34 -10
  78. package/src/ProtoBuf/DotProto/Parser.js +58 -23
  79. package/src/ProtoBuf/Reflect/Element.js +17 -4
  80. package/src/ProtoBuf/Reflect/Message/Field.js +6 -5
  81. package/src/ProtoBuf/Reflect/Message.js +9 -4
  82. package/src/ProtoBuf/Util.js +116 -116
  83. package/src/bower.json +2 -2
  84. package/src/google/protobuf/descriptor.json +55 -15
  85. package/src/{ProtoBuf.js → protobuf.js} +0 -0
  86. package/src/wrap.js +4 -4
  87. package/tests/bench.txt +373 -373
  88. package/tests/complex.json +8 -1
  89. package/tests/custom-options.json +169 -169
  90. package/tests/extend.json +71 -71
  91. package/tests/imports-weak.proto +7 -0
  92. package/tests/imports.json +83 -83
  93. package/tests/nodeunit-browser/nodeunit.css +70 -70
  94. package/tests/nodeunit-browser/nodeunit.js +2108 -2108
  95. package/tests/options.json +32 -32
  96. package/tests/proto2js/Bar.json +46 -46
  97. package/tests/suite.js +107 -82
  98. package/ProtoBuf.png +0 -0
  99. package/dist/ProtoBuf-light.min.js +0 -87
  100. package/dist/ProtoBuf-light.min.js.gz +0 -0
  101. package/dist/ProtoBuf-light.min.map +0 -8
  102. package/dist/ProtoBuf.min.js +0 -108
  103. package/dist/ProtoBuf.min.js.gz +0 -0
  104. package/dist/ProtoBuf.min.map +0 -8
  105. package/externs/ByteBuffer.js +0 -767
  106. package/externs/Long.js +0 -328
  107. package/sandbox/gapi/googleapis/google/api/annotations.proto +0 -29
  108. package/sandbox/gapi/googleapis/google/api/http.proto +0 -245
  109. package/sandbox/gapi/googleapis/google/datastore/v1beta3/datastore.proto +0 -281
  110. package/sandbox/gapi/googleapis/google/datastore/v1beta3/entity.proto +0 -189
  111. package/sandbox/gapi/googleapis/google/datastore/v1beta3/query.proto +0 -281
  112. package/sandbox/gapi/googleapis/google/longrunning/operations.proto +0 -144
  113. package/sandbox/gapi/googleapis/google/protobuf/any.proto +0 -98
  114. package/sandbox/gapi/googleapis/google/protobuf/any_test.proto +0 -41
  115. package/sandbox/gapi/googleapis/google/protobuf/api.proto +0 -201
  116. package/sandbox/gapi/googleapis/google/protobuf/descriptor.proto +0 -773
  117. package/sandbox/gapi/googleapis/google/protobuf/duration.proto +0 -95
  118. package/sandbox/gapi/googleapis/google/protobuf/empty.proto +0 -50
  119. package/sandbox/gapi/googleapis/google/protobuf/field_mask.proto +0 -167
  120. package/sandbox/gapi/googleapis/google/protobuf/map_lite_unittest.proto +0 -130
  121. package/sandbox/gapi/googleapis/google/protobuf/map_proto2_unittest.proto +0 -60
  122. package/sandbox/gapi/googleapis/google/protobuf/map_unittest.proto +0 -129
  123. package/sandbox/gapi/googleapis/google/protobuf/map_unittest_proto3.proto +0 -120
  124. package/sandbox/gapi/googleapis/google/protobuf/source_context.proto +0 -47
  125. package/sandbox/gapi/googleapis/google/protobuf/struct.proto +0 -94
  126. package/sandbox/gapi/googleapis/google/protobuf/timestamp.proto +0 -107
  127. package/sandbox/gapi/googleapis/google/protobuf/type.proto +0 -176
  128. package/sandbox/gapi/googleapis/google/protobuf/unittest.proto +0 -878
  129. package/sandbox/gapi/googleapis/google/protobuf/unittest_arena.proto +0 -46
  130. package/sandbox/gapi/googleapis/google/protobuf/unittest_custom_options.proto +0 -394
  131. package/sandbox/gapi/googleapis/google/protobuf/unittest_drop_unknown_fields.proto +0 -58
  132. package/sandbox/gapi/googleapis/google/protobuf/unittest_embed_optimize_for.proto +0 -51
  133. package/sandbox/gapi/googleapis/google/protobuf/unittest_empty.proto +0 -38
  134. package/sandbox/gapi/googleapis/google/protobuf/unittest_enormous_descriptor.proto +0 -1048
  135. package/sandbox/gapi/googleapis/google/protobuf/unittest_import.proto +0 -66
  136. package/sandbox/gapi/googleapis/google/protobuf/unittest_import_lite.proto +0 -52
  137. package/sandbox/gapi/googleapis/google/protobuf/unittest_import_proto3.proto +0 -68
  138. package/sandbox/gapi/googleapis/google/protobuf/unittest_import_public.proto +0 -41
  139. package/sandbox/gapi/googleapis/google/protobuf/unittest_import_public_lite.proto +0 -43
  140. package/sandbox/gapi/googleapis/google/protobuf/unittest_import_public_proto3.proto +0 -42
  141. package/sandbox/gapi/googleapis/google/protobuf/unittest_lite.proto +0 -385
  142. package/sandbox/gapi/googleapis/google/protobuf/unittest_lite_imports_nonlite.proto +0 -44
  143. package/sandbox/gapi/googleapis/google/protobuf/unittest_mset.proto +0 -82
  144. package/sandbox/gapi/googleapis/google/protobuf/unittest_mset_wire_format.proto +0 -52
  145. package/sandbox/gapi/googleapis/google/protobuf/unittest_no_arena.proto +0 -202
  146. package/sandbox/gapi/googleapis/google/protobuf/unittest_no_arena_import.proto +0 -37
  147. package/sandbox/gapi/googleapis/google/protobuf/unittest_no_arena_lite.proto +0 -42
  148. package/sandbox/gapi/googleapis/google/protobuf/unittest_no_field_presence.proto +0 -138
  149. package/sandbox/gapi/googleapis/google/protobuf/unittest_no_generic_services.proto +0 -54
  150. package/sandbox/gapi/googleapis/google/protobuf/unittest_optimize_for.proto +0 -67
  151. package/sandbox/gapi/googleapis/google/protobuf/unittest_preserve_unknown_enum.proto +0 -71
  152. package/sandbox/gapi/googleapis/google/protobuf/unittest_preserve_unknown_enum2.proto +0 -50
  153. package/sandbox/gapi/googleapis/google/protobuf/unittest_proto3.proto +0 -388
  154. package/sandbox/gapi/googleapis/google/protobuf/unittest_proto3_arena.proto +0 -206
  155. package/sandbox/gapi/googleapis/google/protobuf/unittest_well_known_types.proto +0 -112
  156. package/sandbox/gapi/googleapis/google/protobuf/unknown_enum_test.proto +0 -62
  157. package/sandbox/gapi/googleapis/google/protobuf/wrappers.proto +0 -117
  158. package/sandbox/gapi/googleapis/google/rpc/code.proto +0 -190
  159. package/sandbox/gapi/googleapis/google/rpc/error_details.proto +0 -157
  160. package/sandbox/gapi/googleapis/google/rpc/status.proto +0 -90
  161. package/sandbox/gapi/googleapis/google/type/color.proto +0 -163
  162. package/sandbox/gapi/googleapis/google/type/date.proto +0 -43
  163. package/sandbox/gapi/googleapis/google/type/dayofweek.proto +0 -50
  164. package/sandbox/gapi/googleapis/google/type/latlng.proto +0 -36
  165. package/sandbox/gapi/googleapis/google/type/money.proto +0 -40
  166. package/sandbox/gapi/googleapis/google/type/timeofday.proto +0 -42
  167. package/sandbox/gapi/test.js +0 -17
  168. package/sandbox/gapi/test.proto +0 -12
  169. package/sandbox/issue146/MyOptions.proto +0 -28
  170. package/sandbox/issue146/Sample.proto +0 -21
  171. package/sandbox/issue146/main.js +0 -3
  172. package/sandbox/issue147/enum.proto +0 -8
  173. package/sandbox/issue147/main.js +0 -3
  174. package/sandbox/issue182/commands.proto +0 -10
  175. package/sandbox/issue182/execute.js +0 -22
  176. package/sandbox/issue182/session_commands.proto +0 -14
  177. package/sandbox/issue289/A.proto +0 -8
  178. package/sandbox/issue289/B.proto +0 -8
  179. package/sandbox/issue289/common.proto +0 -5
  180. package/sandbox/issue289/main.js +0 -7
  181. package/sandbox/issue300/IAuth.proto +0 -14
  182. package/sandbox/issue300/Request.proto +0 -14
  183. package/sandbox/issue300/main.js +0 -26
  184. package/sandbox/issue42/innerextend.proto +0 -18
  185. package/sandbox/issue42/main.js +0 -8
  186. package/sandbox/issue42/outerextend.proto +0 -17
  187. package/tests/gtfs-realtime.proto +0 -552
  188. package/webpack.config.js +0 -9
package/externs/Long.js DELETED
@@ -1,328 +0,0 @@
1
- /*
2
- * Copyright 2012 The Closure Compiler Authors.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
-
17
- /**
18
- * @fileoverview Externs for Long.js.
19
- * @see https://github.com/dcodeIO/Long.js
20
- * @externs
21
- */
22
-
23
- /**
24
- BEGIN_NODE_INCLUDE
25
- var Long = require('long');
26
- END_NODE_INCLUDE
27
- */
28
-
29
- /**
30
- * @param {number} low
31
- * @param {number} high
32
- * @param {boolean=} unsigned
33
- * @constructor
34
- */
35
- var Long = function(low, high, unsigned) {};
36
-
37
- /**
38
- * @param {number} value
39
- * @param {boolean=} unsigned
40
- * @return {!Long}
41
- */
42
- Long.fromInt = function(value, unsigned) {};
43
-
44
- /**
45
- * @param {number} value
46
- * @param {boolean=} unsigned
47
- * @return {!Long}
48
- */
49
- Long.fromNumber = function(value, unsigned) {};
50
-
51
- /**
52
- * @param {number} lowBits
53
- * @param {number} highBits
54
- * @param {boolean=} unsigned
55
- * @return {!Long}
56
- */
57
- Long.fromBits = function(lowBits, highBits, unsigned) {};
58
-
59
- /**
60
- * @param {number} part0
61
- * @param {number} part1
62
- * @param {number} part2
63
- * @param {boolean=} unsigned
64
- * @return {!Long}
65
- */
66
- Long.from28Bits = function(part0, part1, part2, unsigned) {};
67
-
68
- /**
69
- * @param {string} str
70
- * @param {(boolean|number)=} unsigned
71
- * @param {number=} radix
72
- * @return {!Long}
73
- */
74
- Long.fromString = function(str, unsigned, radix) {};
75
-
76
- /**
77
- * @type {!Long}
78
- */
79
- Long.ZERO;
80
-
81
- /**
82
- * @type {!Long}
83
- */
84
- Long.ONE;
85
-
86
- /**
87
- * @type {!Long}
88
- */
89
- Long.NEG_ONE;
90
-
91
- /**
92
- * @type {!Long}
93
- */
94
- Long.MAX_SIGNED_VALUE;
95
-
96
- /**
97
- * @type {!Long}
98
- */
99
- Long.MIN_SIGNED_VALUE;
100
-
101
- /**
102
- * @type {!Long}
103
- */
104
- Long.MAX_UNSIGNED_VALUE;
105
-
106
- /**
107
- * @type {!Long}
108
- */
109
- Long.MIN_UNSIGNED_VALUE;
110
-
111
- /**
112
- * @type {!Long}
113
- */
114
- Long.MAX_VALUE;
115
-
116
- /**
117
- * @type {!Long}
118
- */
119
- Long.MIN_VALUE;
120
-
121
- /**
122
- * @type {number}
123
- */
124
- Long.prototype.low;
125
-
126
- /**
127
- * @type {number}
128
- */
129
- Long.prototype.high;
130
-
131
- /**
132
- * @type {boolean}
133
- */
134
- Long.prototype.unsigned;
135
-
136
- /**
137
- * @return {number}
138
- */
139
- Long.prototype.toInt = function() {};
140
-
141
- /**
142
- * @return {number}
143
- */
144
- Long.prototype.toNumber = function() {};
145
-
146
- /**
147
- * @param {number=} radix
148
- * @return {string}
149
- */
150
- Long.prototype.toString = function(radix) {};
151
-
152
- /**
153
- * @return {number}
154
- */
155
- Long.prototype.getHighBits = function() {};
156
-
157
- /**
158
- * @return {number}
159
- */
160
- Long.prototype.getHighBitsUnsigned = function() {};
161
-
162
- /**
163
- * @return {number}
164
- */
165
- Long.prototype.getLowBits = function() {};
166
-
167
- /**
168
- * @return {number}
169
- */
170
- Long.prototype.getLowBitsUnsigned = function() {};
171
-
172
- /**
173
- * @return {number}
174
- */
175
- Long.prototype.getNumBitsAbs = function() {};
176
-
177
- /**
178
- * @return {boolean}
179
- */
180
- Long.prototype.isZero = function() {};
181
-
182
- /**
183
- * @return {boolean}
184
- */
185
- Long.prototype.isNegative = function() {};
186
-
187
- /**
188
- * @return {boolean}
189
- */
190
- Long.prototype.isOdd = function() {};
191
-
192
- /**
193
- * @return {boolean}
194
- */
195
- Long.prototype.isEven = function() {};
196
-
197
- /**
198
- * @param {Long} other
199
- * @return {boolean}
200
- */
201
- Long.prototype.equals = function(other) {};
202
-
203
- /**
204
- * @param {Long} other
205
- * @return {boolean}
206
- */
207
- Long.prototype.notEquals = function(other) {};
208
-
209
- /**
210
- * @param {Long} other
211
- * @return {boolean}
212
- */
213
- Long.prototype.lessThan = function(other) {};
214
-
215
- /**
216
- * @param {Long} other
217
- * @return {boolean}
218
- */
219
- Long.prototype.lessThanOrEqual = function(other) {};
220
-
221
- /**
222
- * @param {Long} other
223
- * @return {boolean}
224
- */
225
- Long.prototype.greaterThan = function(other) {};
226
-
227
- /**
228
- * @param {Long} other
229
- * @return {boolean}
230
- */
231
- Long.prototype.greaterThanOrEqual = function(other) {};
232
-
233
- /**
234
- * @param {Long} other
235
- * @return {number}
236
- */
237
- Long.prototype.compare = function(other) {};
238
-
239
- /**
240
- * @return {!Long}
241
- */
242
- Long.prototype.negate = function() {};
243
-
244
- /**
245
- * @param {Long} other
246
- * @return {!Long}
247
- */
248
- Long.prototype.add = function(other) {};
249
-
250
- /**
251
- * @param {Long} other
252
- * @return {!Long}
253
- */
254
- Long.prototype.subtract = function(other) {};
255
-
256
- /**
257
- * @param {Long} other
258
- * @return {!Long}
259
- */
260
- Long.prototype.multiply = function(other) {};
261
-
262
- /**
263
- * @param {Long} other
264
- * @return {!Long}
265
- */
266
- Long.prototype.div = function(other) {};
267
-
268
- /**
269
- * @param {Long} other
270
- * @return {!Long}
271
- */
272
- Long.prototype.modulo = function(other) {};
273
-
274
- /**
275
- * @return {!Long}
276
- */
277
- Long.prototype.not = function() {};
278
-
279
- /**
280
- * @param {Long} other
281
- * @return {!Long}
282
- */
283
- Long.prototype.and = function(other) {};
284
-
285
- /**
286
- * @param {Long} other
287
- * @return {!Long}
288
- */
289
- Long.prototype.or = function(other) {};
290
-
291
- /**
292
- * @param {Long} other
293
- * @return {!Long}
294
- */
295
- Long.prototype.xor = function(other) {};
296
-
297
- /**
298
- * @param {number} numBits
299
- * @return {!Long}
300
- */
301
- Long.prototype.shiftLeft = function(numBits) {};
302
-
303
- /**
304
- * @param {number} numBits
305
- * @return {!Long}
306
- */
307
- Long.prototype.shiftRight = function(numBits) {};
308
-
309
- /**
310
- * @param {number} numBits
311
- * @return {!Long}
312
- */
313
- Long.prototype.shiftRightUnsigned = function(numBits) {};
314
-
315
- /**
316
- * @return {!Long}
317
- */
318
- Long.prototype.toSigned = function() {};
319
-
320
- /**
321
- * @return {!Long}
322
- */
323
- Long.prototype.toUnsigned = function() {};
324
-
325
- /**
326
- * @return {!Long}
327
- */
328
- Long.prototype.clone = function() {};
@@ -1,29 +0,0 @@
1
- // Copyright (c) 2015, Google Inc.
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
-
15
- syntax = "proto3";
16
-
17
- package google.api;
18
-
19
- import "google/api/http.proto";
20
- import "google/protobuf/descriptor.proto";
21
-
22
- option java_multiple_files = true;
23
- option java_outer_classname = "AnnotationsProto";
24
- option java_package = "com.google.api";
25
-
26
- extend google.protobuf.MethodOptions {
27
- // See `HttpRule`.
28
- HttpRule http = 72295728;
29
- }
@@ -1,245 +0,0 @@
1
- // Copyright (c) 2015, Google Inc.
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
-
15
- syntax = "proto3";
16
-
17
- package google.api;
18
-
19
- option java_multiple_files = true;
20
- option java_outer_classname = "HttpProto";
21
- option java_package = "com.google.api";
22
-
23
-
24
- // `HttpRule` defines the mapping of an RPC method to one or more HTTP
25
- // REST APIs. The mapping determines what portions of the request
26
- // message are populated from the path, query parameters, or body of
27
- // the HTTP request. The mapping is typically specified as an
28
- // `google.api.http` annotation, see "google/api/annotations.proto"
29
- // for details.
30
- //
31
- // The mapping consists of a field specifying the path template and
32
- // method kind. The path template can refer to fields in the request
33
- // message, as in the example below which describes a REST GET
34
- // operation on a resource collection of messages:
35
- //
36
- // ```proto
37
- // service Messaging {
38
- // rpc GetMessage(GetMessageRequest) returns (Message) {
39
- // option (google.api.http).get = "/v1/messages/{message_id}";
40
- // }
41
- // }
42
- // message GetMessageRequest {
43
- // string message_id = 1; // mapped to the URL
44
- // }
45
- // message Message {
46
- // string text = 1; // content of the resource
47
- // }
48
- // ```
49
- //
50
- // This definition enables an automatic, bidrectional mapping of HTTP
51
- // JSON to RPC. Example:
52
- //
53
- // HTTP | RPC
54
- // -----|-----
55
- // `GET /v1/messages/123456` | `GetMessage(message_id: "123456")`
56
- //
57
- // In general, not only fields but also field paths can be referenced
58
- // from a path pattern. Fields mapped to the path pattern cannot be
59
- // repeated and must have a primitive (non-message) type.
60
- //
61
- // Any fields in the request message which are not bound by the path
62
- // pattern automatically become (optional) HTTP query
63
- // parameters. Assume the following definition of the request message:
64
- //
65
- // ```proto
66
- // message GetMessageRequest {
67
- // string message_id = 1; // mapped to the URL
68
- // int64 revision = 2; // becomes a parameter
69
- // }
70
- // ```
71
- //
72
- // This enables a HTTP JSON to RPC mapping as below:
73
- //
74
- // HTTP | RPC
75
- // -----|-----
76
- // `GET /v1/messages/123456?revision=2` | `GetMessage(message_id: "123456" revision: 2)`
77
- //
78
- // Note that fields which are mapped to HTTP parameters must have a
79
- // primitive type or a repeated primitive type. Message types are not
80
- // allowed. In the case of a repeated type, the parameter can be
81
- // repeated in the URL, as in `...?param=A&param=B`.
82
- //
83
- // For HTTP method kinds which allow a request body, the `body` field
84
- // specifies the mapping. Consider a REST update method on the
85
- // message resource collection:
86
- //
87
- // ```proto
88
- // service Messaging {
89
- // rpc UpdateMessage(UpdateMessageRequest) returns (Message) {
90
- // option (google.api.http) = {
91
- // put: "/v1/messages/{message_id}"
92
- // body: "message"
93
- // }
94
- // }
95
- // message UpdateMessageRequest {
96
- // string message_id = 1; // mapped to the URL
97
- // Message message = 2; // mapped to the body
98
- // }
99
- // ```
100
- //
101
- // The following HTTP JSON to RPC mapping is enabled, where the
102
- // representation of the JSON in the request body is determined by
103
- // protos JSON encoding:
104
- //
105
- // HTTP | RPC
106
- // -----|-----
107
- // `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" message { text: "Hi!" })`
108
- //
109
- // The special name `*` can be used in the body mapping to define that
110
- // every field not bound by the path template should be mapped to the
111
- // request body. This enables the following alternative definition of
112
- // the update method:
113
- //
114
- // ```proto
115
- // service Messaging {
116
- // rpc UpdateMessage(Message) returns (Message) {
117
- // option (google.api.http) = {
118
- // put: "/v1/messages/{message_id}"
119
- // body: "*"
120
- // }
121
- // }
122
- // message Message {
123
- // string message_id = 2;
124
- // string text = 2;
125
- // }
126
- // ```
127
- //
128
- // The following HTTP JSON to RPC mapping is enabled:
129
- //
130
- // HTTP | RPC
131
- // -----|-----
132
- // `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" text: "Hi!")`
133
- //
134
- // Note that when using `*` in the body mapping, it is not possible to
135
- // have HTTP parameters, as all fields not bound by the path end in
136
- // the body. This makes this option more rarely used in practice of
137
- // defining REST APIs. The common usage of `*` is in custom methods
138
- // which don't use the URL at all for transferring data.
139
- //
140
- // It is possible to define multiple HTTP methods for one RPC by using
141
- // the `additional_bindings` option. Example:
142
- //
143
- // ```proto
144
- // service Messaging {
145
- // rpc GetMessage(GetMessageRequest) returns (Message) {
146
- // option (google.api.http) = {
147
- // get: "/v1/messages/{message_id}"
148
- // additional_bindings {
149
- // get: "/v1/users/{user_id}/messages/{message_id}"
150
- // }
151
- // }
152
- // }
153
- // message GetMessageRequest {
154
- // string message_id = 1;
155
- // string user_id = 2;
156
- // }
157
- // ```
158
- //
159
- // This enables the following two alternative HTTP JSON to RPC
160
- // mappings:
161
- //
162
- // HTTP | RPC
163
- // -----|-----
164
- // `GET /v1/messages/123456` | `GetMessage(message_id: "123456")`
165
- // `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id: "123456")`
166
- //
167
- // # Rules for HTTP mapping
168
- // The rules for mapping HTTP path, query parameters, and body fields
169
- // to the request message are as follows:
170
- //
171
- // 1. The `body` field specifies either `*` or a field path, or is
172
- // omitted. If omitted, it assumes there is no HTTP body.
173
- // 2. Leaf fields (recursive expansion of nested messages in the
174
- // request) can be classified into three types:
175
- // (a) Matched in the URL template.
176
- // (b) Covered by body (if body is `*`, everything except (a) fields;
177
- // else everything under the body field)
178
- // (c) All other fields.
179
- // 3. URL query parameters found in the HTTP request are mapped to (c) fields.
180
- // 4. Any body sent with an HTTP request can contain only (b) fields.
181
- //
182
- // The syntax of the path template is as follows:
183
- //
184
- // Template = "/" Segments [ Verb ] ;
185
- // Segments = Segment { "/" Segment } ;
186
- // Segment = "*" | "**" | LITERAL | Variable ;
187
- // Variable = "{" FieldPath [ "=" Segments ] "}" ;
188
- // FieldPath = IDENT { "." IDENT } ;
189
- // Verb = ":" LITERAL ;
190
- //
191
- // `*` matches a single path component, `**` zero or more path components, and
192
- // `LITERAL` a constant. A `Variable` can match an entire path as specified
193
- // again by a template; this nested template must not contain further variables.
194
- // If no template is given with a variable, it matches a single path component.
195
- // The notation `{var}` is henceforth equivalent to `{var=*}`. NOTE: the field
196
- // paths in variables and in the `body` must not refer to repeated fields.
197
- //
198
- // Use CustomHttpPattern to specify any HTTP method that is not included in the
199
- // pattern field, such as HEAD, or "*" to leave the HTTP method unspecified for
200
- // a given URL path rule. The wild-card rule is useful for services that provide
201
- // content to Web (HTML) clients.
202
- message HttpRule {
203
-
204
- // Determines the URL pattern is matched by this rules. This pattern can be
205
- // used with any of the {get|put|post|delete|patch} methods. A custom method
206
- // can be defined using the 'custom' field.
207
- oneof pattern {
208
- // Used for listing and getting information about resources.
209
- string get = 2;
210
-
211
- // Used for updating a resource.
212
- string put = 3;
213
-
214
- // Used for creating a resource.
215
- string post = 4;
216
-
217
- // Used for deleting a resource.
218
- string delete = 5;
219
-
220
- // Used for updating a resource.
221
- string patch = 6;
222
-
223
- // Custom pattern is used for defining custom verbs.
224
- CustomHttpPattern custom = 8;
225
- }
226
-
227
- // The name of the request field whose value is mapped to the HTTP body, or
228
- // `*` for mapping all fields not captured by the path pattern to the HTTP
229
- // body. NOTE: the referred field must not be a repeated field.
230
- string body = 7;
231
-
232
- // Additional HTTP bindings for the selector. Nested bindings must
233
- // not contain an `additional_bindings` field themselves (that is,
234
- // the nesting may only be one level deep).
235
- repeated HttpRule additional_bindings = 11;
236
- }
237
-
238
- // A custom pattern is used for defining custom HTTP verb.
239
- message CustomHttpPattern {
240
- // The name of this custom HTTP verb.
241
- string kind = 1;
242
-
243
- // The path matched by this custom verb.
244
- string path = 2;
245
- }