google-cloud-iot-v1 0.5.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,1819 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2023 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "google/cloud/errors"
20
+ require "google/cloud/iot/v1/device_manager_pb"
21
+ require "google/cloud/iot/v1/device_manager/rest/service_stub"
22
+
23
+ module Google
24
+ module Cloud
25
+ module Iot
26
+ module V1
27
+ module DeviceManager
28
+ module Rest
29
+ ##
30
+ # REST client for the DeviceManager service.
31
+ #
32
+ # Internet of Things (IoT) service. Securely connect and manage IoT devices.
33
+ #
34
+ class Client
35
+ include Paths
36
+
37
+ # @private
38
+ attr_reader :device_manager_stub
39
+
40
+ ##
41
+ # Configure the DeviceManager Client class.
42
+ #
43
+ # See {::Google::Cloud::Iot::V1::DeviceManager::Rest::Client::Configuration}
44
+ # for a description of the configuration fields.
45
+ #
46
+ # @example
47
+ #
48
+ # # Modify the configuration for all DeviceManager clients
49
+ # ::Google::Cloud::Iot::V1::DeviceManager::Rest::Client.configure do |config|
50
+ # config.timeout = 10.0
51
+ # end
52
+ #
53
+ # @yield [config] Configure the Client client.
54
+ # @yieldparam config [Client::Configuration]
55
+ #
56
+ # @return [Client::Configuration]
57
+ #
58
+ def self.configure
59
+ @configure ||= begin
60
+ namespace = ["Google", "Cloud", "Iot", "V1"]
61
+ parent_config = while namespace.any?
62
+ parent_name = namespace.join "::"
63
+ parent_const = const_get parent_name
64
+ break parent_const.configure if parent_const.respond_to? :configure
65
+ namespace.pop
66
+ end
67
+ default_config = Client::Configuration.new parent_config
68
+
69
+ default_config.rpcs.create_device_registry.timeout = 120.0
70
+
71
+ default_config.rpcs.get_device_registry.timeout = 120.0
72
+ default_config.rpcs.get_device_registry.retry_policy = {
73
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4]
74
+ }
75
+
76
+ default_config.rpcs.update_device_registry.timeout = 120.0
77
+
78
+ default_config.rpcs.delete_device_registry.timeout = 120.0
79
+ default_config.rpcs.delete_device_registry.retry_policy = {
80
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4]
81
+ }
82
+
83
+ default_config.rpcs.list_device_registries.timeout = 120.0
84
+ default_config.rpcs.list_device_registries.retry_policy = {
85
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4]
86
+ }
87
+
88
+ default_config.rpcs.create_device.timeout = 120.0
89
+
90
+ default_config.rpcs.get_device.timeout = 120.0
91
+ default_config.rpcs.get_device.retry_policy = {
92
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4]
93
+ }
94
+
95
+ default_config.rpcs.update_device.timeout = 120.0
96
+
97
+ default_config.rpcs.delete_device.timeout = 120.0
98
+ default_config.rpcs.delete_device.retry_policy = {
99
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4]
100
+ }
101
+
102
+ default_config.rpcs.list_devices.timeout = 120.0
103
+ default_config.rpcs.list_devices.retry_policy = {
104
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4]
105
+ }
106
+
107
+ default_config.rpcs.modify_cloud_to_device_config.timeout = 120.0
108
+ default_config.rpcs.modify_cloud_to_device_config.retry_policy = {
109
+ initial_delay: 1.0, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4, 8]
110
+ }
111
+
112
+ default_config.rpcs.list_device_config_versions.timeout = 120.0
113
+ default_config.rpcs.list_device_config_versions.retry_policy = {
114
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4]
115
+ }
116
+
117
+ default_config.rpcs.list_device_states.timeout = 120.0
118
+ default_config.rpcs.list_device_states.retry_policy = {
119
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4]
120
+ }
121
+
122
+ default_config.rpcs.set_iam_policy.timeout = 120.0
123
+
124
+ default_config.rpcs.get_iam_policy.timeout = 120.0
125
+
126
+ default_config.rpcs.test_iam_permissions.timeout = 120.0
127
+
128
+ default_config.rpcs.send_command_to_device.timeout = 120.0
129
+ default_config.rpcs.send_command_to_device.retry_policy = {
130
+ initial_delay: 1.0, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4, 8]
131
+ }
132
+
133
+ default_config.rpcs.bind_device_to_gateway.timeout = 120.0
134
+
135
+ default_config.rpcs.unbind_device_from_gateway.timeout = 120.0
136
+
137
+ default_config
138
+ end
139
+ yield @configure if block_given?
140
+ @configure
141
+ end
142
+
143
+ ##
144
+ # Configure the DeviceManager Client instance.
145
+ #
146
+ # The configuration is set to the derived mode, meaning that values can be changed,
147
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
148
+ # should be made on {Client.configure}.
149
+ #
150
+ # See {::Google::Cloud::Iot::V1::DeviceManager::Rest::Client::Configuration}
151
+ # for a description of the configuration fields.
152
+ #
153
+ # @yield [config] Configure the Client client.
154
+ # @yieldparam config [Client::Configuration]
155
+ #
156
+ # @return [Client::Configuration]
157
+ #
158
+ def configure
159
+ yield @config if block_given?
160
+ @config
161
+ end
162
+
163
+ ##
164
+ # Create a new DeviceManager REST client object.
165
+ #
166
+ # @example
167
+ #
168
+ # # Create a client using the default configuration
169
+ # client = ::Google::Cloud::Iot::V1::DeviceManager::Rest::Client.new
170
+ #
171
+ # # Create a client using a custom configuration
172
+ # client = ::Google::Cloud::Iot::V1::DeviceManager::Rest::Client.new do |config|
173
+ # config.timeout = 10.0
174
+ # end
175
+ #
176
+ # @yield [config] Configure the DeviceManager client.
177
+ # @yieldparam config [Client::Configuration]
178
+ #
179
+ def initialize
180
+ # Create the configuration object
181
+ @config = Configuration.new Client.configure
182
+
183
+ # Yield the configuration if needed
184
+ yield @config if block_given?
185
+
186
+ # Create credentials
187
+ credentials = @config.credentials
188
+ # Use self-signed JWT if the endpoint is unchanged from default,
189
+ # but only if the default endpoint does not have a region prefix.
190
+ enable_self_signed_jwt = @config.endpoint == Configuration::DEFAULT_ENDPOINT &&
191
+ !@config.endpoint.split(".").first.include?("-")
192
+ credentials ||= Credentials.default scope: @config.scope,
193
+ enable_self_signed_jwt: enable_self_signed_jwt
194
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
195
+ credentials = Credentials.new credentials, scope: @config.scope
196
+ end
197
+
198
+ @quota_project_id = @config.quota_project
199
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
200
+
201
+ @device_manager_stub = ::Google::Cloud::Iot::V1::DeviceManager::Rest::ServiceStub.new endpoint: @config.endpoint, credentials: credentials
202
+ end
203
+
204
+ # Service calls
205
+
206
+ ##
207
+ # Creates a device registry that contains devices.
208
+ #
209
+ # @overload create_device_registry(request, options = nil)
210
+ # Pass arguments to `create_device_registry` via a request object, either of type
211
+ # {::Google::Cloud::Iot::V1::CreateDeviceRegistryRequest} or an equivalent Hash.
212
+ #
213
+ # @param request [::Google::Cloud::Iot::V1::CreateDeviceRegistryRequest, ::Hash]
214
+ # A request object representing the call parameters. Required. To specify no
215
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
216
+ # @param options [::Gapic::CallOptions, ::Hash]
217
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
218
+ #
219
+ # @overload create_device_registry(parent: nil, device_registry: nil)
220
+ # Pass arguments to `create_device_registry` via keyword arguments. Note that at
221
+ # least one keyword argument is required. To specify no parameters, or to keep all
222
+ # the default parameter values, pass an empty Hash as a request object (see above).
223
+ #
224
+ # @param parent [::String]
225
+ # Required. The project and cloud region where this device registry must be created.
226
+ # For example, `projects/example-project/locations/us-central1`.
227
+ # @param device_registry [::Google::Cloud::Iot::V1::DeviceRegistry, ::Hash]
228
+ # Required. The device registry. The field `name` must be empty. The server will
229
+ # generate that field from the device registry `id` provided and the
230
+ # `parent` field.
231
+ # @yield [result, operation] Access the result along with the TransportOperation object
232
+ # @yieldparam result [::Google::Cloud::Iot::V1::DeviceRegistry]
233
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
234
+ #
235
+ # @return [::Google::Cloud::Iot::V1::DeviceRegistry]
236
+ #
237
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
238
+ def create_device_registry request, options = nil
239
+ raise ::ArgumentError, "request must be provided" if request.nil?
240
+
241
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Iot::V1::CreateDeviceRegistryRequest
242
+
243
+ # Converts hash and nil to an options object
244
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
245
+
246
+ # Customize the options with defaults
247
+ call_metadata = @config.rpcs.create_device_registry.metadata.to_h
248
+
249
+ # Set x-goog-api-client and x-goog-user-project headers
250
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
251
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
252
+ gapic_version: ::Google::Cloud::Iot::V1::VERSION,
253
+ transports_version_send: [:rest]
254
+
255
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
256
+
257
+ options.apply_defaults timeout: @config.rpcs.create_device_registry.timeout,
258
+ metadata: call_metadata,
259
+ retry_policy: @config.rpcs.create_device_registry.retry_policy
260
+
261
+ options.apply_defaults timeout: @config.timeout,
262
+ metadata: @config.metadata,
263
+ retry_policy: @config.retry_policy
264
+
265
+ @device_manager_stub.create_device_registry request, options do |result, operation|
266
+ yield result, operation if block_given?
267
+ return result
268
+ end
269
+ rescue ::Gapic::Rest::Error => e
270
+ raise ::Google::Cloud::Error.from_error(e)
271
+ end
272
+
273
+ ##
274
+ # Gets a device registry configuration.
275
+ #
276
+ # @overload get_device_registry(request, options = nil)
277
+ # Pass arguments to `get_device_registry` via a request object, either of type
278
+ # {::Google::Cloud::Iot::V1::GetDeviceRegistryRequest} or an equivalent Hash.
279
+ #
280
+ # @param request [::Google::Cloud::Iot::V1::GetDeviceRegistryRequest, ::Hash]
281
+ # A request object representing the call parameters. Required. To specify no
282
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
283
+ # @param options [::Gapic::CallOptions, ::Hash]
284
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
285
+ #
286
+ # @overload get_device_registry(name: nil)
287
+ # Pass arguments to `get_device_registry` via keyword arguments. Note that at
288
+ # least one keyword argument is required. To specify no parameters, or to keep all
289
+ # the default parameter values, pass an empty Hash as a request object (see above).
290
+ #
291
+ # @param name [::String]
292
+ # Required. The name of the device registry. For example,
293
+ # `projects/example-project/locations/us-central1/registries/my-registry`.
294
+ # @yield [result, operation] Access the result along with the TransportOperation object
295
+ # @yieldparam result [::Google::Cloud::Iot::V1::DeviceRegistry]
296
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
297
+ #
298
+ # @return [::Google::Cloud::Iot::V1::DeviceRegistry]
299
+ #
300
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
301
+ def get_device_registry request, options = nil
302
+ raise ::ArgumentError, "request must be provided" if request.nil?
303
+
304
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Iot::V1::GetDeviceRegistryRequest
305
+
306
+ # Converts hash and nil to an options object
307
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
308
+
309
+ # Customize the options with defaults
310
+ call_metadata = @config.rpcs.get_device_registry.metadata.to_h
311
+
312
+ # Set x-goog-api-client and x-goog-user-project headers
313
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
314
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
315
+ gapic_version: ::Google::Cloud::Iot::V1::VERSION,
316
+ transports_version_send: [:rest]
317
+
318
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
319
+
320
+ options.apply_defaults timeout: @config.rpcs.get_device_registry.timeout,
321
+ metadata: call_metadata,
322
+ retry_policy: @config.rpcs.get_device_registry.retry_policy
323
+
324
+ options.apply_defaults timeout: @config.timeout,
325
+ metadata: @config.metadata,
326
+ retry_policy: @config.retry_policy
327
+
328
+ @device_manager_stub.get_device_registry request, options do |result, operation|
329
+ yield result, operation if block_given?
330
+ return result
331
+ end
332
+ rescue ::Gapic::Rest::Error => e
333
+ raise ::Google::Cloud::Error.from_error(e)
334
+ end
335
+
336
+ ##
337
+ # Updates a device registry configuration.
338
+ #
339
+ # @overload update_device_registry(request, options = nil)
340
+ # Pass arguments to `update_device_registry` via a request object, either of type
341
+ # {::Google::Cloud::Iot::V1::UpdateDeviceRegistryRequest} or an equivalent Hash.
342
+ #
343
+ # @param request [::Google::Cloud::Iot::V1::UpdateDeviceRegistryRequest, ::Hash]
344
+ # A request object representing the call parameters. Required. To specify no
345
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
346
+ # @param options [::Gapic::CallOptions, ::Hash]
347
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
348
+ #
349
+ # @overload update_device_registry(device_registry: nil, update_mask: nil)
350
+ # Pass arguments to `update_device_registry` via keyword arguments. Note that at
351
+ # least one keyword argument is required. To specify no parameters, or to keep all
352
+ # the default parameter values, pass an empty Hash as a request object (see above).
353
+ #
354
+ # @param device_registry [::Google::Cloud::Iot::V1::DeviceRegistry, ::Hash]
355
+ # Required. The new values for the device registry. The `id` field must be empty, and
356
+ # the `name` field must indicate the path of the resource. For example,
357
+ # `projects/example-project/locations/us-central1/registries/my-registry`.
358
+ # @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
359
+ # Required. Only updates the `device_registry` fields indicated by this mask.
360
+ # The field mask must not be empty, and it must not contain fields that
361
+ # are immutable or only set by the server.
362
+ # Mutable top-level fields: `event_notification_config`, `http_config`,
363
+ # `mqtt_config`, and `state_notification_config`.
364
+ # @yield [result, operation] Access the result along with the TransportOperation object
365
+ # @yieldparam result [::Google::Cloud::Iot::V1::DeviceRegistry]
366
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
367
+ #
368
+ # @return [::Google::Cloud::Iot::V1::DeviceRegistry]
369
+ #
370
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
371
+ def update_device_registry request, options = nil
372
+ raise ::ArgumentError, "request must be provided" if request.nil?
373
+
374
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Iot::V1::UpdateDeviceRegistryRequest
375
+
376
+ # Converts hash and nil to an options object
377
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
378
+
379
+ # Customize the options with defaults
380
+ call_metadata = @config.rpcs.update_device_registry.metadata.to_h
381
+
382
+ # Set x-goog-api-client and x-goog-user-project headers
383
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
384
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
385
+ gapic_version: ::Google::Cloud::Iot::V1::VERSION,
386
+ transports_version_send: [:rest]
387
+
388
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
389
+
390
+ options.apply_defaults timeout: @config.rpcs.update_device_registry.timeout,
391
+ metadata: call_metadata,
392
+ retry_policy: @config.rpcs.update_device_registry.retry_policy
393
+
394
+ options.apply_defaults timeout: @config.timeout,
395
+ metadata: @config.metadata,
396
+ retry_policy: @config.retry_policy
397
+
398
+ @device_manager_stub.update_device_registry request, options do |result, operation|
399
+ yield result, operation if block_given?
400
+ return result
401
+ end
402
+ rescue ::Gapic::Rest::Error => e
403
+ raise ::Google::Cloud::Error.from_error(e)
404
+ end
405
+
406
+ ##
407
+ # Deletes a device registry configuration.
408
+ #
409
+ # @overload delete_device_registry(request, options = nil)
410
+ # Pass arguments to `delete_device_registry` via a request object, either of type
411
+ # {::Google::Cloud::Iot::V1::DeleteDeviceRegistryRequest} or an equivalent Hash.
412
+ #
413
+ # @param request [::Google::Cloud::Iot::V1::DeleteDeviceRegistryRequest, ::Hash]
414
+ # A request object representing the call parameters. Required. To specify no
415
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
416
+ # @param options [::Gapic::CallOptions, ::Hash]
417
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
418
+ #
419
+ # @overload delete_device_registry(name: nil)
420
+ # Pass arguments to `delete_device_registry` via keyword arguments. Note that at
421
+ # least one keyword argument is required. To specify no parameters, or to keep all
422
+ # the default parameter values, pass an empty Hash as a request object (see above).
423
+ #
424
+ # @param name [::String]
425
+ # Required. The name of the device registry. For example,
426
+ # `projects/example-project/locations/us-central1/registries/my-registry`.
427
+ # @yield [result, operation] Access the result along with the TransportOperation object
428
+ # @yieldparam result [::Google::Protobuf::Empty]
429
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
430
+ #
431
+ # @return [::Google::Protobuf::Empty]
432
+ #
433
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
434
+ def delete_device_registry request, options = nil
435
+ raise ::ArgumentError, "request must be provided" if request.nil?
436
+
437
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Iot::V1::DeleteDeviceRegistryRequest
438
+
439
+ # Converts hash and nil to an options object
440
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
441
+
442
+ # Customize the options with defaults
443
+ call_metadata = @config.rpcs.delete_device_registry.metadata.to_h
444
+
445
+ # Set x-goog-api-client and x-goog-user-project headers
446
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
447
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
448
+ gapic_version: ::Google::Cloud::Iot::V1::VERSION,
449
+ transports_version_send: [:rest]
450
+
451
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
452
+
453
+ options.apply_defaults timeout: @config.rpcs.delete_device_registry.timeout,
454
+ metadata: call_metadata,
455
+ retry_policy: @config.rpcs.delete_device_registry.retry_policy
456
+
457
+ options.apply_defaults timeout: @config.timeout,
458
+ metadata: @config.metadata,
459
+ retry_policy: @config.retry_policy
460
+
461
+ @device_manager_stub.delete_device_registry request, options do |result, operation|
462
+ yield result, operation if block_given?
463
+ return result
464
+ end
465
+ rescue ::Gapic::Rest::Error => e
466
+ raise ::Google::Cloud::Error.from_error(e)
467
+ end
468
+
469
+ ##
470
+ # Lists device registries.
471
+ #
472
+ # @overload list_device_registries(request, options = nil)
473
+ # Pass arguments to `list_device_registries` via a request object, either of type
474
+ # {::Google::Cloud::Iot::V1::ListDeviceRegistriesRequest} or an equivalent Hash.
475
+ #
476
+ # @param request [::Google::Cloud::Iot::V1::ListDeviceRegistriesRequest, ::Hash]
477
+ # A request object representing the call parameters. Required. To specify no
478
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
479
+ # @param options [::Gapic::CallOptions, ::Hash]
480
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
481
+ #
482
+ # @overload list_device_registries(parent: nil, page_size: nil, page_token: nil)
483
+ # Pass arguments to `list_device_registries` via keyword arguments. Note that at
484
+ # least one keyword argument is required. To specify no parameters, or to keep all
485
+ # the default parameter values, pass an empty Hash as a request object (see above).
486
+ #
487
+ # @param parent [::String]
488
+ # Required. The project and cloud region path. For example,
489
+ # `projects/example-project/locations/us-central1`.
490
+ # @param page_size [::Integer]
491
+ # The maximum number of registries to return in the response. If this value
492
+ # is zero, the service will select a default size. A call may return fewer
493
+ # objects than requested. A non-empty `next_page_token` in the response
494
+ # indicates that more data is available.
495
+ # @param page_token [::String]
496
+ # The value returned by the last `ListDeviceRegistriesResponse`; indicates
497
+ # that this is a continuation of a prior `ListDeviceRegistries` call and
498
+ # the system should return the next page of data.
499
+ # @yield [result, operation] Access the result along with the TransportOperation object
500
+ # @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Iot::V1::DeviceRegistry>]
501
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
502
+ #
503
+ # @return [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Iot::V1::DeviceRegistry>]
504
+ #
505
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
506
+ def list_device_registries request, options = nil
507
+ raise ::ArgumentError, "request must be provided" if request.nil?
508
+
509
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Iot::V1::ListDeviceRegistriesRequest
510
+
511
+ # Converts hash and nil to an options object
512
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
513
+
514
+ # Customize the options with defaults
515
+ call_metadata = @config.rpcs.list_device_registries.metadata.to_h
516
+
517
+ # Set x-goog-api-client and x-goog-user-project headers
518
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
519
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
520
+ gapic_version: ::Google::Cloud::Iot::V1::VERSION,
521
+ transports_version_send: [:rest]
522
+
523
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
524
+
525
+ options.apply_defaults timeout: @config.rpcs.list_device_registries.timeout,
526
+ metadata: call_metadata,
527
+ retry_policy: @config.rpcs.list_device_registries.retry_policy
528
+
529
+ options.apply_defaults timeout: @config.timeout,
530
+ metadata: @config.metadata,
531
+ retry_policy: @config.retry_policy
532
+
533
+ @device_manager_stub.list_device_registries request, options do |result, operation|
534
+ result = ::Gapic::Rest::PagedEnumerable.new @device_manager_stub, :list_device_registries, "device_registries", request, result, options
535
+ yield result, operation if block_given?
536
+ return result
537
+ end
538
+ rescue ::Gapic::Rest::Error => e
539
+ raise ::Google::Cloud::Error.from_error(e)
540
+ end
541
+
542
+ ##
543
+ # Creates a device in a device registry.
544
+ #
545
+ # @overload create_device(request, options = nil)
546
+ # Pass arguments to `create_device` via a request object, either of type
547
+ # {::Google::Cloud::Iot::V1::CreateDeviceRequest} or an equivalent Hash.
548
+ #
549
+ # @param request [::Google::Cloud::Iot::V1::CreateDeviceRequest, ::Hash]
550
+ # A request object representing the call parameters. Required. To specify no
551
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
552
+ # @param options [::Gapic::CallOptions, ::Hash]
553
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
554
+ #
555
+ # @overload create_device(parent: nil, device: nil)
556
+ # Pass arguments to `create_device` via keyword arguments. Note that at
557
+ # least one keyword argument is required. To specify no parameters, or to keep all
558
+ # the default parameter values, pass an empty Hash as a request object (see above).
559
+ #
560
+ # @param parent [::String]
561
+ # Required. The name of the device registry where this device should be created.
562
+ # For example,
563
+ # `projects/example-project/locations/us-central1/registries/my-registry`.
564
+ # @param device [::Google::Cloud::Iot::V1::Device, ::Hash]
565
+ # Required. The device registration details. The field `name` must be empty. The server
566
+ # generates `name` from the device registry `id` and the
567
+ # `parent` field.
568
+ # @yield [result, operation] Access the result along with the TransportOperation object
569
+ # @yieldparam result [::Google::Cloud::Iot::V1::Device]
570
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
571
+ #
572
+ # @return [::Google::Cloud::Iot::V1::Device]
573
+ #
574
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
575
+ def create_device request, options = nil
576
+ raise ::ArgumentError, "request must be provided" if request.nil?
577
+
578
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Iot::V1::CreateDeviceRequest
579
+
580
+ # Converts hash and nil to an options object
581
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
582
+
583
+ # Customize the options with defaults
584
+ call_metadata = @config.rpcs.create_device.metadata.to_h
585
+
586
+ # Set x-goog-api-client and x-goog-user-project headers
587
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
588
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
589
+ gapic_version: ::Google::Cloud::Iot::V1::VERSION,
590
+ transports_version_send: [:rest]
591
+
592
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
593
+
594
+ options.apply_defaults timeout: @config.rpcs.create_device.timeout,
595
+ metadata: call_metadata,
596
+ retry_policy: @config.rpcs.create_device.retry_policy
597
+
598
+ options.apply_defaults timeout: @config.timeout,
599
+ metadata: @config.metadata,
600
+ retry_policy: @config.retry_policy
601
+
602
+ @device_manager_stub.create_device request, options do |result, operation|
603
+ yield result, operation if block_given?
604
+ return result
605
+ end
606
+ rescue ::Gapic::Rest::Error => e
607
+ raise ::Google::Cloud::Error.from_error(e)
608
+ end
609
+
610
+ ##
611
+ # Gets details about a device.
612
+ #
613
+ # @overload get_device(request, options = nil)
614
+ # Pass arguments to `get_device` via a request object, either of type
615
+ # {::Google::Cloud::Iot::V1::GetDeviceRequest} or an equivalent Hash.
616
+ #
617
+ # @param request [::Google::Cloud::Iot::V1::GetDeviceRequest, ::Hash]
618
+ # A request object representing the call parameters. Required. To specify no
619
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
620
+ # @param options [::Gapic::CallOptions, ::Hash]
621
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
622
+ #
623
+ # @overload get_device(name: nil, field_mask: nil)
624
+ # Pass arguments to `get_device` via keyword arguments. Note that at
625
+ # least one keyword argument is required. To specify no parameters, or to keep all
626
+ # the default parameter values, pass an empty Hash as a request object (see above).
627
+ #
628
+ # @param name [::String]
629
+ # Required. The name of the device. For example,
630
+ # `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
631
+ # `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
632
+ # @param field_mask [::Google::Protobuf::FieldMask, ::Hash]
633
+ # The fields of the `Device` resource to be returned in the response. If the
634
+ # field mask is unset or empty, all fields are returned. Fields have to be
635
+ # provided in snake_case format, for example: `last_heartbeat_time`.
636
+ # @yield [result, operation] Access the result along with the TransportOperation object
637
+ # @yieldparam result [::Google::Cloud::Iot::V1::Device]
638
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
639
+ #
640
+ # @return [::Google::Cloud::Iot::V1::Device]
641
+ #
642
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
643
+ def get_device request, options = nil
644
+ raise ::ArgumentError, "request must be provided" if request.nil?
645
+
646
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Iot::V1::GetDeviceRequest
647
+
648
+ # Converts hash and nil to an options object
649
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
650
+
651
+ # Customize the options with defaults
652
+ call_metadata = @config.rpcs.get_device.metadata.to_h
653
+
654
+ # Set x-goog-api-client and x-goog-user-project headers
655
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
656
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
657
+ gapic_version: ::Google::Cloud::Iot::V1::VERSION,
658
+ transports_version_send: [:rest]
659
+
660
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
661
+
662
+ options.apply_defaults timeout: @config.rpcs.get_device.timeout,
663
+ metadata: call_metadata,
664
+ retry_policy: @config.rpcs.get_device.retry_policy
665
+
666
+ options.apply_defaults timeout: @config.timeout,
667
+ metadata: @config.metadata,
668
+ retry_policy: @config.retry_policy
669
+
670
+ @device_manager_stub.get_device request, options do |result, operation|
671
+ yield result, operation if block_given?
672
+ return result
673
+ end
674
+ rescue ::Gapic::Rest::Error => e
675
+ raise ::Google::Cloud::Error.from_error(e)
676
+ end
677
+
678
+ ##
679
+ # Updates a device.
680
+ #
681
+ # @overload update_device(request, options = nil)
682
+ # Pass arguments to `update_device` via a request object, either of type
683
+ # {::Google::Cloud::Iot::V1::UpdateDeviceRequest} or an equivalent Hash.
684
+ #
685
+ # @param request [::Google::Cloud::Iot::V1::UpdateDeviceRequest, ::Hash]
686
+ # A request object representing the call parameters. Required. To specify no
687
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
688
+ # @param options [::Gapic::CallOptions, ::Hash]
689
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
690
+ #
691
+ # @overload update_device(device: nil, update_mask: nil)
692
+ # Pass arguments to `update_device` via keyword arguments. Note that at
693
+ # least one keyword argument is required. To specify no parameters, or to keep all
694
+ # the default parameter values, pass an empty Hash as a request object (see above).
695
+ #
696
+ # @param device [::Google::Cloud::Iot::V1::Device, ::Hash]
697
+ # Required. The new values for the device. The `id` and `num_id` fields must
698
+ # be empty, and the field `name` must specify the name path. For example,
699
+ # `projects/p0/locations/us-central1/registries/registry0/devices/device0`or
700
+ # `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
701
+ # @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
702
+ # Required. Only updates the `device` fields indicated by this mask.
703
+ # The field mask must not be empty, and it must not contain fields that
704
+ # are immutable or only set by the server.
705
+ # Mutable top-level fields: `credentials`, `blocked`, and `metadata`
706
+ # @yield [result, operation] Access the result along with the TransportOperation object
707
+ # @yieldparam result [::Google::Cloud::Iot::V1::Device]
708
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
709
+ #
710
+ # @return [::Google::Cloud::Iot::V1::Device]
711
+ #
712
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
713
+ def update_device request, options = nil
714
+ raise ::ArgumentError, "request must be provided" if request.nil?
715
+
716
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Iot::V1::UpdateDeviceRequest
717
+
718
+ # Converts hash and nil to an options object
719
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
720
+
721
+ # Customize the options with defaults
722
+ call_metadata = @config.rpcs.update_device.metadata.to_h
723
+
724
+ # Set x-goog-api-client and x-goog-user-project headers
725
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
726
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
727
+ gapic_version: ::Google::Cloud::Iot::V1::VERSION,
728
+ transports_version_send: [:rest]
729
+
730
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
731
+
732
+ options.apply_defaults timeout: @config.rpcs.update_device.timeout,
733
+ metadata: call_metadata,
734
+ retry_policy: @config.rpcs.update_device.retry_policy
735
+
736
+ options.apply_defaults timeout: @config.timeout,
737
+ metadata: @config.metadata,
738
+ retry_policy: @config.retry_policy
739
+
740
+ @device_manager_stub.update_device request, options do |result, operation|
741
+ yield result, operation if block_given?
742
+ return result
743
+ end
744
+ rescue ::Gapic::Rest::Error => e
745
+ raise ::Google::Cloud::Error.from_error(e)
746
+ end
747
+
748
+ ##
749
+ # Deletes a device.
750
+ #
751
+ # @overload delete_device(request, options = nil)
752
+ # Pass arguments to `delete_device` via a request object, either of type
753
+ # {::Google::Cloud::Iot::V1::DeleteDeviceRequest} or an equivalent Hash.
754
+ #
755
+ # @param request [::Google::Cloud::Iot::V1::DeleteDeviceRequest, ::Hash]
756
+ # A request object representing the call parameters. Required. To specify no
757
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
758
+ # @param options [::Gapic::CallOptions, ::Hash]
759
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
760
+ #
761
+ # @overload delete_device(name: nil)
762
+ # Pass arguments to `delete_device` via keyword arguments. Note that at
763
+ # least one keyword argument is required. To specify no parameters, or to keep all
764
+ # the default parameter values, pass an empty Hash as a request object (see above).
765
+ #
766
+ # @param name [::String]
767
+ # Required. The name of the device. For example,
768
+ # `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
769
+ # `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
770
+ # @yield [result, operation] Access the result along with the TransportOperation object
771
+ # @yieldparam result [::Google::Protobuf::Empty]
772
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
773
+ #
774
+ # @return [::Google::Protobuf::Empty]
775
+ #
776
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
777
+ def delete_device request, options = nil
778
+ raise ::ArgumentError, "request must be provided" if request.nil?
779
+
780
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Iot::V1::DeleteDeviceRequest
781
+
782
+ # Converts hash and nil to an options object
783
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
784
+
785
+ # Customize the options with defaults
786
+ call_metadata = @config.rpcs.delete_device.metadata.to_h
787
+
788
+ # Set x-goog-api-client and x-goog-user-project headers
789
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
790
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
791
+ gapic_version: ::Google::Cloud::Iot::V1::VERSION,
792
+ transports_version_send: [:rest]
793
+
794
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
795
+
796
+ options.apply_defaults timeout: @config.rpcs.delete_device.timeout,
797
+ metadata: call_metadata,
798
+ retry_policy: @config.rpcs.delete_device.retry_policy
799
+
800
+ options.apply_defaults timeout: @config.timeout,
801
+ metadata: @config.metadata,
802
+ retry_policy: @config.retry_policy
803
+
804
+ @device_manager_stub.delete_device request, options do |result, operation|
805
+ yield result, operation if block_given?
806
+ return result
807
+ end
808
+ rescue ::Gapic::Rest::Error => e
809
+ raise ::Google::Cloud::Error.from_error(e)
810
+ end
811
+
812
+ ##
813
+ # List devices in a device registry.
814
+ #
815
+ # @overload list_devices(request, options = nil)
816
+ # Pass arguments to `list_devices` via a request object, either of type
817
+ # {::Google::Cloud::Iot::V1::ListDevicesRequest} or an equivalent Hash.
818
+ #
819
+ # @param request [::Google::Cloud::Iot::V1::ListDevicesRequest, ::Hash]
820
+ # A request object representing the call parameters. Required. To specify no
821
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
822
+ # @param options [::Gapic::CallOptions, ::Hash]
823
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
824
+ #
825
+ # @overload list_devices(parent: nil, device_num_ids: nil, device_ids: nil, field_mask: nil, gateway_list_options: nil, page_size: nil, page_token: nil)
826
+ # Pass arguments to `list_devices` via keyword arguments. Note that at
827
+ # least one keyword argument is required. To specify no parameters, or to keep all
828
+ # the default parameter values, pass an empty Hash as a request object (see above).
829
+ #
830
+ # @param parent [::String]
831
+ # Required. The device registry path. Required. For example,
832
+ # `projects/my-project/locations/us-central1/registries/my-registry`.
833
+ # @param device_num_ids [::Array<::Integer>]
834
+ # A list of device numeric IDs. If empty, this field is ignored. Maximum
835
+ # IDs: 10,000.
836
+ # @param device_ids [::Array<::String>]
837
+ # A list of device string IDs. For example, `['device0', 'device12']`.
838
+ # If empty, this field is ignored. Maximum IDs: 10,000
839
+ # @param field_mask [::Google::Protobuf::FieldMask, ::Hash]
840
+ # The fields of the `Device` resource to be returned in the response. The
841
+ # fields `id` and `num_id` are always returned, along with any
842
+ # other fields specified in snake_case format, for example:
843
+ # `last_heartbeat_time`.
844
+ # @param gateway_list_options [::Google::Cloud::Iot::V1::GatewayListOptions, ::Hash]
845
+ # Options related to gateways.
846
+ # @param page_size [::Integer]
847
+ # The maximum number of devices to return in the response. If this value
848
+ # is zero, the service will select a default size. A call may return fewer
849
+ # objects than requested. A non-empty `next_page_token` in the response
850
+ # indicates that more data is available.
851
+ # @param page_token [::String]
852
+ # The value returned by the last `ListDevicesResponse`; indicates
853
+ # that this is a continuation of a prior `ListDevices` call and
854
+ # the system should return the next page of data.
855
+ # @yield [result, operation] Access the result along with the TransportOperation object
856
+ # @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Iot::V1::Device>]
857
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
858
+ #
859
+ # @return [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Iot::V1::Device>]
860
+ #
861
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
862
+ def list_devices request, options = nil
863
+ raise ::ArgumentError, "request must be provided" if request.nil?
864
+
865
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Iot::V1::ListDevicesRequest
866
+
867
+ # Converts hash and nil to an options object
868
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
869
+
870
+ # Customize the options with defaults
871
+ call_metadata = @config.rpcs.list_devices.metadata.to_h
872
+
873
+ # Set x-goog-api-client and x-goog-user-project headers
874
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
875
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
876
+ gapic_version: ::Google::Cloud::Iot::V1::VERSION,
877
+ transports_version_send: [:rest]
878
+
879
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
880
+
881
+ options.apply_defaults timeout: @config.rpcs.list_devices.timeout,
882
+ metadata: call_metadata,
883
+ retry_policy: @config.rpcs.list_devices.retry_policy
884
+
885
+ options.apply_defaults timeout: @config.timeout,
886
+ metadata: @config.metadata,
887
+ retry_policy: @config.retry_policy
888
+
889
+ @device_manager_stub.list_devices request, options do |result, operation|
890
+ result = ::Gapic::Rest::PagedEnumerable.new @device_manager_stub, :list_devices, "devices", request, result, options
891
+ yield result, operation if block_given?
892
+ return result
893
+ end
894
+ rescue ::Gapic::Rest::Error => e
895
+ raise ::Google::Cloud::Error.from_error(e)
896
+ end
897
+
898
+ ##
899
+ # Modifies the configuration for the device, which is eventually sent from
900
+ # the Cloud IoT Core servers. Returns the modified configuration version and
901
+ # its metadata.
902
+ #
903
+ # @overload modify_cloud_to_device_config(request, options = nil)
904
+ # Pass arguments to `modify_cloud_to_device_config` via a request object, either of type
905
+ # {::Google::Cloud::Iot::V1::ModifyCloudToDeviceConfigRequest} or an equivalent Hash.
906
+ #
907
+ # @param request [::Google::Cloud::Iot::V1::ModifyCloudToDeviceConfigRequest, ::Hash]
908
+ # A request object representing the call parameters. Required. To specify no
909
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
910
+ # @param options [::Gapic::CallOptions, ::Hash]
911
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
912
+ #
913
+ # @overload modify_cloud_to_device_config(name: nil, version_to_update: nil, binary_data: nil)
914
+ # Pass arguments to `modify_cloud_to_device_config` via keyword arguments. Note that at
915
+ # least one keyword argument is required. To specify no parameters, or to keep all
916
+ # the default parameter values, pass an empty Hash as a request object (see above).
917
+ #
918
+ # @param name [::String]
919
+ # Required. The name of the device. For example,
920
+ # `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
921
+ # `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
922
+ # @param version_to_update [::Integer]
923
+ # The version number to update. If this value is zero, it will not check the
924
+ # version number of the server and will always update the current version;
925
+ # otherwise, this update will fail if the version number found on the server
926
+ # does not match this version number. This is used to support multiple
927
+ # simultaneous updates without losing data.
928
+ # @param binary_data [::String]
929
+ # Required. The configuration data for the device.
930
+ # @yield [result, operation] Access the result along with the TransportOperation object
931
+ # @yieldparam result [::Google::Cloud::Iot::V1::DeviceConfig]
932
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
933
+ #
934
+ # @return [::Google::Cloud::Iot::V1::DeviceConfig]
935
+ #
936
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
937
+ def modify_cloud_to_device_config request, options = nil
938
+ raise ::ArgumentError, "request must be provided" if request.nil?
939
+
940
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Iot::V1::ModifyCloudToDeviceConfigRequest
941
+
942
+ # Converts hash and nil to an options object
943
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
944
+
945
+ # Customize the options with defaults
946
+ call_metadata = @config.rpcs.modify_cloud_to_device_config.metadata.to_h
947
+
948
+ # Set x-goog-api-client and x-goog-user-project headers
949
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
950
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
951
+ gapic_version: ::Google::Cloud::Iot::V1::VERSION,
952
+ transports_version_send: [:rest]
953
+
954
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
955
+
956
+ options.apply_defaults timeout: @config.rpcs.modify_cloud_to_device_config.timeout,
957
+ metadata: call_metadata,
958
+ retry_policy: @config.rpcs.modify_cloud_to_device_config.retry_policy
959
+
960
+ options.apply_defaults timeout: @config.timeout,
961
+ metadata: @config.metadata,
962
+ retry_policy: @config.retry_policy
963
+
964
+ @device_manager_stub.modify_cloud_to_device_config request, options do |result, operation|
965
+ yield result, operation if block_given?
966
+ return result
967
+ end
968
+ rescue ::Gapic::Rest::Error => e
969
+ raise ::Google::Cloud::Error.from_error(e)
970
+ end
971
+
972
+ ##
973
+ # Lists the last few versions of the device configuration in descending
974
+ # order (i.e.: newest first).
975
+ #
976
+ # @overload list_device_config_versions(request, options = nil)
977
+ # Pass arguments to `list_device_config_versions` via a request object, either of type
978
+ # {::Google::Cloud::Iot::V1::ListDeviceConfigVersionsRequest} or an equivalent Hash.
979
+ #
980
+ # @param request [::Google::Cloud::Iot::V1::ListDeviceConfigVersionsRequest, ::Hash]
981
+ # A request object representing the call parameters. Required. To specify no
982
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
983
+ # @param options [::Gapic::CallOptions, ::Hash]
984
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
985
+ #
986
+ # @overload list_device_config_versions(name: nil, num_versions: nil)
987
+ # Pass arguments to `list_device_config_versions` via keyword arguments. Note that at
988
+ # least one keyword argument is required. To specify no parameters, or to keep all
989
+ # the default parameter values, pass an empty Hash as a request object (see above).
990
+ #
991
+ # @param name [::String]
992
+ # Required. The name of the device. For example,
993
+ # `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
994
+ # `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
995
+ # @param num_versions [::Integer]
996
+ # The number of versions to list. Versions are listed in decreasing order of
997
+ # the version number. The maximum number of versions retained is 10. If this
998
+ # value is zero, it will return all the versions available.
999
+ # @yield [result, operation] Access the result along with the TransportOperation object
1000
+ # @yieldparam result [::Google::Cloud::Iot::V1::ListDeviceConfigVersionsResponse]
1001
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
1002
+ #
1003
+ # @return [::Google::Cloud::Iot::V1::ListDeviceConfigVersionsResponse]
1004
+ #
1005
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
1006
+ def list_device_config_versions request, options = nil
1007
+ raise ::ArgumentError, "request must be provided" if request.nil?
1008
+
1009
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Iot::V1::ListDeviceConfigVersionsRequest
1010
+
1011
+ # Converts hash and nil to an options object
1012
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1013
+
1014
+ # Customize the options with defaults
1015
+ call_metadata = @config.rpcs.list_device_config_versions.metadata.to_h
1016
+
1017
+ # Set x-goog-api-client and x-goog-user-project headers
1018
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1019
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1020
+ gapic_version: ::Google::Cloud::Iot::V1::VERSION,
1021
+ transports_version_send: [:rest]
1022
+
1023
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1024
+
1025
+ options.apply_defaults timeout: @config.rpcs.list_device_config_versions.timeout,
1026
+ metadata: call_metadata,
1027
+ retry_policy: @config.rpcs.list_device_config_versions.retry_policy
1028
+
1029
+ options.apply_defaults timeout: @config.timeout,
1030
+ metadata: @config.metadata,
1031
+ retry_policy: @config.retry_policy
1032
+
1033
+ @device_manager_stub.list_device_config_versions request, options do |result, operation|
1034
+ yield result, operation if block_given?
1035
+ return result
1036
+ end
1037
+ rescue ::Gapic::Rest::Error => e
1038
+ raise ::Google::Cloud::Error.from_error(e)
1039
+ end
1040
+
1041
+ ##
1042
+ # Lists the last few versions of the device state in descending order (i.e.:
1043
+ # newest first).
1044
+ #
1045
+ # @overload list_device_states(request, options = nil)
1046
+ # Pass arguments to `list_device_states` via a request object, either of type
1047
+ # {::Google::Cloud::Iot::V1::ListDeviceStatesRequest} or an equivalent Hash.
1048
+ #
1049
+ # @param request [::Google::Cloud::Iot::V1::ListDeviceStatesRequest, ::Hash]
1050
+ # A request object representing the call parameters. Required. To specify no
1051
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1052
+ # @param options [::Gapic::CallOptions, ::Hash]
1053
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
1054
+ #
1055
+ # @overload list_device_states(name: nil, num_states: nil)
1056
+ # Pass arguments to `list_device_states` via keyword arguments. Note that at
1057
+ # least one keyword argument is required. To specify no parameters, or to keep all
1058
+ # the default parameter values, pass an empty Hash as a request object (see above).
1059
+ #
1060
+ # @param name [::String]
1061
+ # Required. The name of the device. For example,
1062
+ # `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
1063
+ # `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
1064
+ # @param num_states [::Integer]
1065
+ # The number of states to list. States are listed in descending order of
1066
+ # update time. The maximum number of states retained is 10. If this
1067
+ # value is zero, it will return all the states available.
1068
+ # @yield [result, operation] Access the result along with the TransportOperation object
1069
+ # @yieldparam result [::Google::Cloud::Iot::V1::ListDeviceStatesResponse]
1070
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
1071
+ #
1072
+ # @return [::Google::Cloud::Iot::V1::ListDeviceStatesResponse]
1073
+ #
1074
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
1075
+ def list_device_states request, options = nil
1076
+ raise ::ArgumentError, "request must be provided" if request.nil?
1077
+
1078
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Iot::V1::ListDeviceStatesRequest
1079
+
1080
+ # Converts hash and nil to an options object
1081
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1082
+
1083
+ # Customize the options with defaults
1084
+ call_metadata = @config.rpcs.list_device_states.metadata.to_h
1085
+
1086
+ # Set x-goog-api-client and x-goog-user-project headers
1087
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1088
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1089
+ gapic_version: ::Google::Cloud::Iot::V1::VERSION,
1090
+ transports_version_send: [:rest]
1091
+
1092
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1093
+
1094
+ options.apply_defaults timeout: @config.rpcs.list_device_states.timeout,
1095
+ metadata: call_metadata,
1096
+ retry_policy: @config.rpcs.list_device_states.retry_policy
1097
+
1098
+ options.apply_defaults timeout: @config.timeout,
1099
+ metadata: @config.metadata,
1100
+ retry_policy: @config.retry_policy
1101
+
1102
+ @device_manager_stub.list_device_states request, options do |result, operation|
1103
+ yield result, operation if block_given?
1104
+ return result
1105
+ end
1106
+ rescue ::Gapic::Rest::Error => e
1107
+ raise ::Google::Cloud::Error.from_error(e)
1108
+ end
1109
+
1110
+ ##
1111
+ # Sets the access control policy on the specified resource. Replaces any
1112
+ # existing policy.
1113
+ #
1114
+ # @overload set_iam_policy(request, options = nil)
1115
+ # Pass arguments to `set_iam_policy` via a request object, either of type
1116
+ # {::Google::Iam::V1::SetIamPolicyRequest} or an equivalent Hash.
1117
+ #
1118
+ # @param request [::Google::Iam::V1::SetIamPolicyRequest, ::Hash]
1119
+ # A request object representing the call parameters. Required. To specify no
1120
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1121
+ # @param options [::Gapic::CallOptions, ::Hash]
1122
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
1123
+ #
1124
+ # @overload set_iam_policy(resource: nil, policy: nil, update_mask: nil)
1125
+ # Pass arguments to `set_iam_policy` via keyword arguments. Note that at
1126
+ # least one keyword argument is required. To specify no parameters, or to keep all
1127
+ # the default parameter values, pass an empty Hash as a request object (see above).
1128
+ #
1129
+ # @param resource [::String]
1130
+ # REQUIRED: The resource for which the policy is being specified.
1131
+ # See the operation documentation for the appropriate value for this field.
1132
+ # @param policy [::Google::Iam::V1::Policy, ::Hash]
1133
+ # REQUIRED: The complete policy to be applied to the `resource`. The size of
1134
+ # the policy is limited to a few 10s of KB. An empty policy is a
1135
+ # valid policy but certain Cloud Platform services (such as Projects)
1136
+ # might reject them.
1137
+ # @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
1138
+ # OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only
1139
+ # the fields in the mask will be modified. If no mask is provided, the
1140
+ # following default mask is used:
1141
+ #
1142
+ # `paths: "bindings, etag"`
1143
+ # @yield [result, operation] Access the result along with the TransportOperation object
1144
+ # @yieldparam result [::Google::Iam::V1::Policy]
1145
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
1146
+ #
1147
+ # @return [::Google::Iam::V1::Policy]
1148
+ #
1149
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
1150
+ def set_iam_policy request, options = nil
1151
+ raise ::ArgumentError, "request must be provided" if request.nil?
1152
+
1153
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Iam::V1::SetIamPolicyRequest
1154
+
1155
+ # Converts hash and nil to an options object
1156
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1157
+
1158
+ # Customize the options with defaults
1159
+ call_metadata = @config.rpcs.set_iam_policy.metadata.to_h
1160
+
1161
+ # Set x-goog-api-client and x-goog-user-project headers
1162
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1163
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1164
+ gapic_version: ::Google::Cloud::Iot::V1::VERSION,
1165
+ transports_version_send: [:rest]
1166
+
1167
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1168
+
1169
+ options.apply_defaults timeout: @config.rpcs.set_iam_policy.timeout,
1170
+ metadata: call_metadata,
1171
+ retry_policy: @config.rpcs.set_iam_policy.retry_policy
1172
+
1173
+ options.apply_defaults timeout: @config.timeout,
1174
+ metadata: @config.metadata,
1175
+ retry_policy: @config.retry_policy
1176
+
1177
+ @device_manager_stub.set_iam_policy request, options do |result, operation|
1178
+ yield result, operation if block_given?
1179
+ return result
1180
+ end
1181
+ rescue ::Gapic::Rest::Error => e
1182
+ raise ::Google::Cloud::Error.from_error(e)
1183
+ end
1184
+
1185
+ ##
1186
+ # Gets the access control policy for a resource.
1187
+ # Returns an empty policy if the resource exists and does not have a policy
1188
+ # set.
1189
+ #
1190
+ # @overload get_iam_policy(request, options = nil)
1191
+ # Pass arguments to `get_iam_policy` via a request object, either of type
1192
+ # {::Google::Iam::V1::GetIamPolicyRequest} or an equivalent Hash.
1193
+ #
1194
+ # @param request [::Google::Iam::V1::GetIamPolicyRequest, ::Hash]
1195
+ # A request object representing the call parameters. Required. To specify no
1196
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1197
+ # @param options [::Gapic::CallOptions, ::Hash]
1198
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
1199
+ #
1200
+ # @overload get_iam_policy(resource: nil, options: nil)
1201
+ # Pass arguments to `get_iam_policy` via keyword arguments. Note that at
1202
+ # least one keyword argument is required. To specify no parameters, or to keep all
1203
+ # the default parameter values, pass an empty Hash as a request object (see above).
1204
+ #
1205
+ # @param resource [::String]
1206
+ # REQUIRED: The resource for which the policy is being requested.
1207
+ # See the operation documentation for the appropriate value for this field.
1208
+ # @param options [::Google::Iam::V1::GetPolicyOptions, ::Hash]
1209
+ # OPTIONAL: A `GetPolicyOptions` object for specifying options to
1210
+ # `GetIamPolicy`.
1211
+ # @yield [result, operation] Access the result along with the TransportOperation object
1212
+ # @yieldparam result [::Google::Iam::V1::Policy]
1213
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
1214
+ #
1215
+ # @return [::Google::Iam::V1::Policy]
1216
+ #
1217
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
1218
+ def get_iam_policy request, options = nil
1219
+ raise ::ArgumentError, "request must be provided" if request.nil?
1220
+
1221
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Iam::V1::GetIamPolicyRequest
1222
+
1223
+ # Converts hash and nil to an options object
1224
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1225
+
1226
+ # Customize the options with defaults
1227
+ call_metadata = @config.rpcs.get_iam_policy.metadata.to_h
1228
+
1229
+ # Set x-goog-api-client and x-goog-user-project headers
1230
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1231
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1232
+ gapic_version: ::Google::Cloud::Iot::V1::VERSION,
1233
+ transports_version_send: [:rest]
1234
+
1235
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1236
+
1237
+ options.apply_defaults timeout: @config.rpcs.get_iam_policy.timeout,
1238
+ metadata: call_metadata,
1239
+ retry_policy: @config.rpcs.get_iam_policy.retry_policy
1240
+
1241
+ options.apply_defaults timeout: @config.timeout,
1242
+ metadata: @config.metadata,
1243
+ retry_policy: @config.retry_policy
1244
+
1245
+ @device_manager_stub.get_iam_policy request, options do |result, operation|
1246
+ yield result, operation if block_given?
1247
+ return result
1248
+ end
1249
+ rescue ::Gapic::Rest::Error => e
1250
+ raise ::Google::Cloud::Error.from_error(e)
1251
+ end
1252
+
1253
+ ##
1254
+ # Returns permissions that a caller has on the specified resource.
1255
+ # If the resource does not exist, this will return an empty set of
1256
+ # permissions, not a NOT_FOUND error.
1257
+ #
1258
+ # @overload test_iam_permissions(request, options = nil)
1259
+ # Pass arguments to `test_iam_permissions` via a request object, either of type
1260
+ # {::Google::Iam::V1::TestIamPermissionsRequest} or an equivalent Hash.
1261
+ #
1262
+ # @param request [::Google::Iam::V1::TestIamPermissionsRequest, ::Hash]
1263
+ # A request object representing the call parameters. Required. To specify no
1264
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1265
+ # @param options [::Gapic::CallOptions, ::Hash]
1266
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
1267
+ #
1268
+ # @overload test_iam_permissions(resource: nil, permissions: nil)
1269
+ # Pass arguments to `test_iam_permissions` via keyword arguments. Note that at
1270
+ # least one keyword argument is required. To specify no parameters, or to keep all
1271
+ # the default parameter values, pass an empty Hash as a request object (see above).
1272
+ #
1273
+ # @param resource [::String]
1274
+ # REQUIRED: The resource for which the policy detail is being requested.
1275
+ # See the operation documentation for the appropriate value for this field.
1276
+ # @param permissions [::Array<::String>]
1277
+ # The set of permissions to check for the `resource`. Permissions with
1278
+ # wildcards (such as '*' or 'storage.*') are not allowed. For more
1279
+ # information see
1280
+ # [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
1281
+ # @yield [result, operation] Access the result along with the TransportOperation object
1282
+ # @yieldparam result [::Google::Iam::V1::TestIamPermissionsResponse]
1283
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
1284
+ #
1285
+ # @return [::Google::Iam::V1::TestIamPermissionsResponse]
1286
+ #
1287
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
1288
+ def test_iam_permissions request, options = nil
1289
+ raise ::ArgumentError, "request must be provided" if request.nil?
1290
+
1291
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Iam::V1::TestIamPermissionsRequest
1292
+
1293
+ # Converts hash and nil to an options object
1294
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1295
+
1296
+ # Customize the options with defaults
1297
+ call_metadata = @config.rpcs.test_iam_permissions.metadata.to_h
1298
+
1299
+ # Set x-goog-api-client and x-goog-user-project headers
1300
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1301
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1302
+ gapic_version: ::Google::Cloud::Iot::V1::VERSION,
1303
+ transports_version_send: [:rest]
1304
+
1305
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1306
+
1307
+ options.apply_defaults timeout: @config.rpcs.test_iam_permissions.timeout,
1308
+ metadata: call_metadata,
1309
+ retry_policy: @config.rpcs.test_iam_permissions.retry_policy
1310
+
1311
+ options.apply_defaults timeout: @config.timeout,
1312
+ metadata: @config.metadata,
1313
+ retry_policy: @config.retry_policy
1314
+
1315
+ @device_manager_stub.test_iam_permissions request, options do |result, operation|
1316
+ yield result, operation if block_given?
1317
+ return result
1318
+ end
1319
+ rescue ::Gapic::Rest::Error => e
1320
+ raise ::Google::Cloud::Error.from_error(e)
1321
+ end
1322
+
1323
+ ##
1324
+ # Sends a command to the specified device. In order for a device to be able
1325
+ # to receive commands, it must:
1326
+ # 1) be connected to Cloud IoT Core using the MQTT protocol, and
1327
+ # 2) be subscribed to the group of MQTT topics specified by
1328
+ # /devices/\\{device-id}/commands/#. This subscription will receive commands
1329
+ # at the top-level topic /devices/\\{device-id}/commands as well as commands
1330
+ # for subfolders, like /devices/\\{device-id}/commands/subfolder.
1331
+ # Note that subscribing to specific subfolders is not supported.
1332
+ # If the command could not be delivered to the device, this method will
1333
+ # return an error; in particular, if the device is not subscribed, this
1334
+ # method will return FAILED_PRECONDITION. Otherwise, this method will
1335
+ # return OK. If the subscription is QoS 1, at least once delivery will be
1336
+ # guaranteed; for QoS 0, no acknowledgment will be expected from the device.
1337
+ #
1338
+ # @overload send_command_to_device(request, options = nil)
1339
+ # Pass arguments to `send_command_to_device` via a request object, either of type
1340
+ # {::Google::Cloud::Iot::V1::SendCommandToDeviceRequest} or an equivalent Hash.
1341
+ #
1342
+ # @param request [::Google::Cloud::Iot::V1::SendCommandToDeviceRequest, ::Hash]
1343
+ # A request object representing the call parameters. Required. To specify no
1344
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1345
+ # @param options [::Gapic::CallOptions, ::Hash]
1346
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
1347
+ #
1348
+ # @overload send_command_to_device(name: nil, binary_data: nil, subfolder: nil)
1349
+ # Pass arguments to `send_command_to_device` via keyword arguments. Note that at
1350
+ # least one keyword argument is required. To specify no parameters, or to keep all
1351
+ # the default parameter values, pass an empty Hash as a request object (see above).
1352
+ #
1353
+ # @param name [::String]
1354
+ # Required. The name of the device. For example,
1355
+ # `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
1356
+ # `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
1357
+ # @param binary_data [::String]
1358
+ # Required. The command data to send to the device.
1359
+ # @param subfolder [::String]
1360
+ # Optional subfolder for the command. If empty, the command will be delivered
1361
+ # to the /devices/\\{device-id}/commands topic, otherwise it will be delivered
1362
+ # to the /devices/\\{device-id}/commands/\\{subfolder} topic. Multi-level
1363
+ # subfolders are allowed. This field must not have more than 256 characters,
1364
+ # and must not contain any MQTT wildcards ("+" or "#") or null characters.
1365
+ # @yield [result, operation] Access the result along with the TransportOperation object
1366
+ # @yieldparam result [::Google::Cloud::Iot::V1::SendCommandToDeviceResponse]
1367
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
1368
+ #
1369
+ # @return [::Google::Cloud::Iot::V1::SendCommandToDeviceResponse]
1370
+ #
1371
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
1372
+ def send_command_to_device request, options = nil
1373
+ raise ::ArgumentError, "request must be provided" if request.nil?
1374
+
1375
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Iot::V1::SendCommandToDeviceRequest
1376
+
1377
+ # Converts hash and nil to an options object
1378
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1379
+
1380
+ # Customize the options with defaults
1381
+ call_metadata = @config.rpcs.send_command_to_device.metadata.to_h
1382
+
1383
+ # Set x-goog-api-client and x-goog-user-project headers
1384
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1385
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1386
+ gapic_version: ::Google::Cloud::Iot::V1::VERSION,
1387
+ transports_version_send: [:rest]
1388
+
1389
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1390
+
1391
+ options.apply_defaults timeout: @config.rpcs.send_command_to_device.timeout,
1392
+ metadata: call_metadata,
1393
+ retry_policy: @config.rpcs.send_command_to_device.retry_policy
1394
+
1395
+ options.apply_defaults timeout: @config.timeout,
1396
+ metadata: @config.metadata,
1397
+ retry_policy: @config.retry_policy
1398
+
1399
+ @device_manager_stub.send_command_to_device request, options do |result, operation|
1400
+ yield result, operation if block_given?
1401
+ return result
1402
+ end
1403
+ rescue ::Gapic::Rest::Error => e
1404
+ raise ::Google::Cloud::Error.from_error(e)
1405
+ end
1406
+
1407
+ ##
1408
+ # Associates the device with the gateway.
1409
+ #
1410
+ # @overload bind_device_to_gateway(request, options = nil)
1411
+ # Pass arguments to `bind_device_to_gateway` via a request object, either of type
1412
+ # {::Google::Cloud::Iot::V1::BindDeviceToGatewayRequest} or an equivalent Hash.
1413
+ #
1414
+ # @param request [::Google::Cloud::Iot::V1::BindDeviceToGatewayRequest, ::Hash]
1415
+ # A request object representing the call parameters. Required. To specify no
1416
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1417
+ # @param options [::Gapic::CallOptions, ::Hash]
1418
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
1419
+ #
1420
+ # @overload bind_device_to_gateway(parent: nil, gateway_id: nil, device_id: nil)
1421
+ # Pass arguments to `bind_device_to_gateway` via keyword arguments. Note that at
1422
+ # least one keyword argument is required. To specify no parameters, or to keep all
1423
+ # the default parameter values, pass an empty Hash as a request object (see above).
1424
+ #
1425
+ # @param parent [::String]
1426
+ # Required. The name of the registry. For example,
1427
+ # `projects/example-project/locations/us-central1/registries/my-registry`.
1428
+ # @param gateway_id [::String]
1429
+ # Required. The value of `gateway_id` can be either the device numeric ID or the
1430
+ # user-defined device identifier.
1431
+ # @param device_id [::String]
1432
+ # Required. The device to associate with the specified gateway. The value of
1433
+ # `device_id` can be either the device numeric ID or the user-defined device
1434
+ # identifier.
1435
+ # @yield [result, operation] Access the result along with the TransportOperation object
1436
+ # @yieldparam result [::Google::Cloud::Iot::V1::BindDeviceToGatewayResponse]
1437
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
1438
+ #
1439
+ # @return [::Google::Cloud::Iot::V1::BindDeviceToGatewayResponse]
1440
+ #
1441
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
1442
+ def bind_device_to_gateway request, options = nil
1443
+ raise ::ArgumentError, "request must be provided" if request.nil?
1444
+
1445
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Iot::V1::BindDeviceToGatewayRequest
1446
+
1447
+ # Converts hash and nil to an options object
1448
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1449
+
1450
+ # Customize the options with defaults
1451
+ call_metadata = @config.rpcs.bind_device_to_gateway.metadata.to_h
1452
+
1453
+ # Set x-goog-api-client and x-goog-user-project headers
1454
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1455
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1456
+ gapic_version: ::Google::Cloud::Iot::V1::VERSION,
1457
+ transports_version_send: [:rest]
1458
+
1459
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1460
+
1461
+ options.apply_defaults timeout: @config.rpcs.bind_device_to_gateway.timeout,
1462
+ metadata: call_metadata,
1463
+ retry_policy: @config.rpcs.bind_device_to_gateway.retry_policy
1464
+
1465
+ options.apply_defaults timeout: @config.timeout,
1466
+ metadata: @config.metadata,
1467
+ retry_policy: @config.retry_policy
1468
+
1469
+ @device_manager_stub.bind_device_to_gateway request, options do |result, operation|
1470
+ yield result, operation if block_given?
1471
+ return result
1472
+ end
1473
+ rescue ::Gapic::Rest::Error => e
1474
+ raise ::Google::Cloud::Error.from_error(e)
1475
+ end
1476
+
1477
+ ##
1478
+ # Deletes the association between the device and the gateway.
1479
+ #
1480
+ # @overload unbind_device_from_gateway(request, options = nil)
1481
+ # Pass arguments to `unbind_device_from_gateway` via a request object, either of type
1482
+ # {::Google::Cloud::Iot::V1::UnbindDeviceFromGatewayRequest} or an equivalent Hash.
1483
+ #
1484
+ # @param request [::Google::Cloud::Iot::V1::UnbindDeviceFromGatewayRequest, ::Hash]
1485
+ # A request object representing the call parameters. Required. To specify no
1486
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1487
+ # @param options [::Gapic::CallOptions, ::Hash]
1488
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
1489
+ #
1490
+ # @overload unbind_device_from_gateway(parent: nil, gateway_id: nil, device_id: nil)
1491
+ # Pass arguments to `unbind_device_from_gateway` via keyword arguments. Note that at
1492
+ # least one keyword argument is required. To specify no parameters, or to keep all
1493
+ # the default parameter values, pass an empty Hash as a request object (see above).
1494
+ #
1495
+ # @param parent [::String]
1496
+ # Required. The name of the registry. For example,
1497
+ # `projects/example-project/locations/us-central1/registries/my-registry`.
1498
+ # @param gateway_id [::String]
1499
+ # Required. The value of `gateway_id` can be either the device numeric ID or the
1500
+ # user-defined device identifier.
1501
+ # @param device_id [::String]
1502
+ # Required. The device to disassociate from the specified gateway. The value of
1503
+ # `device_id` can be either the device numeric ID or the user-defined device
1504
+ # identifier.
1505
+ # @yield [result, operation] Access the result along with the TransportOperation object
1506
+ # @yieldparam result [::Google::Cloud::Iot::V1::UnbindDeviceFromGatewayResponse]
1507
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
1508
+ #
1509
+ # @return [::Google::Cloud::Iot::V1::UnbindDeviceFromGatewayResponse]
1510
+ #
1511
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
1512
+ def unbind_device_from_gateway request, options = nil
1513
+ raise ::ArgumentError, "request must be provided" if request.nil?
1514
+
1515
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Iot::V1::UnbindDeviceFromGatewayRequest
1516
+
1517
+ # Converts hash and nil to an options object
1518
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1519
+
1520
+ # Customize the options with defaults
1521
+ call_metadata = @config.rpcs.unbind_device_from_gateway.metadata.to_h
1522
+
1523
+ # Set x-goog-api-client and x-goog-user-project headers
1524
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1525
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1526
+ gapic_version: ::Google::Cloud::Iot::V1::VERSION,
1527
+ transports_version_send: [:rest]
1528
+
1529
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1530
+
1531
+ options.apply_defaults timeout: @config.rpcs.unbind_device_from_gateway.timeout,
1532
+ metadata: call_metadata,
1533
+ retry_policy: @config.rpcs.unbind_device_from_gateway.retry_policy
1534
+
1535
+ options.apply_defaults timeout: @config.timeout,
1536
+ metadata: @config.metadata,
1537
+ retry_policy: @config.retry_policy
1538
+
1539
+ @device_manager_stub.unbind_device_from_gateway request, options do |result, operation|
1540
+ yield result, operation if block_given?
1541
+ return result
1542
+ end
1543
+ rescue ::Gapic::Rest::Error => e
1544
+ raise ::Google::Cloud::Error.from_error(e)
1545
+ end
1546
+
1547
+ ##
1548
+ # Configuration class for the DeviceManager REST API.
1549
+ #
1550
+ # This class represents the configuration for DeviceManager REST,
1551
+ # providing control over timeouts, retry behavior, logging, transport
1552
+ # parameters, and other low-level controls. Certain parameters can also be
1553
+ # applied individually to specific RPCs. See
1554
+ # {::Google::Cloud::Iot::V1::DeviceManager::Rest::Client::Configuration::Rpcs}
1555
+ # for a list of RPCs that can be configured independently.
1556
+ #
1557
+ # Configuration can be applied globally to all clients, or to a single client
1558
+ # on construction.
1559
+ #
1560
+ # @example
1561
+ #
1562
+ # # Modify the global config, setting the timeout for
1563
+ # # create_device_registry to 20 seconds,
1564
+ # # and all remaining timeouts to 10 seconds.
1565
+ # ::Google::Cloud::Iot::V1::DeviceManager::Rest::Client.configure do |config|
1566
+ # config.timeout = 10.0
1567
+ # config.rpcs.create_device_registry.timeout = 20.0
1568
+ # end
1569
+ #
1570
+ # # Apply the above configuration only to a new client.
1571
+ # client = ::Google::Cloud::Iot::V1::DeviceManager::Rest::Client.new do |config|
1572
+ # config.timeout = 10.0
1573
+ # config.rpcs.create_device_registry.timeout = 20.0
1574
+ # end
1575
+ #
1576
+ # @!attribute [rw] endpoint
1577
+ # The hostname or hostname:port of the service endpoint.
1578
+ # Defaults to `"cloudiot.googleapis.com"`.
1579
+ # @return [::String]
1580
+ # @!attribute [rw] credentials
1581
+ # Credentials to send with calls. You may provide any of the following types:
1582
+ # * (`String`) The path to a service account key file in JSON format
1583
+ # * (`Hash`) A service account key as a Hash
1584
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
1585
+ # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
1586
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
1587
+ # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
1588
+ # * (`nil`) indicating no credentials
1589
+ # @return [::Object]
1590
+ # @!attribute [rw] scope
1591
+ # The OAuth scopes
1592
+ # @return [::Array<::String>]
1593
+ # @!attribute [rw] lib_name
1594
+ # The library name as recorded in instrumentation and logging
1595
+ # @return [::String]
1596
+ # @!attribute [rw] lib_version
1597
+ # The library version as recorded in instrumentation and logging
1598
+ # @return [::String]
1599
+ # @!attribute [rw] timeout
1600
+ # The call timeout in seconds.
1601
+ # @return [::Numeric]
1602
+ # @!attribute [rw] metadata
1603
+ # Additional headers to be sent with the call.
1604
+ # @return [::Hash{::Symbol=>::String}]
1605
+ # @!attribute [rw] retry_policy
1606
+ # The retry policy. The value is a hash with the following keys:
1607
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
1608
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
1609
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
1610
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
1611
+ # trigger a retry.
1612
+ # @return [::Hash]
1613
+ # @!attribute [rw] quota_project
1614
+ # A separate project against which to charge quota.
1615
+ # @return [::String]
1616
+ #
1617
+ class Configuration
1618
+ extend ::Gapic::Config
1619
+
1620
+ DEFAULT_ENDPOINT = "cloudiot.googleapis.com"
1621
+
1622
+ config_attr :endpoint, DEFAULT_ENDPOINT, ::String
1623
+ config_attr :credentials, nil do |value|
1624
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
1625
+ allowed.any? { |klass| klass === value }
1626
+ end
1627
+ config_attr :scope, nil, ::String, ::Array, nil
1628
+ config_attr :lib_name, nil, ::String, nil
1629
+ config_attr :lib_version, nil, ::String, nil
1630
+ config_attr :timeout, nil, ::Numeric, nil
1631
+ config_attr :metadata, nil, ::Hash, nil
1632
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
1633
+ config_attr :quota_project, nil, ::String, nil
1634
+
1635
+ # @private
1636
+ def initialize parent_config = nil
1637
+ @parent_config = parent_config unless parent_config.nil?
1638
+
1639
+ yield self if block_given?
1640
+ end
1641
+
1642
+ ##
1643
+ # Configurations for individual RPCs
1644
+ # @return [Rpcs]
1645
+ #
1646
+ def rpcs
1647
+ @rpcs ||= begin
1648
+ parent_rpcs = nil
1649
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
1650
+ Rpcs.new parent_rpcs
1651
+ end
1652
+ end
1653
+
1654
+ ##
1655
+ # Configuration RPC class for the DeviceManager API.
1656
+ #
1657
+ # Includes fields providing the configuration for each RPC in this service.
1658
+ # Each configuration object is of type `Gapic::Config::Method` and includes
1659
+ # the following configuration fields:
1660
+ #
1661
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
1662
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
1663
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
1664
+ # include the following keys:
1665
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
1666
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
1667
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
1668
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
1669
+ # trigger a retry.
1670
+ #
1671
+ class Rpcs
1672
+ ##
1673
+ # RPC-specific configuration for `create_device_registry`
1674
+ # @return [::Gapic::Config::Method]
1675
+ #
1676
+ attr_reader :create_device_registry
1677
+ ##
1678
+ # RPC-specific configuration for `get_device_registry`
1679
+ # @return [::Gapic::Config::Method]
1680
+ #
1681
+ attr_reader :get_device_registry
1682
+ ##
1683
+ # RPC-specific configuration for `update_device_registry`
1684
+ # @return [::Gapic::Config::Method]
1685
+ #
1686
+ attr_reader :update_device_registry
1687
+ ##
1688
+ # RPC-specific configuration for `delete_device_registry`
1689
+ # @return [::Gapic::Config::Method]
1690
+ #
1691
+ attr_reader :delete_device_registry
1692
+ ##
1693
+ # RPC-specific configuration for `list_device_registries`
1694
+ # @return [::Gapic::Config::Method]
1695
+ #
1696
+ attr_reader :list_device_registries
1697
+ ##
1698
+ # RPC-specific configuration for `create_device`
1699
+ # @return [::Gapic::Config::Method]
1700
+ #
1701
+ attr_reader :create_device
1702
+ ##
1703
+ # RPC-specific configuration for `get_device`
1704
+ # @return [::Gapic::Config::Method]
1705
+ #
1706
+ attr_reader :get_device
1707
+ ##
1708
+ # RPC-specific configuration for `update_device`
1709
+ # @return [::Gapic::Config::Method]
1710
+ #
1711
+ attr_reader :update_device
1712
+ ##
1713
+ # RPC-specific configuration for `delete_device`
1714
+ # @return [::Gapic::Config::Method]
1715
+ #
1716
+ attr_reader :delete_device
1717
+ ##
1718
+ # RPC-specific configuration for `list_devices`
1719
+ # @return [::Gapic::Config::Method]
1720
+ #
1721
+ attr_reader :list_devices
1722
+ ##
1723
+ # RPC-specific configuration for `modify_cloud_to_device_config`
1724
+ # @return [::Gapic::Config::Method]
1725
+ #
1726
+ attr_reader :modify_cloud_to_device_config
1727
+ ##
1728
+ # RPC-specific configuration for `list_device_config_versions`
1729
+ # @return [::Gapic::Config::Method]
1730
+ #
1731
+ attr_reader :list_device_config_versions
1732
+ ##
1733
+ # RPC-specific configuration for `list_device_states`
1734
+ # @return [::Gapic::Config::Method]
1735
+ #
1736
+ attr_reader :list_device_states
1737
+ ##
1738
+ # RPC-specific configuration for `set_iam_policy`
1739
+ # @return [::Gapic::Config::Method]
1740
+ #
1741
+ attr_reader :set_iam_policy
1742
+ ##
1743
+ # RPC-specific configuration for `get_iam_policy`
1744
+ # @return [::Gapic::Config::Method]
1745
+ #
1746
+ attr_reader :get_iam_policy
1747
+ ##
1748
+ # RPC-specific configuration for `test_iam_permissions`
1749
+ # @return [::Gapic::Config::Method]
1750
+ #
1751
+ attr_reader :test_iam_permissions
1752
+ ##
1753
+ # RPC-specific configuration for `send_command_to_device`
1754
+ # @return [::Gapic::Config::Method]
1755
+ #
1756
+ attr_reader :send_command_to_device
1757
+ ##
1758
+ # RPC-specific configuration for `bind_device_to_gateway`
1759
+ # @return [::Gapic::Config::Method]
1760
+ #
1761
+ attr_reader :bind_device_to_gateway
1762
+ ##
1763
+ # RPC-specific configuration for `unbind_device_from_gateway`
1764
+ # @return [::Gapic::Config::Method]
1765
+ #
1766
+ attr_reader :unbind_device_from_gateway
1767
+
1768
+ # @private
1769
+ def initialize parent_rpcs = nil
1770
+ create_device_registry_config = parent_rpcs.create_device_registry if parent_rpcs.respond_to? :create_device_registry
1771
+ @create_device_registry = ::Gapic::Config::Method.new create_device_registry_config
1772
+ get_device_registry_config = parent_rpcs.get_device_registry if parent_rpcs.respond_to? :get_device_registry
1773
+ @get_device_registry = ::Gapic::Config::Method.new get_device_registry_config
1774
+ update_device_registry_config = parent_rpcs.update_device_registry if parent_rpcs.respond_to? :update_device_registry
1775
+ @update_device_registry = ::Gapic::Config::Method.new update_device_registry_config
1776
+ delete_device_registry_config = parent_rpcs.delete_device_registry if parent_rpcs.respond_to? :delete_device_registry
1777
+ @delete_device_registry = ::Gapic::Config::Method.new delete_device_registry_config
1778
+ list_device_registries_config = parent_rpcs.list_device_registries if parent_rpcs.respond_to? :list_device_registries
1779
+ @list_device_registries = ::Gapic::Config::Method.new list_device_registries_config
1780
+ create_device_config = parent_rpcs.create_device if parent_rpcs.respond_to? :create_device
1781
+ @create_device = ::Gapic::Config::Method.new create_device_config
1782
+ get_device_config = parent_rpcs.get_device if parent_rpcs.respond_to? :get_device
1783
+ @get_device = ::Gapic::Config::Method.new get_device_config
1784
+ update_device_config = parent_rpcs.update_device if parent_rpcs.respond_to? :update_device
1785
+ @update_device = ::Gapic::Config::Method.new update_device_config
1786
+ delete_device_config = parent_rpcs.delete_device if parent_rpcs.respond_to? :delete_device
1787
+ @delete_device = ::Gapic::Config::Method.new delete_device_config
1788
+ list_devices_config = parent_rpcs.list_devices if parent_rpcs.respond_to? :list_devices
1789
+ @list_devices = ::Gapic::Config::Method.new list_devices_config
1790
+ modify_cloud_to_device_config_config = parent_rpcs.modify_cloud_to_device_config if parent_rpcs.respond_to? :modify_cloud_to_device_config
1791
+ @modify_cloud_to_device_config = ::Gapic::Config::Method.new modify_cloud_to_device_config_config
1792
+ list_device_config_versions_config = parent_rpcs.list_device_config_versions if parent_rpcs.respond_to? :list_device_config_versions
1793
+ @list_device_config_versions = ::Gapic::Config::Method.new list_device_config_versions_config
1794
+ list_device_states_config = parent_rpcs.list_device_states if parent_rpcs.respond_to? :list_device_states
1795
+ @list_device_states = ::Gapic::Config::Method.new list_device_states_config
1796
+ set_iam_policy_config = parent_rpcs.set_iam_policy if parent_rpcs.respond_to? :set_iam_policy
1797
+ @set_iam_policy = ::Gapic::Config::Method.new set_iam_policy_config
1798
+ get_iam_policy_config = parent_rpcs.get_iam_policy if parent_rpcs.respond_to? :get_iam_policy
1799
+ @get_iam_policy = ::Gapic::Config::Method.new get_iam_policy_config
1800
+ test_iam_permissions_config = parent_rpcs.test_iam_permissions if parent_rpcs.respond_to? :test_iam_permissions
1801
+ @test_iam_permissions = ::Gapic::Config::Method.new test_iam_permissions_config
1802
+ send_command_to_device_config = parent_rpcs.send_command_to_device if parent_rpcs.respond_to? :send_command_to_device
1803
+ @send_command_to_device = ::Gapic::Config::Method.new send_command_to_device_config
1804
+ bind_device_to_gateway_config = parent_rpcs.bind_device_to_gateway if parent_rpcs.respond_to? :bind_device_to_gateway
1805
+ @bind_device_to_gateway = ::Gapic::Config::Method.new bind_device_to_gateway_config
1806
+ unbind_device_from_gateway_config = parent_rpcs.unbind_device_from_gateway if parent_rpcs.respond_to? :unbind_device_from_gateway
1807
+ @unbind_device_from_gateway = ::Gapic::Config::Method.new unbind_device_from_gateway_config
1808
+
1809
+ yield self if block_given?
1810
+ end
1811
+ end
1812
+ end
1813
+ end
1814
+ end
1815
+ end
1816
+ end
1817
+ end
1818
+ end
1819
+ end