FieldMask.php 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <?php
  2. # Generated by the protocol buffer compiler. DO NOT EDIT!
  3. # source: google/protobuf/field_mask.proto
  4. namespace Google\Protobuf;
  5. use Google\Protobuf\Internal\GPBType;
  6. use Google\Protobuf\Internal\RepeatedField;
  7. use Google\Protobuf\Internal\GPBUtil;
  8. /**
  9. * `FieldMask` represents a set of symbolic field paths, for example:
  10. * paths: "f.a"
  11. * paths: "f.b.d"
  12. * Here `f` represents a field in some root message, `a` and `b`
  13. * fields in the message found in `f`, and `d` a field found in the
  14. * message in `f.b`.
  15. * Field masks are used to specify a subset of fields that should be
  16. * returned by a get operation or modified by an update operation.
  17. * Field masks also have a custom JSON encoding (see below).
  18. * # Field Masks in Projections
  19. * When used in the context of a projection, a response message or
  20. * sub-message is filtered by the API to only contain those fields as
  21. * specified in the mask. For example, if the mask in the previous
  22. * example is applied to a response message as follows:
  23. * f {
  24. * a : 22
  25. * b {
  26. * d : 1
  27. * x : 2
  28. * }
  29. * y : 13
  30. * }
  31. * z: 8
  32. * The result will not contain specific values for fields x,y and z
  33. * (their value will be set to the default, and omitted in proto text
  34. * output):
  35. * f {
  36. * a : 22
  37. * b {
  38. * d : 1
  39. * }
  40. * }
  41. * A repeated field is not allowed except at the last position of a
  42. * paths string.
  43. * If a FieldMask object is not present in a get operation, the
  44. * operation applies to all fields (as if a FieldMask of all fields
  45. * had been specified).
  46. * Note that a field mask does not necessarily apply to the
  47. * top-level response message. In case of a REST get operation, the
  48. * field mask applies directly to the response, but in case of a REST
  49. * list operation, the mask instead applies to each individual message
  50. * in the returned resource list. In case of a REST custom method,
  51. * other definitions may be used. Where the mask applies will be
  52. * clearly documented together with its declaration in the API. In
  53. * any case, the effect on the returned resource/resources is required
  54. * behavior for APIs.
  55. * # Field Masks in Update Operations
  56. * A field mask in update operations specifies which fields of the
  57. * targeted resource are going to be updated. The API is required
  58. * to only change the values of the fields as specified in the mask
  59. * and leave the others untouched. If a resource is passed in to
  60. * describe the updated values, the API ignores the values of all
  61. * fields not covered by the mask.
  62. * If a repeated field is specified for an update operation, the existing
  63. * repeated values in the target resource will be overwritten by the new values.
  64. * Note that a repeated field is only allowed in the last position of a `paths`
  65. * string.
  66. * If a sub-message is specified in the last position of the field mask for an
  67. * update operation, then the existing sub-message in the target resource is
  68. * overwritten. Given the target message:
  69. * f {
  70. * b {
  71. * d : 1
  72. * x : 2
  73. * }
  74. * c : 1
  75. * }
  76. * And an update message:
  77. * f {
  78. * b {
  79. * d : 10
  80. * }
  81. * }
  82. * then if the field mask is:
  83. * paths: "f.b"
  84. * then the result will be:
  85. * f {
  86. * b {
  87. * d : 10
  88. * }
  89. * c : 1
  90. * }
  91. * However, if the update mask was:
  92. * paths: "f.b.d"
  93. * then the result would be:
  94. * f {
  95. * b {
  96. * d : 10
  97. * x : 2
  98. * }
  99. * c : 1
  100. * }
  101. * In order to reset a field's value to the default, the field must
  102. * be in the mask and set to the default value in the provided resource.
  103. * Hence, in order to reset all fields of a resource, provide a default
  104. * instance of the resource and set all fields in the mask, or do
  105. * not provide a mask as described below.
  106. * If a field mask is not present on update, the operation applies to
  107. * all fields (as if a field mask of all fields has been specified).
  108. * Note that in the presence of schema evolution, this may mean that
  109. * fields the client does not know and has therefore not filled into
  110. * the request will be reset to their default. If this is unwanted
  111. * behavior, a specific service may require a client to always specify
  112. * a field mask, producing an error if not.
  113. * As with get operations, the location of the resource which
  114. * describes the updated values in the request message depends on the
  115. * operation kind. In any case, the effect of the field mask is
  116. * required to be honored by the API.
  117. * ## Considerations for HTTP REST
  118. * The HTTP kind of an update operation which uses a field mask must
  119. * be set to PATCH instead of PUT in order to satisfy HTTP semantics
  120. * (PUT must only be used for full updates).
  121. * # JSON Encoding of Field Masks
  122. * In JSON, a field mask is encoded as a single string where paths are
  123. * separated by a comma. Fields name in each path are converted
  124. * to/from lower-camel naming conventions.
  125. * As an example, consider the following message declarations:
  126. * message Profile {
  127. * User user = 1;
  128. * Photo photo = 2;
  129. * }
  130. * message User {
  131. * string display_name = 1;
  132. * string address = 2;
  133. * }
  134. * In proto a field mask for `Profile` may look as such:
  135. * mask {
  136. * paths: "user.display_name"
  137. * paths: "photo"
  138. * }
  139. * In JSON, the same mask is represented as below:
  140. * {
  141. * mask: "user.displayName,photo"
  142. * }
  143. * # Field Masks and Oneof Fields
  144. * Field masks treat fields in oneofs just as regular fields. Consider the
  145. * following message:
  146. * message SampleMessage {
  147. * oneof test_oneof {
  148. * string name = 4;
  149. * SubMessage sub_message = 9;
  150. * }
  151. * }
  152. * The field mask can be:
  153. * mask {
  154. * paths: "name"
  155. * }
  156. * Or:
  157. * mask {
  158. * paths: "sub_message"
  159. * }
  160. * Note that oneof type names ("test_oneof" in this case) cannot be used in
  161. * paths.
  162. * ## Field Mask Verification
  163. * The implementation of any API method which has a FieldMask type field in the
  164. * request should verify the included field paths, and return an
  165. * `INVALID_ARGUMENT` error if any path is duplicated or unmappable.
  166. *
  167. * Generated from protobuf message <code>google.protobuf.FieldMask</code>
  168. */
  169. class FieldMask extends \Google\Protobuf\Internal\Message
  170. {
  171. /**
  172. * The set of field mask paths.
  173. *
  174. * Generated from protobuf field <code>repeated string paths = 1;</code>
  175. */
  176. private $paths;
  177. /**
  178. * Constructor.
  179. *
  180. * @param array $data {
  181. * Optional. Data for populating the Message object.
  182. *
  183. * @type string[]|\Google\Protobuf\Internal\RepeatedField $paths
  184. * The set of field mask paths.
  185. * }
  186. */
  187. public function __construct($data = NULL) {
  188. \GPBMetadata\Google\Protobuf\FieldMask::initOnce();
  189. parent::__construct($data);
  190. }
  191. /**
  192. * The set of field mask paths.
  193. *
  194. * Generated from protobuf field <code>repeated string paths = 1;</code>
  195. * @return \Google\Protobuf\Internal\RepeatedField
  196. */
  197. public function getPaths()
  198. {
  199. return $this->paths;
  200. }
  201. /**
  202. * The set of field mask paths.
  203. *
  204. * Generated from protobuf field <code>repeated string paths = 1;</code>
  205. * @param string[]|\Google\Protobuf\Internal\RepeatedField $var
  206. * @return $this
  207. */
  208. public function setPaths($var)
  209. {
  210. $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
  211. $this->paths = $arr;
  212. return $this;
  213. }
  214. }