google-cloud-pubsub-v1 0.1.2 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,898 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 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/pubsub/v1/schema_pb"
21
+
22
+ module Google
23
+ module Cloud
24
+ module PubSub
25
+ module V1
26
+ module SchemaService
27
+ ##
28
+ # Client for the SchemaService service.
29
+ #
30
+ # Service for doing schema-related operations.
31
+ #
32
+ class Client
33
+ include Paths
34
+
35
+ # @private
36
+ attr_reader :schema_service_stub
37
+
38
+ ##
39
+ # Configure the SchemaService Client class.
40
+ #
41
+ # See {::Google::Cloud::PubSub::V1::SchemaService::Client::Configuration}
42
+ # for a description of the configuration fields.
43
+ #
44
+ # @example
45
+ #
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
50
+ #
51
+ # @yield [config] Configure the Client client.
52
+ # @yieldparam config [Client::Configuration]
53
+ #
54
+ # @return [Client::Configuration]
55
+ #
56
+ def self.configure
57
+ @configure ||= begin
58
+ namespace = ["Google", "Cloud", "PubSub", "V1"]
59
+ parent_config = while namespace.any?
60
+ parent_name = namespace.join "::"
61
+ parent_const = const_get parent_name
62
+ break parent_const.configure if parent_const.respond_to? :configure
63
+ namespace.pop
64
+ end
65
+ default_config = Client::Configuration.new parent_config
66
+
67
+ default_config
68
+ end
69
+ yield @configure if block_given?
70
+ @configure
71
+ end
72
+
73
+ ##
74
+ # Configure the SchemaService Client instance.
75
+ #
76
+ # The configuration is set to the derived mode, meaning that values can be changed,
77
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
78
+ # should be made on {Client.configure}.
79
+ #
80
+ # See {::Google::Cloud::PubSub::V1::SchemaService::Client::Configuration}
81
+ # for a description of the configuration fields.
82
+ #
83
+ # @yield [config] Configure the Client client.
84
+ # @yieldparam config [Client::Configuration]
85
+ #
86
+ # @return [Client::Configuration]
87
+ #
88
+ def configure
89
+ yield @config if block_given?
90
+ @config
91
+ end
92
+
93
+ ##
94
+ # Create a new SchemaService client object.
95
+ #
96
+ # @example
97
+ #
98
+ # # Create a client using the default configuration
99
+ # client = ::Google::Cloud::PubSub::V1::SchemaService::Client.new
100
+ #
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
105
+ #
106
+ # @yield [config] Configure the SchemaService client.
107
+ # @yieldparam config [Client::Configuration]
108
+ #
109
+ def initialize
110
+ # These require statements are intentionally placed here to initialize
111
+ # the gRPC module only when it's required.
112
+ # See https://github.com/googleapis/toolkit/issues/446
113
+ require "gapic/grpc"
114
+ require "google/pubsub/v1/schema_services_pb"
115
+
116
+ # Create the configuration object
117
+ @config = Configuration.new Client.configure
118
+
119
+ # Yield the configuration if needed
120
+ yield @config if block_given?
121
+
122
+ # Create credentials
123
+ credentials = @config.credentials
124
+ # Use self-signed JWT if the endpoint is unchanged from default,
125
+ # but only if the default endpoint does not have a region prefix.
126
+ enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
127
+ !@config.endpoint.split(".").first.include?("-")
128
+ credentials ||= Credentials.default scope: @config.scope,
129
+ enable_self_signed_jwt: enable_self_signed_jwt
130
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
131
+ credentials = Credentials.new credentials, scope: @config.scope
132
+ end
133
+ @quota_project_id = @config.quota_project
134
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
135
+
136
+ @schema_service_stub = ::Gapic::ServiceStub.new(
137
+ ::Google::Cloud::PubSub::V1::SchemaService::Stub,
138
+ credentials: credentials,
139
+ endpoint: @config.endpoint,
140
+ channel_args: @config.channel_args,
141
+ interceptors: @config.interceptors
142
+ )
143
+ end
144
+
145
+ # Service calls
146
+
147
+ ##
148
+ # Creates a schema.
149
+ #
150
+ # @overload create_schema(request, options = nil)
151
+ # Pass arguments to `create_schema` via a request object, either of type
152
+ # {::Google::Cloud::PubSub::V1::CreateSchemaRequest} or an equivalent Hash.
153
+ #
154
+ # @param request [::Google::Cloud::PubSub::V1::CreateSchemaRequest, ::Hash]
155
+ # A request object representing the call parameters. Required. To specify no
156
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
157
+ # @param options [::Gapic::CallOptions, ::Hash]
158
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
159
+ #
160
+ # @overload create_schema(parent: nil, schema: nil, schema_id: nil)
161
+ # Pass arguments to `create_schema` via keyword arguments. Note that at
162
+ # least one keyword argument is required. To specify no parameters, or to keep all
163
+ # the default parameter values, pass an empty Hash as a request object (see above).
164
+ #
165
+ # @param parent [::String]
166
+ # Required. The name of the project in which to create the schema.
167
+ # Format is `projects/{project-id}`.
168
+ # @param schema [::Google::Cloud::PubSub::V1::Schema, ::Hash]
169
+ # Required. The schema object to create.
170
+ #
171
+ # This schema's `name` parameter is ignored. The schema object returned
172
+ # by CreateSchema will have a `name` made using the given `parent` and
173
+ # `schema_id`.
174
+ # @param schema_id [::String]
175
+ # The ID to use for the schema, which will become the final component of
176
+ # the schema's resource name.
177
+ #
178
+ # See https://cloud.google.com/pubsub/docs/admin#resource_names for resource
179
+ # name constraints.
180
+ #
181
+ # @yield [response, operation] Access the result along with the RPC operation
182
+ # @yieldparam response [::Google::Cloud::PubSub::V1::Schema]
183
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
184
+ #
185
+ # @return [::Google::Cloud::PubSub::V1::Schema]
186
+ #
187
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
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
+ #
204
+ def create_schema request, options = nil
205
+ raise ::ArgumentError, "request must be provided" if request.nil?
206
+
207
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::CreateSchemaRequest
208
+
209
+ # Converts hash and nil to an options object
210
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
211
+
212
+ # Customize the options with defaults
213
+ metadata = @config.rpcs.create_schema.metadata.to_h
214
+
215
+ # Set x-goog-api-client and x-goog-user-project headers
216
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
217
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
218
+ gapic_version: ::Google::Cloud::PubSub::V1::VERSION
219
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
220
+
221
+ header_params = {}
222
+ if request.parent
223
+ header_params["parent"] = request.parent
224
+ end
225
+
226
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
227
+ metadata[:"x-goog-request-params"] ||= request_params_header
228
+
229
+ options.apply_defaults timeout: @config.rpcs.create_schema.timeout,
230
+ metadata: metadata,
231
+ retry_policy: @config.rpcs.create_schema.retry_policy
232
+
233
+ options.apply_defaults timeout: @config.timeout,
234
+ metadata: @config.metadata,
235
+ retry_policy: @config.retry_policy
236
+
237
+ @schema_service_stub.call_rpc :create_schema, request, options: options do |response, operation|
238
+ yield response, operation if block_given?
239
+ return response
240
+ end
241
+ rescue ::GRPC::BadStatus => e
242
+ raise ::Google::Cloud::Error.from_error(e)
243
+ end
244
+
245
+ ##
246
+ # Gets a schema.
247
+ #
248
+ # @overload get_schema(request, options = nil)
249
+ # Pass arguments to `get_schema` via a request object, either of type
250
+ # {::Google::Cloud::PubSub::V1::GetSchemaRequest} or an equivalent Hash.
251
+ #
252
+ # @param request [::Google::Cloud::PubSub::V1::GetSchemaRequest, ::Hash]
253
+ # A request object representing the call parameters. Required. To specify no
254
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
255
+ # @param options [::Gapic::CallOptions, ::Hash]
256
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
257
+ #
258
+ # @overload get_schema(name: nil, view: nil)
259
+ # Pass arguments to `get_schema` via keyword arguments. Note that at
260
+ # least one keyword argument is required. To specify no parameters, or to keep all
261
+ # the default parameter values, pass an empty Hash as a request object (see above).
262
+ #
263
+ # @param name [::String]
264
+ # Required. The name of the schema to get.
265
+ # Format is `projects/{project}/schemas/{schema}`.
266
+ # @param view [::Google::Cloud::PubSub::V1::SchemaView]
267
+ # The set of fields to return in the response. If not set, returns a Schema
268
+ # with `name` and `type`, but not `definition`. Set to `FULL` to retrieve all
269
+ # fields.
270
+ #
271
+ # @yield [response, operation] Access the result along with the RPC operation
272
+ # @yieldparam response [::Google::Cloud::PubSub::V1::Schema]
273
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
274
+ #
275
+ # @return [::Google::Cloud::PubSub::V1::Schema]
276
+ #
277
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
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
+ #
294
+ def get_schema request, options = nil
295
+ raise ::ArgumentError, "request must be provided" if request.nil?
296
+
297
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::GetSchemaRequest
298
+
299
+ # Converts hash and nil to an options object
300
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
301
+
302
+ # Customize the options with defaults
303
+ metadata = @config.rpcs.get_schema.metadata.to_h
304
+
305
+ # Set x-goog-api-client and x-goog-user-project headers
306
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
307
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
308
+ gapic_version: ::Google::Cloud::PubSub::V1::VERSION
309
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
310
+
311
+ header_params = {}
312
+ if request.name
313
+ header_params["name"] = request.name
314
+ end
315
+
316
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
317
+ metadata[:"x-goog-request-params"] ||= request_params_header
318
+
319
+ options.apply_defaults timeout: @config.rpcs.get_schema.timeout,
320
+ metadata: metadata,
321
+ retry_policy: @config.rpcs.get_schema.retry_policy
322
+
323
+ options.apply_defaults timeout: @config.timeout,
324
+ metadata: @config.metadata,
325
+ retry_policy: @config.retry_policy
326
+
327
+ @schema_service_stub.call_rpc :get_schema, request, options: options do |response, operation|
328
+ yield response, operation if block_given?
329
+ return response
330
+ end
331
+ rescue ::GRPC::BadStatus => e
332
+ raise ::Google::Cloud::Error.from_error(e)
333
+ end
334
+
335
+ ##
336
+ # Lists schemas in a project.
337
+ #
338
+ # @overload list_schemas(request, options = nil)
339
+ # Pass arguments to `list_schemas` via a request object, either of type
340
+ # {::Google::Cloud::PubSub::V1::ListSchemasRequest} or an equivalent Hash.
341
+ #
342
+ # @param request [::Google::Cloud::PubSub::V1::ListSchemasRequest, ::Hash]
343
+ # A request object representing the call parameters. Required. To specify no
344
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
345
+ # @param options [::Gapic::CallOptions, ::Hash]
346
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
347
+ #
348
+ # @overload list_schemas(parent: nil, view: nil, page_size: nil, page_token: nil)
349
+ # Pass arguments to `list_schemas` via keyword arguments. Note that at
350
+ # least one keyword argument is required. To specify no parameters, or to keep all
351
+ # the default parameter values, pass an empty Hash as a request object (see above).
352
+ #
353
+ # @param parent [::String]
354
+ # Required. The name of the project in which to list schemas.
355
+ # Format is `projects/{project-id}`.
356
+ # @param view [::Google::Cloud::PubSub::V1::SchemaView]
357
+ # The set of Schema fields to return in the response. If not set, returns
358
+ # Schemas with `name` and `type`, but not `definition`. Set to `FULL` to
359
+ # retrieve all fields.
360
+ # @param page_size [::Integer]
361
+ # Maximum number of schemas to return.
362
+ # @param page_token [::String]
363
+ # The value returned by the last `ListSchemasResponse`; indicates that
364
+ # this is a continuation of a prior `ListSchemas` call, and that the
365
+ # system should return the next page of data.
366
+ #
367
+ # @yield [response, operation] Access the result along with the RPC operation
368
+ # @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::PubSub::V1::Schema>]
369
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
370
+ #
371
+ # @return [::Gapic::PagedEnumerable<::Google::Cloud::PubSub::V1::Schema>]
372
+ #
373
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
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
+ #
396
+ def list_schemas request, options = nil
397
+ raise ::ArgumentError, "request must be provided" if request.nil?
398
+
399
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::ListSchemasRequest
400
+
401
+ # Converts hash and nil to an options object
402
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
403
+
404
+ # Customize the options with defaults
405
+ metadata = @config.rpcs.list_schemas.metadata.to_h
406
+
407
+ # Set x-goog-api-client and x-goog-user-project headers
408
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
409
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
410
+ gapic_version: ::Google::Cloud::PubSub::V1::VERSION
411
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
412
+
413
+ header_params = {}
414
+ if request.parent
415
+ header_params["parent"] = request.parent
416
+ end
417
+
418
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
419
+ metadata[:"x-goog-request-params"] ||= request_params_header
420
+
421
+ options.apply_defaults timeout: @config.rpcs.list_schemas.timeout,
422
+ metadata: metadata,
423
+ retry_policy: @config.rpcs.list_schemas.retry_policy
424
+
425
+ options.apply_defaults timeout: @config.timeout,
426
+ metadata: @config.metadata,
427
+ retry_policy: @config.retry_policy
428
+
429
+ @schema_service_stub.call_rpc :list_schemas, request, options: options do |response, operation|
430
+ response = ::Gapic::PagedEnumerable.new @schema_service_stub, :list_schemas, request, response, operation, options
431
+ yield response, operation if block_given?
432
+ return response
433
+ end
434
+ rescue ::GRPC::BadStatus => e
435
+ raise ::Google::Cloud::Error.from_error(e)
436
+ end
437
+
438
+ ##
439
+ # Deletes a schema.
440
+ #
441
+ # @overload delete_schema(request, options = nil)
442
+ # Pass arguments to `delete_schema` via a request object, either of type
443
+ # {::Google::Cloud::PubSub::V1::DeleteSchemaRequest} or an equivalent Hash.
444
+ #
445
+ # @param request [::Google::Cloud::PubSub::V1::DeleteSchemaRequest, ::Hash]
446
+ # A request object representing the call parameters. Required. To specify no
447
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
448
+ # @param options [::Gapic::CallOptions, ::Hash]
449
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
450
+ #
451
+ # @overload delete_schema(name: nil)
452
+ # Pass arguments to `delete_schema` via keyword arguments. Note that at
453
+ # least one keyword argument is required. To specify no parameters, or to keep all
454
+ # the default parameter values, pass an empty Hash as a request object (see above).
455
+ #
456
+ # @param name [::String]
457
+ # Required. Name of the schema to delete.
458
+ # Format is `projects/{project}/schemas/{schema}`.
459
+ #
460
+ # @yield [response, operation] Access the result along with the RPC operation
461
+ # @yieldparam response [::Google::Protobuf::Empty]
462
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
463
+ #
464
+ # @return [::Google::Protobuf::Empty]
465
+ #
466
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
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
+ #
483
+ def delete_schema request, options = nil
484
+ raise ::ArgumentError, "request must be provided" if request.nil?
485
+
486
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::DeleteSchemaRequest
487
+
488
+ # Converts hash and nil to an options object
489
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
490
+
491
+ # Customize the options with defaults
492
+ metadata = @config.rpcs.delete_schema.metadata.to_h
493
+
494
+ # Set x-goog-api-client and x-goog-user-project headers
495
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
496
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
497
+ gapic_version: ::Google::Cloud::PubSub::V1::VERSION
498
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
499
+
500
+ header_params = {}
501
+ if request.name
502
+ header_params["name"] = request.name
503
+ end
504
+
505
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
506
+ metadata[:"x-goog-request-params"] ||= request_params_header
507
+
508
+ options.apply_defaults timeout: @config.rpcs.delete_schema.timeout,
509
+ metadata: metadata,
510
+ retry_policy: @config.rpcs.delete_schema.retry_policy
511
+
512
+ options.apply_defaults timeout: @config.timeout,
513
+ metadata: @config.metadata,
514
+ retry_policy: @config.retry_policy
515
+
516
+ @schema_service_stub.call_rpc :delete_schema, request, options: options do |response, operation|
517
+ yield response, operation if block_given?
518
+ return response
519
+ end
520
+ rescue ::GRPC::BadStatus => e
521
+ raise ::Google::Cloud::Error.from_error(e)
522
+ end
523
+
524
+ ##
525
+ # Validates a schema.
526
+ #
527
+ # @overload validate_schema(request, options = nil)
528
+ # Pass arguments to `validate_schema` via a request object, either of type
529
+ # {::Google::Cloud::PubSub::V1::ValidateSchemaRequest} or an equivalent Hash.
530
+ #
531
+ # @param request [::Google::Cloud::PubSub::V1::ValidateSchemaRequest, ::Hash]
532
+ # A request object representing the call parameters. Required. To specify no
533
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
534
+ # @param options [::Gapic::CallOptions, ::Hash]
535
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
536
+ #
537
+ # @overload validate_schema(parent: nil, schema: nil)
538
+ # Pass arguments to `validate_schema` via keyword arguments. Note that at
539
+ # least one keyword argument is required. To specify no parameters, or to keep all
540
+ # the default parameter values, pass an empty Hash as a request object (see above).
541
+ #
542
+ # @param parent [::String]
543
+ # Required. The name of the project in which to validate schemas.
544
+ # Format is `projects/{project-id}`.
545
+ # @param schema [::Google::Cloud::PubSub::V1::Schema, ::Hash]
546
+ # Required. The schema object to validate.
547
+ #
548
+ # @yield [response, operation] Access the result along with the RPC operation
549
+ # @yieldparam response [::Google::Cloud::PubSub::V1::ValidateSchemaResponse]
550
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
551
+ #
552
+ # @return [::Google::Cloud::PubSub::V1::ValidateSchemaResponse]
553
+ #
554
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
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
+ #
571
+ def validate_schema request, options = nil
572
+ raise ::ArgumentError, "request must be provided" if request.nil?
573
+
574
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::ValidateSchemaRequest
575
+
576
+ # Converts hash and nil to an options object
577
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
578
+
579
+ # Customize the options with defaults
580
+ metadata = @config.rpcs.validate_schema.metadata.to_h
581
+
582
+ # Set x-goog-api-client and x-goog-user-project headers
583
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
584
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
585
+ gapic_version: ::Google::Cloud::PubSub::V1::VERSION
586
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
587
+
588
+ header_params = {}
589
+ if request.parent
590
+ header_params["parent"] = request.parent
591
+ end
592
+
593
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
594
+ metadata[:"x-goog-request-params"] ||= request_params_header
595
+
596
+ options.apply_defaults timeout: @config.rpcs.validate_schema.timeout,
597
+ metadata: metadata,
598
+ retry_policy: @config.rpcs.validate_schema.retry_policy
599
+
600
+ options.apply_defaults timeout: @config.timeout,
601
+ metadata: @config.metadata,
602
+ retry_policy: @config.retry_policy
603
+
604
+ @schema_service_stub.call_rpc :validate_schema, request, options: options do |response, operation|
605
+ yield response, operation if block_given?
606
+ return response
607
+ end
608
+ rescue ::GRPC::BadStatus => e
609
+ raise ::Google::Cloud::Error.from_error(e)
610
+ end
611
+
612
+ ##
613
+ # Validates a message against a schema.
614
+ #
615
+ # @overload validate_message(request, options = nil)
616
+ # Pass arguments to `validate_message` via a request object, either of type
617
+ # {::Google::Cloud::PubSub::V1::ValidateMessageRequest} or an equivalent Hash.
618
+ #
619
+ # @param request [::Google::Cloud::PubSub::V1::ValidateMessageRequest, ::Hash]
620
+ # A request object representing the call parameters. Required. To specify no
621
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
622
+ # @param options [::Gapic::CallOptions, ::Hash]
623
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
624
+ #
625
+ # @overload validate_message(parent: nil, name: nil, schema: nil, message: nil, encoding: nil)
626
+ # Pass arguments to `validate_message` via keyword arguments. Note that at
627
+ # least one keyword argument is required. To specify no parameters, or to keep all
628
+ # the default parameter values, pass an empty Hash as a request object (see above).
629
+ #
630
+ # @param parent [::String]
631
+ # Required. The name of the project in which to validate schemas.
632
+ # Format is `projects/{project-id}`.
633
+ # @param name [::String]
634
+ # Name of the schema against which to validate.
635
+ #
636
+ # Format is `projects/{project}/schemas/{schema}`.
637
+ # @param schema [::Google::Cloud::PubSub::V1::Schema, ::Hash]
638
+ # Ad-hoc schema against which to validate
639
+ # @param message [::String]
640
+ # Message to validate against the provided `schema_spec`.
641
+ # @param encoding [::Google::Cloud::PubSub::V1::Encoding]
642
+ # The encoding expected for messages
643
+ #
644
+ # @yield [response, operation] Access the result along with the RPC operation
645
+ # @yieldparam response [::Google::Cloud::PubSub::V1::ValidateMessageResponse]
646
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
647
+ #
648
+ # @return [::Google::Cloud::PubSub::V1::ValidateMessageResponse]
649
+ #
650
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
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
+ #
667
+ def validate_message request, options = nil
668
+ raise ::ArgumentError, "request must be provided" if request.nil?
669
+
670
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::ValidateMessageRequest
671
+
672
+ # Converts hash and nil to an options object
673
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
674
+
675
+ # Customize the options with defaults
676
+ metadata = @config.rpcs.validate_message.metadata.to_h
677
+
678
+ # Set x-goog-api-client and x-goog-user-project headers
679
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
680
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
681
+ gapic_version: ::Google::Cloud::PubSub::V1::VERSION
682
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
683
+
684
+ header_params = {}
685
+ if request.parent
686
+ header_params["parent"] = request.parent
687
+ end
688
+
689
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
690
+ metadata[:"x-goog-request-params"] ||= request_params_header
691
+
692
+ options.apply_defaults timeout: @config.rpcs.validate_message.timeout,
693
+ metadata: metadata,
694
+ retry_policy: @config.rpcs.validate_message.retry_policy
695
+
696
+ options.apply_defaults timeout: @config.timeout,
697
+ metadata: @config.metadata,
698
+ retry_policy: @config.retry_policy
699
+
700
+ @schema_service_stub.call_rpc :validate_message, request, options: options do |response, operation|
701
+ yield response, operation if block_given?
702
+ return response
703
+ end
704
+ rescue ::GRPC::BadStatus => e
705
+ raise ::Google::Cloud::Error.from_error(e)
706
+ end
707
+
708
+ ##
709
+ # Configuration class for the SchemaService API.
710
+ #
711
+ # This class represents the configuration for SchemaService,
712
+ # providing control over timeouts, retry behavior, logging, transport
713
+ # parameters, and other low-level controls. Certain parameters can also be
714
+ # applied individually to specific RPCs. See
715
+ # {::Google::Cloud::PubSub::V1::SchemaService::Client::Configuration::Rpcs}
716
+ # for a list of RPCs that can be configured independently.
717
+ #
718
+ # Configuration can be applied globally to all clients, or to a single client
719
+ # on construction.
720
+ #
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
736
+ #
737
+ # @!attribute [rw] endpoint
738
+ # The hostname or hostname:port of the service endpoint.
739
+ # Defaults to `"pubsub.googleapis.com"`.
740
+ # @return [::String]
741
+ # @!attribute [rw] credentials
742
+ # Credentials to send with calls. You may provide any of the following types:
743
+ # * (`String`) The path to a service account key file in JSON format
744
+ # * (`Hash`) A service account key as a Hash
745
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
746
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
747
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
748
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
749
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
750
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
751
+ # * (`nil`) indicating no credentials
752
+ # @return [::Object]
753
+ # @!attribute [rw] scope
754
+ # The OAuth scopes
755
+ # @return [::Array<::String>]
756
+ # @!attribute [rw] lib_name
757
+ # The library name as recorded in instrumentation and logging
758
+ # @return [::String]
759
+ # @!attribute [rw] lib_version
760
+ # The library version as recorded in instrumentation and logging
761
+ # @return [::String]
762
+ # @!attribute [rw] channel_args
763
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
764
+ # `GRPC::Core::Channel` object is provided as the credential.
765
+ # @return [::Hash]
766
+ # @!attribute [rw] interceptors
767
+ # An array of interceptors that are run before calls are executed.
768
+ # @return [::Array<::GRPC::ClientInterceptor>]
769
+ # @!attribute [rw] timeout
770
+ # The call timeout in seconds.
771
+ # @return [::Numeric]
772
+ # @!attribute [rw] metadata
773
+ # Additional gRPC headers to be sent with the call.
774
+ # @return [::Hash{::Symbol=>::String}]
775
+ # @!attribute [rw] retry_policy
776
+ # The retry policy. The value is a hash with the following keys:
777
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
778
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
779
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
780
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
781
+ # trigger a retry.
782
+ # @return [::Hash]
783
+ # @!attribute [rw] quota_project
784
+ # A separate project against which to charge quota.
785
+ # @return [::String]
786
+ #
787
+ class Configuration
788
+ extend ::Gapic::Config
789
+
790
+ config_attr :endpoint, "pubsub.googleapis.com", ::String
791
+ config_attr :credentials, nil do |value|
792
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
793
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
794
+ allowed.any? { |klass| klass === value }
795
+ end
796
+ config_attr :scope, nil, ::String, ::Array, nil
797
+ config_attr :lib_name, nil, ::String, nil
798
+ config_attr :lib_version, nil, ::String, nil
799
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
800
+ config_attr :interceptors, nil, ::Array, nil
801
+ config_attr :timeout, nil, ::Numeric, nil
802
+ config_attr :metadata, nil, ::Hash, nil
803
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
804
+ config_attr :quota_project, nil, ::String, nil
805
+
806
+ # @private
807
+ def initialize parent_config = nil
808
+ @parent_config = parent_config unless parent_config.nil?
809
+
810
+ yield self if block_given?
811
+ end
812
+
813
+ ##
814
+ # Configurations for individual RPCs
815
+ # @return [Rpcs]
816
+ #
817
+ def rpcs
818
+ @rpcs ||= begin
819
+ parent_rpcs = nil
820
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
821
+ Rpcs.new parent_rpcs
822
+ end
823
+ end
824
+
825
+ ##
826
+ # Configuration RPC class for the SchemaService API.
827
+ #
828
+ # Includes fields providing the configuration for each RPC in this service.
829
+ # Each configuration object is of type `Gapic::Config::Method` and includes
830
+ # the following configuration fields:
831
+ #
832
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
833
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
834
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
835
+ # include the following keys:
836
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
837
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
838
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
839
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
840
+ # trigger a retry.
841
+ #
842
+ class Rpcs
843
+ ##
844
+ # RPC-specific configuration for `create_schema`
845
+ # @return [::Gapic::Config::Method]
846
+ #
847
+ attr_reader :create_schema
848
+ ##
849
+ # RPC-specific configuration for `get_schema`
850
+ # @return [::Gapic::Config::Method]
851
+ #
852
+ attr_reader :get_schema
853
+ ##
854
+ # RPC-specific configuration for `list_schemas`
855
+ # @return [::Gapic::Config::Method]
856
+ #
857
+ attr_reader :list_schemas
858
+ ##
859
+ # RPC-specific configuration for `delete_schema`
860
+ # @return [::Gapic::Config::Method]
861
+ #
862
+ attr_reader :delete_schema
863
+ ##
864
+ # RPC-specific configuration for `validate_schema`
865
+ # @return [::Gapic::Config::Method]
866
+ #
867
+ attr_reader :validate_schema
868
+ ##
869
+ # RPC-specific configuration for `validate_message`
870
+ # @return [::Gapic::Config::Method]
871
+ #
872
+ attr_reader :validate_message
873
+
874
+ # @private
875
+ def initialize parent_rpcs = nil
876
+ create_schema_config = parent_rpcs.create_schema if parent_rpcs.respond_to? :create_schema
877
+ @create_schema = ::Gapic::Config::Method.new create_schema_config
878
+ get_schema_config = parent_rpcs.get_schema if parent_rpcs.respond_to? :get_schema
879
+ @get_schema = ::Gapic::Config::Method.new get_schema_config
880
+ list_schemas_config = parent_rpcs.list_schemas if parent_rpcs.respond_to? :list_schemas
881
+ @list_schemas = ::Gapic::Config::Method.new list_schemas_config
882
+ delete_schema_config = parent_rpcs.delete_schema if parent_rpcs.respond_to? :delete_schema
883
+ @delete_schema = ::Gapic::Config::Method.new delete_schema_config
884
+ validate_schema_config = parent_rpcs.validate_schema if parent_rpcs.respond_to? :validate_schema
885
+ @validate_schema = ::Gapic::Config::Method.new validate_schema_config
886
+ validate_message_config = parent_rpcs.validate_message if parent_rpcs.respond_to? :validate_message
887
+ @validate_message = ::Gapic::Config::Method.new validate_message_config
888
+
889
+ yield self if block_given?
890
+ end
891
+ end
892
+ end
893
+ end
894
+ end
895
+ end
896
+ end
897
+ end
898
+ end