google-cloud-eventarc-publishing-v1 0.4.0 → 0.5.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d9d6bd0508e60a6e8d295566ceef014f8fe2a25b08484eedb7a181f7b27bd279
4
- data.tar.gz: c7b3ebbb13044b136fdaca92befefc560be34b3dd30601d8d4b257260dea852d
3
+ metadata.gz: b1cdcb2e874e05cf09dd69f84e3604118e44b456b147fad16ef9526bb277502e
4
+ data.tar.gz: 14aea5174d436dc118e1b12a6c36287dee213510301a326d7fdce6b758bf675b
5
5
  SHA512:
6
- metadata.gz: 62179721c954abd92b513d8140251d07ed2ab9dad56fe65c420d944d5e84860d541a67a47660506785dfd0d6b7a25302672493b0afc67e8f1c3b7a6c0ca5470d
7
- data.tar.gz: 6db2934add4710ec8e86b90eeee241e10f1fdec18e353042ea495ba6b0ddd75b29fa20805f6a5cb327ca330f14436e8dce3958957c87e8e10fce7eda0442d937
6
+ metadata.gz: 0a7cccf450d2290badd9d068869945f4d5d033eefa5908d4315bc80a1af2afe450565ccc1896aa1f2e76538d62fe7d970bb94b41541fa859ee6ba61cce75046f
7
+ data.tar.gz: 8156b65ac5ef65f9da12a890606581cdbdc0571da3f7bf73e3bb3e05104edacc43969f31a270f3f36a9e9d87dfdc86973de9e25aa0f04bc55e2d09a2f16ffc47
data/README.md CHANGED
@@ -46,7 +46,7 @@ for general usage information.
46
46
  ## Enabling Logging
47
47
 
48
48
  To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library.
49
- The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/stdlib/libdoc/logger/rdoc/Logger.html) as shown below,
49
+ The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/current/stdlibs/logger/Logger.html) as shown below,
50
50
  or a [`Google::Cloud::Logging::Logger`](https://googleapis.dev/ruby/google-cloud-logging/latest)
51
51
  that will write logs to [Cloud Logging](https://cloud.google.com/logging/). See [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb)
52
52
  and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information.
@@ -0,0 +1,458 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2023 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "google/cloud/errors"
20
+ require "google/cloud/eventarc/publishing/v1/publisher_pb"
21
+ require "google/cloud/eventarc/publishing/v1/publisher/rest/service_stub"
22
+
23
+ module Google
24
+ module Cloud
25
+ module Eventarc
26
+ module Publishing
27
+ module V1
28
+ module Publisher
29
+ module Rest
30
+ ##
31
+ # REST client for the Publisher service.
32
+ #
33
+ # Eventarc processes events generated by an event provider and delivers them to
34
+ # a subscriber.
35
+ #
36
+ # An event provider is a software-as-a-service (SaaS) system or
37
+ # product that can generate and deliver events through Eventarc.
38
+ #
39
+ # A third-party event provider is an event provider from outside of Google.
40
+ #
41
+ # A partner is a third-party event provider that is integrated with Eventarc.
42
+ #
43
+ # A subscriber is a GCP customer interested in receiving events.
44
+ #
45
+ # Channel is a first-class Eventarc resource that is created and managed
46
+ # by the subscriber in their GCP project. A Channel represents a subscriber's
47
+ # intent to receive events from an event provider. A Channel is associated with
48
+ # exactly one event provider.
49
+ #
50
+ # ChannelConnection is a first-class Eventarc resource that
51
+ # is created and managed by the partner in their GCP project. A
52
+ # ChannelConnection represents a connection between a partner and a
53
+ # subscriber's Channel. A ChannelConnection has a one-to-one mapping with a
54
+ # Channel.
55
+ #
56
+ # Publisher allows an event provider to publish events to Eventarc.
57
+ #
58
+ class Client
59
+ # @private
60
+ attr_reader :publisher_stub
61
+
62
+ ##
63
+ # Configure the Publisher Client class.
64
+ #
65
+ # See {::Google::Cloud::Eventarc::Publishing::V1::Publisher::Rest::Client::Configuration}
66
+ # for a description of the configuration fields.
67
+ #
68
+ # @example
69
+ #
70
+ # # Modify the configuration for all Publisher clients
71
+ # ::Google::Cloud::Eventarc::Publishing::V1::Publisher::Rest::Client.configure do |config|
72
+ # config.timeout = 10.0
73
+ # end
74
+ #
75
+ # @yield [config] Configure the Client client.
76
+ # @yieldparam config [Client::Configuration]
77
+ #
78
+ # @return [Client::Configuration]
79
+ #
80
+ def self.configure
81
+ @configure ||= begin
82
+ namespace = ["Google", "Cloud", "Eventarc", "Publishing", "V1"]
83
+ parent_config = while namespace.any?
84
+ parent_name = namespace.join "::"
85
+ parent_const = const_get parent_name
86
+ break parent_const.configure if parent_const.respond_to? :configure
87
+ namespace.pop
88
+ end
89
+ default_config = Client::Configuration.new parent_config
90
+
91
+ default_config.rpcs.publish_channel_connection_events.timeout = 60.0
92
+
93
+ default_config
94
+ end
95
+ yield @configure if block_given?
96
+ @configure
97
+ end
98
+
99
+ ##
100
+ # Configure the Publisher Client instance.
101
+ #
102
+ # The configuration is set to the derived mode, meaning that values can be changed,
103
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
104
+ # should be made on {Client.configure}.
105
+ #
106
+ # See {::Google::Cloud::Eventarc::Publishing::V1::Publisher::Rest::Client::Configuration}
107
+ # for a description of the configuration fields.
108
+ #
109
+ # @yield [config] Configure the Client client.
110
+ # @yieldparam config [Client::Configuration]
111
+ #
112
+ # @return [Client::Configuration]
113
+ #
114
+ def configure
115
+ yield @config if block_given?
116
+ @config
117
+ end
118
+
119
+ ##
120
+ # Create a new Publisher REST client object.
121
+ #
122
+ # @example
123
+ #
124
+ # # Create a client using the default configuration
125
+ # client = ::Google::Cloud::Eventarc::Publishing::V1::Publisher::Rest::Client.new
126
+ #
127
+ # # Create a client using a custom configuration
128
+ # client = ::Google::Cloud::Eventarc::Publishing::V1::Publisher::Rest::Client.new do |config|
129
+ # config.timeout = 10.0
130
+ # end
131
+ #
132
+ # @yield [config] Configure the Publisher client.
133
+ # @yieldparam config [Client::Configuration]
134
+ #
135
+ def initialize
136
+ # Create the configuration object
137
+ @config = Configuration.new Client.configure
138
+
139
+ # Yield the configuration if needed
140
+ yield @config if block_given?
141
+
142
+ # Create credentials
143
+ credentials = @config.credentials
144
+ # Use self-signed JWT if the endpoint is unchanged from default,
145
+ # but only if the default endpoint does not have a region prefix.
146
+ enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
147
+ !@config.endpoint.split(".").first.include?("-")
148
+ credentials ||= Credentials.default scope: @config.scope,
149
+ enable_self_signed_jwt: enable_self_signed_jwt
150
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
151
+ credentials = Credentials.new credentials, scope: @config.scope
152
+ end
153
+
154
+ @quota_project_id = @config.quota_project
155
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
156
+
157
+ @publisher_stub = ::Google::Cloud::Eventarc::Publishing::V1::Publisher::Rest::ServiceStub.new endpoint: @config.endpoint, credentials: credentials
158
+ end
159
+
160
+ # Service calls
161
+
162
+ ##
163
+ # Publish events to a ChannelConnection in a partner's project.
164
+ #
165
+ # @overload publish_channel_connection_events(request, options = nil)
166
+ # Pass arguments to `publish_channel_connection_events` via a request object, either of type
167
+ # {::Google::Cloud::Eventarc::Publishing::V1::PublishChannelConnectionEventsRequest} or an equivalent Hash.
168
+ #
169
+ # @param request [::Google::Cloud::Eventarc::Publishing::V1::PublishChannelConnectionEventsRequest, ::Hash]
170
+ # A request object representing the call parameters. Required. To specify no
171
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
172
+ # @param options [::Gapic::CallOptions, ::Hash]
173
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
174
+ #
175
+ # @overload publish_channel_connection_events(channel_connection: nil, events: nil, text_events: nil)
176
+ # Pass arguments to `publish_channel_connection_events` via keyword arguments. Note that at
177
+ # least one keyword argument is required. To specify no parameters, or to keep all
178
+ # the default parameter values, pass an empty Hash as a request object (see above).
179
+ #
180
+ # @param channel_connection [::String]
181
+ # The channel_connection that the events are published from. For example:
182
+ # `projects/{partner_project_id}/locations/{location}/channelConnections/{channel_connection_id}`.
183
+ # @param events [::Array<::Google::Protobuf::Any, ::Hash>]
184
+ # The CloudEvents v1.0 events to publish. No other types are allowed.
185
+ # If this field is set, then the `text_events` fields must not be set.
186
+ # @param text_events [::Array<::String>]
187
+ # The text representation of events to publish.
188
+ # CloudEvent v1.0 in JSON format is the only allowed type. Refer to
189
+ # https://github.com/cloudevents/spec/blob/v1.0.2/cloudevents/formats/json-format.md
190
+ # for specification.
191
+ # If this field is set, then the `events` fields must not be set.
192
+ # @yield [result, operation] Access the result along with the TransportOperation object
193
+ # @yieldparam result [::Google::Cloud::Eventarc::Publishing::V1::PublishChannelConnectionEventsResponse]
194
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
195
+ #
196
+ # @return [::Google::Cloud::Eventarc::Publishing::V1::PublishChannelConnectionEventsResponse]
197
+ #
198
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
199
+ def publish_channel_connection_events request, options = nil
200
+ raise ::ArgumentError, "request must be provided" if request.nil?
201
+
202
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Eventarc::Publishing::V1::PublishChannelConnectionEventsRequest
203
+
204
+ # Converts hash and nil to an options object
205
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
206
+
207
+ # Customize the options with defaults
208
+ call_metadata = @config.rpcs.publish_channel_connection_events.metadata.to_h
209
+
210
+ # Set x-goog-api-client and x-goog-user-project headers
211
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
212
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
213
+ gapic_version: ::Google::Cloud::Eventarc::Publishing::V1::VERSION,
214
+ transports_version_send: [:rest]
215
+
216
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
217
+
218
+ options.apply_defaults timeout: @config.rpcs.publish_channel_connection_events.timeout,
219
+ metadata: call_metadata,
220
+ retry_policy: @config.rpcs.publish_channel_connection_events.retry_policy
221
+
222
+ options.apply_defaults timeout: @config.timeout,
223
+ metadata: @config.metadata,
224
+ retry_policy: @config.retry_policy
225
+
226
+ @publisher_stub.publish_channel_connection_events request, options do |result, operation|
227
+ yield result, operation if block_given?
228
+ return result
229
+ end
230
+ rescue ::Gapic::Rest::Error => e
231
+ raise ::Google::Cloud::Error.from_error(e)
232
+ end
233
+
234
+ ##
235
+ # Publish events to a subscriber's channel.
236
+ #
237
+ # @overload publish_events(request, options = nil)
238
+ # Pass arguments to `publish_events` via a request object, either of type
239
+ # {::Google::Cloud::Eventarc::Publishing::V1::PublishEventsRequest} or an equivalent Hash.
240
+ #
241
+ # @param request [::Google::Cloud::Eventarc::Publishing::V1::PublishEventsRequest, ::Hash]
242
+ # A request object representing the call parameters. Required. To specify no
243
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
244
+ # @param options [::Gapic::CallOptions, ::Hash]
245
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
246
+ #
247
+ # @overload publish_events(channel: nil, events: nil, text_events: nil)
248
+ # Pass arguments to `publish_events` via keyword arguments. Note that at
249
+ # least one keyword argument is required. To specify no parameters, or to keep all
250
+ # the default parameter values, pass an empty Hash as a request object (see above).
251
+ #
252
+ # @param channel [::String]
253
+ # The full name of the channel to publish to. For example:
254
+ # `projects/{project}/locations/{location}/channels/{channel-id}`.
255
+ # @param events [::Array<::Google::Protobuf::Any, ::Hash>]
256
+ # The CloudEvents v1.0 events to publish. No other types are allowed.
257
+ # If this field is set, then the `text_events` fields must not be set.
258
+ # @param text_events [::Array<::String>]
259
+ # The text representation of events to publish.
260
+ # CloudEvent v1.0 in JSON format is the only allowed type. Refer to
261
+ # https://github.com/cloudevents/spec/blob/v1.0.2/cloudevents/formats/json-format.md
262
+ # for specification.
263
+ # If this field is set, then the `events` fields must not be set.
264
+ # @yield [result, operation] Access the result along with the TransportOperation object
265
+ # @yieldparam result [::Google::Cloud::Eventarc::Publishing::V1::PublishEventsResponse]
266
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
267
+ #
268
+ # @return [::Google::Cloud::Eventarc::Publishing::V1::PublishEventsResponse]
269
+ #
270
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
271
+ def publish_events request, options = nil
272
+ raise ::ArgumentError, "request must be provided" if request.nil?
273
+
274
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Eventarc::Publishing::V1::PublishEventsRequest
275
+
276
+ # Converts hash and nil to an options object
277
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
278
+
279
+ # Customize the options with defaults
280
+ call_metadata = @config.rpcs.publish_events.metadata.to_h
281
+
282
+ # Set x-goog-api-client and x-goog-user-project headers
283
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
284
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
285
+ gapic_version: ::Google::Cloud::Eventarc::Publishing::V1::VERSION,
286
+ transports_version_send: [:rest]
287
+
288
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
289
+
290
+ options.apply_defaults timeout: @config.rpcs.publish_events.timeout,
291
+ metadata: call_metadata,
292
+ retry_policy: @config.rpcs.publish_events.retry_policy
293
+
294
+ options.apply_defaults timeout: @config.timeout,
295
+ metadata: @config.metadata,
296
+ retry_policy: @config.retry_policy
297
+
298
+ @publisher_stub.publish_events request, options do |result, operation|
299
+ yield result, operation if block_given?
300
+ return result
301
+ end
302
+ rescue ::Gapic::Rest::Error => e
303
+ raise ::Google::Cloud::Error.from_error(e)
304
+ end
305
+
306
+ ##
307
+ # Configuration class for the Publisher REST API.
308
+ #
309
+ # This class represents the configuration for Publisher REST,
310
+ # providing control over timeouts, retry behavior, logging, transport
311
+ # parameters, and other low-level controls. Certain parameters can also be
312
+ # applied individually to specific RPCs. See
313
+ # {::Google::Cloud::Eventarc::Publishing::V1::Publisher::Rest::Client::Configuration::Rpcs}
314
+ # for a list of RPCs that can be configured independently.
315
+ #
316
+ # Configuration can be applied globally to all clients, or to a single client
317
+ # on construction.
318
+ #
319
+ # @example
320
+ #
321
+ # # Modify the global config, setting the timeout for
322
+ # # publish_channel_connection_events to 20 seconds,
323
+ # # and all remaining timeouts to 10 seconds.
324
+ # ::Google::Cloud::Eventarc::Publishing::V1::Publisher::Rest::Client.configure do |config|
325
+ # config.timeout = 10.0
326
+ # config.rpcs.publish_channel_connection_events.timeout = 20.0
327
+ # end
328
+ #
329
+ # # Apply the above configuration only to a new client.
330
+ # client = ::Google::Cloud::Eventarc::Publishing::V1::Publisher::Rest::Client.new do |config|
331
+ # config.timeout = 10.0
332
+ # config.rpcs.publish_channel_connection_events.timeout = 20.0
333
+ # end
334
+ #
335
+ # @!attribute [rw] endpoint
336
+ # The hostname or hostname:port of the service endpoint.
337
+ # Defaults to `"eventarcpublishing.googleapis.com"`.
338
+ # @return [::String]
339
+ # @!attribute [rw] credentials
340
+ # Credentials to send with calls. You may provide any of the following types:
341
+ # * (`String`) The path to a service account key file in JSON format
342
+ # * (`Hash`) A service account key as a Hash
343
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
344
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
345
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
346
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
347
+ # * (`nil`) indicating no credentials
348
+ # @return [::Object]
349
+ # @!attribute [rw] scope
350
+ # The OAuth scopes
351
+ # @return [::Array<::String>]
352
+ # @!attribute [rw] lib_name
353
+ # The library name as recorded in instrumentation and logging
354
+ # @return [::String]
355
+ # @!attribute [rw] lib_version
356
+ # The library version as recorded in instrumentation and logging
357
+ # @return [::String]
358
+ # @!attribute [rw] timeout
359
+ # The call timeout in seconds.
360
+ # @return [::Numeric]
361
+ # @!attribute [rw] metadata
362
+ # Additional headers to be sent with the call.
363
+ # @return [::Hash{::Symbol=>::String}]
364
+ # @!attribute [rw] retry_policy
365
+ # The retry policy. The value is a hash with the following keys:
366
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
367
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
368
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
369
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
370
+ # trigger a retry.
371
+ # @return [::Hash]
372
+ # @!attribute [rw] quota_project
373
+ # A separate project against which to charge quota.
374
+ # @return [::String]
375
+ #
376
+ class Configuration
377
+ extend ::Gapic::Config
378
+
379
+ config_attr :endpoint, "eventarcpublishing.googleapis.com", ::String
380
+ config_attr :credentials, nil do |value|
381
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
382
+ allowed.any? { |klass| klass === value }
383
+ end
384
+ config_attr :scope, nil, ::String, ::Array, nil
385
+ config_attr :lib_name, nil, ::String, nil
386
+ config_attr :lib_version, nil, ::String, nil
387
+ config_attr :timeout, nil, ::Numeric, nil
388
+ config_attr :metadata, nil, ::Hash, nil
389
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
390
+ config_attr :quota_project, nil, ::String, nil
391
+
392
+ # @private
393
+ def initialize parent_config = nil
394
+ @parent_config = parent_config unless parent_config.nil?
395
+
396
+ yield self if block_given?
397
+ end
398
+
399
+ ##
400
+ # Configurations for individual RPCs
401
+ # @return [Rpcs]
402
+ #
403
+ def rpcs
404
+ @rpcs ||= begin
405
+ parent_rpcs = nil
406
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
407
+ Rpcs.new parent_rpcs
408
+ end
409
+ end
410
+
411
+ ##
412
+ # Configuration RPC class for the Publisher API.
413
+ #
414
+ # Includes fields providing the configuration for each RPC in this service.
415
+ # Each configuration object is of type `Gapic::Config::Method` and includes
416
+ # the following configuration fields:
417
+ #
418
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
419
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
420
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
421
+ # include the following keys:
422
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
423
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
424
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
425
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
426
+ # trigger a retry.
427
+ #
428
+ class Rpcs
429
+ ##
430
+ # RPC-specific configuration for `publish_channel_connection_events`
431
+ # @return [::Gapic::Config::Method]
432
+ #
433
+ attr_reader :publish_channel_connection_events
434
+ ##
435
+ # RPC-specific configuration for `publish_events`
436
+ # @return [::Gapic::Config::Method]
437
+ #
438
+ attr_reader :publish_events
439
+
440
+ # @private
441
+ def initialize parent_rpcs = nil
442
+ publish_channel_connection_events_config = parent_rpcs.publish_channel_connection_events if parent_rpcs.respond_to? :publish_channel_connection_events
443
+ @publish_channel_connection_events = ::Gapic::Config::Method.new publish_channel_connection_events_config
444
+ publish_events_config = parent_rpcs.publish_events if parent_rpcs.respond_to? :publish_events
445
+ @publish_events = ::Gapic::Config::Method.new publish_events_config
446
+
447
+ yield self if block_given?
448
+ end
449
+ end
450
+ end
451
+ end
452
+ end
453
+ end
454
+ end
455
+ end
456
+ end
457
+ end
458
+ end
@@ -0,0 +1,170 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2023 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "google/cloud/eventarc/publishing/v1/publisher_pb"
20
+
21
+ module Google
22
+ module Cloud
23
+ module Eventarc
24
+ module Publishing
25
+ module V1
26
+ module Publisher
27
+ module Rest
28
+ ##
29
+ # REST service stub for the Publisher service.
30
+ # Service stub contains baseline method implementations
31
+ # including transcoding, making the REST call, and deserialing the response.
32
+ #
33
+ class ServiceStub
34
+ def initialize endpoint:, credentials:
35
+ # These require statements are intentionally placed here to initialize
36
+ # the REST modules only when it's required.
37
+ require "gapic/rest"
38
+
39
+ @client_stub = ::Gapic::Rest::ClientStub.new endpoint: endpoint, credentials: credentials,
40
+ numeric_enums: true,
41
+ raise_faraday_errors: false
42
+ end
43
+
44
+ ##
45
+ # Baseline implementation for the publish_channel_connection_events REST call
46
+ #
47
+ # @param request_pb [::Google::Cloud::Eventarc::Publishing::V1::PublishChannelConnectionEventsRequest]
48
+ # A request object representing the call parameters. Required.
49
+ # @param options [::Gapic::CallOptions]
50
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
51
+ #
52
+ # @yield [result, operation] Access the result along with the TransportOperation object
53
+ # @yieldparam result [::Google::Cloud::Eventarc::Publishing::V1::PublishChannelConnectionEventsResponse]
54
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
55
+ #
56
+ # @return [::Google::Cloud::Eventarc::Publishing::V1::PublishChannelConnectionEventsResponse]
57
+ # A result object deserialized from the server's reply
58
+ def publish_channel_connection_events request_pb, options = nil
59
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
60
+
61
+ verb, uri, query_string_params, body = ServiceStub.transcode_publish_channel_connection_events_request request_pb
62
+ query_string_params = if query_string_params.any?
63
+ query_string_params.to_h { |p| p.split("=", 2) }
64
+ else
65
+ {}
66
+ end
67
+
68
+ response = @client_stub.make_http_request(
69
+ verb,
70
+ uri: uri,
71
+ body: body || "",
72
+ params: query_string_params,
73
+ options: options
74
+ )
75
+ operation = ::Gapic::Rest::TransportOperation.new response
76
+ result = ::Google::Cloud::Eventarc::Publishing::V1::PublishChannelConnectionEventsResponse.decode_json response.body, ignore_unknown_fields: true
77
+
78
+ yield result, operation if block_given?
79
+ result
80
+ end
81
+
82
+ ##
83
+ # Baseline implementation for the publish_events REST call
84
+ #
85
+ # @param request_pb [::Google::Cloud::Eventarc::Publishing::V1::PublishEventsRequest]
86
+ # A request object representing the call parameters. Required.
87
+ # @param options [::Gapic::CallOptions]
88
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
89
+ #
90
+ # @yield [result, operation] Access the result along with the TransportOperation object
91
+ # @yieldparam result [::Google::Cloud::Eventarc::Publishing::V1::PublishEventsResponse]
92
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
93
+ #
94
+ # @return [::Google::Cloud::Eventarc::Publishing::V1::PublishEventsResponse]
95
+ # A result object deserialized from the server's reply
96
+ def publish_events request_pb, options = nil
97
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
98
+
99
+ verb, uri, query_string_params, body = ServiceStub.transcode_publish_events_request request_pb
100
+ query_string_params = if query_string_params.any?
101
+ query_string_params.to_h { |p| p.split("=", 2) }
102
+ else
103
+ {}
104
+ end
105
+
106
+ response = @client_stub.make_http_request(
107
+ verb,
108
+ uri: uri,
109
+ body: body || "",
110
+ params: query_string_params,
111
+ options: options
112
+ )
113
+ operation = ::Gapic::Rest::TransportOperation.new response
114
+ result = ::Google::Cloud::Eventarc::Publishing::V1::PublishEventsResponse.decode_json response.body, ignore_unknown_fields: true
115
+
116
+ yield result, operation if block_given?
117
+ result
118
+ end
119
+
120
+ ##
121
+ # @private
122
+ #
123
+ # GRPC transcoding helper method for the publish_channel_connection_events REST call
124
+ #
125
+ # @param request_pb [::Google::Cloud::Eventarc::Publishing::V1::PublishChannelConnectionEventsRequest]
126
+ # A request object representing the call parameters. Required.
127
+ # @return [Array(String, [String, nil], Hash{String => String})]
128
+ # Uri, Body, Query string parameters
129
+ def self.transcode_publish_channel_connection_events_request request_pb
130
+ transcoder = Gapic::Rest::GrpcTranscoder.new
131
+ .with_bindings(
132
+ uri_method: :post,
133
+ uri_template: "/v1/{channel_connection}:publishEvents",
134
+ body: "*",
135
+ matches: [
136
+ ["channel_connection", %r{^projects/[^/]+/locations/[^/]+/channelConnections/[^/]+/?$}, false]
137
+ ]
138
+ )
139
+ transcoder.transcode request_pb
140
+ end
141
+
142
+ ##
143
+ # @private
144
+ #
145
+ # GRPC transcoding helper method for the publish_events REST call
146
+ #
147
+ # @param request_pb [::Google::Cloud::Eventarc::Publishing::V1::PublishEventsRequest]
148
+ # A request object representing the call parameters. Required.
149
+ # @return [Array(String, [String, nil], Hash{String => String})]
150
+ # Uri, Body, Query string parameters
151
+ def self.transcode_publish_events_request request_pb
152
+ transcoder = Gapic::Rest::GrpcTranscoder.new
153
+ .with_bindings(
154
+ uri_method: :post,
155
+ uri_template: "/v1/{channel}:publishEvents",
156
+ body: "*",
157
+ matches: [
158
+ ["channel", %r{^projects/[^/]+/locations/[^/]+/channels/[^/]+/?$}, false]
159
+ ]
160
+ )
161
+ transcoder.transcode request_pb
162
+ end
163
+ end
164
+ end
165
+ end
166
+ end
167
+ end
168
+ end
169
+ end
170
+ end