1 /* 2 * Copyright 2022 Google LLC 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * https://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.google.cloud.iot.v1; 18 19 import com.google.api.core.ApiFuture; 20 import com.google.api.core.ApiFutures; 21 import com.google.api.gax.core.BackgroundResource; 22 import com.google.api.gax.paging.AbstractFixedSizeCollection; 23 import com.google.api.gax.paging.AbstractPage; 24 import com.google.api.gax.paging.AbstractPagedListResponse; 25 import com.google.api.gax.rpc.PageContext; 26 import com.google.api.gax.rpc.UnaryCallable; 27 import com.google.api.resourcenames.ResourceName; 28 import com.google.cloud.iot.v1.stub.DeviceManagerStub; 29 import com.google.cloud.iot.v1.stub.DeviceManagerStubSettings; 30 import com.google.common.util.concurrent.MoreExecutors; 31 import com.google.iam.v1.GetIamPolicyRequest; 32 import com.google.iam.v1.Policy; 33 import com.google.iam.v1.SetIamPolicyRequest; 34 import com.google.iam.v1.TestIamPermissionsRequest; 35 import com.google.iam.v1.TestIamPermissionsResponse; 36 import com.google.protobuf.ByteString; 37 import com.google.protobuf.Empty; 38 import com.google.protobuf.FieldMask; 39 import java.io.IOException; 40 import java.util.List; 41 import java.util.concurrent.TimeUnit; 42 import javax.annotation.Generated; 43 44 // AUTO-GENERATED DOCUMENTATION AND CLASS. 45 /** 46 * Service Description: Internet of Things (IoT) service. Securely connect and manage IoT devices. 47 * 48 * <p>This class provides the ability to make remote calls to the backing service through method 49 * calls that map to API methods. Sample code to get started: 50 * 51 * <pre>{@code 52 * // This snippet has been automatically generated and should be regarded as a code template only. 53 * // It will require modifications to work: 54 * // - It may require correct/in-range values for request initialization. 55 * // - It may require specifying regional endpoints when creating the service client as shown in 56 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 57 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 58 * LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); 59 * DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build(); 60 * DeviceRegistry response = deviceManagerClient.createDeviceRegistry(parent, deviceRegistry); 61 * } 62 * }</pre> 63 * 64 * <p>Note: close() needs to be called on the DeviceManagerClient object to clean up resources such 65 * as threads. In the example above, try-with-resources is used, which automatically calls close(). 66 * 67 * <p>The surface of this class includes several types of Java methods for each of the API's 68 * methods: 69 * 70 * <ol> 71 * <li>A "flattened" method. With this type of method, the fields of the request type have been 72 * converted into function parameters. It may be the case that not all fields are available as 73 * parameters, and not every API method will have a flattened method entry point. 74 * <li>A "request object" method. This type of method only takes one parameter, a request object, 75 * which must be constructed before the call. Not every API method will have a request object 76 * method. 77 * <li>A "callable" method. This type of method takes no parameters and returns an immutable API 78 * callable object, which can be used to initiate calls to the service. 79 * </ol> 80 * 81 * <p>See the individual methods for example code. 82 * 83 * <p>Many parameters require resource names to be formatted in a particular way. To assist with 84 * these names, this class includes a format method for each type of name, and additionally a parse 85 * method to extract the individual identifiers contained within names that are returned. 86 * 87 * <p>This class can be customized by passing in a custom instance of DeviceManagerSettings to 88 * create(). For example: 89 * 90 * <p>To customize credentials: 91 * 92 * <pre>{@code 93 * // This snippet has been automatically generated and should be regarded as a code template only. 94 * // It will require modifications to work: 95 * // - It may require correct/in-range values for request initialization. 96 * // - It may require specifying regional endpoints when creating the service client as shown in 97 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 98 * DeviceManagerSettings deviceManagerSettings = 99 * DeviceManagerSettings.newBuilder() 100 * .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) 101 * .build(); 102 * DeviceManagerClient deviceManagerClient = DeviceManagerClient.create(deviceManagerSettings); 103 * }</pre> 104 * 105 * <p>To customize the endpoint: 106 * 107 * <pre>{@code 108 * // This snippet has been automatically generated and should be regarded as a code template only. 109 * // It will require modifications to work: 110 * // - It may require correct/in-range values for request initialization. 111 * // - It may require specifying regional endpoints when creating the service client as shown in 112 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 113 * DeviceManagerSettings deviceManagerSettings = 114 * DeviceManagerSettings.newBuilder().setEndpoint(myEndpoint).build(); 115 * DeviceManagerClient deviceManagerClient = DeviceManagerClient.create(deviceManagerSettings); 116 * }</pre> 117 * 118 * <p>To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over 119 * the wire: 120 * 121 * <pre>{@code 122 * // This snippet has been automatically generated and should be regarded as a code template only. 123 * // It will require modifications to work: 124 * // - It may require correct/in-range values for request initialization. 125 * // - It may require specifying regional endpoints when creating the service client as shown in 126 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 127 * DeviceManagerSettings deviceManagerSettings = 128 * DeviceManagerSettings.newHttpJsonBuilder().build(); 129 * DeviceManagerClient deviceManagerClient = DeviceManagerClient.create(deviceManagerSettings); 130 * }</pre> 131 * 132 * <p>Please refer to the GitHub repository's samples for more quickstart code snippets. 133 */ 134 @Generated("by gapic-generator-java") 135 public class DeviceManagerClient implements BackgroundResource { 136 private final DeviceManagerSettings settings; 137 private final DeviceManagerStub stub; 138 139 /** Constructs an instance of DeviceManagerClient with default settings. */ create()140 public static final DeviceManagerClient create() throws IOException { 141 return create(DeviceManagerSettings.newBuilder().build()); 142 } 143 144 /** 145 * Constructs an instance of DeviceManagerClient, using the given settings. The channels are 146 * created based on the settings passed in, or defaults for any settings that are not set. 147 */ create(DeviceManagerSettings settings)148 public static final DeviceManagerClient create(DeviceManagerSettings settings) 149 throws IOException { 150 return new DeviceManagerClient(settings); 151 } 152 153 /** 154 * Constructs an instance of DeviceManagerClient, using the given stub for making calls. This is 155 * for advanced usage - prefer using create(DeviceManagerSettings). 156 */ create(DeviceManagerStub stub)157 public static final DeviceManagerClient create(DeviceManagerStub stub) { 158 return new DeviceManagerClient(stub); 159 } 160 161 /** 162 * Constructs an instance of DeviceManagerClient, using the given settings. This is protected so 163 * that it is easy to make a subclass, but otherwise, the static factory methods should be 164 * preferred. 165 */ DeviceManagerClient(DeviceManagerSettings settings)166 protected DeviceManagerClient(DeviceManagerSettings settings) throws IOException { 167 this.settings = settings; 168 this.stub = ((DeviceManagerStubSettings) settings.getStubSettings()).createStub(); 169 } 170 DeviceManagerClient(DeviceManagerStub stub)171 protected DeviceManagerClient(DeviceManagerStub stub) { 172 this.settings = null; 173 this.stub = stub; 174 } 175 getSettings()176 public final DeviceManagerSettings getSettings() { 177 return settings; 178 } 179 getStub()180 public DeviceManagerStub getStub() { 181 return stub; 182 } 183 184 // AUTO-GENERATED DOCUMENTATION AND METHOD. 185 /** 186 * Creates a device registry that contains devices. 187 * 188 * <p>Sample code: 189 * 190 * <pre>{@code 191 * // This snippet has been automatically generated and should be regarded as a code template only. 192 * // It will require modifications to work: 193 * // - It may require correct/in-range values for request initialization. 194 * // - It may require specifying regional endpoints when creating the service client as shown in 195 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 196 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 197 * LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); 198 * DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build(); 199 * DeviceRegistry response = deviceManagerClient.createDeviceRegistry(parent, deviceRegistry); 200 * } 201 * }</pre> 202 * 203 * @param parent Required. The project and cloud region where this device registry must be 204 * created. For example, `projects/example-project/locations/us-central1`. 205 * @param deviceRegistry Required. The device registry. The field `name` must be empty. The server 206 * will generate that field from the device registry `id` provided and the `parent` field. 207 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 208 */ createDeviceRegistry( LocationName parent, DeviceRegistry deviceRegistry)209 public final DeviceRegistry createDeviceRegistry( 210 LocationName parent, DeviceRegistry deviceRegistry) { 211 CreateDeviceRegistryRequest request = 212 CreateDeviceRegistryRequest.newBuilder() 213 .setParent(parent == null ? null : parent.toString()) 214 .setDeviceRegistry(deviceRegistry) 215 .build(); 216 return createDeviceRegistry(request); 217 } 218 219 // AUTO-GENERATED DOCUMENTATION AND METHOD. 220 /** 221 * Creates a device registry that contains devices. 222 * 223 * <p>Sample code: 224 * 225 * <pre>{@code 226 * // This snippet has been automatically generated and should be regarded as a code template only. 227 * // It will require modifications to work: 228 * // - It may require correct/in-range values for request initialization. 229 * // - It may require specifying regional endpoints when creating the service client as shown in 230 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 231 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 232 * String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); 233 * DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build(); 234 * DeviceRegistry response = deviceManagerClient.createDeviceRegistry(parent, deviceRegistry); 235 * } 236 * }</pre> 237 * 238 * @param parent Required. The project and cloud region where this device registry must be 239 * created. For example, `projects/example-project/locations/us-central1`. 240 * @param deviceRegistry Required. The device registry. The field `name` must be empty. The server 241 * will generate that field from the device registry `id` provided and the `parent` field. 242 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 243 */ createDeviceRegistry(String parent, DeviceRegistry deviceRegistry)244 public final DeviceRegistry createDeviceRegistry(String parent, DeviceRegistry deviceRegistry) { 245 CreateDeviceRegistryRequest request = 246 CreateDeviceRegistryRequest.newBuilder() 247 .setParent(parent) 248 .setDeviceRegistry(deviceRegistry) 249 .build(); 250 return createDeviceRegistry(request); 251 } 252 253 // AUTO-GENERATED DOCUMENTATION AND METHOD. 254 /** 255 * Creates a device registry that contains devices. 256 * 257 * <p>Sample code: 258 * 259 * <pre>{@code 260 * // This snippet has been automatically generated and should be regarded as a code template only. 261 * // It will require modifications to work: 262 * // - It may require correct/in-range values for request initialization. 263 * // - It may require specifying regional endpoints when creating the service client as shown in 264 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 265 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 266 * CreateDeviceRegistryRequest request = 267 * CreateDeviceRegistryRequest.newBuilder() 268 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 269 * .setDeviceRegistry(DeviceRegistry.newBuilder().build()) 270 * .build(); 271 * DeviceRegistry response = deviceManagerClient.createDeviceRegistry(request); 272 * } 273 * }</pre> 274 * 275 * @param request The request object containing all of the parameters for the API call. 276 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 277 */ createDeviceRegistry(CreateDeviceRegistryRequest request)278 public final DeviceRegistry createDeviceRegistry(CreateDeviceRegistryRequest request) { 279 return createDeviceRegistryCallable().call(request); 280 } 281 282 // AUTO-GENERATED DOCUMENTATION AND METHOD. 283 /** 284 * Creates a device registry that contains devices. 285 * 286 * <p>Sample code: 287 * 288 * <pre>{@code 289 * // This snippet has been automatically generated and should be regarded as a code template only. 290 * // It will require modifications to work: 291 * // - It may require correct/in-range values for request initialization. 292 * // - It may require specifying regional endpoints when creating the service client as shown in 293 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 294 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 295 * CreateDeviceRegistryRequest request = 296 * CreateDeviceRegistryRequest.newBuilder() 297 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 298 * .setDeviceRegistry(DeviceRegistry.newBuilder().build()) 299 * .build(); 300 * ApiFuture<DeviceRegistry> future = 301 * deviceManagerClient.createDeviceRegistryCallable().futureCall(request); 302 * // Do something. 303 * DeviceRegistry response = future.get(); 304 * } 305 * }</pre> 306 */ 307 public final UnaryCallable<CreateDeviceRegistryRequest, DeviceRegistry> createDeviceRegistryCallable()308 createDeviceRegistryCallable() { 309 return stub.createDeviceRegistryCallable(); 310 } 311 312 // AUTO-GENERATED DOCUMENTATION AND METHOD. 313 /** 314 * Gets a device registry configuration. 315 * 316 * <p>Sample code: 317 * 318 * <pre>{@code 319 * // This snippet has been automatically generated and should be regarded as a code template only. 320 * // It will require modifications to work: 321 * // - It may require correct/in-range values for request initialization. 322 * // - It may require specifying regional endpoints when creating the service client as shown in 323 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 324 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 325 * RegistryName name = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); 326 * DeviceRegistry response = deviceManagerClient.getDeviceRegistry(name); 327 * } 328 * }</pre> 329 * 330 * @param name Required. The name of the device registry. For example, 331 * `projects/example-project/locations/us-central1/registries/my-registry`. 332 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 333 */ getDeviceRegistry(RegistryName name)334 public final DeviceRegistry getDeviceRegistry(RegistryName name) { 335 GetDeviceRegistryRequest request = 336 GetDeviceRegistryRequest.newBuilder() 337 .setName(name == null ? null : name.toString()) 338 .build(); 339 return getDeviceRegistry(request); 340 } 341 342 // AUTO-GENERATED DOCUMENTATION AND METHOD. 343 /** 344 * Gets a device registry configuration. 345 * 346 * <p>Sample code: 347 * 348 * <pre>{@code 349 * // This snippet has been automatically generated and should be regarded as a code template only. 350 * // It will require modifications to work: 351 * // - It may require correct/in-range values for request initialization. 352 * // - It may require specifying regional endpoints when creating the service client as shown in 353 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 354 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 355 * String name = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString(); 356 * DeviceRegistry response = deviceManagerClient.getDeviceRegistry(name); 357 * } 358 * }</pre> 359 * 360 * @param name Required. The name of the device registry. For example, 361 * `projects/example-project/locations/us-central1/registries/my-registry`. 362 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 363 */ getDeviceRegistry(String name)364 public final DeviceRegistry getDeviceRegistry(String name) { 365 GetDeviceRegistryRequest request = GetDeviceRegistryRequest.newBuilder().setName(name).build(); 366 return getDeviceRegistry(request); 367 } 368 369 // AUTO-GENERATED DOCUMENTATION AND METHOD. 370 /** 371 * Gets a device registry configuration. 372 * 373 * <p>Sample code: 374 * 375 * <pre>{@code 376 * // This snippet has been automatically generated and should be regarded as a code template only. 377 * // It will require modifications to work: 378 * // - It may require correct/in-range values for request initialization. 379 * // - It may require specifying regional endpoints when creating the service client as shown in 380 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 381 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 382 * GetDeviceRegistryRequest request = 383 * GetDeviceRegistryRequest.newBuilder() 384 * .setName(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) 385 * .build(); 386 * DeviceRegistry response = deviceManagerClient.getDeviceRegistry(request); 387 * } 388 * }</pre> 389 * 390 * @param request The request object containing all of the parameters for the API call. 391 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 392 */ getDeviceRegistry(GetDeviceRegistryRequest request)393 public final DeviceRegistry getDeviceRegistry(GetDeviceRegistryRequest request) { 394 return getDeviceRegistryCallable().call(request); 395 } 396 397 // AUTO-GENERATED DOCUMENTATION AND METHOD. 398 /** 399 * Gets a device registry configuration. 400 * 401 * <p>Sample code: 402 * 403 * <pre>{@code 404 * // This snippet has been automatically generated and should be regarded as a code template only. 405 * // It will require modifications to work: 406 * // - It may require correct/in-range values for request initialization. 407 * // - It may require specifying regional endpoints when creating the service client as shown in 408 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 409 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 410 * GetDeviceRegistryRequest request = 411 * GetDeviceRegistryRequest.newBuilder() 412 * .setName(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) 413 * .build(); 414 * ApiFuture<DeviceRegistry> future = 415 * deviceManagerClient.getDeviceRegistryCallable().futureCall(request); 416 * // Do something. 417 * DeviceRegistry response = future.get(); 418 * } 419 * }</pre> 420 */ getDeviceRegistryCallable()421 public final UnaryCallable<GetDeviceRegistryRequest, DeviceRegistry> getDeviceRegistryCallable() { 422 return stub.getDeviceRegistryCallable(); 423 } 424 425 // AUTO-GENERATED DOCUMENTATION AND METHOD. 426 /** 427 * Updates a device registry configuration. 428 * 429 * <p>Sample code: 430 * 431 * <pre>{@code 432 * // This snippet has been automatically generated and should be regarded as a code template only. 433 * // It will require modifications to work: 434 * // - It may require correct/in-range values for request initialization. 435 * // - It may require specifying regional endpoints when creating the service client as shown in 436 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 437 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 438 * DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build(); 439 * FieldMask updateMask = FieldMask.newBuilder().build(); 440 * DeviceRegistry response = 441 * deviceManagerClient.updateDeviceRegistry(deviceRegistry, updateMask); 442 * } 443 * }</pre> 444 * 445 * @param deviceRegistry Required. The new values for the device registry. The `id` field must be 446 * empty, and the `name` field must indicate the path of the resource. For example, 447 * `projects/example-project/locations/us-central1/registries/my-registry`. 448 * @param updateMask Required. Only updates the `device_registry` fields indicated by this mask. 449 * The field mask must not be empty, and it must not contain fields that are immutable or only 450 * set by the server. Mutable top-level fields: `event_notification_config`, `http_config`, 451 * `mqtt_config`, and `state_notification_config`. 452 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 453 */ updateDeviceRegistry( DeviceRegistry deviceRegistry, FieldMask updateMask)454 public final DeviceRegistry updateDeviceRegistry( 455 DeviceRegistry deviceRegistry, FieldMask updateMask) { 456 UpdateDeviceRegistryRequest request = 457 UpdateDeviceRegistryRequest.newBuilder() 458 .setDeviceRegistry(deviceRegistry) 459 .setUpdateMask(updateMask) 460 .build(); 461 return updateDeviceRegistry(request); 462 } 463 464 // AUTO-GENERATED DOCUMENTATION AND METHOD. 465 /** 466 * Updates a device registry configuration. 467 * 468 * <p>Sample code: 469 * 470 * <pre>{@code 471 * // This snippet has been automatically generated and should be regarded as a code template only. 472 * // It will require modifications to work: 473 * // - It may require correct/in-range values for request initialization. 474 * // - It may require specifying regional endpoints when creating the service client as shown in 475 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 476 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 477 * UpdateDeviceRegistryRequest request = 478 * UpdateDeviceRegistryRequest.newBuilder() 479 * .setDeviceRegistry(DeviceRegistry.newBuilder().build()) 480 * .setUpdateMask(FieldMask.newBuilder().build()) 481 * .build(); 482 * DeviceRegistry response = deviceManagerClient.updateDeviceRegistry(request); 483 * } 484 * }</pre> 485 * 486 * @param request The request object containing all of the parameters for the API call. 487 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 488 */ updateDeviceRegistry(UpdateDeviceRegistryRequest request)489 public final DeviceRegistry updateDeviceRegistry(UpdateDeviceRegistryRequest request) { 490 return updateDeviceRegistryCallable().call(request); 491 } 492 493 // AUTO-GENERATED DOCUMENTATION AND METHOD. 494 /** 495 * Updates a device registry configuration. 496 * 497 * <p>Sample code: 498 * 499 * <pre>{@code 500 * // This snippet has been automatically generated and should be regarded as a code template only. 501 * // It will require modifications to work: 502 * // - It may require correct/in-range values for request initialization. 503 * // - It may require specifying regional endpoints when creating the service client as shown in 504 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 505 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 506 * UpdateDeviceRegistryRequest request = 507 * UpdateDeviceRegistryRequest.newBuilder() 508 * .setDeviceRegistry(DeviceRegistry.newBuilder().build()) 509 * .setUpdateMask(FieldMask.newBuilder().build()) 510 * .build(); 511 * ApiFuture<DeviceRegistry> future = 512 * deviceManagerClient.updateDeviceRegistryCallable().futureCall(request); 513 * // Do something. 514 * DeviceRegistry response = future.get(); 515 * } 516 * }</pre> 517 */ 518 public final UnaryCallable<UpdateDeviceRegistryRequest, DeviceRegistry> updateDeviceRegistryCallable()519 updateDeviceRegistryCallable() { 520 return stub.updateDeviceRegistryCallable(); 521 } 522 523 // AUTO-GENERATED DOCUMENTATION AND METHOD. 524 /** 525 * Deletes a device registry configuration. 526 * 527 * <p>Sample code: 528 * 529 * <pre>{@code 530 * // This snippet has been automatically generated and should be regarded as a code template only. 531 * // It will require modifications to work: 532 * // - It may require correct/in-range values for request initialization. 533 * // - It may require specifying regional endpoints when creating the service client as shown in 534 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 535 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 536 * RegistryName name = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); 537 * deviceManagerClient.deleteDeviceRegistry(name); 538 * } 539 * }</pre> 540 * 541 * @param name Required. The name of the device registry. For example, 542 * `projects/example-project/locations/us-central1/registries/my-registry`. 543 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 544 */ deleteDeviceRegistry(RegistryName name)545 public final void deleteDeviceRegistry(RegistryName name) { 546 DeleteDeviceRegistryRequest request = 547 DeleteDeviceRegistryRequest.newBuilder() 548 .setName(name == null ? null : name.toString()) 549 .build(); 550 deleteDeviceRegistry(request); 551 } 552 553 // AUTO-GENERATED DOCUMENTATION AND METHOD. 554 /** 555 * Deletes a device registry configuration. 556 * 557 * <p>Sample code: 558 * 559 * <pre>{@code 560 * // This snippet has been automatically generated and should be regarded as a code template only. 561 * // It will require modifications to work: 562 * // - It may require correct/in-range values for request initialization. 563 * // - It may require specifying regional endpoints when creating the service client as shown in 564 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 565 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 566 * String name = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString(); 567 * deviceManagerClient.deleteDeviceRegistry(name); 568 * } 569 * }</pre> 570 * 571 * @param name Required. The name of the device registry. For example, 572 * `projects/example-project/locations/us-central1/registries/my-registry`. 573 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 574 */ deleteDeviceRegistry(String name)575 public final void deleteDeviceRegistry(String name) { 576 DeleteDeviceRegistryRequest request = 577 DeleteDeviceRegistryRequest.newBuilder().setName(name).build(); 578 deleteDeviceRegistry(request); 579 } 580 581 // AUTO-GENERATED DOCUMENTATION AND METHOD. 582 /** 583 * Deletes a device registry configuration. 584 * 585 * <p>Sample code: 586 * 587 * <pre>{@code 588 * // This snippet has been automatically generated and should be regarded as a code template only. 589 * // It will require modifications to work: 590 * // - It may require correct/in-range values for request initialization. 591 * // - It may require specifying regional endpoints when creating the service client as shown in 592 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 593 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 594 * DeleteDeviceRegistryRequest request = 595 * DeleteDeviceRegistryRequest.newBuilder() 596 * .setName(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) 597 * .build(); 598 * deviceManagerClient.deleteDeviceRegistry(request); 599 * } 600 * }</pre> 601 * 602 * @param request The request object containing all of the parameters for the API call. 603 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 604 */ deleteDeviceRegistry(DeleteDeviceRegistryRequest request)605 public final void deleteDeviceRegistry(DeleteDeviceRegistryRequest request) { 606 deleteDeviceRegistryCallable().call(request); 607 } 608 609 // AUTO-GENERATED DOCUMENTATION AND METHOD. 610 /** 611 * Deletes a device registry configuration. 612 * 613 * <p>Sample code: 614 * 615 * <pre>{@code 616 * // This snippet has been automatically generated and should be regarded as a code template only. 617 * // It will require modifications to work: 618 * // - It may require correct/in-range values for request initialization. 619 * // - It may require specifying regional endpoints when creating the service client as shown in 620 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 621 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 622 * DeleteDeviceRegistryRequest request = 623 * DeleteDeviceRegistryRequest.newBuilder() 624 * .setName(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) 625 * .build(); 626 * ApiFuture<Empty> future = 627 * deviceManagerClient.deleteDeviceRegistryCallable().futureCall(request); 628 * // Do something. 629 * future.get(); 630 * } 631 * }</pre> 632 */ deleteDeviceRegistryCallable()633 public final UnaryCallable<DeleteDeviceRegistryRequest, Empty> deleteDeviceRegistryCallable() { 634 return stub.deleteDeviceRegistryCallable(); 635 } 636 637 // AUTO-GENERATED DOCUMENTATION AND METHOD. 638 /** 639 * Lists device registries. 640 * 641 * <p>Sample code: 642 * 643 * <pre>{@code 644 * // This snippet has been automatically generated and should be regarded as a code template only. 645 * // It will require modifications to work: 646 * // - It may require correct/in-range values for request initialization. 647 * // - It may require specifying regional endpoints when creating the service client as shown in 648 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 649 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 650 * LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); 651 * for (DeviceRegistry element : deviceManagerClient.listDeviceRegistries(parent).iterateAll()) { 652 * // doThingsWith(element); 653 * } 654 * } 655 * }</pre> 656 * 657 * @param parent Required. The project and cloud region path. For example, 658 * `projects/example-project/locations/us-central1`. 659 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 660 */ listDeviceRegistries(LocationName parent)661 public final ListDeviceRegistriesPagedResponse listDeviceRegistries(LocationName parent) { 662 ListDeviceRegistriesRequest request = 663 ListDeviceRegistriesRequest.newBuilder() 664 .setParent(parent == null ? null : parent.toString()) 665 .build(); 666 return listDeviceRegistries(request); 667 } 668 669 // AUTO-GENERATED DOCUMENTATION AND METHOD. 670 /** 671 * Lists device registries. 672 * 673 * <p>Sample code: 674 * 675 * <pre>{@code 676 * // This snippet has been automatically generated and should be regarded as a code template only. 677 * // It will require modifications to work: 678 * // - It may require correct/in-range values for request initialization. 679 * // - It may require specifying regional endpoints when creating the service client as shown in 680 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 681 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 682 * String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); 683 * for (DeviceRegistry element : deviceManagerClient.listDeviceRegistries(parent).iterateAll()) { 684 * // doThingsWith(element); 685 * } 686 * } 687 * }</pre> 688 * 689 * @param parent Required. The project and cloud region path. For example, 690 * `projects/example-project/locations/us-central1`. 691 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 692 */ listDeviceRegistries(String parent)693 public final ListDeviceRegistriesPagedResponse listDeviceRegistries(String parent) { 694 ListDeviceRegistriesRequest request = 695 ListDeviceRegistriesRequest.newBuilder().setParent(parent).build(); 696 return listDeviceRegistries(request); 697 } 698 699 // AUTO-GENERATED DOCUMENTATION AND METHOD. 700 /** 701 * Lists device registries. 702 * 703 * <p>Sample code: 704 * 705 * <pre>{@code 706 * // This snippet has been automatically generated and should be regarded as a code template only. 707 * // It will require modifications to work: 708 * // - It may require correct/in-range values for request initialization. 709 * // - It may require specifying regional endpoints when creating the service client as shown in 710 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 711 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 712 * ListDeviceRegistriesRequest request = 713 * ListDeviceRegistriesRequest.newBuilder() 714 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 715 * .setPageSize(883849137) 716 * .setPageToken("pageToken873572522") 717 * .build(); 718 * for (DeviceRegistry element : 719 * deviceManagerClient.listDeviceRegistries(request).iterateAll()) { 720 * // doThingsWith(element); 721 * } 722 * } 723 * }</pre> 724 * 725 * @param request The request object containing all of the parameters for the API call. 726 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 727 */ listDeviceRegistries( ListDeviceRegistriesRequest request)728 public final ListDeviceRegistriesPagedResponse listDeviceRegistries( 729 ListDeviceRegistriesRequest request) { 730 return listDeviceRegistriesPagedCallable().call(request); 731 } 732 733 // AUTO-GENERATED DOCUMENTATION AND METHOD. 734 /** 735 * Lists device registries. 736 * 737 * <p>Sample code: 738 * 739 * <pre>{@code 740 * // This snippet has been automatically generated and should be regarded as a code template only. 741 * // It will require modifications to work: 742 * // - It may require correct/in-range values for request initialization. 743 * // - It may require specifying regional endpoints when creating the service client as shown in 744 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 745 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 746 * ListDeviceRegistriesRequest request = 747 * ListDeviceRegistriesRequest.newBuilder() 748 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 749 * .setPageSize(883849137) 750 * .setPageToken("pageToken873572522") 751 * .build(); 752 * ApiFuture<DeviceRegistry> future = 753 * deviceManagerClient.listDeviceRegistriesPagedCallable().futureCall(request); 754 * // Do something. 755 * for (DeviceRegistry element : future.get().iterateAll()) { 756 * // doThingsWith(element); 757 * } 758 * } 759 * }</pre> 760 */ 761 public final UnaryCallable<ListDeviceRegistriesRequest, ListDeviceRegistriesPagedResponse> listDeviceRegistriesPagedCallable()762 listDeviceRegistriesPagedCallable() { 763 return stub.listDeviceRegistriesPagedCallable(); 764 } 765 766 // AUTO-GENERATED DOCUMENTATION AND METHOD. 767 /** 768 * Lists device registries. 769 * 770 * <p>Sample code: 771 * 772 * <pre>{@code 773 * // This snippet has been automatically generated and should be regarded as a code template only. 774 * // It will require modifications to work: 775 * // - It may require correct/in-range values for request initialization. 776 * // - It may require specifying regional endpoints when creating the service client as shown in 777 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 778 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 779 * ListDeviceRegistriesRequest request = 780 * ListDeviceRegistriesRequest.newBuilder() 781 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 782 * .setPageSize(883849137) 783 * .setPageToken("pageToken873572522") 784 * .build(); 785 * while (true) { 786 * ListDeviceRegistriesResponse response = 787 * deviceManagerClient.listDeviceRegistriesCallable().call(request); 788 * for (DeviceRegistry element : response.getDeviceRegistriesList()) { 789 * // doThingsWith(element); 790 * } 791 * String nextPageToken = response.getNextPageToken(); 792 * if (!Strings.isNullOrEmpty(nextPageToken)) { 793 * request = request.toBuilder().setPageToken(nextPageToken).build(); 794 * } else { 795 * break; 796 * } 797 * } 798 * } 799 * }</pre> 800 */ 801 public final UnaryCallable<ListDeviceRegistriesRequest, ListDeviceRegistriesResponse> listDeviceRegistriesCallable()802 listDeviceRegistriesCallable() { 803 return stub.listDeviceRegistriesCallable(); 804 } 805 806 // AUTO-GENERATED DOCUMENTATION AND METHOD. 807 /** 808 * Creates a device in a device registry. 809 * 810 * <p>Sample code: 811 * 812 * <pre>{@code 813 * // This snippet has been automatically generated and should be regarded as a code template only. 814 * // It will require modifications to work: 815 * // - It may require correct/in-range values for request initialization. 816 * // - It may require specifying regional endpoints when creating the service client as shown in 817 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 818 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 819 * RegistryName parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); 820 * Device device = Device.newBuilder().build(); 821 * Device response = deviceManagerClient.createDevice(parent, device); 822 * } 823 * }</pre> 824 * 825 * @param parent Required. The name of the device registry where this device should be created. 826 * For example, `projects/example-project/locations/us-central1/registries/my-registry`. 827 * @param device Required. The device registration details. The field `name` must be empty. The 828 * server generates `name` from the device registry `id` and the `parent` field. 829 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 830 */ createDevice(RegistryName parent, Device device)831 public final Device createDevice(RegistryName parent, Device device) { 832 CreateDeviceRequest request = 833 CreateDeviceRequest.newBuilder() 834 .setParent(parent == null ? null : parent.toString()) 835 .setDevice(device) 836 .build(); 837 return createDevice(request); 838 } 839 840 // AUTO-GENERATED DOCUMENTATION AND METHOD. 841 /** 842 * Creates a device in a device registry. 843 * 844 * <p>Sample code: 845 * 846 * <pre>{@code 847 * // This snippet has been automatically generated and should be regarded as a code template only. 848 * // It will require modifications to work: 849 * // - It may require correct/in-range values for request initialization. 850 * // - It may require specifying regional endpoints when creating the service client as shown in 851 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 852 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 853 * String parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString(); 854 * Device device = Device.newBuilder().build(); 855 * Device response = deviceManagerClient.createDevice(parent, device); 856 * } 857 * }</pre> 858 * 859 * @param parent Required. The name of the device registry where this device should be created. 860 * For example, `projects/example-project/locations/us-central1/registries/my-registry`. 861 * @param device Required. The device registration details. The field `name` must be empty. The 862 * server generates `name` from the device registry `id` and the `parent` field. 863 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 864 */ createDevice(String parent, Device device)865 public final Device createDevice(String parent, Device device) { 866 CreateDeviceRequest request = 867 CreateDeviceRequest.newBuilder().setParent(parent).setDevice(device).build(); 868 return createDevice(request); 869 } 870 871 // AUTO-GENERATED DOCUMENTATION AND METHOD. 872 /** 873 * Creates a device in a device registry. 874 * 875 * <p>Sample code: 876 * 877 * <pre>{@code 878 * // This snippet has been automatically generated and should be regarded as a code template only. 879 * // It will require modifications to work: 880 * // - It may require correct/in-range values for request initialization. 881 * // - It may require specifying regional endpoints when creating the service client as shown in 882 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 883 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 884 * CreateDeviceRequest request = 885 * CreateDeviceRequest.newBuilder() 886 * .setParent(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) 887 * .setDevice(Device.newBuilder().build()) 888 * .build(); 889 * Device response = deviceManagerClient.createDevice(request); 890 * } 891 * }</pre> 892 * 893 * @param request The request object containing all of the parameters for the API call. 894 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 895 */ createDevice(CreateDeviceRequest request)896 public final Device createDevice(CreateDeviceRequest request) { 897 return createDeviceCallable().call(request); 898 } 899 900 // AUTO-GENERATED DOCUMENTATION AND METHOD. 901 /** 902 * Creates a device in a device registry. 903 * 904 * <p>Sample code: 905 * 906 * <pre>{@code 907 * // This snippet has been automatically generated and should be regarded as a code template only. 908 * // It will require modifications to work: 909 * // - It may require correct/in-range values for request initialization. 910 * // - It may require specifying regional endpoints when creating the service client as shown in 911 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 912 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 913 * CreateDeviceRequest request = 914 * CreateDeviceRequest.newBuilder() 915 * .setParent(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) 916 * .setDevice(Device.newBuilder().build()) 917 * .build(); 918 * ApiFuture<Device> future = deviceManagerClient.createDeviceCallable().futureCall(request); 919 * // Do something. 920 * Device response = future.get(); 921 * } 922 * }</pre> 923 */ createDeviceCallable()924 public final UnaryCallable<CreateDeviceRequest, Device> createDeviceCallable() { 925 return stub.createDeviceCallable(); 926 } 927 928 // AUTO-GENERATED DOCUMENTATION AND METHOD. 929 /** 930 * Gets details about a device. 931 * 932 * <p>Sample code: 933 * 934 * <pre>{@code 935 * // This snippet has been automatically generated and should be regarded as a code template only. 936 * // It will require modifications to work: 937 * // - It may require correct/in-range values for request initialization. 938 * // - It may require specifying regional endpoints when creating the service client as shown in 939 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 940 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 941 * DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]"); 942 * Device response = deviceManagerClient.getDevice(name); 943 * } 944 * }</pre> 945 * 946 * @param name Required. The name of the device. For example, 947 * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or 948 * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. 949 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 950 */ getDevice(DeviceName name)951 public final Device getDevice(DeviceName name) { 952 GetDeviceRequest request = 953 GetDeviceRequest.newBuilder().setName(name == null ? null : name.toString()).build(); 954 return getDevice(request); 955 } 956 957 // AUTO-GENERATED DOCUMENTATION AND METHOD. 958 /** 959 * Gets details about a device. 960 * 961 * <p>Sample code: 962 * 963 * <pre>{@code 964 * // This snippet has been automatically generated and should be regarded as a code template only. 965 * // It will require modifications to work: 966 * // - It may require correct/in-range values for request initialization. 967 * // - It may require specifying regional endpoints when creating the service client as shown in 968 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 969 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 970 * String name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString(); 971 * Device response = deviceManagerClient.getDevice(name); 972 * } 973 * }</pre> 974 * 975 * @param name Required. The name of the device. For example, 976 * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or 977 * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. 978 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 979 */ getDevice(String name)980 public final Device getDevice(String name) { 981 GetDeviceRequest request = GetDeviceRequest.newBuilder().setName(name).build(); 982 return getDevice(request); 983 } 984 985 // AUTO-GENERATED DOCUMENTATION AND METHOD. 986 /** 987 * Gets details about a device. 988 * 989 * <p>Sample code: 990 * 991 * <pre>{@code 992 * // This snippet has been automatically generated and should be regarded as a code template only. 993 * // It will require modifications to work: 994 * // - It may require correct/in-range values for request initialization. 995 * // - It may require specifying regional endpoints when creating the service client as shown in 996 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 997 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 998 * GetDeviceRequest request = 999 * GetDeviceRequest.newBuilder() 1000 * .setName( 1001 * DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString()) 1002 * .setFieldMask(FieldMask.newBuilder().build()) 1003 * .build(); 1004 * Device response = deviceManagerClient.getDevice(request); 1005 * } 1006 * }</pre> 1007 * 1008 * @param request The request object containing all of the parameters for the API call. 1009 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1010 */ getDevice(GetDeviceRequest request)1011 public final Device getDevice(GetDeviceRequest request) { 1012 return getDeviceCallable().call(request); 1013 } 1014 1015 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1016 /** 1017 * Gets details about a device. 1018 * 1019 * <p>Sample code: 1020 * 1021 * <pre>{@code 1022 * // This snippet has been automatically generated and should be regarded as a code template only. 1023 * // It will require modifications to work: 1024 * // - It may require correct/in-range values for request initialization. 1025 * // - It may require specifying regional endpoints when creating the service client as shown in 1026 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1027 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 1028 * GetDeviceRequest request = 1029 * GetDeviceRequest.newBuilder() 1030 * .setName( 1031 * DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString()) 1032 * .setFieldMask(FieldMask.newBuilder().build()) 1033 * .build(); 1034 * ApiFuture<Device> future = deviceManagerClient.getDeviceCallable().futureCall(request); 1035 * // Do something. 1036 * Device response = future.get(); 1037 * } 1038 * }</pre> 1039 */ getDeviceCallable()1040 public final UnaryCallable<GetDeviceRequest, Device> getDeviceCallable() { 1041 return stub.getDeviceCallable(); 1042 } 1043 1044 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1045 /** 1046 * Updates a device. 1047 * 1048 * <p>Sample code: 1049 * 1050 * <pre>{@code 1051 * // This snippet has been automatically generated and should be regarded as a code template only. 1052 * // It will require modifications to work: 1053 * // - It may require correct/in-range values for request initialization. 1054 * // - It may require specifying regional endpoints when creating the service client as shown in 1055 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1056 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 1057 * Device device = Device.newBuilder().build(); 1058 * FieldMask updateMask = FieldMask.newBuilder().build(); 1059 * Device response = deviceManagerClient.updateDevice(device, updateMask); 1060 * } 1061 * }</pre> 1062 * 1063 * @param device Required. The new values for the device. The `id` and `num_id` fields must be 1064 * empty, and the field `name` must specify the name path. For example, 1065 * `projects/p0/locations/us-central1/registries/registry0/devices/device0`or 1066 * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. 1067 * @param updateMask Required. Only updates the `device` fields indicated by this mask. The field 1068 * mask must not be empty, and it must not contain fields that are immutable or only set by 1069 * the server. Mutable top-level fields: `credentials`, `blocked`, and `metadata` 1070 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1071 */ updateDevice(Device device, FieldMask updateMask)1072 public final Device updateDevice(Device device, FieldMask updateMask) { 1073 UpdateDeviceRequest request = 1074 UpdateDeviceRequest.newBuilder().setDevice(device).setUpdateMask(updateMask).build(); 1075 return updateDevice(request); 1076 } 1077 1078 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1079 /** 1080 * Updates a device. 1081 * 1082 * <p>Sample code: 1083 * 1084 * <pre>{@code 1085 * // This snippet has been automatically generated and should be regarded as a code template only. 1086 * // It will require modifications to work: 1087 * // - It may require correct/in-range values for request initialization. 1088 * // - It may require specifying regional endpoints when creating the service client as shown in 1089 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1090 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 1091 * UpdateDeviceRequest request = 1092 * UpdateDeviceRequest.newBuilder() 1093 * .setDevice(Device.newBuilder().build()) 1094 * .setUpdateMask(FieldMask.newBuilder().build()) 1095 * .build(); 1096 * Device response = deviceManagerClient.updateDevice(request); 1097 * } 1098 * }</pre> 1099 * 1100 * @param request The request object containing all of the parameters for the API call. 1101 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1102 */ updateDevice(UpdateDeviceRequest request)1103 public final Device updateDevice(UpdateDeviceRequest request) { 1104 return updateDeviceCallable().call(request); 1105 } 1106 1107 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1108 /** 1109 * Updates a device. 1110 * 1111 * <p>Sample code: 1112 * 1113 * <pre>{@code 1114 * // This snippet has been automatically generated and should be regarded as a code template only. 1115 * // It will require modifications to work: 1116 * // - It may require correct/in-range values for request initialization. 1117 * // - It may require specifying regional endpoints when creating the service client as shown in 1118 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1119 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 1120 * UpdateDeviceRequest request = 1121 * UpdateDeviceRequest.newBuilder() 1122 * .setDevice(Device.newBuilder().build()) 1123 * .setUpdateMask(FieldMask.newBuilder().build()) 1124 * .build(); 1125 * ApiFuture<Device> future = deviceManagerClient.updateDeviceCallable().futureCall(request); 1126 * // Do something. 1127 * Device response = future.get(); 1128 * } 1129 * }</pre> 1130 */ updateDeviceCallable()1131 public final UnaryCallable<UpdateDeviceRequest, Device> updateDeviceCallable() { 1132 return stub.updateDeviceCallable(); 1133 } 1134 1135 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1136 /** 1137 * Deletes a device. 1138 * 1139 * <p>Sample code: 1140 * 1141 * <pre>{@code 1142 * // This snippet has been automatically generated and should be regarded as a code template only. 1143 * // It will require modifications to work: 1144 * // - It may require correct/in-range values for request initialization. 1145 * // - It may require specifying regional endpoints when creating the service client as shown in 1146 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1147 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 1148 * DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]"); 1149 * deviceManagerClient.deleteDevice(name); 1150 * } 1151 * }</pre> 1152 * 1153 * @param name Required. The name of the device. For example, 1154 * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or 1155 * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. 1156 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1157 */ deleteDevice(DeviceName name)1158 public final void deleteDevice(DeviceName name) { 1159 DeleteDeviceRequest request = 1160 DeleteDeviceRequest.newBuilder().setName(name == null ? null : name.toString()).build(); 1161 deleteDevice(request); 1162 } 1163 1164 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1165 /** 1166 * Deletes a device. 1167 * 1168 * <p>Sample code: 1169 * 1170 * <pre>{@code 1171 * // This snippet has been automatically generated and should be regarded as a code template only. 1172 * // It will require modifications to work: 1173 * // - It may require correct/in-range values for request initialization. 1174 * // - It may require specifying regional endpoints when creating the service client as shown in 1175 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1176 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 1177 * String name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString(); 1178 * deviceManagerClient.deleteDevice(name); 1179 * } 1180 * }</pre> 1181 * 1182 * @param name Required. The name of the device. For example, 1183 * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or 1184 * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. 1185 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1186 */ deleteDevice(String name)1187 public final void deleteDevice(String name) { 1188 DeleteDeviceRequest request = DeleteDeviceRequest.newBuilder().setName(name).build(); 1189 deleteDevice(request); 1190 } 1191 1192 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1193 /** 1194 * Deletes a device. 1195 * 1196 * <p>Sample code: 1197 * 1198 * <pre>{@code 1199 * // This snippet has been automatically generated and should be regarded as a code template only. 1200 * // It will require modifications to work: 1201 * // - It may require correct/in-range values for request initialization. 1202 * // - It may require specifying regional endpoints when creating the service client as shown in 1203 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1204 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 1205 * DeleteDeviceRequest request = 1206 * DeleteDeviceRequest.newBuilder() 1207 * .setName( 1208 * DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString()) 1209 * .build(); 1210 * deviceManagerClient.deleteDevice(request); 1211 * } 1212 * }</pre> 1213 * 1214 * @param request The request object containing all of the parameters for the API call. 1215 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1216 */ deleteDevice(DeleteDeviceRequest request)1217 public final void deleteDevice(DeleteDeviceRequest request) { 1218 deleteDeviceCallable().call(request); 1219 } 1220 1221 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1222 /** 1223 * Deletes a device. 1224 * 1225 * <p>Sample code: 1226 * 1227 * <pre>{@code 1228 * // This snippet has been automatically generated and should be regarded as a code template only. 1229 * // It will require modifications to work: 1230 * // - It may require correct/in-range values for request initialization. 1231 * // - It may require specifying regional endpoints when creating the service client as shown in 1232 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1233 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 1234 * DeleteDeviceRequest request = 1235 * DeleteDeviceRequest.newBuilder() 1236 * .setName( 1237 * DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString()) 1238 * .build(); 1239 * ApiFuture<Empty> future = deviceManagerClient.deleteDeviceCallable().futureCall(request); 1240 * // Do something. 1241 * future.get(); 1242 * } 1243 * }</pre> 1244 */ deleteDeviceCallable()1245 public final UnaryCallable<DeleteDeviceRequest, Empty> deleteDeviceCallable() { 1246 return stub.deleteDeviceCallable(); 1247 } 1248 1249 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1250 /** 1251 * List devices in a device registry. 1252 * 1253 * <p>Sample code: 1254 * 1255 * <pre>{@code 1256 * // This snippet has been automatically generated and should be regarded as a code template only. 1257 * // It will require modifications to work: 1258 * // - It may require correct/in-range values for request initialization. 1259 * // - It may require specifying regional endpoints when creating the service client as shown in 1260 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1261 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 1262 * RegistryName parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); 1263 * for (Device element : deviceManagerClient.listDevices(parent).iterateAll()) { 1264 * // doThingsWith(element); 1265 * } 1266 * } 1267 * }</pre> 1268 * 1269 * @param parent Required. The device registry path. Required. For example, 1270 * `projects/my-project/locations/us-central1/registries/my-registry`. 1271 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1272 */ listDevices(RegistryName parent)1273 public final ListDevicesPagedResponse listDevices(RegistryName parent) { 1274 ListDevicesRequest request = 1275 ListDevicesRequest.newBuilder() 1276 .setParent(parent == null ? null : parent.toString()) 1277 .build(); 1278 return listDevices(request); 1279 } 1280 1281 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1282 /** 1283 * List devices in a device registry. 1284 * 1285 * <p>Sample code: 1286 * 1287 * <pre>{@code 1288 * // This snippet has been automatically generated and should be regarded as a code template only. 1289 * // It will require modifications to work: 1290 * // - It may require correct/in-range values for request initialization. 1291 * // - It may require specifying regional endpoints when creating the service client as shown in 1292 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1293 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 1294 * String parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString(); 1295 * for (Device element : deviceManagerClient.listDevices(parent).iterateAll()) { 1296 * // doThingsWith(element); 1297 * } 1298 * } 1299 * }</pre> 1300 * 1301 * @param parent Required. The device registry path. Required. For example, 1302 * `projects/my-project/locations/us-central1/registries/my-registry`. 1303 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1304 */ listDevices(String parent)1305 public final ListDevicesPagedResponse listDevices(String parent) { 1306 ListDevicesRequest request = ListDevicesRequest.newBuilder().setParent(parent).build(); 1307 return listDevices(request); 1308 } 1309 1310 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1311 /** 1312 * List devices in a device registry. 1313 * 1314 * <p>Sample code: 1315 * 1316 * <pre>{@code 1317 * // This snippet has been automatically generated and should be regarded as a code template only. 1318 * // It will require modifications to work: 1319 * // - It may require correct/in-range values for request initialization. 1320 * // - It may require specifying regional endpoints when creating the service client as shown in 1321 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1322 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 1323 * ListDevicesRequest request = 1324 * ListDevicesRequest.newBuilder() 1325 * .setParent(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) 1326 * .addAllDeviceNumIds(new ArrayList<Long>()) 1327 * .addAllDeviceIds(new ArrayList<String>()) 1328 * .setFieldMask(FieldMask.newBuilder().build()) 1329 * .setGatewayListOptions(GatewayListOptions.newBuilder().build()) 1330 * .setPageSize(883849137) 1331 * .setPageToken("pageToken873572522") 1332 * .build(); 1333 * for (Device element : deviceManagerClient.listDevices(request).iterateAll()) { 1334 * // doThingsWith(element); 1335 * } 1336 * } 1337 * }</pre> 1338 * 1339 * @param request The request object containing all of the parameters for the API call. 1340 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1341 */ listDevices(ListDevicesRequest request)1342 public final ListDevicesPagedResponse listDevices(ListDevicesRequest request) { 1343 return listDevicesPagedCallable().call(request); 1344 } 1345 1346 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1347 /** 1348 * List devices in a device registry. 1349 * 1350 * <p>Sample code: 1351 * 1352 * <pre>{@code 1353 * // This snippet has been automatically generated and should be regarded as a code template only. 1354 * // It will require modifications to work: 1355 * // - It may require correct/in-range values for request initialization. 1356 * // - It may require specifying regional endpoints when creating the service client as shown in 1357 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1358 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 1359 * ListDevicesRequest request = 1360 * ListDevicesRequest.newBuilder() 1361 * .setParent(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) 1362 * .addAllDeviceNumIds(new ArrayList<Long>()) 1363 * .addAllDeviceIds(new ArrayList<String>()) 1364 * .setFieldMask(FieldMask.newBuilder().build()) 1365 * .setGatewayListOptions(GatewayListOptions.newBuilder().build()) 1366 * .setPageSize(883849137) 1367 * .setPageToken("pageToken873572522") 1368 * .build(); 1369 * ApiFuture<Device> future = deviceManagerClient.listDevicesPagedCallable().futureCall(request); 1370 * // Do something. 1371 * for (Device element : future.get().iterateAll()) { 1372 * // doThingsWith(element); 1373 * } 1374 * } 1375 * }</pre> 1376 */ 1377 public final UnaryCallable<ListDevicesRequest, ListDevicesPagedResponse> listDevicesPagedCallable()1378 listDevicesPagedCallable() { 1379 return stub.listDevicesPagedCallable(); 1380 } 1381 1382 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1383 /** 1384 * List devices in a device registry. 1385 * 1386 * <p>Sample code: 1387 * 1388 * <pre>{@code 1389 * // This snippet has been automatically generated and should be regarded as a code template only. 1390 * // It will require modifications to work: 1391 * // - It may require correct/in-range values for request initialization. 1392 * // - It may require specifying regional endpoints when creating the service client as shown in 1393 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1394 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 1395 * ListDevicesRequest request = 1396 * ListDevicesRequest.newBuilder() 1397 * .setParent(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) 1398 * .addAllDeviceNumIds(new ArrayList<Long>()) 1399 * .addAllDeviceIds(new ArrayList<String>()) 1400 * .setFieldMask(FieldMask.newBuilder().build()) 1401 * .setGatewayListOptions(GatewayListOptions.newBuilder().build()) 1402 * .setPageSize(883849137) 1403 * .setPageToken("pageToken873572522") 1404 * .build(); 1405 * while (true) { 1406 * ListDevicesResponse response = deviceManagerClient.listDevicesCallable().call(request); 1407 * for (Device element : response.getDevicesList()) { 1408 * // doThingsWith(element); 1409 * } 1410 * String nextPageToken = response.getNextPageToken(); 1411 * if (!Strings.isNullOrEmpty(nextPageToken)) { 1412 * request = request.toBuilder().setPageToken(nextPageToken).build(); 1413 * } else { 1414 * break; 1415 * } 1416 * } 1417 * } 1418 * }</pre> 1419 */ listDevicesCallable()1420 public final UnaryCallable<ListDevicesRequest, ListDevicesResponse> listDevicesCallable() { 1421 return stub.listDevicesCallable(); 1422 } 1423 1424 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1425 /** 1426 * Modifies the configuration for the device, which is eventually sent from the Cloud IoT Core 1427 * servers. Returns the modified configuration version and its metadata. 1428 * 1429 * <p>Sample code: 1430 * 1431 * <pre>{@code 1432 * // This snippet has been automatically generated and should be regarded as a code template only. 1433 * // It will require modifications to work: 1434 * // - It may require correct/in-range values for request initialization. 1435 * // - It may require specifying regional endpoints when creating the service client as shown in 1436 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1437 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 1438 * DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]"); 1439 * ByteString binaryData = ByteString.EMPTY; 1440 * DeviceConfig response = deviceManagerClient.modifyCloudToDeviceConfig(name, binaryData); 1441 * } 1442 * }</pre> 1443 * 1444 * @param name Required. The name of the device. For example, 1445 * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or 1446 * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. 1447 * @param binaryData Required. The configuration data for the device. 1448 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1449 */ modifyCloudToDeviceConfig(DeviceName name, ByteString binaryData)1450 public final DeviceConfig modifyCloudToDeviceConfig(DeviceName name, ByteString binaryData) { 1451 ModifyCloudToDeviceConfigRequest request = 1452 ModifyCloudToDeviceConfigRequest.newBuilder() 1453 .setName(name == null ? null : name.toString()) 1454 .setBinaryData(binaryData) 1455 .build(); 1456 return modifyCloudToDeviceConfig(request); 1457 } 1458 1459 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1460 /** 1461 * Modifies the configuration for the device, which is eventually sent from the Cloud IoT Core 1462 * servers. Returns the modified configuration version and its metadata. 1463 * 1464 * <p>Sample code: 1465 * 1466 * <pre>{@code 1467 * // This snippet has been automatically generated and should be regarded as a code template only. 1468 * // It will require modifications to work: 1469 * // - It may require correct/in-range values for request initialization. 1470 * // - It may require specifying regional endpoints when creating the service client as shown in 1471 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1472 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 1473 * String name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString(); 1474 * ByteString binaryData = ByteString.EMPTY; 1475 * DeviceConfig response = deviceManagerClient.modifyCloudToDeviceConfig(name, binaryData); 1476 * } 1477 * }</pre> 1478 * 1479 * @param name Required. The name of the device. For example, 1480 * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or 1481 * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. 1482 * @param binaryData Required. The configuration data for the device. 1483 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1484 */ modifyCloudToDeviceConfig(String name, ByteString binaryData)1485 public final DeviceConfig modifyCloudToDeviceConfig(String name, ByteString binaryData) { 1486 ModifyCloudToDeviceConfigRequest request = 1487 ModifyCloudToDeviceConfigRequest.newBuilder() 1488 .setName(name) 1489 .setBinaryData(binaryData) 1490 .build(); 1491 return modifyCloudToDeviceConfig(request); 1492 } 1493 1494 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1495 /** 1496 * Modifies the configuration for the device, which is eventually sent from the Cloud IoT Core 1497 * servers. Returns the modified configuration version and its metadata. 1498 * 1499 * <p>Sample code: 1500 * 1501 * <pre>{@code 1502 * // This snippet has been automatically generated and should be regarded as a code template only. 1503 * // It will require modifications to work: 1504 * // - It may require correct/in-range values for request initialization. 1505 * // - It may require specifying regional endpoints when creating the service client as shown in 1506 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1507 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 1508 * ModifyCloudToDeviceConfigRequest request = 1509 * ModifyCloudToDeviceConfigRequest.newBuilder() 1510 * .setName( 1511 * DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString()) 1512 * .setVersionToUpdate(462348390) 1513 * .setBinaryData(ByteString.EMPTY) 1514 * .build(); 1515 * DeviceConfig response = deviceManagerClient.modifyCloudToDeviceConfig(request); 1516 * } 1517 * }</pre> 1518 * 1519 * @param request The request object containing all of the parameters for the API call. 1520 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1521 */ modifyCloudToDeviceConfig(ModifyCloudToDeviceConfigRequest request)1522 public final DeviceConfig modifyCloudToDeviceConfig(ModifyCloudToDeviceConfigRequest request) { 1523 return modifyCloudToDeviceConfigCallable().call(request); 1524 } 1525 1526 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1527 /** 1528 * Modifies the configuration for the device, which is eventually sent from the Cloud IoT Core 1529 * servers. Returns the modified configuration version and its metadata. 1530 * 1531 * <p>Sample code: 1532 * 1533 * <pre>{@code 1534 * // This snippet has been automatically generated and should be regarded as a code template only. 1535 * // It will require modifications to work: 1536 * // - It may require correct/in-range values for request initialization. 1537 * // - It may require specifying regional endpoints when creating the service client as shown in 1538 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1539 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 1540 * ModifyCloudToDeviceConfigRequest request = 1541 * ModifyCloudToDeviceConfigRequest.newBuilder() 1542 * .setName( 1543 * DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString()) 1544 * .setVersionToUpdate(462348390) 1545 * .setBinaryData(ByteString.EMPTY) 1546 * .build(); 1547 * ApiFuture<DeviceConfig> future = 1548 * deviceManagerClient.modifyCloudToDeviceConfigCallable().futureCall(request); 1549 * // Do something. 1550 * DeviceConfig response = future.get(); 1551 * } 1552 * }</pre> 1553 */ 1554 public final UnaryCallable<ModifyCloudToDeviceConfigRequest, DeviceConfig> modifyCloudToDeviceConfigCallable()1555 modifyCloudToDeviceConfigCallable() { 1556 return stub.modifyCloudToDeviceConfigCallable(); 1557 } 1558 1559 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1560 /** 1561 * Lists the last few versions of the device configuration in descending order (i.e.: newest 1562 * first). 1563 * 1564 * <p>Sample code: 1565 * 1566 * <pre>{@code 1567 * // This snippet has been automatically generated and should be regarded as a code template only. 1568 * // It will require modifications to work: 1569 * // - It may require correct/in-range values for request initialization. 1570 * // - It may require specifying regional endpoints when creating the service client as shown in 1571 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1572 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 1573 * DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]"); 1574 * ListDeviceConfigVersionsResponse response = 1575 * deviceManagerClient.listDeviceConfigVersions(name); 1576 * } 1577 * }</pre> 1578 * 1579 * @param name Required. The name of the device. For example, 1580 * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or 1581 * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. 1582 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1583 */ listDeviceConfigVersions(DeviceName name)1584 public final ListDeviceConfigVersionsResponse listDeviceConfigVersions(DeviceName name) { 1585 ListDeviceConfigVersionsRequest request = 1586 ListDeviceConfigVersionsRequest.newBuilder() 1587 .setName(name == null ? null : name.toString()) 1588 .build(); 1589 return listDeviceConfigVersions(request); 1590 } 1591 1592 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1593 /** 1594 * Lists the last few versions of the device configuration in descending order (i.e.: newest 1595 * first). 1596 * 1597 * <p>Sample code: 1598 * 1599 * <pre>{@code 1600 * // This snippet has been automatically generated and should be regarded as a code template only. 1601 * // It will require modifications to work: 1602 * // - It may require correct/in-range values for request initialization. 1603 * // - It may require specifying regional endpoints when creating the service client as shown in 1604 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1605 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 1606 * String name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString(); 1607 * ListDeviceConfigVersionsResponse response = 1608 * deviceManagerClient.listDeviceConfigVersions(name); 1609 * } 1610 * }</pre> 1611 * 1612 * @param name Required. The name of the device. For example, 1613 * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or 1614 * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. 1615 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1616 */ listDeviceConfigVersions(String name)1617 public final ListDeviceConfigVersionsResponse listDeviceConfigVersions(String name) { 1618 ListDeviceConfigVersionsRequest request = 1619 ListDeviceConfigVersionsRequest.newBuilder().setName(name).build(); 1620 return listDeviceConfigVersions(request); 1621 } 1622 1623 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1624 /** 1625 * Lists the last few versions of the device configuration in descending order (i.e.: newest 1626 * first). 1627 * 1628 * <p>Sample code: 1629 * 1630 * <pre>{@code 1631 * // This snippet has been automatically generated and should be regarded as a code template only. 1632 * // It will require modifications to work: 1633 * // - It may require correct/in-range values for request initialization. 1634 * // - It may require specifying regional endpoints when creating the service client as shown in 1635 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1636 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 1637 * ListDeviceConfigVersionsRequest request = 1638 * ListDeviceConfigVersionsRequest.newBuilder() 1639 * .setName( 1640 * DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString()) 1641 * .setNumVersions(-315385036) 1642 * .build(); 1643 * ListDeviceConfigVersionsResponse response = 1644 * deviceManagerClient.listDeviceConfigVersions(request); 1645 * } 1646 * }</pre> 1647 * 1648 * @param request The request object containing all of the parameters for the API call. 1649 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1650 */ listDeviceConfigVersions( ListDeviceConfigVersionsRequest request)1651 public final ListDeviceConfigVersionsResponse listDeviceConfigVersions( 1652 ListDeviceConfigVersionsRequest request) { 1653 return listDeviceConfigVersionsCallable().call(request); 1654 } 1655 1656 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1657 /** 1658 * Lists the last few versions of the device configuration in descending order (i.e.: newest 1659 * first). 1660 * 1661 * <p>Sample code: 1662 * 1663 * <pre>{@code 1664 * // This snippet has been automatically generated and should be regarded as a code template only. 1665 * // It will require modifications to work: 1666 * // - It may require correct/in-range values for request initialization. 1667 * // - It may require specifying regional endpoints when creating the service client as shown in 1668 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1669 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 1670 * ListDeviceConfigVersionsRequest request = 1671 * ListDeviceConfigVersionsRequest.newBuilder() 1672 * .setName( 1673 * DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString()) 1674 * .setNumVersions(-315385036) 1675 * .build(); 1676 * ApiFuture<ListDeviceConfigVersionsResponse> future = 1677 * deviceManagerClient.listDeviceConfigVersionsCallable().futureCall(request); 1678 * // Do something. 1679 * ListDeviceConfigVersionsResponse response = future.get(); 1680 * } 1681 * }</pre> 1682 */ 1683 public final UnaryCallable<ListDeviceConfigVersionsRequest, ListDeviceConfigVersionsResponse> listDeviceConfigVersionsCallable()1684 listDeviceConfigVersionsCallable() { 1685 return stub.listDeviceConfigVersionsCallable(); 1686 } 1687 1688 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1689 /** 1690 * Lists the last few versions of the device state in descending order (i.e.: newest first). 1691 * 1692 * <p>Sample code: 1693 * 1694 * <pre>{@code 1695 * // This snippet has been automatically generated and should be regarded as a code template only. 1696 * // It will require modifications to work: 1697 * // - It may require correct/in-range values for request initialization. 1698 * // - It may require specifying regional endpoints when creating the service client as shown in 1699 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1700 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 1701 * DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]"); 1702 * ListDeviceStatesResponse response = deviceManagerClient.listDeviceStates(name); 1703 * } 1704 * }</pre> 1705 * 1706 * @param name Required. The name of the device. For example, 1707 * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or 1708 * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. 1709 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1710 */ listDeviceStates(DeviceName name)1711 public final ListDeviceStatesResponse listDeviceStates(DeviceName name) { 1712 ListDeviceStatesRequest request = 1713 ListDeviceStatesRequest.newBuilder().setName(name == null ? null : name.toString()).build(); 1714 return listDeviceStates(request); 1715 } 1716 1717 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1718 /** 1719 * Lists the last few versions of the device state in descending order (i.e.: newest first). 1720 * 1721 * <p>Sample code: 1722 * 1723 * <pre>{@code 1724 * // This snippet has been automatically generated and should be regarded as a code template only. 1725 * // It will require modifications to work: 1726 * // - It may require correct/in-range values for request initialization. 1727 * // - It may require specifying regional endpoints when creating the service client as shown in 1728 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1729 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 1730 * String name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString(); 1731 * ListDeviceStatesResponse response = deviceManagerClient.listDeviceStates(name); 1732 * } 1733 * }</pre> 1734 * 1735 * @param name Required. The name of the device. For example, 1736 * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or 1737 * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. 1738 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1739 */ listDeviceStates(String name)1740 public final ListDeviceStatesResponse listDeviceStates(String name) { 1741 ListDeviceStatesRequest request = ListDeviceStatesRequest.newBuilder().setName(name).build(); 1742 return listDeviceStates(request); 1743 } 1744 1745 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1746 /** 1747 * Lists the last few versions of the device state in descending order (i.e.: newest first). 1748 * 1749 * <p>Sample code: 1750 * 1751 * <pre>{@code 1752 * // This snippet has been automatically generated and should be regarded as a code template only. 1753 * // It will require modifications to work: 1754 * // - It may require correct/in-range values for request initialization. 1755 * // - It may require specifying regional endpoints when creating the service client as shown in 1756 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1757 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 1758 * ListDeviceStatesRequest request = 1759 * ListDeviceStatesRequest.newBuilder() 1760 * .setName( 1761 * DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString()) 1762 * .setNumStates(1643330779) 1763 * .build(); 1764 * ListDeviceStatesResponse response = deviceManagerClient.listDeviceStates(request); 1765 * } 1766 * }</pre> 1767 * 1768 * @param request The request object containing all of the parameters for the API call. 1769 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1770 */ listDeviceStates(ListDeviceStatesRequest request)1771 public final ListDeviceStatesResponse listDeviceStates(ListDeviceStatesRequest request) { 1772 return listDeviceStatesCallable().call(request); 1773 } 1774 1775 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1776 /** 1777 * Lists the last few versions of the device state in descending order (i.e.: newest first). 1778 * 1779 * <p>Sample code: 1780 * 1781 * <pre>{@code 1782 * // This snippet has been automatically generated and should be regarded as a code template only. 1783 * // It will require modifications to work: 1784 * // - It may require correct/in-range values for request initialization. 1785 * // - It may require specifying regional endpoints when creating the service client as shown in 1786 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1787 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 1788 * ListDeviceStatesRequest request = 1789 * ListDeviceStatesRequest.newBuilder() 1790 * .setName( 1791 * DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString()) 1792 * .setNumStates(1643330779) 1793 * .build(); 1794 * ApiFuture<ListDeviceStatesResponse> future = 1795 * deviceManagerClient.listDeviceStatesCallable().futureCall(request); 1796 * // Do something. 1797 * ListDeviceStatesResponse response = future.get(); 1798 * } 1799 * }</pre> 1800 */ 1801 public final UnaryCallable<ListDeviceStatesRequest, ListDeviceStatesResponse> listDeviceStatesCallable()1802 listDeviceStatesCallable() { 1803 return stub.listDeviceStatesCallable(); 1804 } 1805 1806 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1807 /** 1808 * Sets the access control policy on the specified resource. Replaces any existing policy. 1809 * 1810 * <p>Sample code: 1811 * 1812 * <pre>{@code 1813 * // This snippet has been automatically generated and should be regarded as a code template only. 1814 * // It will require modifications to work: 1815 * // - It may require correct/in-range values for request initialization. 1816 * // - It may require specifying regional endpoints when creating the service client as shown in 1817 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1818 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 1819 * ResourceName resource = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); 1820 * Policy policy = Policy.newBuilder().build(); 1821 * Policy response = deviceManagerClient.setIamPolicy(resource, policy); 1822 * } 1823 * }</pre> 1824 * 1825 * @param resource REQUIRED: The resource for which the policy is being specified. See the 1826 * operation documentation for the appropriate value for this field. 1827 * @param policy REQUIRED: The complete policy to be applied to the `resource`. The size of the 1828 * policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Cloud 1829 * Platform services (such as Projects) might reject them. 1830 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1831 */ setIamPolicy(ResourceName resource, Policy policy)1832 public final Policy setIamPolicy(ResourceName resource, Policy policy) { 1833 SetIamPolicyRequest request = 1834 SetIamPolicyRequest.newBuilder() 1835 .setResource(resource == null ? null : resource.toString()) 1836 .setPolicy(policy) 1837 .build(); 1838 return setIamPolicy(request); 1839 } 1840 1841 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1842 /** 1843 * Sets the access control policy on the specified resource. Replaces any existing policy. 1844 * 1845 * <p>Sample code: 1846 * 1847 * <pre>{@code 1848 * // This snippet has been automatically generated and should be regarded as a code template only. 1849 * // It will require modifications to work: 1850 * // - It may require correct/in-range values for request initialization. 1851 * // - It may require specifying regional endpoints when creating the service client as shown in 1852 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1853 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 1854 * String resource = 1855 * DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString(); 1856 * Policy policy = Policy.newBuilder().build(); 1857 * Policy response = deviceManagerClient.setIamPolicy(resource, policy); 1858 * } 1859 * }</pre> 1860 * 1861 * @param resource REQUIRED: The resource for which the policy is being specified. See the 1862 * operation documentation for the appropriate value for this field. 1863 * @param policy REQUIRED: The complete policy to be applied to the `resource`. The size of the 1864 * policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Cloud 1865 * Platform services (such as Projects) might reject them. 1866 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1867 */ setIamPolicy(String resource, Policy policy)1868 public final Policy setIamPolicy(String resource, Policy policy) { 1869 SetIamPolicyRequest request = 1870 SetIamPolicyRequest.newBuilder().setResource(resource).setPolicy(policy).build(); 1871 return setIamPolicy(request); 1872 } 1873 1874 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1875 /** 1876 * Sets the access control policy on the specified resource. Replaces any existing policy. 1877 * 1878 * <p>Sample code: 1879 * 1880 * <pre>{@code 1881 * // This snippet has been automatically generated and should be regarded as a code template only. 1882 * // It will require modifications to work: 1883 * // - It may require correct/in-range values for request initialization. 1884 * // - It may require specifying regional endpoints when creating the service client as shown in 1885 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1886 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 1887 * SetIamPolicyRequest request = 1888 * SetIamPolicyRequest.newBuilder() 1889 * .setResource(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) 1890 * .setPolicy(Policy.newBuilder().build()) 1891 * .setUpdateMask(FieldMask.newBuilder().build()) 1892 * .build(); 1893 * Policy response = deviceManagerClient.setIamPolicy(request); 1894 * } 1895 * }</pre> 1896 * 1897 * @param request The request object containing all of the parameters for the API call. 1898 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1899 */ setIamPolicy(SetIamPolicyRequest request)1900 public final Policy setIamPolicy(SetIamPolicyRequest request) { 1901 return setIamPolicyCallable().call(request); 1902 } 1903 1904 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1905 /** 1906 * Sets the access control policy on the specified resource. Replaces any existing policy. 1907 * 1908 * <p>Sample code: 1909 * 1910 * <pre>{@code 1911 * // This snippet has been automatically generated and should be regarded as a code template only. 1912 * // It will require modifications to work: 1913 * // - It may require correct/in-range values for request initialization. 1914 * // - It may require specifying regional endpoints when creating the service client as shown in 1915 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1916 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 1917 * SetIamPolicyRequest request = 1918 * SetIamPolicyRequest.newBuilder() 1919 * .setResource(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) 1920 * .setPolicy(Policy.newBuilder().build()) 1921 * .setUpdateMask(FieldMask.newBuilder().build()) 1922 * .build(); 1923 * ApiFuture<Policy> future = deviceManagerClient.setIamPolicyCallable().futureCall(request); 1924 * // Do something. 1925 * Policy response = future.get(); 1926 * } 1927 * }</pre> 1928 */ setIamPolicyCallable()1929 public final UnaryCallable<SetIamPolicyRequest, Policy> setIamPolicyCallable() { 1930 return stub.setIamPolicyCallable(); 1931 } 1932 1933 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1934 /** 1935 * Gets the access control policy for a resource. Returns an empty policy if the resource exists 1936 * and does not have a policy set. 1937 * 1938 * <p>Sample code: 1939 * 1940 * <pre>{@code 1941 * // This snippet has been automatically generated and should be regarded as a code template only. 1942 * // It will require modifications to work: 1943 * // - It may require correct/in-range values for request initialization. 1944 * // - It may require specifying regional endpoints when creating the service client as shown in 1945 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1946 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 1947 * ResourceName resource = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); 1948 * Policy response = deviceManagerClient.getIamPolicy(resource); 1949 * } 1950 * }</pre> 1951 * 1952 * @param resource REQUIRED: The resource for which the policy is being requested. See the 1953 * operation documentation for the appropriate value for this field. 1954 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1955 */ getIamPolicy(ResourceName resource)1956 public final Policy getIamPolicy(ResourceName resource) { 1957 GetIamPolicyRequest request = 1958 GetIamPolicyRequest.newBuilder() 1959 .setResource(resource == null ? null : resource.toString()) 1960 .build(); 1961 return getIamPolicy(request); 1962 } 1963 1964 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1965 /** 1966 * Gets the access control policy for a resource. Returns an empty policy if the resource exists 1967 * and does not have a policy set. 1968 * 1969 * <p>Sample code: 1970 * 1971 * <pre>{@code 1972 * // This snippet has been automatically generated and should be regarded as a code template only. 1973 * // It will require modifications to work: 1974 * // - It may require correct/in-range values for request initialization. 1975 * // - It may require specifying regional endpoints when creating the service client as shown in 1976 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1977 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 1978 * String resource = 1979 * DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString(); 1980 * Policy response = deviceManagerClient.getIamPolicy(resource); 1981 * } 1982 * }</pre> 1983 * 1984 * @param resource REQUIRED: The resource for which the policy is being requested. See the 1985 * operation documentation for the appropriate value for this field. 1986 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1987 */ getIamPolicy(String resource)1988 public final Policy getIamPolicy(String resource) { 1989 GetIamPolicyRequest request = GetIamPolicyRequest.newBuilder().setResource(resource).build(); 1990 return getIamPolicy(request); 1991 } 1992 1993 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1994 /** 1995 * Gets the access control policy for a resource. Returns an empty policy if the resource exists 1996 * and does not have a policy set. 1997 * 1998 * <p>Sample code: 1999 * 2000 * <pre>{@code 2001 * // This snippet has been automatically generated and should be regarded as a code template only. 2002 * // It will require modifications to work: 2003 * // - It may require correct/in-range values for request initialization. 2004 * // - It may require specifying regional endpoints when creating the service client as shown in 2005 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2006 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 2007 * GetIamPolicyRequest request = 2008 * GetIamPolicyRequest.newBuilder() 2009 * .setResource(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) 2010 * .setOptions(GetPolicyOptions.newBuilder().build()) 2011 * .build(); 2012 * Policy response = deviceManagerClient.getIamPolicy(request); 2013 * } 2014 * }</pre> 2015 * 2016 * @param request The request object containing all of the parameters for the API call. 2017 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 2018 */ getIamPolicy(GetIamPolicyRequest request)2019 public final Policy getIamPolicy(GetIamPolicyRequest request) { 2020 return getIamPolicyCallable().call(request); 2021 } 2022 2023 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2024 /** 2025 * Gets the access control policy for a resource. Returns an empty policy if the resource exists 2026 * and does not have a policy set. 2027 * 2028 * <p>Sample code: 2029 * 2030 * <pre>{@code 2031 * // This snippet has been automatically generated and should be regarded as a code template only. 2032 * // It will require modifications to work: 2033 * // - It may require correct/in-range values for request initialization. 2034 * // - It may require specifying regional endpoints when creating the service client as shown in 2035 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2036 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 2037 * GetIamPolicyRequest request = 2038 * GetIamPolicyRequest.newBuilder() 2039 * .setResource(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) 2040 * .setOptions(GetPolicyOptions.newBuilder().build()) 2041 * .build(); 2042 * ApiFuture<Policy> future = deviceManagerClient.getIamPolicyCallable().futureCall(request); 2043 * // Do something. 2044 * Policy response = future.get(); 2045 * } 2046 * }</pre> 2047 */ getIamPolicyCallable()2048 public final UnaryCallable<GetIamPolicyRequest, Policy> getIamPolicyCallable() { 2049 return stub.getIamPolicyCallable(); 2050 } 2051 2052 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2053 /** 2054 * Returns permissions that a caller has on the specified resource. If the resource does not 2055 * exist, this will return an empty set of permissions, not a NOT_FOUND error. 2056 * 2057 * <p>Sample code: 2058 * 2059 * <pre>{@code 2060 * // This snippet has been automatically generated and should be regarded as a code template only. 2061 * // It will require modifications to work: 2062 * // - It may require correct/in-range values for request initialization. 2063 * // - It may require specifying regional endpoints when creating the service client as shown in 2064 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2065 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 2066 * ResourceName resource = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); 2067 * List<String> permissions = new ArrayList<>(); 2068 * TestIamPermissionsResponse response = 2069 * deviceManagerClient.testIamPermissions(resource, permissions); 2070 * } 2071 * }</pre> 2072 * 2073 * @param resource REQUIRED: The resource for which the policy detail is being requested. See the 2074 * operation documentation for the appropriate value for this field. 2075 * @param permissions The set of permissions to check for the `resource`. Permissions with 2076 * wildcards (such as '*' or 'storage.*') are not allowed. For more information see 2077 * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). 2078 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 2079 */ testIamPermissions( ResourceName resource, List<String> permissions)2080 public final TestIamPermissionsResponse testIamPermissions( 2081 ResourceName resource, List<String> permissions) { 2082 TestIamPermissionsRequest request = 2083 TestIamPermissionsRequest.newBuilder() 2084 .setResource(resource == null ? null : resource.toString()) 2085 .addAllPermissions(permissions) 2086 .build(); 2087 return testIamPermissions(request); 2088 } 2089 2090 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2091 /** 2092 * Returns permissions that a caller has on the specified resource. If the resource does not 2093 * exist, this will return an empty set of permissions, not a NOT_FOUND error. 2094 * 2095 * <p>Sample code: 2096 * 2097 * <pre>{@code 2098 * // This snippet has been automatically generated and should be regarded as a code template only. 2099 * // It will require modifications to work: 2100 * // - It may require correct/in-range values for request initialization. 2101 * // - It may require specifying regional endpoints when creating the service client as shown in 2102 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2103 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 2104 * String resource = 2105 * DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString(); 2106 * List<String> permissions = new ArrayList<>(); 2107 * TestIamPermissionsResponse response = 2108 * deviceManagerClient.testIamPermissions(resource, permissions); 2109 * } 2110 * }</pre> 2111 * 2112 * @param resource REQUIRED: The resource for which the policy detail is being requested. See the 2113 * operation documentation for the appropriate value for this field. 2114 * @param permissions The set of permissions to check for the `resource`. Permissions with 2115 * wildcards (such as '*' or 'storage.*') are not allowed. For more information see 2116 * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). 2117 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 2118 */ testIamPermissions( String resource, List<String> permissions)2119 public final TestIamPermissionsResponse testIamPermissions( 2120 String resource, List<String> permissions) { 2121 TestIamPermissionsRequest request = 2122 TestIamPermissionsRequest.newBuilder() 2123 .setResource(resource) 2124 .addAllPermissions(permissions) 2125 .build(); 2126 return testIamPermissions(request); 2127 } 2128 2129 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2130 /** 2131 * Returns permissions that a caller has on the specified resource. If the resource does not 2132 * exist, this will return an empty set of permissions, not a NOT_FOUND error. 2133 * 2134 * <p>Sample code: 2135 * 2136 * <pre>{@code 2137 * // This snippet has been automatically generated and should be regarded as a code template only. 2138 * // It will require modifications to work: 2139 * // - It may require correct/in-range values for request initialization. 2140 * // - It may require specifying regional endpoints when creating the service client as shown in 2141 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2142 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 2143 * TestIamPermissionsRequest request = 2144 * TestIamPermissionsRequest.newBuilder() 2145 * .setResource(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) 2146 * .addAllPermissions(new ArrayList<String>()) 2147 * .build(); 2148 * TestIamPermissionsResponse response = deviceManagerClient.testIamPermissions(request); 2149 * } 2150 * }</pre> 2151 * 2152 * @param request The request object containing all of the parameters for the API call. 2153 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 2154 */ testIamPermissions(TestIamPermissionsRequest request)2155 public final TestIamPermissionsResponse testIamPermissions(TestIamPermissionsRequest request) { 2156 return testIamPermissionsCallable().call(request); 2157 } 2158 2159 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2160 /** 2161 * Returns permissions that a caller has on the specified resource. If the resource does not 2162 * exist, this will return an empty set of permissions, not a NOT_FOUND error. 2163 * 2164 * <p>Sample code: 2165 * 2166 * <pre>{@code 2167 * // This snippet has been automatically generated and should be regarded as a code template only. 2168 * // It will require modifications to work: 2169 * // - It may require correct/in-range values for request initialization. 2170 * // - It may require specifying regional endpoints when creating the service client as shown in 2171 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2172 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 2173 * TestIamPermissionsRequest request = 2174 * TestIamPermissionsRequest.newBuilder() 2175 * .setResource(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) 2176 * .addAllPermissions(new ArrayList<String>()) 2177 * .build(); 2178 * ApiFuture<TestIamPermissionsResponse> future = 2179 * deviceManagerClient.testIamPermissionsCallable().futureCall(request); 2180 * // Do something. 2181 * TestIamPermissionsResponse response = future.get(); 2182 * } 2183 * }</pre> 2184 */ 2185 public final UnaryCallable<TestIamPermissionsRequest, TestIamPermissionsResponse> testIamPermissionsCallable()2186 testIamPermissionsCallable() { 2187 return stub.testIamPermissionsCallable(); 2188 } 2189 2190 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2191 /** 2192 * Sends a command to the specified device. In order for a device to be able to receive commands, 2193 * it must: 1) be connected to Cloud IoT Core using the MQTT protocol, and 2) be subscribed to the 2194 * group of MQTT topics specified by /devices/{device-id}/commands/#. This subscription will 2195 * receive commands at the top-level topic /devices/{device-id}/commands as well as commands for 2196 * subfolders, like /devices/{device-id}/commands/subfolder. Note that subscribing to specific 2197 * subfolders is not supported. If the command could not be delivered to the device, this method 2198 * will return an error; in particular, if the device is not subscribed, this method will return 2199 * FAILED_PRECONDITION. Otherwise, this method will return OK. If the subscription is QoS 1, at 2200 * least once delivery will be guaranteed; for QoS 0, no acknowledgment will be expected from the 2201 * device. 2202 * 2203 * <p>Sample code: 2204 * 2205 * <pre>{@code 2206 * // This snippet has been automatically generated and should be regarded as a code template only. 2207 * // It will require modifications to work: 2208 * // - It may require correct/in-range values for request initialization. 2209 * // - It may require specifying regional endpoints when creating the service client as shown in 2210 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2211 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 2212 * DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]"); 2213 * ByteString binaryData = ByteString.EMPTY; 2214 * SendCommandToDeviceResponse response = 2215 * deviceManagerClient.sendCommandToDevice(name, binaryData); 2216 * } 2217 * }</pre> 2218 * 2219 * @param name Required. The name of the device. For example, 2220 * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or 2221 * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. 2222 * @param binaryData Required. The command data to send to the device. 2223 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 2224 */ sendCommandToDevice( DeviceName name, ByteString binaryData)2225 public final SendCommandToDeviceResponse sendCommandToDevice( 2226 DeviceName name, ByteString binaryData) { 2227 SendCommandToDeviceRequest request = 2228 SendCommandToDeviceRequest.newBuilder() 2229 .setName(name == null ? null : name.toString()) 2230 .setBinaryData(binaryData) 2231 .build(); 2232 return sendCommandToDevice(request); 2233 } 2234 2235 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2236 /** 2237 * Sends a command to the specified device. In order for a device to be able to receive commands, 2238 * it must: 1) be connected to Cloud IoT Core using the MQTT protocol, and 2) be subscribed to the 2239 * group of MQTT topics specified by /devices/{device-id}/commands/#. This subscription will 2240 * receive commands at the top-level topic /devices/{device-id}/commands as well as commands for 2241 * subfolders, like /devices/{device-id}/commands/subfolder. Note that subscribing to specific 2242 * subfolders is not supported. If the command could not be delivered to the device, this method 2243 * will return an error; in particular, if the device is not subscribed, this method will return 2244 * FAILED_PRECONDITION. Otherwise, this method will return OK. If the subscription is QoS 1, at 2245 * least once delivery will be guaranteed; for QoS 0, no acknowledgment will be expected from the 2246 * device. 2247 * 2248 * <p>Sample code: 2249 * 2250 * <pre>{@code 2251 * // This snippet has been automatically generated and should be regarded as a code template only. 2252 * // It will require modifications to work: 2253 * // - It may require correct/in-range values for request initialization. 2254 * // - It may require specifying regional endpoints when creating the service client as shown in 2255 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2256 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 2257 * String name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString(); 2258 * ByteString binaryData = ByteString.EMPTY; 2259 * SendCommandToDeviceResponse response = 2260 * deviceManagerClient.sendCommandToDevice(name, binaryData); 2261 * } 2262 * }</pre> 2263 * 2264 * @param name Required. The name of the device. For example, 2265 * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or 2266 * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. 2267 * @param binaryData Required. The command data to send to the device. 2268 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 2269 */ sendCommandToDevice(String name, ByteString binaryData)2270 public final SendCommandToDeviceResponse sendCommandToDevice(String name, ByteString binaryData) { 2271 SendCommandToDeviceRequest request = 2272 SendCommandToDeviceRequest.newBuilder().setName(name).setBinaryData(binaryData).build(); 2273 return sendCommandToDevice(request); 2274 } 2275 2276 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2277 /** 2278 * Sends a command to the specified device. In order for a device to be able to receive commands, 2279 * it must: 1) be connected to Cloud IoT Core using the MQTT protocol, and 2) be subscribed to the 2280 * group of MQTT topics specified by /devices/{device-id}/commands/#. This subscription will 2281 * receive commands at the top-level topic /devices/{device-id}/commands as well as commands for 2282 * subfolders, like /devices/{device-id}/commands/subfolder. Note that subscribing to specific 2283 * subfolders is not supported. If the command could not be delivered to the device, this method 2284 * will return an error; in particular, if the device is not subscribed, this method will return 2285 * FAILED_PRECONDITION. Otherwise, this method will return OK. If the subscription is QoS 1, at 2286 * least once delivery will be guaranteed; for QoS 0, no acknowledgment will be expected from the 2287 * device. 2288 * 2289 * <p>Sample code: 2290 * 2291 * <pre>{@code 2292 * // This snippet has been automatically generated and should be regarded as a code template only. 2293 * // It will require modifications to work: 2294 * // - It may require correct/in-range values for request initialization. 2295 * // - It may require specifying regional endpoints when creating the service client as shown in 2296 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2297 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 2298 * DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]"); 2299 * ByteString binaryData = ByteString.EMPTY; 2300 * String subfolder = "subfolder153561774"; 2301 * SendCommandToDeviceResponse response = 2302 * deviceManagerClient.sendCommandToDevice(name, binaryData, subfolder); 2303 * } 2304 * }</pre> 2305 * 2306 * @param name Required. The name of the device. For example, 2307 * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or 2308 * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. 2309 * @param binaryData Required. The command data to send to the device. 2310 * @param subfolder Optional subfolder for the command. If empty, the command will be delivered to 2311 * the /devices/{device-id}/commands topic, otherwise it will be delivered to the 2312 * /devices/{device-id}/commands/{subfolder} topic. Multi-level subfolders are allowed. This 2313 * field must not have more than 256 characters, and must not contain any MQTT wildcards ("+" 2314 * or "#") or null characters. 2315 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 2316 */ sendCommandToDevice( DeviceName name, ByteString binaryData, String subfolder)2317 public final SendCommandToDeviceResponse sendCommandToDevice( 2318 DeviceName name, ByteString binaryData, String subfolder) { 2319 SendCommandToDeviceRequest request = 2320 SendCommandToDeviceRequest.newBuilder() 2321 .setName(name == null ? null : name.toString()) 2322 .setBinaryData(binaryData) 2323 .setSubfolder(subfolder) 2324 .build(); 2325 return sendCommandToDevice(request); 2326 } 2327 2328 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2329 /** 2330 * Sends a command to the specified device. In order for a device to be able to receive commands, 2331 * it must: 1) be connected to Cloud IoT Core using the MQTT protocol, and 2) be subscribed to the 2332 * group of MQTT topics specified by /devices/{device-id}/commands/#. This subscription will 2333 * receive commands at the top-level topic /devices/{device-id}/commands as well as commands for 2334 * subfolders, like /devices/{device-id}/commands/subfolder. Note that subscribing to specific 2335 * subfolders is not supported. If the command could not be delivered to the device, this method 2336 * will return an error; in particular, if the device is not subscribed, this method will return 2337 * FAILED_PRECONDITION. Otherwise, this method will return OK. If the subscription is QoS 1, at 2338 * least once delivery will be guaranteed; for QoS 0, no acknowledgment will be expected from the 2339 * device. 2340 * 2341 * <p>Sample code: 2342 * 2343 * <pre>{@code 2344 * // This snippet has been automatically generated and should be regarded as a code template only. 2345 * // It will require modifications to work: 2346 * // - It may require correct/in-range values for request initialization. 2347 * // - It may require specifying regional endpoints when creating the service client as shown in 2348 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2349 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 2350 * String name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString(); 2351 * ByteString binaryData = ByteString.EMPTY; 2352 * String subfolder = "subfolder153561774"; 2353 * SendCommandToDeviceResponse response = 2354 * deviceManagerClient.sendCommandToDevice(name, binaryData, subfolder); 2355 * } 2356 * }</pre> 2357 * 2358 * @param name Required. The name of the device. For example, 2359 * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or 2360 * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. 2361 * @param binaryData Required. The command data to send to the device. 2362 * @param subfolder Optional subfolder for the command. If empty, the command will be delivered to 2363 * the /devices/{device-id}/commands topic, otherwise it will be delivered to the 2364 * /devices/{device-id}/commands/{subfolder} topic. Multi-level subfolders are allowed. This 2365 * field must not have more than 256 characters, and must not contain any MQTT wildcards ("+" 2366 * or "#") or null characters. 2367 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 2368 */ sendCommandToDevice( String name, ByteString binaryData, String subfolder)2369 public final SendCommandToDeviceResponse sendCommandToDevice( 2370 String name, ByteString binaryData, String subfolder) { 2371 SendCommandToDeviceRequest request = 2372 SendCommandToDeviceRequest.newBuilder() 2373 .setName(name) 2374 .setBinaryData(binaryData) 2375 .setSubfolder(subfolder) 2376 .build(); 2377 return sendCommandToDevice(request); 2378 } 2379 2380 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2381 /** 2382 * Sends a command to the specified device. In order for a device to be able to receive commands, 2383 * it must: 1) be connected to Cloud IoT Core using the MQTT protocol, and 2) be subscribed to the 2384 * group of MQTT topics specified by /devices/{device-id}/commands/#. This subscription will 2385 * receive commands at the top-level topic /devices/{device-id}/commands as well as commands for 2386 * subfolders, like /devices/{device-id}/commands/subfolder. Note that subscribing to specific 2387 * subfolders is not supported. If the command could not be delivered to the device, this method 2388 * will return an error; in particular, if the device is not subscribed, this method will return 2389 * FAILED_PRECONDITION. Otherwise, this method will return OK. If the subscription is QoS 1, at 2390 * least once delivery will be guaranteed; for QoS 0, no acknowledgment will be expected from the 2391 * device. 2392 * 2393 * <p>Sample code: 2394 * 2395 * <pre>{@code 2396 * // This snippet has been automatically generated and should be regarded as a code template only. 2397 * // It will require modifications to work: 2398 * // - It may require correct/in-range values for request initialization. 2399 * // - It may require specifying regional endpoints when creating the service client as shown in 2400 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2401 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 2402 * SendCommandToDeviceRequest request = 2403 * SendCommandToDeviceRequest.newBuilder() 2404 * .setName( 2405 * DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString()) 2406 * .setBinaryData(ByteString.EMPTY) 2407 * .setSubfolder("subfolder153561774") 2408 * .build(); 2409 * SendCommandToDeviceResponse response = deviceManagerClient.sendCommandToDevice(request); 2410 * } 2411 * }</pre> 2412 * 2413 * @param request The request object containing all of the parameters for the API call. 2414 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 2415 */ sendCommandToDevice(SendCommandToDeviceRequest request)2416 public final SendCommandToDeviceResponse sendCommandToDevice(SendCommandToDeviceRequest request) { 2417 return sendCommandToDeviceCallable().call(request); 2418 } 2419 2420 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2421 /** 2422 * Sends a command to the specified device. In order for a device to be able to receive commands, 2423 * it must: 1) be connected to Cloud IoT Core using the MQTT protocol, and 2) be subscribed to the 2424 * group of MQTT topics specified by /devices/{device-id}/commands/#. This subscription will 2425 * receive commands at the top-level topic /devices/{device-id}/commands as well as commands for 2426 * subfolders, like /devices/{device-id}/commands/subfolder. Note that subscribing to specific 2427 * subfolders is not supported. If the command could not be delivered to the device, this method 2428 * will return an error; in particular, if the device is not subscribed, this method will return 2429 * FAILED_PRECONDITION. Otherwise, this method will return OK. If the subscription is QoS 1, at 2430 * least once delivery will be guaranteed; for QoS 0, no acknowledgment will be expected from the 2431 * device. 2432 * 2433 * <p>Sample code: 2434 * 2435 * <pre>{@code 2436 * // This snippet has been automatically generated and should be regarded as a code template only. 2437 * // It will require modifications to work: 2438 * // - It may require correct/in-range values for request initialization. 2439 * // - It may require specifying regional endpoints when creating the service client as shown in 2440 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2441 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 2442 * SendCommandToDeviceRequest request = 2443 * SendCommandToDeviceRequest.newBuilder() 2444 * .setName( 2445 * DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString()) 2446 * .setBinaryData(ByteString.EMPTY) 2447 * .setSubfolder("subfolder153561774") 2448 * .build(); 2449 * ApiFuture<SendCommandToDeviceResponse> future = 2450 * deviceManagerClient.sendCommandToDeviceCallable().futureCall(request); 2451 * // Do something. 2452 * SendCommandToDeviceResponse response = future.get(); 2453 * } 2454 * }</pre> 2455 */ 2456 public final UnaryCallable<SendCommandToDeviceRequest, SendCommandToDeviceResponse> sendCommandToDeviceCallable()2457 sendCommandToDeviceCallable() { 2458 return stub.sendCommandToDeviceCallable(); 2459 } 2460 2461 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2462 /** 2463 * Associates the device with the gateway. 2464 * 2465 * <p>Sample code: 2466 * 2467 * <pre>{@code 2468 * // This snippet has been automatically generated and should be regarded as a code template only. 2469 * // It will require modifications to work: 2470 * // - It may require correct/in-range values for request initialization. 2471 * // - It may require specifying regional endpoints when creating the service client as shown in 2472 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2473 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 2474 * RegistryName parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); 2475 * String gatewayId = "gatewayId-1354641793"; 2476 * String deviceId = "deviceId1109191185"; 2477 * BindDeviceToGatewayResponse response = 2478 * deviceManagerClient.bindDeviceToGateway(parent, gatewayId, deviceId); 2479 * } 2480 * }</pre> 2481 * 2482 * @param parent Required. The name of the registry. For example, 2483 * `projects/example-project/locations/us-central1/registries/my-registry`. 2484 * @param gatewayId Required. The value of `gateway_id` can be either the device numeric ID or the 2485 * user-defined device identifier. 2486 * @param deviceId Required. The device to associate with the specified gateway. The value of 2487 * `device_id` can be either the device numeric ID or the user-defined device identifier. 2488 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 2489 */ bindDeviceToGateway( RegistryName parent, String gatewayId, String deviceId)2490 public final BindDeviceToGatewayResponse bindDeviceToGateway( 2491 RegistryName parent, String gatewayId, String deviceId) { 2492 BindDeviceToGatewayRequest request = 2493 BindDeviceToGatewayRequest.newBuilder() 2494 .setParent(parent == null ? null : parent.toString()) 2495 .setGatewayId(gatewayId) 2496 .setDeviceId(deviceId) 2497 .build(); 2498 return bindDeviceToGateway(request); 2499 } 2500 2501 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2502 /** 2503 * Associates the device with the gateway. 2504 * 2505 * <p>Sample code: 2506 * 2507 * <pre>{@code 2508 * // This snippet has been automatically generated and should be regarded as a code template only. 2509 * // It will require modifications to work: 2510 * // - It may require correct/in-range values for request initialization. 2511 * // - It may require specifying regional endpoints when creating the service client as shown in 2512 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2513 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 2514 * String parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString(); 2515 * String gatewayId = "gatewayId-1354641793"; 2516 * String deviceId = "deviceId1109191185"; 2517 * BindDeviceToGatewayResponse response = 2518 * deviceManagerClient.bindDeviceToGateway(parent, gatewayId, deviceId); 2519 * } 2520 * }</pre> 2521 * 2522 * @param parent Required. The name of the registry. For example, 2523 * `projects/example-project/locations/us-central1/registries/my-registry`. 2524 * @param gatewayId Required. The value of `gateway_id` can be either the device numeric ID or the 2525 * user-defined device identifier. 2526 * @param deviceId Required. The device to associate with the specified gateway. The value of 2527 * `device_id` can be either the device numeric ID or the user-defined device identifier. 2528 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 2529 */ bindDeviceToGateway( String parent, String gatewayId, String deviceId)2530 public final BindDeviceToGatewayResponse bindDeviceToGateway( 2531 String parent, String gatewayId, String deviceId) { 2532 BindDeviceToGatewayRequest request = 2533 BindDeviceToGatewayRequest.newBuilder() 2534 .setParent(parent) 2535 .setGatewayId(gatewayId) 2536 .setDeviceId(deviceId) 2537 .build(); 2538 return bindDeviceToGateway(request); 2539 } 2540 2541 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2542 /** 2543 * Associates the device with the gateway. 2544 * 2545 * <p>Sample code: 2546 * 2547 * <pre>{@code 2548 * // This snippet has been automatically generated and should be regarded as a code template only. 2549 * // It will require modifications to work: 2550 * // - It may require correct/in-range values for request initialization. 2551 * // - It may require specifying regional endpoints when creating the service client as shown in 2552 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2553 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 2554 * BindDeviceToGatewayRequest request = 2555 * BindDeviceToGatewayRequest.newBuilder() 2556 * .setParent(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) 2557 * .setGatewayId("gatewayId-1354641793") 2558 * .setDeviceId("deviceId1109191185") 2559 * .build(); 2560 * BindDeviceToGatewayResponse response = deviceManagerClient.bindDeviceToGateway(request); 2561 * } 2562 * }</pre> 2563 * 2564 * @param request The request object containing all of the parameters for the API call. 2565 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 2566 */ bindDeviceToGateway(BindDeviceToGatewayRequest request)2567 public final BindDeviceToGatewayResponse bindDeviceToGateway(BindDeviceToGatewayRequest request) { 2568 return bindDeviceToGatewayCallable().call(request); 2569 } 2570 2571 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2572 /** 2573 * Associates the device with the gateway. 2574 * 2575 * <p>Sample code: 2576 * 2577 * <pre>{@code 2578 * // This snippet has been automatically generated and should be regarded as a code template only. 2579 * // It will require modifications to work: 2580 * // - It may require correct/in-range values for request initialization. 2581 * // - It may require specifying regional endpoints when creating the service client as shown in 2582 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2583 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 2584 * BindDeviceToGatewayRequest request = 2585 * BindDeviceToGatewayRequest.newBuilder() 2586 * .setParent(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) 2587 * .setGatewayId("gatewayId-1354641793") 2588 * .setDeviceId("deviceId1109191185") 2589 * .build(); 2590 * ApiFuture<BindDeviceToGatewayResponse> future = 2591 * deviceManagerClient.bindDeviceToGatewayCallable().futureCall(request); 2592 * // Do something. 2593 * BindDeviceToGatewayResponse response = future.get(); 2594 * } 2595 * }</pre> 2596 */ 2597 public final UnaryCallable<BindDeviceToGatewayRequest, BindDeviceToGatewayResponse> bindDeviceToGatewayCallable()2598 bindDeviceToGatewayCallable() { 2599 return stub.bindDeviceToGatewayCallable(); 2600 } 2601 2602 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2603 /** 2604 * Deletes the association between the device and the gateway. 2605 * 2606 * <p>Sample code: 2607 * 2608 * <pre>{@code 2609 * // This snippet has been automatically generated and should be regarded as a code template only. 2610 * // It will require modifications to work: 2611 * // - It may require correct/in-range values for request initialization. 2612 * // - It may require specifying regional endpoints when creating the service client as shown in 2613 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2614 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 2615 * RegistryName parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); 2616 * String gatewayId = "gatewayId-1354641793"; 2617 * String deviceId = "deviceId1109191185"; 2618 * UnbindDeviceFromGatewayResponse response = 2619 * deviceManagerClient.unbindDeviceFromGateway(parent, gatewayId, deviceId); 2620 * } 2621 * }</pre> 2622 * 2623 * @param parent Required. The name of the registry. For example, 2624 * `projects/example-project/locations/us-central1/registries/my-registry`. 2625 * @param gatewayId Required. The value of `gateway_id` can be either the device numeric ID or the 2626 * user-defined device identifier. 2627 * @param deviceId Required. The device to disassociate from the specified gateway. The value of 2628 * `device_id` can be either the device numeric ID or the user-defined device identifier. 2629 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 2630 */ unbindDeviceFromGateway( RegistryName parent, String gatewayId, String deviceId)2631 public final UnbindDeviceFromGatewayResponse unbindDeviceFromGateway( 2632 RegistryName parent, String gatewayId, String deviceId) { 2633 UnbindDeviceFromGatewayRequest request = 2634 UnbindDeviceFromGatewayRequest.newBuilder() 2635 .setParent(parent == null ? null : parent.toString()) 2636 .setGatewayId(gatewayId) 2637 .setDeviceId(deviceId) 2638 .build(); 2639 return unbindDeviceFromGateway(request); 2640 } 2641 2642 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2643 /** 2644 * Deletes the association between the device and the gateway. 2645 * 2646 * <p>Sample code: 2647 * 2648 * <pre>{@code 2649 * // This snippet has been automatically generated and should be regarded as a code template only. 2650 * // It will require modifications to work: 2651 * // - It may require correct/in-range values for request initialization. 2652 * // - It may require specifying regional endpoints when creating the service client as shown in 2653 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2654 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 2655 * String parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString(); 2656 * String gatewayId = "gatewayId-1354641793"; 2657 * String deviceId = "deviceId1109191185"; 2658 * UnbindDeviceFromGatewayResponse response = 2659 * deviceManagerClient.unbindDeviceFromGateway(parent, gatewayId, deviceId); 2660 * } 2661 * }</pre> 2662 * 2663 * @param parent Required. The name of the registry. For example, 2664 * `projects/example-project/locations/us-central1/registries/my-registry`. 2665 * @param gatewayId Required. The value of `gateway_id` can be either the device numeric ID or the 2666 * user-defined device identifier. 2667 * @param deviceId Required. The device to disassociate from the specified gateway. The value of 2668 * `device_id` can be either the device numeric ID or the user-defined device identifier. 2669 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 2670 */ unbindDeviceFromGateway( String parent, String gatewayId, String deviceId)2671 public final UnbindDeviceFromGatewayResponse unbindDeviceFromGateway( 2672 String parent, String gatewayId, String deviceId) { 2673 UnbindDeviceFromGatewayRequest request = 2674 UnbindDeviceFromGatewayRequest.newBuilder() 2675 .setParent(parent) 2676 .setGatewayId(gatewayId) 2677 .setDeviceId(deviceId) 2678 .build(); 2679 return unbindDeviceFromGateway(request); 2680 } 2681 2682 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2683 /** 2684 * Deletes the association between the device and the gateway. 2685 * 2686 * <p>Sample code: 2687 * 2688 * <pre>{@code 2689 * // This snippet has been automatically generated and should be regarded as a code template only. 2690 * // It will require modifications to work: 2691 * // - It may require correct/in-range values for request initialization. 2692 * // - It may require specifying regional endpoints when creating the service client as shown in 2693 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2694 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 2695 * UnbindDeviceFromGatewayRequest request = 2696 * UnbindDeviceFromGatewayRequest.newBuilder() 2697 * .setParent(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) 2698 * .setGatewayId("gatewayId-1354641793") 2699 * .setDeviceId("deviceId1109191185") 2700 * .build(); 2701 * UnbindDeviceFromGatewayResponse response = 2702 * deviceManagerClient.unbindDeviceFromGateway(request); 2703 * } 2704 * }</pre> 2705 * 2706 * @param request The request object containing all of the parameters for the API call. 2707 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 2708 */ unbindDeviceFromGateway( UnbindDeviceFromGatewayRequest request)2709 public final UnbindDeviceFromGatewayResponse unbindDeviceFromGateway( 2710 UnbindDeviceFromGatewayRequest request) { 2711 return unbindDeviceFromGatewayCallable().call(request); 2712 } 2713 2714 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2715 /** 2716 * Deletes the association between the device and the gateway. 2717 * 2718 * <p>Sample code: 2719 * 2720 * <pre>{@code 2721 * // This snippet has been automatically generated and should be regarded as a code template only. 2722 * // It will require modifications to work: 2723 * // - It may require correct/in-range values for request initialization. 2724 * // - It may require specifying regional endpoints when creating the service client as shown in 2725 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2726 * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { 2727 * UnbindDeviceFromGatewayRequest request = 2728 * UnbindDeviceFromGatewayRequest.newBuilder() 2729 * .setParent(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) 2730 * .setGatewayId("gatewayId-1354641793") 2731 * .setDeviceId("deviceId1109191185") 2732 * .build(); 2733 * ApiFuture<UnbindDeviceFromGatewayResponse> future = 2734 * deviceManagerClient.unbindDeviceFromGatewayCallable().futureCall(request); 2735 * // Do something. 2736 * UnbindDeviceFromGatewayResponse response = future.get(); 2737 * } 2738 * }</pre> 2739 */ 2740 public final UnaryCallable<UnbindDeviceFromGatewayRequest, UnbindDeviceFromGatewayResponse> unbindDeviceFromGatewayCallable()2741 unbindDeviceFromGatewayCallable() { 2742 return stub.unbindDeviceFromGatewayCallable(); 2743 } 2744 2745 @Override close()2746 public final void close() { 2747 stub.close(); 2748 } 2749 2750 @Override shutdown()2751 public void shutdown() { 2752 stub.shutdown(); 2753 } 2754 2755 @Override isShutdown()2756 public boolean isShutdown() { 2757 return stub.isShutdown(); 2758 } 2759 2760 @Override isTerminated()2761 public boolean isTerminated() { 2762 return stub.isTerminated(); 2763 } 2764 2765 @Override shutdownNow()2766 public void shutdownNow() { 2767 stub.shutdownNow(); 2768 } 2769 2770 @Override awaitTermination(long duration, TimeUnit unit)2771 public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { 2772 return stub.awaitTermination(duration, unit); 2773 } 2774 2775 public static class ListDeviceRegistriesPagedResponse 2776 extends AbstractPagedListResponse< 2777 ListDeviceRegistriesRequest, 2778 ListDeviceRegistriesResponse, 2779 DeviceRegistry, 2780 ListDeviceRegistriesPage, 2781 ListDeviceRegistriesFixedSizeCollection> { 2782 createAsync( PageContext<ListDeviceRegistriesRequest, ListDeviceRegistriesResponse, DeviceRegistry> context, ApiFuture<ListDeviceRegistriesResponse> futureResponse)2783 public static ApiFuture<ListDeviceRegistriesPagedResponse> createAsync( 2784 PageContext<ListDeviceRegistriesRequest, ListDeviceRegistriesResponse, DeviceRegistry> 2785 context, 2786 ApiFuture<ListDeviceRegistriesResponse> futureResponse) { 2787 ApiFuture<ListDeviceRegistriesPage> futurePage = 2788 ListDeviceRegistriesPage.createEmptyPage().createPageAsync(context, futureResponse); 2789 return ApiFutures.transform( 2790 futurePage, 2791 input -> new ListDeviceRegistriesPagedResponse(input), 2792 MoreExecutors.directExecutor()); 2793 } 2794 ListDeviceRegistriesPagedResponse(ListDeviceRegistriesPage page)2795 private ListDeviceRegistriesPagedResponse(ListDeviceRegistriesPage page) { 2796 super(page, ListDeviceRegistriesFixedSizeCollection.createEmptyCollection()); 2797 } 2798 } 2799 2800 public static class ListDeviceRegistriesPage 2801 extends AbstractPage< 2802 ListDeviceRegistriesRequest, 2803 ListDeviceRegistriesResponse, 2804 DeviceRegistry, 2805 ListDeviceRegistriesPage> { 2806 ListDeviceRegistriesPage( PageContext<ListDeviceRegistriesRequest, ListDeviceRegistriesResponse, DeviceRegistry> context, ListDeviceRegistriesResponse response)2807 private ListDeviceRegistriesPage( 2808 PageContext<ListDeviceRegistriesRequest, ListDeviceRegistriesResponse, DeviceRegistry> 2809 context, 2810 ListDeviceRegistriesResponse response) { 2811 super(context, response); 2812 } 2813 createEmptyPage()2814 private static ListDeviceRegistriesPage createEmptyPage() { 2815 return new ListDeviceRegistriesPage(null, null); 2816 } 2817 2818 @Override createPage( PageContext<ListDeviceRegistriesRequest, ListDeviceRegistriesResponse, DeviceRegistry> context, ListDeviceRegistriesResponse response)2819 protected ListDeviceRegistriesPage createPage( 2820 PageContext<ListDeviceRegistriesRequest, ListDeviceRegistriesResponse, DeviceRegistry> 2821 context, 2822 ListDeviceRegistriesResponse response) { 2823 return new ListDeviceRegistriesPage(context, response); 2824 } 2825 2826 @Override createPageAsync( PageContext<ListDeviceRegistriesRequest, ListDeviceRegistriesResponse, DeviceRegistry> context, ApiFuture<ListDeviceRegistriesResponse> futureResponse)2827 public ApiFuture<ListDeviceRegistriesPage> createPageAsync( 2828 PageContext<ListDeviceRegistriesRequest, ListDeviceRegistriesResponse, DeviceRegistry> 2829 context, 2830 ApiFuture<ListDeviceRegistriesResponse> futureResponse) { 2831 return super.createPageAsync(context, futureResponse); 2832 } 2833 } 2834 2835 public static class ListDeviceRegistriesFixedSizeCollection 2836 extends AbstractFixedSizeCollection< 2837 ListDeviceRegistriesRequest, 2838 ListDeviceRegistriesResponse, 2839 DeviceRegistry, 2840 ListDeviceRegistriesPage, 2841 ListDeviceRegistriesFixedSizeCollection> { 2842 ListDeviceRegistriesFixedSizeCollection( List<ListDeviceRegistriesPage> pages, int collectionSize)2843 private ListDeviceRegistriesFixedSizeCollection( 2844 List<ListDeviceRegistriesPage> pages, int collectionSize) { 2845 super(pages, collectionSize); 2846 } 2847 createEmptyCollection()2848 private static ListDeviceRegistriesFixedSizeCollection createEmptyCollection() { 2849 return new ListDeviceRegistriesFixedSizeCollection(null, 0); 2850 } 2851 2852 @Override createCollection( List<ListDeviceRegistriesPage> pages, int collectionSize)2853 protected ListDeviceRegistriesFixedSizeCollection createCollection( 2854 List<ListDeviceRegistriesPage> pages, int collectionSize) { 2855 return new ListDeviceRegistriesFixedSizeCollection(pages, collectionSize); 2856 } 2857 } 2858 2859 public static class ListDevicesPagedResponse 2860 extends AbstractPagedListResponse< 2861 ListDevicesRequest, 2862 ListDevicesResponse, 2863 Device, 2864 ListDevicesPage, 2865 ListDevicesFixedSizeCollection> { 2866 createAsync( PageContext<ListDevicesRequest, ListDevicesResponse, Device> context, ApiFuture<ListDevicesResponse> futureResponse)2867 public static ApiFuture<ListDevicesPagedResponse> createAsync( 2868 PageContext<ListDevicesRequest, ListDevicesResponse, Device> context, 2869 ApiFuture<ListDevicesResponse> futureResponse) { 2870 ApiFuture<ListDevicesPage> futurePage = 2871 ListDevicesPage.createEmptyPage().createPageAsync(context, futureResponse); 2872 return ApiFutures.transform( 2873 futurePage, input -> new ListDevicesPagedResponse(input), MoreExecutors.directExecutor()); 2874 } 2875 ListDevicesPagedResponse(ListDevicesPage page)2876 private ListDevicesPagedResponse(ListDevicesPage page) { 2877 super(page, ListDevicesFixedSizeCollection.createEmptyCollection()); 2878 } 2879 } 2880 2881 public static class ListDevicesPage 2882 extends AbstractPage<ListDevicesRequest, ListDevicesResponse, Device, ListDevicesPage> { 2883 ListDevicesPage( PageContext<ListDevicesRequest, ListDevicesResponse, Device> context, ListDevicesResponse response)2884 private ListDevicesPage( 2885 PageContext<ListDevicesRequest, ListDevicesResponse, Device> context, 2886 ListDevicesResponse response) { 2887 super(context, response); 2888 } 2889 createEmptyPage()2890 private static ListDevicesPage createEmptyPage() { 2891 return new ListDevicesPage(null, null); 2892 } 2893 2894 @Override createPage( PageContext<ListDevicesRequest, ListDevicesResponse, Device> context, ListDevicesResponse response)2895 protected ListDevicesPage createPage( 2896 PageContext<ListDevicesRequest, ListDevicesResponse, Device> context, 2897 ListDevicesResponse response) { 2898 return new ListDevicesPage(context, response); 2899 } 2900 2901 @Override createPageAsync( PageContext<ListDevicesRequest, ListDevicesResponse, Device> context, ApiFuture<ListDevicesResponse> futureResponse)2902 public ApiFuture<ListDevicesPage> createPageAsync( 2903 PageContext<ListDevicesRequest, ListDevicesResponse, Device> context, 2904 ApiFuture<ListDevicesResponse> futureResponse) { 2905 return super.createPageAsync(context, futureResponse); 2906 } 2907 } 2908 2909 public static class ListDevicesFixedSizeCollection 2910 extends AbstractFixedSizeCollection< 2911 ListDevicesRequest, 2912 ListDevicesResponse, 2913 Device, 2914 ListDevicesPage, 2915 ListDevicesFixedSizeCollection> { 2916 ListDevicesFixedSizeCollection(List<ListDevicesPage> pages, int collectionSize)2917 private ListDevicesFixedSizeCollection(List<ListDevicesPage> pages, int collectionSize) { 2918 super(pages, collectionSize); 2919 } 2920 createEmptyCollection()2921 private static ListDevicesFixedSizeCollection createEmptyCollection() { 2922 return new ListDevicesFixedSizeCollection(null, 0); 2923 } 2924 2925 @Override createCollection( List<ListDevicesPage> pages, int collectionSize)2926 protected ListDevicesFixedSizeCollection createCollection( 2927 List<ListDevicesPage> pages, int collectionSize) { 2928 return new ListDevicesFixedSizeCollection(pages, collectionSize); 2929 } 2930 } 2931 } 2932