field_mask.proto 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. // Protocol Buffers - Google's data interchange format
  2. // Copyright 2008 Google Inc. All rights reserved.
  3. // https://developers.google.com/protocol-buffers/
  4. //
  5. // Redistribution and use in source and binary forms, with or without
  6. // modification, are permitted provided that the following conditions are
  7. // met:
  8. //
  9. // * Redistributions of source code must retain the above copyright
  10. // notice, this list of conditions and the following disclaimer.
  11. // * Redistributions in binary form must reproduce the above
  12. // copyright notice, this list of conditions and the following disclaimer
  13. // in the documentation and/or other materials provided with the
  14. // distribution.
  15. // * Neither the name of Google Inc. nor the names of its
  16. // contributors may be used to endorse or promote products derived from
  17. // this software without specific prior written permission.
  18. //
  19. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  20. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  22. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  23. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  24. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  25. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  26. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  27. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  28. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  29. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. syntax = "proto3";
  31. package google.protobuf;
  32. option java_package = "com.google.protobuf";
  33. option java_outer_classname = "FieldMaskProto";
  34. option java_multiple_files = true;
  35. option objc_class_prefix = "GPB";
  36. option csharp_namespace = "Google.Protobuf.WellKnownTypes";
  37. option go_package = "google.golang.org/protobuf/types/known/fieldmaskpb";
  38. option cc_enable_arenas = true;
  39. // `FieldMask` represents a set of symbolic field paths, for example:
  40. //
  41. // paths: "f.a"
  42. // paths: "f.b.d"
  43. //
  44. // Here `f` represents a field in some root message, `a` and `b`
  45. // fields in the message found in `f`, and `d` a field found in the
  46. // message in `f.b`.
  47. //
  48. // Field masks are used to specify a subset of fields that should be
  49. // returned by a get operation or modified by an update operation.
  50. // Field masks also have a custom JSON encoding (see below).
  51. //
  52. // # Field Masks in Projections
  53. //
  54. // When used in the context of a projection, a response message or
  55. // sub-message is filtered by the API to only contain those fields as
  56. // specified in the mask. For example, if the mask in the previous
  57. // example is applied to a response message as follows:
  58. //
  59. // f {
  60. // a : 22
  61. // b {
  62. // d : 1
  63. // x : 2
  64. // }
  65. // y : 13
  66. // }
  67. // z: 8
  68. //
  69. // The result will not contain specific values for fields x,y and z
  70. // (their value will be set to the default, and omitted in proto text
  71. // output):
  72. //
  73. //
  74. // f {
  75. // a : 22
  76. // b {
  77. // d : 1
  78. // }
  79. // }
  80. //
  81. // A repeated field is not allowed except at the last position of a
  82. // paths string.
  83. //
  84. // If a FieldMask object is not present in a get operation, the
  85. // operation applies to all fields (as if a FieldMask of all fields
  86. // had been specified).
  87. //
  88. // Note that a field mask does not necessarily apply to the
  89. // top-level response message. In case of a REST get operation, the
  90. // field mask applies directly to the response, but in case of a REST
  91. // list operation, the mask instead applies to each individual message
  92. // in the returned resource list. In case of a REST custom method,
  93. // other definitions may be used. Where the mask applies will be
  94. // clearly documented together with its declaration in the API. In
  95. // any case, the effect on the returned resource/resources is required
  96. // behavior for APIs.
  97. //
  98. // # Field Masks in Update Operations
  99. //
  100. // A field mask in update operations specifies which fields of the
  101. // targeted resource are going to be updated. The API is required
  102. // to only change the values of the fields as specified in the mask
  103. // and leave the others untouched. If a resource is passed in to
  104. // describe the updated values, the API ignores the values of all
  105. // fields not covered by the mask.
  106. //
  107. // If a repeated field is specified for an update operation, new values will
  108. // be appended to the existing repeated field in the target resource. Note that
  109. // a repeated field is only allowed in the last position of a `paths` string.
  110. //
  111. // If a sub-message is specified in the last position of the field mask for an
  112. // update operation, then new value will be merged into the existing sub-message
  113. // in the target resource.
  114. //
  115. // For example, given the target message:
  116. //
  117. // f {
  118. // b {
  119. // d: 1
  120. // x: 2
  121. // }
  122. // c: [1]
  123. // }
  124. //
  125. // And an update message:
  126. //
  127. // f {
  128. // b {
  129. // d: 10
  130. // }
  131. // c: [2]
  132. // }
  133. //
  134. // then if the field mask is:
  135. //
  136. // paths: ["f.b", "f.c"]
  137. //
  138. // then the result will be:
  139. //
  140. // f {
  141. // b {
  142. // d: 10
  143. // x: 2
  144. // }
  145. // c: [1, 2]
  146. // }
  147. //
  148. // An implementation may provide options to override this default behavior for
  149. // repeated and message fields.
  150. //
  151. // In order to reset a field's value to the default, the field must
  152. // be in the mask and set to the default value in the provided resource.
  153. // Hence, in order to reset all fields of a resource, provide a default
  154. // instance of the resource and set all fields in the mask, or do
  155. // not provide a mask as described below.
  156. //
  157. // If a field mask is not present on update, the operation applies to
  158. // all fields (as if a field mask of all fields has been specified).
  159. // Note that in the presence of schema evolution, this may mean that
  160. // fields the client does not know and has therefore not filled into
  161. // the request will be reset to their default. If this is unwanted
  162. // behavior, a specific service may require a client to always specify
  163. // a field mask, producing an error if not.
  164. //
  165. // As with get operations, the location of the resource which
  166. // describes the updated values in the request message depends on the
  167. // operation kind. In any case, the effect of the field mask is
  168. // required to be honored by the API.
  169. //
  170. // ## Considerations for HTTP REST
  171. //
  172. // The HTTP kind of an update operation which uses a field mask must
  173. // be set to PATCH instead of PUT in order to satisfy HTTP semantics
  174. // (PUT must only be used for full updates).
  175. //
  176. // # JSON Encoding of Field Masks
  177. //
  178. // In JSON, a field mask is encoded as a single string where paths are
  179. // separated by a comma. Fields name in each path are converted
  180. // to/from lower-camel naming conventions.
  181. //
  182. // As an example, consider the following message declarations:
  183. //
  184. // message Profile {
  185. // User user = 1;
  186. // Photo photo = 2;
  187. // }
  188. // message User {
  189. // string display_name = 1;
  190. // string address = 2;
  191. // }
  192. //
  193. // In proto a field mask for `Profile` may look as such:
  194. //
  195. // mask {
  196. // paths: "user.display_name"
  197. // paths: "photo"
  198. // }
  199. //
  200. // In JSON, the same mask is represented as below:
  201. //
  202. // {
  203. // mask: "user.displayName,photo"
  204. // }
  205. //
  206. // # Field Masks and Oneof Fields
  207. //
  208. // Field masks treat fields in oneofs just as regular fields. Consider the
  209. // following message:
  210. //
  211. // message SampleMessage {
  212. // oneof test_oneof {
  213. // string name = 4;
  214. // SubMessage sub_message = 9;
  215. // }
  216. // }
  217. //
  218. // The field mask can be:
  219. //
  220. // mask {
  221. // paths: "name"
  222. // }
  223. //
  224. // Or:
  225. //
  226. // mask {
  227. // paths: "sub_message"
  228. // }
  229. //
  230. // Note that oneof type names ("test_oneof" in this case) cannot be used in
  231. // paths.
  232. //
  233. // ## Field Mask Verification
  234. //
  235. // The implementation of any API method which has a FieldMask type field in the
  236. // request should verify the included field paths, and return an
  237. // `INVALID_ARGUMENT` error if any path is unmappable.
  238. message FieldMask {
  239. // The set of field mask paths.
  240. repeated string paths = 1;
  241. }