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