google-cloud-pubsub-v1 0.1.2 → 0.2.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: 2f017ced38ffbe3a6ec5cdf748a75e2ade99323170bb66ec0b26a96e8b8dcdef
4
- data.tar.gz: a75323af7a9a5b603eaba855584b18b24029e977562f4add330403fa433a97ab
3
+ metadata.gz: 84eddaa5b8a088112b529edcd0702afd1f10b5012f4f6d73421bb91f9a282678
4
+ data.tar.gz: 89a74937041c66b72c169dc1afb07b2de242d147c9fb3cacea43735f5fe22b91
5
5
  SHA512:
6
- metadata.gz: 7ca58d39bc975570473a5cffb803796298a66ca336501f789d5945dd26ead08b1f6a346f67c3941b5781512c414be724e1cc979eecd89d4cc8ec9bce34dc5ae0
7
- data.tar.gz: 3e3b53191c7b1e13a9822428f878cc63fa7ad1fe99754f6c70fe879dbd072633e1739c567d0c669b3926519ef0d40d18300f1ae37e123385d39ba58c9dbfb22d
6
+ metadata.gz: 516863d8c775da4dcbfe4ada45e932bdb5a65a22f2fa4ff6bf57834c93453691dbd143bf7c444a480db9588afdd0dcd736eb022e08e7d53540719e6ba30745e2
7
+ data.tar.gz: e01373539c0d3ec481b3cd40a293e3872fe26107ec4b3984feb9365691e8a0a82ab78a1b6e41d792fdb8ee8a8dfa11bea9a58a2e6a055b6852ba45a7777ed3eb
@@ -27,7 +27,7 @@ export PUBSUB_CREDENTIALS=path/to/keyfile.json
27
27
  ```ruby
28
28
  require "google/cloud/pubsub/v1"
29
29
 
30
- client = ::Google::Cloud::PubSub::V1::Publisher::Client.new
30
+ client = ::Google::Cloud::PubSub::V1::SchemaService::Client.new
31
31
  ```
32
32
 
33
33
  ## Credential Lookup
@@ -64,7 +64,7 @@ containers where writing files is difficult or not encouraged.
64
64
 
65
65
  The environment variables that google-cloud-pubsub-v1
66
66
  checks for credentials are configured on the service Credentials class (such as
67
- {::Google::Cloud::PubSub::V1::Publisher::Credentials}):
67
+ {::Google::Cloud::PubSub::V1::SchemaService::Credentials}):
68
68
 
69
69
  1. `PUBSUB_CREDENTIALS` - Path to JSON file, or JSON contents
70
70
  2. `PUBSUB_KEYFILE` - Path to JSON file, or JSON contents
@@ -77,7 +77,7 @@ require "google/cloud/pubsub/v1"
77
77
 
78
78
  ENV["PUBSUB_CREDENTIALS"] = "path/to/keyfile.json"
79
79
 
80
- client = ::Google::Cloud::PubSub::V1::Publisher::Client.new
80
+ client = ::Google::Cloud::PubSub::V1::SchemaService::Client.new
81
81
  ```
82
82
 
83
83
  ### Configuration
@@ -88,7 +88,7 @@ environment variables. Either on an individual client initialization:
88
88
  ```ruby
89
89
  require "google/cloud/pubsub/v1"
90
90
 
91
- client = ::Google::Cloud::PubSub::V1::Publisher::Client.new do |config|
91
+ client = ::Google::Cloud::PubSub::V1::SchemaService::Client.new do |config|
92
92
  config.credentials = "path/to/keyfile.json"
93
93
  end
94
94
  ```
@@ -98,11 +98,11 @@ Or configured globally for all clients:
98
98
  ```ruby
99
99
  require "google/cloud/pubsub/v1"
100
100
 
101
- ::Google::Cloud::PubSub::V1::Publisher::Client.configure do |config|
101
+ ::Google::Cloud::PubSub::V1::SchemaService::Client.configure do |config|
102
102
  config.credentials = "path/to/keyfile.json"
103
103
  end
104
104
 
105
- client = ::Google::Cloud::PubSub::V1::Publisher::Client.new
105
+ client = ::Google::Cloud::PubSub::V1::SchemaService::Client.new
106
106
  ```
107
107
 
108
108
  ### Cloud SDK
data/README.md CHANGED
@@ -26,9 +26,9 @@ In order to use this library, you first need to go through the following steps:
26
26
  ```ruby
27
27
  require "google/cloud/pubsub/v1"
28
28
 
29
- client = ::Google::Cloud::PubSub::V1::Publisher::Client.new
29
+ client = ::Google::Cloud::PubSub::V1::SchemaService::Client.new
30
30
  request = my_create_request
31
- response = client.create_topic request
31
+ response = client.create_schema request
32
32
  ```
33
33
 
34
34
  View the [Client Library Documentation](https://googleapis.dev/ruby/google-cloud-pubsub-v1/latest)
@@ -16,6 +16,7 @@
16
16
 
17
17
  # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
18
 
19
+ require "google/cloud/pubsub/v1/schema_service"
19
20
  require "google/cloud/pubsub/v1/publisher"
20
21
  require "google/cloud/pubsub/v1/subscriber"
21
22
  require "google/cloud/pubsub/v1/iam_policy"
@@ -28,10 +29,13 @@ module Google
28
29
  # To load this package, including all its services, and instantiate a client:
29
30
  #
30
31
  # require "google/cloud/pubsub/v1"
31
- # client = ::Google::Cloud::PubSub::V1::Publisher::Client.new
32
+ # client = ::Google::Cloud::PubSub::V1::SchemaService::Client.new
32
33
  #
33
34
  module V1
34
35
  end
35
36
  end
36
37
  end
37
38
  end
39
+
40
+ helper_path = ::File.join __dir__, "v1", "_helpers.rb"
41
+ require "google/cloud/pubsub/v1/_helpers" if ::File.file? helper_path
@@ -218,8 +218,8 @@ module Google
218
218
  # Service calls
219
219
 
220
220
  ##
221
- # Creates the given topic with the given name. See the [resource name rules](
222
- # https://cloud.google.com/pubsub/docs/admin#resource_names).
221
+ # Creates the given topic with the given name. See the [resource name rules]
222
+ # (https://cloud.google.com/pubsub/docs/admin#resource_names).
223
223
  #
224
224
  # @overload create_topic(request, options = nil)
225
225
  # Pass arguments to `create_topic` via a request object, either of type
@@ -231,7 +231,7 @@ module Google
231
231
  # @param options [::Gapic::CallOptions, ::Hash]
232
232
  # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
233
233
  #
234
- # @overload create_topic(name: nil, labels: nil, message_storage_policy: nil, kms_key_name: nil)
234
+ # @overload create_topic(name: nil, labels: nil, message_storage_policy: nil, kms_key_name: nil, schema_settings: nil, satisfies_pzs: nil)
235
235
  # Pass arguments to `create_topic` via keyword arguments. Note that at
236
236
  # least one keyword argument is required. To specify no parameters, or to keep all
237
237
  # the default parameter values, pass an empty Hash as a request object (see above).
@@ -255,6 +255,13 @@ module Google
255
255
  # to messages published on this topic.
256
256
  #
257
257
  # The expected format is `projects/*/locations/*/keyRings/*/cryptoKeys/*`.
258
+ # @param schema_settings [::Google::Cloud::PubSub::V1::SchemaSettings, ::Hash]
259
+ # Settings for validating messages published against a schema.
260
+ #
261
+ # EXPERIMENTAL: Schema support is in development and may not work yet.
262
+ # @param satisfies_pzs [::Boolean]
263
+ # Reserved for future use. This field is set only in responses from the
264
+ # server; it is ignored if it is set in any requests.
258
265
  #
259
266
  # @yield [response, operation] Access the result along with the RPC operation
260
267
  # @yieldparam response [::Google::Cloud::PubSub::V1::Topic]
@@ -38,6 +38,23 @@ module Google
38
38
  "projects/#{project}"
39
39
  end
40
40
 
41
+ ##
42
+ # Create a fully-qualified Schema resource string.
43
+ #
44
+ # The resource will be in the following format:
45
+ #
46
+ # `projects/{project}/schemas/{schema}`
47
+ #
48
+ # @param project [String]
49
+ # @param schema [String]
50
+ #
51
+ # @return [::String]
52
+ def schema_path project:, schema:
53
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
54
+
55
+ "projects/#{project}/schemas/#{schema}"
56
+ end
57
+
41
58
  ##
42
59
  # Create a fully-qualified Subscription resource string.
43
60
  #
@@ -0,0 +1,47 @@
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 "gapic/common"
20
+ require "gapic/config"
21
+ require "gapic/config/method"
22
+
23
+ require "google/cloud/pubsub/v1/version"
24
+
25
+ require "google/cloud/pubsub/v1/schema_service/credentials"
26
+ require "google/cloud/pubsub/v1/schema_service/paths"
27
+ require "google/cloud/pubsub/v1/schema_service/client"
28
+
29
+ module Google
30
+ module Cloud
31
+ module PubSub
32
+ module V1
33
+ ##
34
+ # To load this service and instantiate a client:
35
+ #
36
+ # require "google/cloud/pubsub/v1/schema_service"
37
+ # client = ::Google::Cloud::PubSub::V1::SchemaService::Client.new
38
+ #
39
+ module SchemaService
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+
46
+ helper_path = ::File.join __dir__, "schema_service", "helpers.rb"
47
+ require "google/cloud/pubsub/v1/schema_service/helpers" if ::File.file? helper_path
@@ -0,0 +1,777 @@
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
+ class Client
31
+ include Paths
32
+
33
+ # @private
34
+ attr_reader :schema_service_stub
35
+
36
+ ##
37
+ # Configure the SchemaService Client class.
38
+ #
39
+ # See {::Google::Cloud::PubSub::V1::SchemaService::Client::Configuration}
40
+ # for a description of the configuration fields.
41
+ #
42
+ # ## Example
43
+ #
44
+ # To modify the configuration for all SchemaService clients:
45
+ #
46
+ # ::Google::Cloud::PubSub::V1::SchemaService::Client.configure do |config|
47
+ # config.timeout = 10.0
48
+ # end
49
+ #
50
+ # @yield [config] Configure the Client client.
51
+ # @yieldparam config [Client::Configuration]
52
+ #
53
+ # @return [Client::Configuration]
54
+ #
55
+ def self.configure
56
+ @configure ||= begin
57
+ namespace = ["Google", "Cloud", "PubSub", "V1"]
58
+ parent_config = while namespace.any?
59
+ parent_name = namespace.join "::"
60
+ parent_const = const_get parent_name
61
+ break parent_const.configure if parent_const&.respond_to? :configure
62
+ namespace.pop
63
+ end
64
+ default_config = Client::Configuration.new parent_config
65
+
66
+ default_config
67
+ end
68
+ yield @configure if block_given?
69
+ @configure
70
+ end
71
+
72
+ ##
73
+ # Configure the SchemaService Client instance.
74
+ #
75
+ # The configuration is set to the derived mode, meaning that values can be changed,
76
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
77
+ # should be made on {Client.configure}.
78
+ #
79
+ # See {::Google::Cloud::PubSub::V1::SchemaService::Client::Configuration}
80
+ # for a description of the configuration fields.
81
+ #
82
+ # @yield [config] Configure the Client client.
83
+ # @yieldparam config [Client::Configuration]
84
+ #
85
+ # @return [Client::Configuration]
86
+ #
87
+ def configure
88
+ yield @config if block_given?
89
+ @config
90
+ end
91
+
92
+ ##
93
+ # Create a new SchemaService client object.
94
+ #
95
+ # ## Examples
96
+ #
97
+ # To create a new SchemaService client with the default
98
+ # configuration:
99
+ #
100
+ # client = ::Google::Cloud::PubSub::V1::SchemaService::Client.new
101
+ #
102
+ # To create a new SchemaService client with a custom
103
+ # configuration:
104
+ #
105
+ # client = ::Google::Cloud::PubSub::V1::SchemaService::Client.new do |config|
106
+ # config.timeout = 10.0
107
+ # end
108
+ #
109
+ # @yield [config] Configure the SchemaService client.
110
+ # @yieldparam config [Client::Configuration]
111
+ #
112
+ def initialize
113
+ # These require statements are intentionally placed here to initialize
114
+ # the gRPC module only when it's required.
115
+ # See https://github.com/googleapis/toolkit/issues/446
116
+ require "gapic/grpc"
117
+ require "google/pubsub/v1/schema_services_pb"
118
+
119
+ # Create the configuration object
120
+ @config = Configuration.new Client.configure
121
+
122
+ # Yield the configuration if needed
123
+ yield @config if block_given?
124
+
125
+ # Create credentials
126
+ credentials = @config.credentials
127
+ credentials ||= Credentials.default scope: @config.scope
128
+ if credentials.is_a?(String) || credentials.is_a?(Hash)
129
+ credentials = Credentials.new credentials, scope: @config.scope
130
+ end
131
+ @quota_project_id = @config.quota_project
132
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
133
+
134
+ @schema_service_stub = ::Gapic::ServiceStub.new(
135
+ ::Google::Cloud::PubSub::V1::SchemaService::Stub,
136
+ credentials: credentials,
137
+ endpoint: @config.endpoint,
138
+ channel_args: @config.channel_args,
139
+ interceptors: @config.interceptors
140
+ )
141
+ end
142
+
143
+ # Service calls
144
+
145
+ ##
146
+ # Creates a schema.
147
+ #
148
+ # @overload create_schema(request, options = nil)
149
+ # Pass arguments to `create_schema` via a request object, either of type
150
+ # {::Google::Cloud::PubSub::V1::CreateSchemaRequest} or an equivalent Hash.
151
+ #
152
+ # @param request [::Google::Cloud::PubSub::V1::CreateSchemaRequest, ::Hash]
153
+ # A request object representing the call parameters. Required. To specify no
154
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
155
+ # @param options [::Gapic::CallOptions, ::Hash]
156
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
157
+ #
158
+ # @overload create_schema(parent: nil, schema: nil, schema_id: nil)
159
+ # Pass arguments to `create_schema` via keyword arguments. Note that at
160
+ # least one keyword argument is required. To specify no parameters, or to keep all
161
+ # the default parameter values, pass an empty Hash as a request object (see above).
162
+ #
163
+ # @param parent [::String]
164
+ # Required. The name of the project in which to create the schema.
165
+ # Format is `projects/{project-id}`.
166
+ # @param schema [::Google::Cloud::PubSub::V1::Schema, ::Hash]
167
+ # Required. The schema object to create.
168
+ #
169
+ # This schema's `name` parameter is ignored. The schema object returned
170
+ # by CreateSchema will have a `name` made using the given `parent` and
171
+ # `schema_id`.
172
+ # @param schema_id [::String]
173
+ # The ID to use for the schema, which will become the final component of
174
+ # the schema's resource name.
175
+ #
176
+ # See https://cloud.google.com/pubsub/docs/admin#resource_names for resource
177
+ # name constraints.
178
+ #
179
+ # @yield [response, operation] Access the result along with the RPC operation
180
+ # @yieldparam response [::Google::Cloud::PubSub::V1::Schema]
181
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
182
+ #
183
+ # @return [::Google::Cloud::PubSub::V1::Schema]
184
+ #
185
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
186
+ #
187
+ def create_schema request, options = nil
188
+ raise ::ArgumentError, "request must be provided" if request.nil?
189
+
190
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::CreateSchemaRequest
191
+
192
+ # Converts hash and nil to an options object
193
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
194
+
195
+ # Customize the options with defaults
196
+ metadata = @config.rpcs.create_schema.metadata.to_h
197
+
198
+ # Set x-goog-api-client and x-goog-user-project headers
199
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
200
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
201
+ gapic_version: ::Google::Cloud::PubSub::V1::VERSION
202
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
203
+
204
+ header_params = {
205
+ "parent" => request.parent
206
+ }
207
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
208
+ metadata[:"x-goog-request-params"] ||= request_params_header
209
+
210
+ options.apply_defaults timeout: @config.rpcs.create_schema.timeout,
211
+ metadata: metadata,
212
+ retry_policy: @config.rpcs.create_schema.retry_policy
213
+ options.apply_defaults metadata: @config.metadata,
214
+ retry_policy: @config.retry_policy
215
+
216
+ @schema_service_stub.call_rpc :create_schema, request, options: options do |response, operation|
217
+ yield response, operation if block_given?
218
+ return response
219
+ end
220
+ rescue ::GRPC::BadStatus => e
221
+ raise ::Google::Cloud::Error.from_error(e)
222
+ end
223
+
224
+ ##
225
+ # Gets a schema.
226
+ #
227
+ # @overload get_schema(request, options = nil)
228
+ # Pass arguments to `get_schema` via a request object, either of type
229
+ # {::Google::Cloud::PubSub::V1::GetSchemaRequest} or an equivalent Hash.
230
+ #
231
+ # @param request [::Google::Cloud::PubSub::V1::GetSchemaRequest, ::Hash]
232
+ # A request object representing the call parameters. Required. To specify no
233
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
234
+ # @param options [::Gapic::CallOptions, ::Hash]
235
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
236
+ #
237
+ # @overload get_schema(name: nil, view: nil)
238
+ # Pass arguments to `get_schema` via keyword arguments. Note that at
239
+ # least one keyword argument is required. To specify no parameters, or to keep all
240
+ # the default parameter values, pass an empty Hash as a request object (see above).
241
+ #
242
+ # @param name [::String]
243
+ # Required. The name of the schema to get.
244
+ # Format is `projects/{project}/schemas/{schema}`.
245
+ # @param view [::Google::Cloud::PubSub::V1::SchemaView]
246
+ # The set of fields to return in the response. If not set, returns a Schema
247
+ # with `name` and `type`, but not `definition`. Set to `FULL` to retrieve all
248
+ # fields.
249
+ #
250
+ # @yield [response, operation] Access the result along with the RPC operation
251
+ # @yieldparam response [::Google::Cloud::PubSub::V1::Schema]
252
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
253
+ #
254
+ # @return [::Google::Cloud::PubSub::V1::Schema]
255
+ #
256
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
257
+ #
258
+ def get_schema request, options = nil
259
+ raise ::ArgumentError, "request must be provided" if request.nil?
260
+
261
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::GetSchemaRequest
262
+
263
+ # Converts hash and nil to an options object
264
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
265
+
266
+ # Customize the options with defaults
267
+ metadata = @config.rpcs.get_schema.metadata.to_h
268
+
269
+ # Set x-goog-api-client and x-goog-user-project headers
270
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
271
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
272
+ gapic_version: ::Google::Cloud::PubSub::V1::VERSION
273
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
274
+
275
+ header_params = {
276
+ "name" => request.name
277
+ }
278
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
279
+ metadata[:"x-goog-request-params"] ||= request_params_header
280
+
281
+ options.apply_defaults timeout: @config.rpcs.get_schema.timeout,
282
+ metadata: metadata,
283
+ retry_policy: @config.rpcs.get_schema.retry_policy
284
+ options.apply_defaults metadata: @config.metadata,
285
+ retry_policy: @config.retry_policy
286
+
287
+ @schema_service_stub.call_rpc :get_schema, request, options: options do |response, operation|
288
+ yield response, operation if block_given?
289
+ return response
290
+ end
291
+ rescue ::GRPC::BadStatus => e
292
+ raise ::Google::Cloud::Error.from_error(e)
293
+ end
294
+
295
+ ##
296
+ # Lists schemas in a project.
297
+ #
298
+ # @overload list_schemas(request, options = nil)
299
+ # Pass arguments to `list_schemas` via a request object, either of type
300
+ # {::Google::Cloud::PubSub::V1::ListSchemasRequest} or an equivalent Hash.
301
+ #
302
+ # @param request [::Google::Cloud::PubSub::V1::ListSchemasRequest, ::Hash]
303
+ # A request object representing the call parameters. Required. To specify no
304
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
305
+ # @param options [::Gapic::CallOptions, ::Hash]
306
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
307
+ #
308
+ # @overload list_schemas(parent: nil, view: nil, page_size: nil, page_token: nil)
309
+ # Pass arguments to `list_schemas` via keyword arguments. Note that at
310
+ # least one keyword argument is required. To specify no parameters, or to keep all
311
+ # the default parameter values, pass an empty Hash as a request object (see above).
312
+ #
313
+ # @param parent [::String]
314
+ # Required. The name of the project in which to list schemas.
315
+ # Format is `projects/{project-id}`.
316
+ # @param view [::Google::Cloud::PubSub::V1::SchemaView]
317
+ # The set of Schema fields to return in the response. If not set, returns
318
+ # Schemas with `name` and `type`, but not `definition`. Set to `FULL` to
319
+ # retrieve all fields.
320
+ # @param page_size [::Integer]
321
+ # Maximum number of schemas to return.
322
+ # @param page_token [::String]
323
+ # The value returned by the last `ListSchemasResponse`; indicates that
324
+ # this is a continuation of a prior `ListSchemas` call, and that the
325
+ # system should return the next page of data.
326
+ #
327
+ # @yield [response, operation] Access the result along with the RPC operation
328
+ # @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::PubSub::V1::Schema>]
329
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
330
+ #
331
+ # @return [::Gapic::PagedEnumerable<::Google::Cloud::PubSub::V1::Schema>]
332
+ #
333
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
334
+ #
335
+ def list_schemas request, options = nil
336
+ raise ::ArgumentError, "request must be provided" if request.nil?
337
+
338
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::ListSchemasRequest
339
+
340
+ # Converts hash and nil to an options object
341
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
342
+
343
+ # Customize the options with defaults
344
+ metadata = @config.rpcs.list_schemas.metadata.to_h
345
+
346
+ # Set x-goog-api-client and x-goog-user-project headers
347
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
348
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
349
+ gapic_version: ::Google::Cloud::PubSub::V1::VERSION
350
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
351
+
352
+ header_params = {
353
+ "parent" => request.parent
354
+ }
355
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
356
+ metadata[:"x-goog-request-params"] ||= request_params_header
357
+
358
+ options.apply_defaults timeout: @config.rpcs.list_schemas.timeout,
359
+ metadata: metadata,
360
+ retry_policy: @config.rpcs.list_schemas.retry_policy
361
+ options.apply_defaults metadata: @config.metadata,
362
+ retry_policy: @config.retry_policy
363
+
364
+ @schema_service_stub.call_rpc :list_schemas, request, options: options do |response, operation|
365
+ response = ::Gapic::PagedEnumerable.new @schema_service_stub, :list_schemas, request, response, operation, options
366
+ yield response, operation if block_given?
367
+ return response
368
+ end
369
+ rescue ::GRPC::BadStatus => e
370
+ raise ::Google::Cloud::Error.from_error(e)
371
+ end
372
+
373
+ ##
374
+ # Deletes a schema.
375
+ #
376
+ # @overload delete_schema(request, options = nil)
377
+ # Pass arguments to `delete_schema` via a request object, either of type
378
+ # {::Google::Cloud::PubSub::V1::DeleteSchemaRequest} or an equivalent Hash.
379
+ #
380
+ # @param request [::Google::Cloud::PubSub::V1::DeleteSchemaRequest, ::Hash]
381
+ # A request object representing the call parameters. Required. To specify no
382
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
383
+ # @param options [::Gapic::CallOptions, ::Hash]
384
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
385
+ #
386
+ # @overload delete_schema(name: nil)
387
+ # Pass arguments to `delete_schema` via keyword arguments. Note that at
388
+ # least one keyword argument is required. To specify no parameters, or to keep all
389
+ # the default parameter values, pass an empty Hash as a request object (see above).
390
+ #
391
+ # @param name [::String]
392
+ # Required. Name of the schema to delete.
393
+ # Format is `projects/{project}/schemas/{schema}`.
394
+ #
395
+ # @yield [response, operation] Access the result along with the RPC operation
396
+ # @yieldparam response [::Google::Protobuf::Empty]
397
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
398
+ #
399
+ # @return [::Google::Protobuf::Empty]
400
+ #
401
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
402
+ #
403
+ def delete_schema request, options = nil
404
+ raise ::ArgumentError, "request must be provided" if request.nil?
405
+
406
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::DeleteSchemaRequest
407
+
408
+ # Converts hash and nil to an options object
409
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
410
+
411
+ # Customize the options with defaults
412
+ metadata = @config.rpcs.delete_schema.metadata.to_h
413
+
414
+ # Set x-goog-api-client and x-goog-user-project headers
415
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
416
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
417
+ gapic_version: ::Google::Cloud::PubSub::V1::VERSION
418
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
419
+
420
+ header_params = {
421
+ "name" => request.name
422
+ }
423
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
424
+ metadata[:"x-goog-request-params"] ||= request_params_header
425
+
426
+ options.apply_defaults timeout: @config.rpcs.delete_schema.timeout,
427
+ metadata: metadata,
428
+ retry_policy: @config.rpcs.delete_schema.retry_policy
429
+ options.apply_defaults metadata: @config.metadata,
430
+ retry_policy: @config.retry_policy
431
+
432
+ @schema_service_stub.call_rpc :delete_schema, request, options: options do |response, operation|
433
+ yield response, operation if block_given?
434
+ return response
435
+ end
436
+ rescue ::GRPC::BadStatus => e
437
+ raise ::Google::Cloud::Error.from_error(e)
438
+ end
439
+
440
+ ##
441
+ # Validates a schema.
442
+ #
443
+ # @overload validate_schema(request, options = nil)
444
+ # Pass arguments to `validate_schema` via a request object, either of type
445
+ # {::Google::Cloud::PubSub::V1::ValidateSchemaRequest} or an equivalent Hash.
446
+ #
447
+ # @param request [::Google::Cloud::PubSub::V1::ValidateSchemaRequest, ::Hash]
448
+ # A request object representing the call parameters. Required. To specify no
449
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
450
+ # @param options [::Gapic::CallOptions, ::Hash]
451
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
452
+ #
453
+ # @overload validate_schema(parent: nil, schema: nil)
454
+ # Pass arguments to `validate_schema` via keyword arguments. Note that at
455
+ # least one keyword argument is required. To specify no parameters, or to keep all
456
+ # the default parameter values, pass an empty Hash as a request object (see above).
457
+ #
458
+ # @param parent [::String]
459
+ # Required. The name of the project in which to validate schemas.
460
+ # Format is `projects/{project-id}`.
461
+ # @param schema [::Google::Cloud::PubSub::V1::Schema, ::Hash]
462
+ # Required. The schema object to validate.
463
+ #
464
+ # @yield [response, operation] Access the result along with the RPC operation
465
+ # @yieldparam response [::Google::Cloud::PubSub::V1::ValidateSchemaResponse]
466
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
467
+ #
468
+ # @return [::Google::Cloud::PubSub::V1::ValidateSchemaResponse]
469
+ #
470
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
471
+ #
472
+ def validate_schema request, options = nil
473
+ raise ::ArgumentError, "request must be provided" if request.nil?
474
+
475
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::ValidateSchemaRequest
476
+
477
+ # Converts hash and nil to an options object
478
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
479
+
480
+ # Customize the options with defaults
481
+ metadata = @config.rpcs.validate_schema.metadata.to_h
482
+
483
+ # Set x-goog-api-client and x-goog-user-project headers
484
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
485
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
486
+ gapic_version: ::Google::Cloud::PubSub::V1::VERSION
487
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
488
+
489
+ header_params = {
490
+ "parent" => request.parent
491
+ }
492
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
493
+ metadata[:"x-goog-request-params"] ||= request_params_header
494
+
495
+ options.apply_defaults timeout: @config.rpcs.validate_schema.timeout,
496
+ metadata: metadata,
497
+ retry_policy: @config.rpcs.validate_schema.retry_policy
498
+ options.apply_defaults metadata: @config.metadata,
499
+ retry_policy: @config.retry_policy
500
+
501
+ @schema_service_stub.call_rpc :validate_schema, request, options: options do |response, operation|
502
+ yield response, operation if block_given?
503
+ return response
504
+ end
505
+ rescue ::GRPC::BadStatus => e
506
+ raise ::Google::Cloud::Error.from_error(e)
507
+ end
508
+
509
+ ##
510
+ # Validates a message against a schema.
511
+ #
512
+ # @overload validate_message(request, options = nil)
513
+ # Pass arguments to `validate_message` via a request object, either of type
514
+ # {::Google::Cloud::PubSub::V1::ValidateMessageRequest} or an equivalent Hash.
515
+ #
516
+ # @param request [::Google::Cloud::PubSub::V1::ValidateMessageRequest, ::Hash]
517
+ # A request object representing the call parameters. Required. To specify no
518
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
519
+ # @param options [::Gapic::CallOptions, ::Hash]
520
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
521
+ #
522
+ # @overload validate_message(parent: nil, name: nil, schema: nil, message: nil, encoding: nil)
523
+ # Pass arguments to `validate_message` via keyword arguments. Note that at
524
+ # least one keyword argument is required. To specify no parameters, or to keep all
525
+ # the default parameter values, pass an empty Hash as a request object (see above).
526
+ #
527
+ # @param parent [::String]
528
+ # Required. The name of the project in which to validate schemas.
529
+ # Format is `projects/{project-id}`.
530
+ # @param name [::String]
531
+ # Name of the schema against which to validate.
532
+ #
533
+ # Format is `projects/{project}/schemas/{schema}`.
534
+ # @param schema [::Google::Cloud::PubSub::V1::Schema, ::Hash]
535
+ # Ad-hoc schema against which to validate
536
+ # @param message [::String]
537
+ # Message to validate against the provided `schema_spec`.
538
+ # @param encoding [::Google::Cloud::PubSub::V1::Encoding]
539
+ # The encoding expected for messages
540
+ #
541
+ # @yield [response, operation] Access the result along with the RPC operation
542
+ # @yieldparam response [::Google::Cloud::PubSub::V1::ValidateMessageResponse]
543
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
544
+ #
545
+ # @return [::Google::Cloud::PubSub::V1::ValidateMessageResponse]
546
+ #
547
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
548
+ #
549
+ def validate_message request, options = nil
550
+ raise ::ArgumentError, "request must be provided" if request.nil?
551
+
552
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::ValidateMessageRequest
553
+
554
+ # Converts hash and nil to an options object
555
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
556
+
557
+ # Customize the options with defaults
558
+ metadata = @config.rpcs.validate_message.metadata.to_h
559
+
560
+ # Set x-goog-api-client and x-goog-user-project headers
561
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
562
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
563
+ gapic_version: ::Google::Cloud::PubSub::V1::VERSION
564
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
565
+
566
+ header_params = {
567
+ "parent" => request.parent
568
+ }
569
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
570
+ metadata[:"x-goog-request-params"] ||= request_params_header
571
+
572
+ options.apply_defaults timeout: @config.rpcs.validate_message.timeout,
573
+ metadata: metadata,
574
+ retry_policy: @config.rpcs.validate_message.retry_policy
575
+ options.apply_defaults metadata: @config.metadata,
576
+ retry_policy: @config.retry_policy
577
+
578
+ @schema_service_stub.call_rpc :validate_message, request, options: options do |response, operation|
579
+ yield response, operation if block_given?
580
+ return response
581
+ end
582
+ rescue ::GRPC::BadStatus => e
583
+ raise ::Google::Cloud::Error.from_error(e)
584
+ end
585
+
586
+ ##
587
+ # Configuration class for the SchemaService API.
588
+ #
589
+ # This class represents the configuration for SchemaService,
590
+ # providing control over timeouts, retry behavior, logging, transport
591
+ # parameters, and other low-level controls. Certain parameters can also be
592
+ # applied individually to specific RPCs. See
593
+ # {::Google::Cloud::PubSub::V1::SchemaService::Client::Configuration::Rpcs}
594
+ # for a list of RPCs that can be configured independently.
595
+ #
596
+ # Configuration can be applied globally to all clients, or to a single client
597
+ # on construction.
598
+ #
599
+ # # Examples
600
+ #
601
+ # To modify the global config, setting the timeout for create_schema
602
+ # to 20 seconds, and all remaining timeouts to 10 seconds:
603
+ #
604
+ # ::Google::Cloud::PubSub::V1::SchemaService::Client.configure do |config|
605
+ # config.timeout = 10.0
606
+ # config.rpcs.create_schema.timeout = 20.0
607
+ # end
608
+ #
609
+ # To apply the above configuration only to a new client:
610
+ #
611
+ # client = ::Google::Cloud::PubSub::V1::SchemaService::Client.new do |config|
612
+ # config.timeout = 10.0
613
+ # config.rpcs.create_schema.timeout = 20.0
614
+ # end
615
+ #
616
+ # @!attribute [rw] endpoint
617
+ # The hostname or hostname:port of the service endpoint.
618
+ # Defaults to `"pubsub.googleapis.com"`.
619
+ # @return [::String]
620
+ # @!attribute [rw] credentials
621
+ # Credentials to send with calls. You may provide any of the following types:
622
+ # * (`String`) The path to a service account key file in JSON format
623
+ # * (`Hash`) A service account key as a Hash
624
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
625
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
626
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
627
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
628
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
629
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
630
+ # * (`nil`) indicating no credentials
631
+ # @return [::Object]
632
+ # @!attribute [rw] scope
633
+ # The OAuth scopes
634
+ # @return [::Array<::String>]
635
+ # @!attribute [rw] lib_name
636
+ # The library name as recorded in instrumentation and logging
637
+ # @return [::String]
638
+ # @!attribute [rw] lib_version
639
+ # The library version as recorded in instrumentation and logging
640
+ # @return [::String]
641
+ # @!attribute [rw] channel_args
642
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
643
+ # `GRPC::Core::Channel` object is provided as the credential.
644
+ # @return [::Hash]
645
+ # @!attribute [rw] interceptors
646
+ # An array of interceptors that are run before calls are executed.
647
+ # @return [::Array<::GRPC::ClientInterceptor>]
648
+ # @!attribute [rw] timeout
649
+ # The call timeout in seconds.
650
+ # @return [::Numeric]
651
+ # @!attribute [rw] metadata
652
+ # Additional gRPC headers to be sent with the call.
653
+ # @return [::Hash{::Symbol=>::String}]
654
+ # @!attribute [rw] retry_policy
655
+ # The retry policy. The value is a hash with the following keys:
656
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
657
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
658
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
659
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
660
+ # trigger a retry.
661
+ # @return [::Hash]
662
+ # @!attribute [rw] quota_project
663
+ # A separate project against which to charge quota.
664
+ # @return [::String]
665
+ #
666
+ class Configuration
667
+ extend ::Gapic::Config
668
+
669
+ config_attr :endpoint, "pubsub.googleapis.com", ::String
670
+ config_attr :credentials, nil do |value|
671
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
672
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
673
+ allowed.any? { |klass| klass === value }
674
+ end
675
+ config_attr :scope, nil, ::String, ::Array, nil
676
+ config_attr :lib_name, nil, ::String, nil
677
+ config_attr :lib_version, nil, ::String, nil
678
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, ::Hash, nil)
679
+ config_attr :interceptors, nil, ::Array, nil
680
+ config_attr :timeout, nil, ::Numeric, nil
681
+ config_attr :metadata, nil, ::Hash, nil
682
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
683
+ config_attr :quota_project, nil, ::String, nil
684
+
685
+ # @private
686
+ def initialize parent_config = nil
687
+ @parent_config = parent_config unless parent_config.nil?
688
+
689
+ yield self if block_given?
690
+ end
691
+
692
+ ##
693
+ # Configurations for individual RPCs
694
+ # @return [Rpcs]
695
+ #
696
+ def rpcs
697
+ @rpcs ||= begin
698
+ parent_rpcs = nil
699
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config&.respond_to?(:rpcs)
700
+ Rpcs.new parent_rpcs
701
+ end
702
+ end
703
+
704
+ ##
705
+ # Configuration RPC class for the SchemaService API.
706
+ #
707
+ # Includes fields providing the configuration for each RPC in this service.
708
+ # Each configuration object is of type `Gapic::Config::Method` and includes
709
+ # the following configuration fields:
710
+ #
711
+ # * `timeout` (*type:* `Numeric`) - The call timeout in milliseconds
712
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
713
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
714
+ # include the following keys:
715
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
716
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
717
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
718
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
719
+ # trigger a retry.
720
+ #
721
+ class Rpcs
722
+ ##
723
+ # RPC-specific configuration for `create_schema`
724
+ # @return [::Gapic::Config::Method]
725
+ #
726
+ attr_reader :create_schema
727
+ ##
728
+ # RPC-specific configuration for `get_schema`
729
+ # @return [::Gapic::Config::Method]
730
+ #
731
+ attr_reader :get_schema
732
+ ##
733
+ # RPC-specific configuration for `list_schemas`
734
+ # @return [::Gapic::Config::Method]
735
+ #
736
+ attr_reader :list_schemas
737
+ ##
738
+ # RPC-specific configuration for `delete_schema`
739
+ # @return [::Gapic::Config::Method]
740
+ #
741
+ attr_reader :delete_schema
742
+ ##
743
+ # RPC-specific configuration for `validate_schema`
744
+ # @return [::Gapic::Config::Method]
745
+ #
746
+ attr_reader :validate_schema
747
+ ##
748
+ # RPC-specific configuration for `validate_message`
749
+ # @return [::Gapic::Config::Method]
750
+ #
751
+ attr_reader :validate_message
752
+
753
+ # @private
754
+ def initialize parent_rpcs = nil
755
+ create_schema_config = parent_rpcs&.create_schema if parent_rpcs&.respond_to? :create_schema
756
+ @create_schema = ::Gapic::Config::Method.new create_schema_config
757
+ get_schema_config = parent_rpcs&.get_schema if parent_rpcs&.respond_to? :get_schema
758
+ @get_schema = ::Gapic::Config::Method.new get_schema_config
759
+ list_schemas_config = parent_rpcs&.list_schemas if parent_rpcs&.respond_to? :list_schemas
760
+ @list_schemas = ::Gapic::Config::Method.new list_schemas_config
761
+ delete_schema_config = parent_rpcs&.delete_schema if parent_rpcs&.respond_to? :delete_schema
762
+ @delete_schema = ::Gapic::Config::Method.new delete_schema_config
763
+ validate_schema_config = parent_rpcs&.validate_schema if parent_rpcs&.respond_to? :validate_schema
764
+ @validate_schema = ::Gapic::Config::Method.new validate_schema_config
765
+ validate_message_config = parent_rpcs&.validate_message if parent_rpcs&.respond_to? :validate_message
766
+ @validate_message = ::Gapic::Config::Method.new validate_message_config
767
+
768
+ yield self if block_given?
769
+ end
770
+ end
771
+ end
772
+ end
773
+ end
774
+ end
775
+ end
776
+ end
777
+ end