google-cloud-pubsub 1.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +18 -0
  3. data/AUTHENTICATION.md +177 -0
  4. data/CHANGELOG.md +538 -0
  5. data/CODE_OF_CONDUCT.md +40 -0
  6. data/CONTRIBUTING.md +188 -0
  7. data/EMULATOR.md +37 -0
  8. data/LICENSE +201 -0
  9. data/LOGGING.md +32 -0
  10. data/OVERVIEW.md +557 -0
  11. data/TROUBLESHOOTING.md +31 -0
  12. data/lib/google-cloud-pubsub.rb +139 -0
  13. data/lib/google/cloud/pubsub.rb +173 -0
  14. data/lib/google/cloud/pubsub/async_publisher.rb +399 -0
  15. data/lib/google/cloud/pubsub/async_publisher/batch.rb +309 -0
  16. data/lib/google/cloud/pubsub/batch_publisher.rb +99 -0
  17. data/lib/google/cloud/pubsub/convert.rb +91 -0
  18. data/lib/google/cloud/pubsub/credentials.rb +47 -0
  19. data/lib/google/cloud/pubsub/errors.rb +85 -0
  20. data/lib/google/cloud/pubsub/message.rb +158 -0
  21. data/lib/google/cloud/pubsub/policy.rb +187 -0
  22. data/lib/google/cloud/pubsub/project.rb +393 -0
  23. data/lib/google/cloud/pubsub/publish_result.rb +103 -0
  24. data/lib/google/cloud/pubsub/received_message.rb +297 -0
  25. data/lib/google/cloud/pubsub/retry_policy.rb +90 -0
  26. data/lib/google/cloud/pubsub/service.rb +514 -0
  27. data/lib/google/cloud/pubsub/snapshot.rb +202 -0
  28. data/lib/google/cloud/pubsub/snapshot/list.rb +178 -0
  29. data/lib/google/cloud/pubsub/subscriber.rb +399 -0
  30. data/lib/google/cloud/pubsub/subscriber/enumerator_queue.rb +54 -0
  31. data/lib/google/cloud/pubsub/subscriber/inventory.rb +166 -0
  32. data/lib/google/cloud/pubsub/subscriber/sequencer.rb +115 -0
  33. data/lib/google/cloud/pubsub/subscriber/stream.rb +401 -0
  34. data/lib/google/cloud/pubsub/subscriber/timed_unary_buffer.rb +231 -0
  35. data/lib/google/cloud/pubsub/subscription.rb +1279 -0
  36. data/lib/google/cloud/pubsub/subscription/list.rb +205 -0
  37. data/lib/google/cloud/pubsub/subscription/push_config.rb +244 -0
  38. data/lib/google/cloud/pubsub/topic.rb +934 -0
  39. data/lib/google/cloud/pubsub/topic/list.rb +171 -0
  40. data/lib/google/cloud/pubsub/v1.rb +17 -0
  41. data/lib/google/cloud/pubsub/v1/credentials.rb +41 -0
  42. data/lib/google/cloud/pubsub/v1/doc/google/iam/v1/iam_policy.rb +21 -0
  43. data/lib/google/cloud/pubsub/v1/doc/google/iam/v1/options.rb +21 -0
  44. data/lib/google/cloud/pubsub/v1/doc/google/iam/v1/policy.rb +21 -0
  45. data/lib/google/cloud/pubsub/v1/doc/google/protobuf/duration.rb +91 -0
  46. data/lib/google/cloud/pubsub/v1/doc/google/protobuf/empty.rb +29 -0
  47. data/lib/google/cloud/pubsub/v1/doc/google/protobuf/field_mask.rb +222 -0
  48. data/lib/google/cloud/pubsub/v1/doc/google/protobuf/timestamp.rb +113 -0
  49. data/lib/google/cloud/pubsub/v1/doc/google/pubsub/v1/pubsub.rb +833 -0
  50. data/lib/google/cloud/pubsub/v1/doc/google/type/expr.rb +19 -0
  51. data/lib/google/cloud/pubsub/v1/publisher_client.rb +928 -0
  52. data/lib/google/cloud/pubsub/v1/publisher_client_config.json +120 -0
  53. data/lib/google/cloud/pubsub/v1/subscriber_client.rb +1466 -0
  54. data/lib/google/cloud/pubsub/v1/subscriber_client_config.json +153 -0
  55. data/lib/google/cloud/pubsub/version.rb +24 -0
  56. data/lib/google/pubsub/v1/pubsub_pb.rb +269 -0
  57. data/lib/google/pubsub/v1/pubsub_services_pb.rb +215 -0
  58. metadata +337 -0
@@ -0,0 +1,171 @@
1
+ # Copyright 2015 Google LLC
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
+ # https://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
+
16
+ require "delegate"
17
+
18
+ module Google
19
+ module Cloud
20
+ module PubSub
21
+ class Topic
22
+ ##
23
+ # Topic::List is a special case Array with additional values.
24
+ class List < DelegateClass(::Array)
25
+ ##
26
+ # If not empty, indicates that there are more topics
27
+ # that match the request and this value should be passed to
28
+ # the next {Google::Cloud::PubSub::Project#topics} to continue.
29
+ attr_accessor :token
30
+
31
+ ##
32
+ # @private Create a new Topic::List with an array of values.
33
+ def initialize arr = []
34
+ super arr
35
+ end
36
+
37
+ ##
38
+ # Whether there a next page of topics.
39
+ #
40
+ # @return [Boolean]
41
+ #
42
+ # @example
43
+ # require "google/cloud/pubsub"
44
+ #
45
+ # pubsub = Google::Cloud::PubSub.new
46
+ #
47
+ # topics = pubsub.topics
48
+ # if topics.next?
49
+ # next_topics = topics.next
50
+ # end
51
+ #
52
+ def next?
53
+ !token.nil?
54
+ end
55
+
56
+ ##
57
+ # Retrieve the next page of topics.
58
+ #
59
+ # @return [Topic::List]
60
+ #
61
+ # @example
62
+ # require "google/cloud/pubsub"
63
+ #
64
+ # pubsub = Google::Cloud::PubSub.new
65
+ #
66
+ # topics = pubsub.topics
67
+ # if topics.next?
68
+ # next_topics = topics.next
69
+ # end
70
+ #
71
+ def next
72
+ return nil unless next?
73
+ ensure_service!
74
+ options = { token: token, max: @max }
75
+ grpc = @service.list_topics options
76
+ self.class.from_grpc grpc, @service, @max
77
+ end
78
+
79
+ ##
80
+ # Retrieves remaining results by repeatedly invoking {#next} until
81
+ # {#next?} returns `false`. Calls the given block once for each
82
+ # result, which is passed as the argument to the block.
83
+ #
84
+ # An Enumerator is returned if no block is given.
85
+ #
86
+ # This method will make repeated API calls until all remaining results
87
+ # are retrieved. (Unlike `#each`, for example, which merely iterates
88
+ # over the results returned by a single API call.) Use with caution.
89
+ #
90
+ # @param [Integer] request_limit The upper limit of API requests to
91
+ # make to load all topics. Default is no limit.
92
+ # @yield [topic] The block for accessing each topic.
93
+ # @yieldparam [Topic] topic The topic object.
94
+ #
95
+ # @return [Enumerator]
96
+ #
97
+ # @example Iterating each topic by passing a block:
98
+ # require "google/cloud/pubsub"
99
+ #
100
+ # pubsub = Google::Cloud::PubSub.new
101
+ #
102
+ # topics = pubsub.topics
103
+ # topics.all do |topic|
104
+ # puts topic.name
105
+ # end
106
+ #
107
+ # @example Using the enumerator by not passing a block:
108
+ # require "google/cloud/pubsub"
109
+ #
110
+ # pubsub = Google::Cloud::PubSub.new
111
+ #
112
+ # topics = pubsub.topics
113
+ # all_names = topics.all.map do |topic|
114
+ # topic.name
115
+ # end
116
+ #
117
+ # @example Limit the number of API calls made:
118
+ # require "google/cloud/pubsub"
119
+ #
120
+ # pubsub = Google::Cloud::PubSub.new
121
+ #
122
+ # topics = pubsub.topics
123
+ # topics.all(request_limit: 10) do |topic|
124
+ # puts topic.name
125
+ # end
126
+ #
127
+ def all request_limit: nil
128
+ request_limit = request_limit.to_i if request_limit
129
+ return enum_for :all, request_limit: request_limit unless block_given?
130
+ results = self
131
+ loop do
132
+ results.each { |r| yield r }
133
+ if request_limit
134
+ request_limit -= 1
135
+ break if request_limit.negative?
136
+ end
137
+ break unless results.next?
138
+ results = results.next
139
+ end
140
+ end
141
+
142
+ ##
143
+ # @private New Topic::List from a
144
+ # Google::Cloud::PubSub::V1::ListTopicsResponse object.
145
+ def self.from_grpc grpc_list, service, max = nil
146
+ topics = new(Array(grpc_list.topics).map do |grpc|
147
+ Topic.from_grpc grpc, service
148
+ end)
149
+ token = grpc_list.next_page_token
150
+ token = nil if token == "".freeze
151
+ topics.instance_variable_set :@token, token
152
+ topics.instance_variable_set :@service, service
153
+ topics.instance_variable_set :@max, max
154
+ topics
155
+ end
156
+
157
+ protected
158
+
159
+ ##
160
+ # @private Raise an error unless an active connection to the service
161
+ # is available.
162
+ def ensure_service!
163
+ raise "Must have active connection to service" unless @service
164
+ end
165
+ end
166
+ end
167
+ end
168
+
169
+ Pubsub = PubSub unless const_defined? :Pubsub
170
+ end
171
+ end
@@ -0,0 +1,17 @@
1
+ # Copyright 2015 Google LLC
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
+ # https://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
+
16
+ require "google/cloud/pubsub/v1/publisher_client"
17
+ require "google/cloud/pubsub/v1/subscriber_client"
@@ -0,0 +1,41 @@
1
+ # Copyright 2020 Google LLC
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
+ # https://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
+
16
+ require "googleauth"
17
+
18
+ module Google
19
+ module Cloud
20
+ module PubSub
21
+ module V1
22
+ class Credentials < Google::Auth::Credentials
23
+ SCOPE = ["https://www.googleapis.com/auth/pubsub"].freeze
24
+ PATH_ENV_VARS = %w(PUBSUB_CREDENTIALS
25
+ PUBSUB_KEYFILE
26
+ GOOGLE_CLOUD_CREDENTIALS
27
+ GOOGLE_CLOUD_KEYFILE
28
+ GCLOUD_KEYFILE)
29
+ JSON_ENV_VARS = %w(PUBSUB_CREDENTIALS_JSON
30
+ PUBSUB_KEYFILE_JSON
31
+ GOOGLE_CLOUD_CREDENTIALS_JSON
32
+ GOOGLE_CLOUD_KEYFILE_JSON
33
+ GCLOUD_KEYFILE_JSON)
34
+ DEFAULT_PATHS = ["~/.config/gcloud/application_default_credentials.json"]
35
+ end
36
+ end
37
+ end
38
+
39
+ Pubsub = PubSub unless const_defined? :Pubsub
40
+ end
41
+ end
@@ -0,0 +1,21 @@
1
+ # Copyright 2020 Google LLC
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
+ # https://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
+
16
+ module Google
17
+ module Iam
18
+ module V1
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ # Copyright 2020 Google LLC
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
+ # https://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
+
16
+ module Google
17
+ module Iam
18
+ module V1
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ # Copyright 2020 Google LLC
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
+ # https://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
+
16
+ module Google
17
+ module Iam
18
+ module V1
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,91 @@
1
+ # Copyright 2020 Google LLC
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
+ # https://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
+
16
+ module Google
17
+ module Protobuf
18
+ # A Duration represents a signed, fixed-length span of time represented
19
+ # as a count of seconds and fractions of seconds at nanosecond
20
+ # resolution. It is independent of any calendar and concepts like "day"
21
+ # or "month". It is related to Timestamp in that the difference between
22
+ # two Timestamp values is a Duration and it can be added or subtracted
23
+ # from a Timestamp. Range is approximately +-10,000 years.
24
+ #
25
+ # = Examples
26
+ #
27
+ # Example 1: Compute Duration from two Timestamps in pseudo code.
28
+ #
29
+ # Timestamp start = ...;
30
+ # Timestamp end = ...;
31
+ # Duration duration = ...;
32
+ #
33
+ # duration.seconds = end.seconds - start.seconds;
34
+ # duration.nanos = end.nanos - start.nanos;
35
+ #
36
+ # if (duration.seconds < 0 && duration.nanos > 0) {
37
+ # duration.seconds += 1;
38
+ # duration.nanos -= 1000000000;
39
+ # } else if (durations.seconds > 0 && duration.nanos < 0) {
40
+ # duration.seconds -= 1;
41
+ # duration.nanos += 1000000000;
42
+ # }
43
+ #
44
+ # Example 2: Compute Timestamp from Timestamp + Duration in pseudo code.
45
+ #
46
+ # Timestamp start = ...;
47
+ # Duration duration = ...;
48
+ # Timestamp end = ...;
49
+ #
50
+ # end.seconds = start.seconds + duration.seconds;
51
+ # end.nanos = start.nanos + duration.nanos;
52
+ #
53
+ # if (end.nanos < 0) {
54
+ # end.seconds -= 1;
55
+ # end.nanos += 1000000000;
56
+ # } else if (end.nanos >= 1000000000) {
57
+ # end.seconds += 1;
58
+ # end.nanos -= 1000000000;
59
+ # }
60
+ #
61
+ # Example 3: Compute Duration from datetime.timedelta in Python.
62
+ #
63
+ # td = datetime.timedelta(days=3, minutes=10)
64
+ # duration = Duration()
65
+ # duration.FromTimedelta(td)
66
+ #
67
+ # = JSON Mapping
68
+ #
69
+ # In JSON format, the Duration type is encoded as a string rather than an
70
+ # object, where the string ends in the suffix "s" (indicating seconds) and
71
+ # is preceded by the number of seconds, with nanoseconds expressed as
72
+ # fractional seconds. For example, 3 seconds with 0 nanoseconds should be
73
+ # encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should
74
+ # be expressed in JSON format as "3.000000001s", and 3 seconds and 1
75
+ # microsecond should be expressed in JSON format as "3.000001s".
76
+ # @!attribute [rw] seconds
77
+ # @return [Integer]
78
+ # Signed seconds of the span of time. Must be from -315,576,000,000
79
+ # to +315,576,000,000 inclusive. Note: these bounds are computed from:
80
+ # 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years
81
+ # @!attribute [rw] nanos
82
+ # @return [Integer]
83
+ # Signed fractions of a second at nanosecond resolution of the span
84
+ # of time. Durations less than one second are represented with a 0
85
+ # `seconds` field and a positive or negative `nanos` field. For durations
86
+ # of one second or more, a non-zero value for the `nanos` field must be
87
+ # of the same sign as the `seconds` field. Must be from -999,999,999
88
+ # to +999,999,999 inclusive.
89
+ class Duration; end
90
+ end
91
+ end
@@ -0,0 +1,29 @@
1
+ # Copyright 2020 Google LLC
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
+ # https://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
+
16
+ module Google
17
+ module Protobuf
18
+ # A generic empty message that you can re-use to avoid defining duplicated
19
+ # empty messages in your APIs. A typical example is to use it as the request
20
+ # or the response type of an API method. For instance:
21
+ #
22
+ # service Foo {
23
+ # rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);
24
+ # }
25
+ #
26
+ # The JSON representation for `Empty` is empty JSON object `{}`.
27
+ class Empty; end
28
+ end
29
+ end
@@ -0,0 +1,222 @@
1
+ # Copyright 2020 Google LLC
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
+ # https://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
+
16
+ module Google
17
+ module Protobuf
18
+ # `FieldMask` represents a set of symbolic field paths, for example:
19
+ #
20
+ # paths: "f.a"
21
+ # paths: "f.b.d"
22
+ #
23
+ # Here `f` represents a field in some root message, `a` and `b`
24
+ # fields in the message found in `f`, and `d` a field found in the
25
+ # message in `f.b`.
26
+ #
27
+ # Field masks are used to specify a subset of fields that should be
28
+ # returned by a get operation or modified by an update operation.
29
+ # Field masks also have a custom JSON encoding (see below).
30
+ #
31
+ # = Field Masks in Projections
32
+ #
33
+ # When used in the context of a projection, a response message or
34
+ # sub-message is filtered by the API to only contain those fields as
35
+ # specified in the mask. For example, if the mask in the previous
36
+ # example is applied to a response message as follows:
37
+ #
38
+ # f {
39
+ # a : 22
40
+ # b {
41
+ # d : 1
42
+ # x : 2
43
+ # }
44
+ # y : 13
45
+ # }
46
+ # z: 8
47
+ #
48
+ # The result will not contain specific values for fields x,y and z
49
+ # (their value will be set to the default, and omitted in proto text
50
+ # output):
51
+ #
52
+ #
53
+ # f {
54
+ # a : 22
55
+ # b {
56
+ # d : 1
57
+ # }
58
+ # }
59
+ #
60
+ # A repeated field is not allowed except at the last position of a
61
+ # paths string.
62
+ #
63
+ # If a FieldMask object is not present in a get operation, the
64
+ # operation applies to all fields (as if a FieldMask of all fields
65
+ # had been specified).
66
+ #
67
+ # Note that a field mask does not necessarily apply to the
68
+ # top-level response message. In case of a REST get operation, the
69
+ # field mask applies directly to the response, but in case of a REST
70
+ # list operation, the mask instead applies to each individual message
71
+ # in the returned resource list. In case of a REST custom method,
72
+ # other definitions may be used. Where the mask applies will be
73
+ # clearly documented together with its declaration in the API. In
74
+ # any case, the effect on the returned resource/resources is required
75
+ # behavior for APIs.
76
+ #
77
+ # = Field Masks in Update Operations
78
+ #
79
+ # A field mask in update operations specifies which fields of the
80
+ # targeted resource are going to be updated. The API is required
81
+ # to only change the values of the fields as specified in the mask
82
+ # and leave the others untouched. If a resource is passed in to
83
+ # describe the updated values, the API ignores the values of all
84
+ # fields not covered by the mask.
85
+ #
86
+ # If a repeated field is specified for an update operation, new values will
87
+ # be appended to the existing repeated field in the target resource. Note that
88
+ # a repeated field is only allowed in the last position of a `paths` string.
89
+ #
90
+ # If a sub-message is specified in the last position of the field mask for an
91
+ # update operation, then new value will be merged into the existing sub-message
92
+ # in the target resource.
93
+ #
94
+ # For example, given the target message:
95
+ #
96
+ # f {
97
+ # b {
98
+ # d: 1
99
+ # x: 2
100
+ # }
101
+ # c: [1]
102
+ # }
103
+ #
104
+ # And an update message:
105
+ #
106
+ # f {
107
+ # b {
108
+ # d: 10
109
+ # }
110
+ # c: [2]
111
+ # }
112
+ #
113
+ # then if the field mask is:
114
+ #
115
+ # paths: ["f.b", "f.c"]
116
+ #
117
+ # then the result will be:
118
+ #
119
+ # f {
120
+ # b {
121
+ # d: 10
122
+ # x: 2
123
+ # }
124
+ # c: [1, 2]
125
+ # }
126
+ #
127
+ # An implementation may provide options to override this default behavior for
128
+ # repeated and message fields.
129
+ #
130
+ # In order to reset a field's value to the default, the field must
131
+ # be in the mask and set to the default value in the provided resource.
132
+ # Hence, in order to reset all fields of a resource, provide a default
133
+ # instance of the resource and set all fields in the mask, or do
134
+ # not provide a mask as described below.
135
+ #
136
+ # If a field mask is not present on update, the operation applies to
137
+ # all fields (as if a field mask of all fields has been specified).
138
+ # Note that in the presence of schema evolution, this may mean that
139
+ # fields the client does not know and has therefore not filled into
140
+ # the request will be reset to their default. If this is unwanted
141
+ # behavior, a specific service may require a client to always specify
142
+ # a field mask, producing an error if not.
143
+ #
144
+ # As with get operations, the location of the resource which
145
+ # describes the updated values in the request message depends on the
146
+ # operation kind. In any case, the effect of the field mask is
147
+ # required to be honored by the API.
148
+ #
149
+ # == Considerations for HTTP REST
150
+ #
151
+ # The HTTP kind of an update operation which uses a field mask must
152
+ # be set to PATCH instead of PUT in order to satisfy HTTP semantics
153
+ # (PUT must only be used for full updates).
154
+ #
155
+ # = JSON Encoding of Field Masks
156
+ #
157
+ # In JSON, a field mask is encoded as a single string where paths are
158
+ # separated by a comma. Fields name in each path are converted
159
+ # to/from lower-camel naming conventions.
160
+ #
161
+ # As an example, consider the following message declarations:
162
+ #
163
+ # message Profile {
164
+ # User user = 1;
165
+ # Photo photo = 2;
166
+ # }
167
+ # message User {
168
+ # string display_name = 1;
169
+ # string address = 2;
170
+ # }
171
+ #
172
+ # In proto a field mask for `Profile` may look as such:
173
+ #
174
+ # mask {
175
+ # paths: "user.display_name"
176
+ # paths: "photo"
177
+ # }
178
+ #
179
+ # In JSON, the same mask is represented as below:
180
+ #
181
+ # {
182
+ # mask: "user.displayName,photo"
183
+ # }
184
+ #
185
+ # = Field Masks and Oneof Fields
186
+ #
187
+ # Field masks treat fields in oneofs just as regular fields. Consider the
188
+ # following message:
189
+ #
190
+ # message SampleMessage {
191
+ # oneof test_oneof {
192
+ # string name = 4;
193
+ # SubMessage sub_message = 9;
194
+ # }
195
+ # }
196
+ #
197
+ # The field mask can be:
198
+ #
199
+ # mask {
200
+ # paths: "name"
201
+ # }
202
+ #
203
+ # Or:
204
+ #
205
+ # mask {
206
+ # paths: "sub_message"
207
+ # }
208
+ #
209
+ # Note that oneof type names ("test_oneof" in this case) cannot be used in
210
+ # paths.
211
+ #
212
+ # == Field Mask Verification
213
+ #
214
+ # The implementation of any API method which has a FieldMask type field in the
215
+ # request should verify the included field paths, and return an
216
+ # `INVALID_ARGUMENT` error if any path is duplicated or unmappable.
217
+ # @!attribute [rw] paths
218
+ # @return [Array<String>]
219
+ # The set of field mask paths.
220
+ class FieldMask; end
221
+ end
222
+ end