google-cloud-pubsub 2.22.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +27 -0
  3. data/OVERVIEW.md +188 -144
  4. data/lib/google/cloud/pubsub/admin_clients.rb +116 -0
  5. data/lib/google/cloud/pubsub/async_publisher.rb +9 -9
  6. data/lib/google/cloud/pubsub/batch_publisher.rb +4 -4
  7. data/lib/google/cloud/pubsub/errors.rb +3 -3
  8. data/lib/google/cloud/pubsub/message.rb +8 -8
  9. data/lib/google/cloud/pubsub/{subscriber → message_listener}/enumerator_queue.rb +1 -1
  10. data/lib/google/cloud/pubsub/{subscriber → message_listener}/inventory.rb +2 -4
  11. data/lib/google/cloud/pubsub/{subscriber → message_listener}/sequencer.rb +1 -1
  12. data/lib/google/cloud/pubsub/{subscriber → message_listener}/stream.rb +10 -10
  13. data/lib/google/cloud/pubsub/{subscriber → message_listener}/timed_unary_buffer.rb +1 -1
  14. data/lib/google/cloud/pubsub/message_listener.rb +413 -0
  15. data/lib/google/cloud/pubsub/project.rb +98 -531
  16. data/lib/google/cloud/pubsub/publisher.rb +373 -0
  17. data/lib/google/cloud/pubsub/received_message.rb +50 -45
  18. data/lib/google/cloud/pubsub/service.rb +24 -386
  19. data/lib/google/cloud/pubsub/subscriber.rb +442 -279
  20. data/lib/google/cloud/pubsub/version.rb +1 -1
  21. data/lib/google/cloud/pubsub.rb +8 -15
  22. data/lib/google-cloud-pubsub.rb +5 -4
  23. metadata +18 -26
  24. data/lib/google/cloud/pubsub/policy.rb +0 -188
  25. data/lib/google/cloud/pubsub/retry_policy.rb +0 -88
  26. data/lib/google/cloud/pubsub/schema/list.rb +0 -180
  27. data/lib/google/cloud/pubsub/schema.rb +0 -378
  28. data/lib/google/cloud/pubsub/snapshot/list.rb +0 -178
  29. data/lib/google/cloud/pubsub/snapshot.rb +0 -205
  30. data/lib/google/cloud/pubsub/subscription/list.rb +0 -205
  31. data/lib/google/cloud/pubsub/subscription/push_config.rb +0 -268
  32. data/lib/google/cloud/pubsub/subscription.rb +0 -1467
  33. data/lib/google/cloud/pubsub/topic/list.rb +0 -171
  34. data/lib/google/cloud/pubsub/topic.rb +0 -1100
@@ -1,205 +0,0 @@
1
- # Copyright 2017 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/errors"
17
- require "google/cloud/pubsub/snapshot/list"
18
- require "google/cloud/pubsub/v1"
19
-
20
- module Google
21
- module Cloud
22
- module PubSub
23
- ##
24
- # # Snapshot
25
- #
26
- # A named resource created from a subscription to retain a stream of
27
- # messages from a topic. A snapshot is guaranteed to retain:
28
- #
29
- # * The existing backlog on the subscription. More precisely, this is
30
- # defined as the messages in the subscription's backlog that are
31
- # unacknowledged upon the successful completion of the
32
- # `create_snapshot` operation; as well as:
33
- # * Any messages published to the subscription's topic following the
34
- # successful completion of the `create_snapshot` operation.
35
- #
36
- # @example
37
- # require "google/cloud/pubsub"
38
- #
39
- # pubsub = Google::Cloud::PubSub.new
40
- # sub = pubsub.subscription "my-sub"
41
- #
42
- # snapshot = sub.create_snapshot "my-snapshot"
43
- # snapshot.name #=> "projects/my-project/snapshots/my-snapshot"
44
- #
45
- class Snapshot
46
- ##
47
- # @private The Service object.
48
- attr_accessor :service
49
-
50
- ##
51
- # @private The gRPC Google::Cloud::PubSub::V1::Snapshot object.
52
- attr_accessor :grpc
53
-
54
- ##
55
- # @private Create an empty {Snapshot} object.
56
- def initialize
57
- @service = nil
58
- @grpc = Google::Cloud::PubSub::V1::Snapshot.new
59
- end
60
-
61
- ##
62
- # The name of the snapshot.
63
- #
64
- # @return [String] A fully-qualified snapshot name in the form
65
- # `projects/{project_id}/snapshots/{snapshot_id}`.
66
- def name
67
- @grpc.name
68
- end
69
-
70
- ##
71
- # The {Topic} from which this snapshot is retaining messages.
72
- #
73
- # @return [Topic]
74
- #
75
- # @example
76
- # require "google/cloud/pubsub"
77
- #
78
- # pubsub = Google::Cloud::PubSub.new
79
- # sub = pubsub.subscription "my-sub"
80
- #
81
- # snapshot = sub.create_snapshot "my-snapshot"
82
- # snapshot.topic.name #=> "projects/my-project/topics/my-topic"
83
- #
84
- def topic
85
- Topic.from_name @grpc.topic, service
86
- end
87
-
88
- ##
89
- # The snapshot is guaranteed to exist up until this time.
90
- # A newly-created snapshot expires no later than 7 days from the time of
91
- # its creation. Its exact lifetime is determined at creation by the
92
- # existing backlog in the source subscription. Specifically, the
93
- # lifetime of the snapshot is 7 days - (age of oldest unacked message in
94
- # the subscription). For example, consider a subscription whose oldest
95
- # unacked message is 3 days old. If a snapshot is created from this
96
- # subscription, the snapshot -- which will always capture this 3-day-old
97
- # backlog as long as the snapshot exists -- will expire in 4 days.
98
- #
99
- # @return [Time] The time until which the snapshot is guaranteed to
100
- # exist.
101
- #
102
- # @example
103
- # require "google/cloud/pubsub"
104
- #
105
- # pubsub = Google::Cloud::PubSub.new
106
- # sub = pubsub.subscription "my-sub"
107
- #
108
- # snapshot = sub.create_snapshot "my-snapshot"
109
- # snapshot.topic.name #=> "projects/my-project/topics/my-topic"
110
- # snapshot.expiration_time
111
- #
112
- def expiration_time
113
- self.class.timestamp_from_grpc @grpc.expire_time
114
- end
115
-
116
- ##
117
- # A hash of user-provided labels associated with this snapshot.
118
- # Labels can be used to organize and group snapshots.See [Creating and
119
- # Managing Labels](https://cloud.google.com/pubsub/docs/labels).
120
- #
121
- # The returned hash is frozen and changes are not allowed. Use
122
- # {#labels=} to update the labels for this snapshot.
123
- #
124
- # @return [Hash] The frozen labels hash.
125
- #
126
- def labels
127
- @grpc.labels.to_h.freeze
128
- end
129
-
130
- ##
131
- # Sets the hash of user-provided labels associated with this
132
- # snapshot. Labels can be used to organize and group snapshots.
133
- # Label keys and values can be no longer than 63 characters, can only
134
- # contain lowercase letters, numeric characters, underscores and dashes.
135
- # International characters are allowed. Label values are optional. Label
136
- # keys must start with a letter and each label in the list must have a
137
- # different key. See [Creating and Managing
138
- # Labels](https://cloud.google.com/pubsub/docs/labels).
139
- #
140
- # @param [Hash] new_labels The new labels hash.
141
- #
142
- def labels= new_labels
143
- raise ArgumentError, "Value must be a Hash" if new_labels.nil?
144
- labels_map = Google::Protobuf::Map.new :string, :string
145
- Hash(new_labels).each { |k, v| labels_map[String(k)] = String(v) }
146
- update_grpc = @grpc.dup
147
- update_grpc.labels = labels_map
148
- @grpc = service.update_snapshot update_grpc, :labels
149
- end
150
-
151
- ##
152
- # Removes an existing snapshot. All messages retained in the snapshot
153
- # are immediately dropped. After a snapshot is deleted, a new one may be
154
- # created with the same name, but the new one has no association with
155
- # the old snapshot or its subscription, unless the same subscription is
156
- # specified.
157
- #
158
- # @return [Boolean] Returns `true` if the snapshot was deleted.
159
- #
160
- # @example
161
- # require "google/cloud/pubsub"
162
- #
163
- # pubsub = Google::Cloud::PubSub.new
164
- #
165
- # pubsub.snapshots.each do |snapshot|
166
- # snapshot.delete
167
- # end
168
- #
169
- def delete
170
- ensure_service!
171
- service.delete_snapshot name
172
- true
173
- end
174
-
175
- ##
176
- # @private New Snapshot from a Google::Cloud::PubSub::V1::Snapshot
177
- # object.
178
- def self.from_grpc grpc, service
179
- new.tap do |f|
180
- f.grpc = grpc
181
- f.service = service
182
- end
183
- end
184
-
185
- ##
186
- # @private Get a Time object from a Google::Protobuf::Timestamp object.
187
- def self.timestamp_from_grpc grpc_timestamp
188
- return nil if grpc_timestamp.nil?
189
- Time.at grpc_timestamp.seconds, Rational(grpc_timestamp.nanos, 1000)
190
- end
191
-
192
- protected
193
-
194
- ##
195
- # @private Raise an error unless an active connection to the service is
196
- # available.
197
- def ensure_service!
198
- raise "Must have active connection to service" unless service
199
- end
200
- end
201
- end
202
-
203
- Pubsub = PubSub unless const_defined? :Pubsub
204
- end
205
- end
@@ -1,205 +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 "delegate"
17
-
18
- module Google
19
- module Cloud
20
- module PubSub
21
- class Subscription
22
- ##
23
- # Subscription::List is a special case Array with additional values.
24
- class List < DelegateClass(::Array)
25
- ##
26
- # If not empty, indicates that there are more subscriptions
27
- # that match the request and this value should be passed to
28
- # the next {Google::Cloud::PubSub::Topic#subscriptions} to continue.
29
- attr_accessor :token
30
-
31
- ##
32
- # @private Create a new Subscription::List with an array of values.
33
- def initialize arr = []
34
- @topic = nil
35
- @prefix = nil
36
- @token = nil
37
- @max = nil
38
- super arr
39
- end
40
-
41
- ##
42
- # Whether there a next page of subscriptions.
43
- #
44
- # @return [Boolean]
45
- #
46
- # @example
47
- # require "google/cloud/pubsub"
48
- #
49
- # pubsub = Google::Cloud::PubSub.new
50
- #
51
- # subscriptions = pubsub.subscriptions
52
- # if subscriptions.next?
53
- # next_subscriptions = subscriptions.next
54
- # end
55
- #
56
- def next?
57
- !token.nil?
58
- end
59
-
60
- ##
61
- # Retrieve the next page of subscriptions.
62
- #
63
- # @return [Subscription::List]
64
- #
65
- # @example
66
- # require "google/cloud/pubsub"
67
- #
68
- # pubsub = Google::Cloud::PubSub.new
69
- #
70
- # subscriptions = pubsub.subscriptions
71
- # if subscriptions.next?
72
- # next_subscriptions = subscriptions.next
73
- # end
74
- #
75
- def next
76
- return nil unless next?
77
- ensure_service!
78
- if @topic
79
- next_topic_subscriptions
80
- else
81
- next_subscriptions
82
- end
83
- end
84
-
85
- ##
86
- # Retrieves remaining results by repeatedly invoking {#next} until
87
- # {#next?} returns `false`. Calls the given block once for each
88
- # result, which is passed as the argument to the block.
89
- #
90
- # An Enumerator is returned if no block is given.
91
- #
92
- # This method will make repeated API calls until all remaining results
93
- # are retrieved. (Unlike `#each`, for example, which merely iterates
94
- # over the results returned by a single API call.) Use with caution.
95
- #
96
- # @param [Integer] request_limit The upper limit of API requests to
97
- # make to load all subscriptions. Default is no limit.
98
- # @yield [subscription] The block for accessing each subscription.
99
- # @yieldparam [Subscription] subscription The subscription object.
100
- #
101
- # @return [Enumerator]
102
- #
103
- # @example Iterating each subscription by passing a block:
104
- # require "google/cloud/pubsub"
105
- #
106
- # pubsub = Google::Cloud::PubSub.new
107
- #
108
- # subscriptions = pubsub.subscriptions
109
- # subscriptions.all do |subscription|
110
- # puts subscription.name
111
- # end
112
- #
113
- # @example Using the enumerator by not passing a block:
114
- # require "google/cloud/pubsub"
115
- #
116
- # pubsub = Google::Cloud::PubSub.new
117
- #
118
- # subscriptions = pubsub.subscriptions
119
- # all_names = subscriptions.all.map do |subscription|
120
- # subscription.name
121
- # end
122
- #
123
- # @example Limit the number of API calls made:
124
- # require "google/cloud/pubsub"
125
- #
126
- # pubsub = Google::Cloud::PubSub.new
127
- #
128
- # subscriptions = pubsub.subscriptions
129
- # subscriptions.all(request_limit: 10) do |subscription|
130
- # puts subscription.name
131
- # end
132
- #
133
- def all request_limit: nil, &block
134
- request_limit = request_limit.to_i if request_limit
135
- return enum_for :all, request_limit: request_limit unless block_given?
136
- results = self
137
- loop do
138
- results.each(&block)
139
- if request_limit
140
- request_limit -= 1
141
- break if request_limit.negative?
142
- end
143
- break unless results.next?
144
- results = results.next
145
- end
146
- end
147
-
148
- ##
149
- # @private New Subscriptions::List from a
150
- # Google::Cloud::PubSub::V1::ListSubscriptionsRequest object.
151
- def self.from_grpc grpc_list, service, max = nil
152
- subs = new(Array(grpc_list.subscriptions).map do |grpc|
153
- Subscription.from_grpc grpc, service
154
- end)
155
- token = grpc_list.next_page_token
156
- token = nil if token == "".freeze
157
- subs.instance_variable_set :@token, token
158
- subs.instance_variable_set :@service, service
159
- subs.instance_variable_set :@max, max
160
- subs
161
- end
162
-
163
- ##
164
- # @private New Subscriptions::List from a
165
- # Google::Cloud::PubSub::V1::ListTopicSubscriptionsResponse object.
166
- def self.from_topic_grpc grpc_list, service, topic, max = nil
167
- subs = new(Array(grpc_list.subscriptions).map do |grpc|
168
- Subscription.from_name grpc, service
169
- end)
170
- token = grpc_list.next_page_token
171
- token = nil if token == "".freeze
172
- subs.instance_variable_set :@token, token
173
- subs.instance_variable_set :@service, service
174
- subs.instance_variable_set :@topic, topic
175
- subs.instance_variable_set :@max, max
176
- subs
177
- end
178
-
179
- protected
180
-
181
- ##
182
- # @private Raise an error unless an active connection to the service
183
- # is available.
184
- def ensure_service!
185
- raise "Must have active connection to service" unless @service
186
- end
187
-
188
- def next_subscriptions
189
- options = { prefix: @prefix, token: @token, max: @max }
190
- grpc = @service.list_subscriptions options
191
- self.class.from_grpc grpc, @service, @max
192
- end
193
-
194
- def next_topic_subscriptions
195
- options = { token: @token, max: @max }
196
- grpc = @service.list_topics_subscriptions @topic, options
197
- self.class.from_topic_grpc grpc, @service, @topic, @max
198
- end
199
- end
200
- end
201
- end
202
-
203
- Pubsub = PubSub unless const_defined? :Pubsub
204
- end
205
- end
@@ -1,268 +0,0 @@
1
- # Copyright 2019 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/pubsub/v1/pubsub_pb"
17
-
18
- module Google
19
- module Cloud
20
- module PubSub
21
- class Subscription
22
- ##
23
- # Configuration for a push delivery endpoint.
24
- #
25
- # @example Create a push config:
26
- # require "google/cloud/pubsub"
27
- #
28
- # pubsub = Google::Cloud::PubSub.new
29
- # topic = pubsub.topic "my-topic"
30
- #
31
- # push_config = Google::Cloud::PubSub::Subscription::PushConfig.new endpoint: "http://example.net/callback"
32
- # push_config.set_oidc_token "service-account@example.net", "audience-header-value"
33
- #
34
- # sub = topic.subscribe "my-subscription", push_config: push_config
35
- #
36
- # @example Read a push config:
37
- # require "google/cloud/pubsub"
38
- #
39
- # pubsub = Google::Cloud::PubSub.new
40
- #
41
- # sub = pubsub.subscription "my-topic-sub"
42
- # sub.push_config.endpoint #=> "http://example.com/callback"
43
- # sub.push_config.authentication.email #=> "user@example.com"
44
- # sub.push_config.authentication.audience #=> "client-12345"
45
- #
46
- # @example Update a push config:
47
- # require "google/cloud/pubsub"
48
- #
49
- # pubsub = Google::Cloud::PubSub.new
50
- # sub = pubsub.subscription "my-subscription"
51
- #
52
- # sub.push_config do |pc|
53
- # pc.endpoint = "http://example.net/callback"
54
- # pc.set_oidc_token "user@example.net", "client-67890"
55
- # end
56
- #
57
- class PushConfig
58
- ##
59
- # Creates a new push configuration.
60
- #
61
- # @param [String] endpoint A URL locating the endpoint to which messages should be pushed. For
62
- # example, a Webhook endpoint might use `https://example.com/push`.
63
- # @param [String] email The service account email to be used for generating the OIDC token.
64
- # The caller must have the `iam.serviceAccounts.actAs` permission for the service account.
65
- # @param [String] audience The audience to be used when generating OIDC token. The audience claim identifies
66
- # the recipients that the JWT is intended for. The audience value is a single case-sensitive string. Having
67
- # multiple values (array) for the audience field is not supported. More info about the OIDC JWT token
68
- # audience here: https://tools.ietf.org/html/rfc7519#section-4.1.3 Note: if not specified, the `endpoint`
69
- # URL will be used.
70
- #
71
- def initialize endpoint: nil, email: nil, audience: nil
72
- @grpc = Google::Cloud::PubSub::V1::PushConfig.new
73
-
74
- self.endpoint = endpoint unless endpoint.nil?
75
-
76
- raise ArgumentError, "audience provided without email. Authentication is invalid" if audience && !email
77
-
78
- set_oidc_token email, audience if email
79
- end
80
-
81
- ##
82
- # A URL locating the endpoint to which messages should be pushed. For example, a Webhook endpoint might use
83
- # `https://example.com/push`.
84
- #
85
- # @return [String]
86
- def endpoint
87
- @grpc.push_endpoint
88
- end
89
-
90
- ##
91
- # Sets the URL locating the endpoint to which messages should be pushed. For example, a Webhook endpoint might
92
- # use `https://example.com/push`.
93
- #
94
- # @param [String, nil] new_endpoint New URL value
95
- def endpoint= new_endpoint
96
- @grpc.push_endpoint = String new_endpoint
97
- end
98
-
99
- ##
100
- # The authentication method used by push endpoints to verify the source of push requests.
101
- #
102
- # @return [OidcToken, nil] An OIDC JWT token if specified, `nil`
103
- # otherwise.
104
- def authentication
105
- return nil unless @grpc.authentication_method == :oidc_token
106
-
107
- OidcToken.from_grpc @grpc.oidc_token
108
- end
109
-
110
- ##
111
- # Sets the authentication method used by push endpoints to verify the source of push requests.
112
- #
113
- # @param [OidcToken, nil] new_auth An authentication value.
114
- def authentication= new_auth
115
- if new_auth.nil?
116
- @grpc.oidc_token = nil
117
- else
118
- raise ArgumentError unless new_auth.is_a? OidcToken
119
-
120
- @grpc.oidc_token = new_auth.to_grpc
121
- end
122
- end
123
-
124
- ##
125
- # Checks whether authentication is an {OidcToken}.
126
- #
127
- # @return [Boolean]
128
- def oidc_token?
129
- authentication.is_a? OidcToken
130
- end
131
-
132
- ##
133
- # Sets the authentication method to use an {OidcToken}.
134
- #
135
- # @param [String] email Service account email.
136
- # @param [String] audience Audience to be used.
137
- def set_oidc_token email, audience
138
- oidc_token = OidcToken.new.tap do |token|
139
- token.email = email
140
- token.audience = audience
141
- end
142
- self.authentication = oidc_token
143
- end
144
-
145
- ##
146
- # The format of the pushed message. This attribute indicates the version of the data expected by the endpoint.
147
- # This controls the shape of the pushed message (i.e., its fields and metadata). The endpoint version is based
148
- # on the version of the Pub/Sub API.
149
- #
150
- # If not present during the Subscription creation, it will default to the version of the API used to make such
151
- # call.
152
- #
153
- # The possible values for this attribute are:
154
- #
155
- # * `v1beta1`: uses the push format defined in the v1beta1 Pub/Sub
156
- # API.
157
- # * `v1` or `v1beta2`: uses the push format defined in the v1 Pub/Sub
158
- # API.
159
- #
160
- # @return [String]
161
- def version
162
- @grpc.attributes["x-goog-version"]
163
- end
164
-
165
- ##
166
- # Sets the format of the pushed message.
167
- #
168
- # The possible values for this attribute are:
169
- #
170
- # * `v1beta1`: uses the push format defined in the v1beta1 Pub/Sub
171
- # API.
172
- # * `v1` or `v1beta2`: uses the push format defined in the v1 Pub/Sub
173
- # API.
174
- #
175
- # @param [String, nil] new_version The new version value.
176
- def version= new_version
177
- if new_version.nil?
178
- @grpc.attributes.delete "x-goog-version"
179
- else
180
- @grpc.attributes["x-goog-version"] = new_version
181
- end
182
- end
183
-
184
- ##
185
- # @private
186
- def to_grpc
187
- @grpc
188
- end
189
-
190
- ##
191
- # @private
192
- def self.from_grpc grpc
193
- new.tap do |pc|
194
- pc.instance_variable_set :@grpc, grpc.dup if grpc
195
- end
196
- end
197
-
198
- ##
199
- # Contains information needed for generating an [OpenID Connect
200
- # token](https://developers.google.com/identity/protocols/OpenIDConnect).
201
- class OidcToken
202
- ##
203
- # @private
204
- def initialize
205
- @grpc = Google::Cloud::PubSub::V1::PushConfig::OidcToken.new
206
- end
207
-
208
- ##
209
- # The service account email to be used for generating the OIDC token. The caller must have the
210
- # `iam.serviceAccounts.actAs` permission for the service account.
211
- #
212
- # @return [String]
213
- def email
214
- @grpc.service_account_email
215
- end
216
-
217
- ##
218
- # Sets the service account email to be used for generating the OIDC token. The caller must have the
219
- # `iam.serviceAccounts.actAs` permission for the service account.
220
- #
221
- # @param [String] new_email New service account email value.
222
- def email= new_email
223
- @grpc.service_account_email = new_email
224
- end
225
-
226
- ##
227
- # The audience to be used when generating OIDC token. The audience claim identifies the recipients that
228
- # the JWT is intended for. The audience value is a single case-sensitive string. Having multiple values
229
- # (array) for the audience field is not supported. More info about the OIDC JWT token audience here:
230
- # https://tools.ietf.org/html/rfc7519#section-4.1.3 Note: if not specified, the `endpoint` URL will be used.
231
- #
232
- # @return [String]
233
- def audience
234
- @grpc.audience
235
- end
236
-
237
- ##
238
- # Sets the audience to be used when generating OIDC token. The audience claim identifies the recipients that
239
- # the JWT is intended for. The audience value is a single case-sensitive string. Having multiple values
240
- # (array) for the audience field is not supported. More info about the OIDC JWT token audience here:
241
- # https://tools.ietf.org/html/rfc7519#section-4.1.3 Note: if not specified, the `endpoint` URL will be used.
242
- #
243
- # @param [String] new_audience New audience value.
244
- def audience= new_audience
245
- @grpc.audience = new_audience
246
- end
247
-
248
- ##
249
- # @private
250
- def to_grpc
251
- @grpc
252
- end
253
-
254
- ##
255
- # @private
256
- def self.from_grpc grpc
257
- grpc ||= Google::Cloud::PubSub::V1::PushConfig::OidcToken.new
258
-
259
- new.tap do |pc|
260
- pc.instance_variable_set :@grpc, grpc.dup
261
- end
262
- end
263
- end
264
- end
265
- end
266
- end
267
- end
268
- end