google-cloud-pubsub-v1 0.5.0 → 0.6.1

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.
@@ -41,13 +41,12 @@ module Google
41
41
  # See {::Google::Cloud::PubSub::V1::SchemaService::Client::Configuration}
42
42
  # for a description of the configuration fields.
43
43
  #
44
- # ## Example
44
+ # @example
45
45
  #
46
- # To modify the configuration for all SchemaService clients:
47
- #
48
- # ::Google::Cloud::PubSub::V1::SchemaService::Client.configure do |config|
49
- # config.timeout = 10.0
50
- # end
46
+ # # Modify the configuration for all SchemaService clients
47
+ # ::Google::Cloud::PubSub::V1::SchemaService::Client.configure do |config|
48
+ # config.timeout = 10.0
49
+ # end
51
50
  #
52
51
  # @yield [config] Configure the Client client.
53
52
  # @yieldparam config [Client::Configuration]
@@ -94,19 +93,15 @@ module Google
94
93
  ##
95
94
  # Create a new SchemaService client object.
96
95
  #
97
- # ## Examples
98
- #
99
- # To create a new SchemaService client with the default
100
- # configuration:
96
+ # @example
101
97
  #
102
- # client = ::Google::Cloud::PubSub::V1::SchemaService::Client.new
98
+ # # Create a client using the default configuration
99
+ # client = ::Google::Cloud::PubSub::V1::SchemaService::Client.new
103
100
  #
104
- # To create a new SchemaService client with a custom
105
- # configuration:
106
- #
107
- # client = ::Google::Cloud::PubSub::V1::SchemaService::Client.new do |config|
108
- # config.timeout = 10.0
109
- # end
101
+ # # Create a client using a custom configuration
102
+ # client = ::Google::Cloud::PubSub::V1::SchemaService::Client.new do |config|
103
+ # config.timeout = 10.0
104
+ # end
110
105
  #
111
106
  # @yield [config] Configure the SchemaService client.
112
107
  # @yieldparam config [Client::Configuration]
@@ -126,10 +121,9 @@ module Google
126
121
 
127
122
  # Create credentials
128
123
  credentials = @config.credentials
129
- # Use self-signed JWT if the scope and endpoint are unchanged from default,
124
+ # Use self-signed JWT if the endpoint is unchanged from default,
130
125
  # but only if the default endpoint does not have a region prefix.
131
- enable_self_signed_jwt = @config.scope == Client.configure.scope &&
132
- @config.endpoint == Client.configure.endpoint &&
126
+ enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
133
127
  !@config.endpoint.split(".").first.include?("-")
134
128
  credentials ||= Credentials.default scope: @config.scope,
135
129
  enable_self_signed_jwt: enable_self_signed_jwt
@@ -192,6 +186,21 @@ module Google
192
186
  #
193
187
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
194
188
  #
189
+ # @example Basic example
190
+ # require "google/cloud/pubsub/v1"
191
+ #
192
+ # # Create a client object. The client can be reused for multiple calls.
193
+ # client = Google::Cloud::PubSub::V1::SchemaService::Client.new
194
+ #
195
+ # # Create a request. To set request fields, pass in keyword arguments.
196
+ # request = Google::Cloud::PubSub::V1::CreateSchemaRequest.new
197
+ #
198
+ # # Call the create_schema method.
199
+ # result = client.create_schema request
200
+ #
201
+ # # The returned object is of type Google::Cloud::PubSub::V1::Schema.
202
+ # p result
203
+ #
195
204
  def create_schema request, options = nil
196
205
  raise ::ArgumentError, "request must be provided" if request.nil?
197
206
 
@@ -209,16 +218,20 @@ module Google
209
218
  gapic_version: ::Google::Cloud::PubSub::V1::VERSION
210
219
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
211
220
 
212
- header_params = {
213
- "parent" => request.parent
214
- }
221
+ header_params = {}
222
+ if request.parent
223
+ header_params["parent"] = request.parent
224
+ end
225
+
215
226
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
216
227
  metadata[:"x-goog-request-params"] ||= request_params_header
217
228
 
218
229
  options.apply_defaults timeout: @config.rpcs.create_schema.timeout,
219
230
  metadata: metadata,
220
231
  retry_policy: @config.rpcs.create_schema.retry_policy
221
- options.apply_defaults metadata: @config.metadata,
232
+
233
+ options.apply_defaults timeout: @config.timeout,
234
+ metadata: @config.metadata,
222
235
  retry_policy: @config.retry_policy
223
236
 
224
237
  @schema_service_stub.call_rpc :create_schema, request, options: options do |response, operation|
@@ -263,6 +276,21 @@ module Google
263
276
  #
264
277
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
265
278
  #
279
+ # @example Basic example
280
+ # require "google/cloud/pubsub/v1"
281
+ #
282
+ # # Create a client object. The client can be reused for multiple calls.
283
+ # client = Google::Cloud::PubSub::V1::SchemaService::Client.new
284
+ #
285
+ # # Create a request. To set request fields, pass in keyword arguments.
286
+ # request = Google::Cloud::PubSub::V1::GetSchemaRequest.new
287
+ #
288
+ # # Call the get_schema method.
289
+ # result = client.get_schema request
290
+ #
291
+ # # The returned object is of type Google::Cloud::PubSub::V1::Schema.
292
+ # p result
293
+ #
266
294
  def get_schema request, options = nil
267
295
  raise ::ArgumentError, "request must be provided" if request.nil?
268
296
 
@@ -280,16 +308,20 @@ module Google
280
308
  gapic_version: ::Google::Cloud::PubSub::V1::VERSION
281
309
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
282
310
 
283
- header_params = {
284
- "name" => request.name
285
- }
311
+ header_params = {}
312
+ if request.name
313
+ header_params["name"] = request.name
314
+ end
315
+
286
316
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
287
317
  metadata[:"x-goog-request-params"] ||= request_params_header
288
318
 
289
319
  options.apply_defaults timeout: @config.rpcs.get_schema.timeout,
290
320
  metadata: metadata,
291
321
  retry_policy: @config.rpcs.get_schema.retry_policy
292
- options.apply_defaults metadata: @config.metadata,
322
+
323
+ options.apply_defaults timeout: @config.timeout,
324
+ metadata: @config.metadata,
293
325
  retry_policy: @config.retry_policy
294
326
 
295
327
  @schema_service_stub.call_rpc :get_schema, request, options: options do |response, operation|
@@ -340,6 +372,27 @@ module Google
340
372
  #
341
373
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
342
374
  #
375
+ # @example Basic example
376
+ # require "google/cloud/pubsub/v1"
377
+ #
378
+ # # Create a client object. The client can be reused for multiple calls.
379
+ # client = Google::Cloud::PubSub::V1::SchemaService::Client.new
380
+ #
381
+ # # Create a request. To set request fields, pass in keyword arguments.
382
+ # request = Google::Cloud::PubSub::V1::ListSchemasRequest.new
383
+ #
384
+ # # Call the list_schemas method.
385
+ # result = client.list_schemas request
386
+ #
387
+ # # The returned object is of type Gapic::PagedEnumerable. You can
388
+ # # iterate over all elements by calling #each, and the enumerable
389
+ # # will lazily make API calls to fetch subsequent pages. Other
390
+ # # methods are also available for managing paging directly.
391
+ # result.each do |response|
392
+ # # Each element is of type ::Google::Cloud::PubSub::V1::Schema.
393
+ # p response
394
+ # end
395
+ #
343
396
  def list_schemas request, options = nil
344
397
  raise ::ArgumentError, "request must be provided" if request.nil?
345
398
 
@@ -357,16 +410,20 @@ module Google
357
410
  gapic_version: ::Google::Cloud::PubSub::V1::VERSION
358
411
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
359
412
 
360
- header_params = {
361
- "parent" => request.parent
362
- }
413
+ header_params = {}
414
+ if request.parent
415
+ header_params["parent"] = request.parent
416
+ end
417
+
363
418
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
364
419
  metadata[:"x-goog-request-params"] ||= request_params_header
365
420
 
366
421
  options.apply_defaults timeout: @config.rpcs.list_schemas.timeout,
367
422
  metadata: metadata,
368
423
  retry_policy: @config.rpcs.list_schemas.retry_policy
369
- options.apply_defaults metadata: @config.metadata,
424
+
425
+ options.apply_defaults timeout: @config.timeout,
426
+ metadata: @config.metadata,
370
427
  retry_policy: @config.retry_policy
371
428
 
372
429
  @schema_service_stub.call_rpc :list_schemas, request, options: options do |response, operation|
@@ -408,6 +465,21 @@ module Google
408
465
  #
409
466
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
410
467
  #
468
+ # @example Basic example
469
+ # require "google/cloud/pubsub/v1"
470
+ #
471
+ # # Create a client object. The client can be reused for multiple calls.
472
+ # client = Google::Cloud::PubSub::V1::SchemaService::Client.new
473
+ #
474
+ # # Create a request. To set request fields, pass in keyword arguments.
475
+ # request = Google::Cloud::PubSub::V1::DeleteSchemaRequest.new
476
+ #
477
+ # # Call the delete_schema method.
478
+ # result = client.delete_schema request
479
+ #
480
+ # # The returned object is of type Google::Protobuf::Empty.
481
+ # p result
482
+ #
411
483
  def delete_schema request, options = nil
412
484
  raise ::ArgumentError, "request must be provided" if request.nil?
413
485
 
@@ -425,16 +497,20 @@ module Google
425
497
  gapic_version: ::Google::Cloud::PubSub::V1::VERSION
426
498
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
427
499
 
428
- header_params = {
429
- "name" => request.name
430
- }
500
+ header_params = {}
501
+ if request.name
502
+ header_params["name"] = request.name
503
+ end
504
+
431
505
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
432
506
  metadata[:"x-goog-request-params"] ||= request_params_header
433
507
 
434
508
  options.apply_defaults timeout: @config.rpcs.delete_schema.timeout,
435
509
  metadata: metadata,
436
510
  retry_policy: @config.rpcs.delete_schema.retry_policy
437
- options.apply_defaults metadata: @config.metadata,
511
+
512
+ options.apply_defaults timeout: @config.timeout,
513
+ metadata: @config.metadata,
438
514
  retry_policy: @config.retry_policy
439
515
 
440
516
  @schema_service_stub.call_rpc :delete_schema, request, options: options do |response, operation|
@@ -477,6 +553,21 @@ module Google
477
553
  #
478
554
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
479
555
  #
556
+ # @example Basic example
557
+ # require "google/cloud/pubsub/v1"
558
+ #
559
+ # # Create a client object. The client can be reused for multiple calls.
560
+ # client = Google::Cloud::PubSub::V1::SchemaService::Client.new
561
+ #
562
+ # # Create a request. To set request fields, pass in keyword arguments.
563
+ # request = Google::Cloud::PubSub::V1::ValidateSchemaRequest.new
564
+ #
565
+ # # Call the validate_schema method.
566
+ # result = client.validate_schema request
567
+ #
568
+ # # The returned object is of type Google::Cloud::PubSub::V1::ValidateSchemaResponse.
569
+ # p result
570
+ #
480
571
  def validate_schema request, options = nil
481
572
  raise ::ArgumentError, "request must be provided" if request.nil?
482
573
 
@@ -494,16 +585,20 @@ module Google
494
585
  gapic_version: ::Google::Cloud::PubSub::V1::VERSION
495
586
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
496
587
 
497
- header_params = {
498
- "parent" => request.parent
499
- }
588
+ header_params = {}
589
+ if request.parent
590
+ header_params["parent"] = request.parent
591
+ end
592
+
500
593
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
501
594
  metadata[:"x-goog-request-params"] ||= request_params_header
502
595
 
503
596
  options.apply_defaults timeout: @config.rpcs.validate_schema.timeout,
504
597
  metadata: metadata,
505
598
  retry_policy: @config.rpcs.validate_schema.retry_policy
506
- options.apply_defaults metadata: @config.metadata,
599
+
600
+ options.apply_defaults timeout: @config.timeout,
601
+ metadata: @config.metadata,
507
602
  retry_policy: @config.retry_policy
508
603
 
509
604
  @schema_service_stub.call_rpc :validate_schema, request, options: options do |response, operation|
@@ -554,6 +649,21 @@ module Google
554
649
  #
555
650
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
556
651
  #
652
+ # @example Basic example
653
+ # require "google/cloud/pubsub/v1"
654
+ #
655
+ # # Create a client object. The client can be reused for multiple calls.
656
+ # client = Google::Cloud::PubSub::V1::SchemaService::Client.new
657
+ #
658
+ # # Create a request. To set request fields, pass in keyword arguments.
659
+ # request = Google::Cloud::PubSub::V1::ValidateMessageRequest.new
660
+ #
661
+ # # Call the validate_message method.
662
+ # result = client.validate_message request
663
+ #
664
+ # # The returned object is of type Google::Cloud::PubSub::V1::ValidateMessageResponse.
665
+ # p result
666
+ #
557
667
  def validate_message request, options = nil
558
668
  raise ::ArgumentError, "request must be provided" if request.nil?
559
669
 
@@ -571,16 +681,20 @@ module Google
571
681
  gapic_version: ::Google::Cloud::PubSub::V1::VERSION
572
682
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
573
683
 
574
- header_params = {
575
- "parent" => request.parent
576
- }
684
+ header_params = {}
685
+ if request.parent
686
+ header_params["parent"] = request.parent
687
+ end
688
+
577
689
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
578
690
  metadata[:"x-goog-request-params"] ||= request_params_header
579
691
 
580
692
  options.apply_defaults timeout: @config.rpcs.validate_message.timeout,
581
693
  metadata: metadata,
582
694
  retry_policy: @config.rpcs.validate_message.retry_policy
583
- options.apply_defaults metadata: @config.metadata,
695
+
696
+ options.apply_defaults timeout: @config.timeout,
697
+ metadata: @config.metadata,
584
698
  retry_policy: @config.retry_policy
585
699
 
586
700
  @schema_service_stub.call_rpc :validate_message, request, options: options do |response, operation|
@@ -604,22 +718,21 @@ module Google
604
718
  # Configuration can be applied globally to all clients, or to a single client
605
719
  # on construction.
606
720
  #
607
- # # Examples
608
- #
609
- # To modify the global config, setting the timeout for create_schema
610
- # to 20 seconds, and all remaining timeouts to 10 seconds:
611
- #
612
- # ::Google::Cloud::PubSub::V1::SchemaService::Client.configure do |config|
613
- # config.timeout = 10.0
614
- # config.rpcs.create_schema.timeout = 20.0
615
- # end
616
- #
617
- # To apply the above configuration only to a new client:
618
- #
619
- # client = ::Google::Cloud::PubSub::V1::SchemaService::Client.new do |config|
620
- # config.timeout = 10.0
621
- # config.rpcs.create_schema.timeout = 20.0
622
- # end
721
+ # @example
722
+ #
723
+ # # Modify the global config, setting the timeout for
724
+ # # create_schema to 20 seconds,
725
+ # # and all remaining timeouts to 10 seconds.
726
+ # ::Google::Cloud::PubSub::V1::SchemaService::Client.configure do |config|
727
+ # config.timeout = 10.0
728
+ # config.rpcs.create_schema.timeout = 20.0
729
+ # end
730
+ #
731
+ # # Apply the above configuration only to a new client.
732
+ # client = ::Google::Cloud::PubSub::V1::SchemaService::Client.new do |config|
733
+ # config.timeout = 10.0
734
+ # config.rpcs.create_schema.timeout = 20.0
735
+ # end
623
736
  #
624
737
  # @!attribute [rw] endpoint
625
738
  # The hostname or hostname:port of the service endpoint.