google-cloud-pubsub 1.10.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/AUTHENTICATION.md +2 -1
- data/CHANGELOG.md +23 -0
- data/lib/google-cloud-pubsub.rb +13 -13
- data/lib/google/cloud/pubsub.rb +15 -18
- data/lib/google/cloud/pubsub/async_publisher.rb +1 -2
- data/lib/google/cloud/pubsub/credentials.rb +2 -2
- data/lib/google/cloud/pubsub/service.rb +102 -251
- data/lib/google/cloud/pubsub/subscriber/stream.rb +1 -2
- data/lib/google/cloud/pubsub/subscription.rb +1 -1
- data/lib/google/cloud/pubsub/version.rb +1 -1
- metadata +7 -78
- data/lib/google/cloud/pubsub/v1.rb +0 -17
- data/lib/google/cloud/pubsub/v1/credentials.rb +0 -41
- data/lib/google/cloud/pubsub/v1/doc/google/iam/v1/iam_policy.rb +0 -21
- data/lib/google/cloud/pubsub/v1/doc/google/iam/v1/options.rb +0 -21
- data/lib/google/cloud/pubsub/v1/doc/google/iam/v1/policy.rb +0 -21
- data/lib/google/cloud/pubsub/v1/doc/google/protobuf/duration.rb +0 -91
- data/lib/google/cloud/pubsub/v1/doc/google/protobuf/empty.rb +0 -29
- data/lib/google/cloud/pubsub/v1/doc/google/protobuf/field_mask.rb +0 -222
- data/lib/google/cloud/pubsub/v1/doc/google/protobuf/timestamp.rb +0 -113
- data/lib/google/cloud/pubsub/v1/doc/google/pubsub/v1/pubsub.rb +0 -833
- data/lib/google/cloud/pubsub/v1/doc/google/type/expr.rb +0 -19
- data/lib/google/cloud/pubsub/v1/publisher_client.rb +0 -928
- data/lib/google/cloud/pubsub/v1/publisher_client_config.json +0 -120
- data/lib/google/cloud/pubsub/v1/subscriber_client.rb +0 -1466
- data/lib/google/cloud/pubsub/v1/subscriber_client_config.json +0 -153
- data/lib/google/pubsub/v1/pubsub_pb.rb +0 -269
- data/lib/google/pubsub/v1/pubsub_services_pb.rb +0 -215
@@ -271,9 +271,8 @@ module Google
|
|
271
271
|
stop
|
272
272
|
rescue GRPC::Cancelled, GRPC::DeadlineExceeded, GRPC::Internal,
|
273
273
|
GRPC::ResourceExhausted, GRPC::Unauthenticated,
|
274
|
-
GRPC::Unavailable
|
274
|
+
GRPC::Unavailable
|
275
275
|
# Restart the stream with an incremental back for a retriable error.
|
276
|
-
# Also when GRPC raises the internal CallError.
|
277
276
|
|
278
277
|
retry
|
279
278
|
rescue RestartStream
|
@@ -346,7 +346,7 @@ module Google
|
|
346
346
|
# to unset.
|
347
347
|
#
|
348
348
|
def expires_in= ttl
|
349
|
-
new_expiration_policy = Google::
|
349
|
+
new_expiration_policy = Google::Cloud::PubSub::V1::ExpirationPolicy.new ttl: Convert.number_to_duration(ttl)
|
350
350
|
|
351
351
|
update_grpc = Google::Cloud::PubSub::V1::Subscription.new name: name, expiration_policy: new_expiration_policy
|
352
352
|
@grpc = service.update_subscription update_grpc, :expiration_policy
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google-cloud-pubsub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Moore
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-
|
12
|
+
date: 2020-08-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: concurrent-ruby
|
@@ -31,82 +31,28 @@ dependencies:
|
|
31
31
|
requirements:
|
32
32
|
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: '1.
|
34
|
+
version: '1.5'
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: '1.
|
41
|
+
version: '1.5'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
|
-
name: google-
|
43
|
+
name: google-cloud-pubsub-v1
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
46
|
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: '
|
48
|
+
version: '0.0'
|
49
49
|
type: :runtime
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
53
|
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: '
|
56
|
-
- !ruby/object:Gem::Dependency
|
57
|
-
name: googleapis-common-protos
|
58
|
-
requirement: !ruby/object:Gem::Requirement
|
59
|
-
requirements:
|
60
|
-
- - ">="
|
61
|
-
- !ruby/object:Gem::Version
|
62
|
-
version: 1.3.9
|
63
|
-
- - "<"
|
64
|
-
- !ruby/object:Gem::Version
|
65
|
-
version: '2.0'
|
66
|
-
type: :runtime
|
67
|
-
prerelease: false
|
68
|
-
version_requirements: !ruby/object:Gem::Requirement
|
69
|
-
requirements:
|
70
|
-
- - ">="
|
71
|
-
- !ruby/object:Gem::Version
|
72
|
-
version: 1.3.9
|
73
|
-
- - "<"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '2.0'
|
76
|
-
- !ruby/object:Gem::Dependency
|
77
|
-
name: googleapis-common-protos-types
|
78
|
-
requirement: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: 1.0.4
|
83
|
-
- - "<"
|
84
|
-
- !ruby/object:Gem::Version
|
85
|
-
version: '2.0'
|
86
|
-
type: :runtime
|
87
|
-
prerelease: false
|
88
|
-
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
requirements:
|
90
|
-
- - ">="
|
91
|
-
- !ruby/object:Gem::Version
|
92
|
-
version: 1.0.4
|
93
|
-
- - "<"
|
94
|
-
- !ruby/object:Gem::Version
|
95
|
-
version: '2.0'
|
96
|
-
- !ruby/object:Gem::Dependency
|
97
|
-
name: grpc-google-iam-v1
|
98
|
-
requirement: !ruby/object:Gem::Requirement
|
99
|
-
requirements:
|
100
|
-
- - "~>"
|
101
|
-
- !ruby/object:Gem::Version
|
102
|
-
version: 0.6.9
|
103
|
-
type: :runtime
|
104
|
-
prerelease: false
|
105
|
-
version_requirements: !ruby/object:Gem::Requirement
|
106
|
-
requirements:
|
107
|
-
- - "~>"
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
version: 0.6.9
|
55
|
+
version: '0.0'
|
110
56
|
- !ruby/object:Gem::Dependency
|
111
57
|
name: autotest-suffix
|
112
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -293,24 +239,7 @@ files:
|
|
293
239
|
- lib/google/cloud/pubsub/subscription/push_config.rb
|
294
240
|
- lib/google/cloud/pubsub/topic.rb
|
295
241
|
- lib/google/cloud/pubsub/topic/list.rb
|
296
|
-
- lib/google/cloud/pubsub/v1.rb
|
297
|
-
- lib/google/cloud/pubsub/v1/credentials.rb
|
298
|
-
- lib/google/cloud/pubsub/v1/doc/google/iam/v1/iam_policy.rb
|
299
|
-
- lib/google/cloud/pubsub/v1/doc/google/iam/v1/options.rb
|
300
|
-
- lib/google/cloud/pubsub/v1/doc/google/iam/v1/policy.rb
|
301
|
-
- lib/google/cloud/pubsub/v1/doc/google/protobuf/duration.rb
|
302
|
-
- lib/google/cloud/pubsub/v1/doc/google/protobuf/empty.rb
|
303
|
-
- lib/google/cloud/pubsub/v1/doc/google/protobuf/field_mask.rb
|
304
|
-
- lib/google/cloud/pubsub/v1/doc/google/protobuf/timestamp.rb
|
305
|
-
- lib/google/cloud/pubsub/v1/doc/google/pubsub/v1/pubsub.rb
|
306
|
-
- lib/google/cloud/pubsub/v1/doc/google/type/expr.rb
|
307
|
-
- lib/google/cloud/pubsub/v1/publisher_client.rb
|
308
|
-
- lib/google/cloud/pubsub/v1/publisher_client_config.json
|
309
|
-
- lib/google/cloud/pubsub/v1/subscriber_client.rb
|
310
|
-
- lib/google/cloud/pubsub/v1/subscriber_client_config.json
|
311
242
|
- lib/google/cloud/pubsub/version.rb
|
312
|
-
- lib/google/pubsub/v1/pubsub_pb.rb
|
313
|
-
- lib/google/pubsub/v1/pubsub_services_pb.rb
|
314
243
|
homepage: https://github.com/googleapis/google-cloud-ruby/tree/master/google-cloud-pubsub
|
315
244
|
licenses:
|
316
245
|
- Apache-2.0
|
@@ -1,17 +0,0 @@
|
|
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"
|
@@ -1,41 +0,0 @@
|
|
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
|
@@ -1,21 +0,0 @@
|
|
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
|
@@ -1,21 +0,0 @@
|
|
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
|
@@ -1,21 +0,0 @@
|
|
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
|
@@ -1,91 +0,0 @@
|
|
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
|
@@ -1,29 +0,0 @@
|
|
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
|
@@ -1,222 +0,0 @@
|
|
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
|