Class DeviceManagerClient
- All Implemented Interfaces:
BackgroundResource,AutoCloseable
This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build();
DeviceRegistry response = deviceManagerClient.createDeviceRegistry(parent, deviceRegistry);
}
Note: close() needs to be called on the DeviceManagerClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().
| Method | Description | Method Variants |
|---|---|---|
CreateDeviceRegistry |
Creates a device registry that contains devices. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
GetDeviceRegistry |
Gets a device registry configuration. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
UpdateDeviceRegistry |
Updates a device registry configuration. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
DeleteDeviceRegistry |
Deletes a device registry configuration. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
ListDeviceRegistries |
Lists device registries. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
CreateDevice |
Creates a device in a device registry. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
GetDevice |
Gets details about a device. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
UpdateDevice |
Updates a device. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
DeleteDevice |
Deletes a device. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
ListDevices |
List devices in a device registry. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
ModifyCloudToDeviceConfig |
Modifies the configuration for the device, which is eventually sent from the Cloud IoT Core servers. Returns the modified configuration version and its metadata. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
ListDeviceConfigVersions |
Lists the last few versions of the device configuration in descending order (i.e.: newest first). |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
ListDeviceStates |
Lists the last few versions of the device state in descending order (i.e.: newest first). |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
SetIamPolicy |
Sets the access control policy on the specified resource. Replaces any existing policy. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
GetIamPolicy |
Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
TestIamPermissions |
Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a NOT_FOUND error. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
SendCommandToDevice |
Sends a command to the specified device. In order for a device to be able to receive commands, it must: 1) be connected to Cloud IoT Core using the MQTT protocol, and 2) be subscribed to the group of MQTT topics specified by /devices/{device-id}/commands/#. This subscription will receive commands at the top-level topic /devices/{device-id}/commands as well as commands for subfolders, like /devices/{device-id}/commands/subfolder. Note that subscribing to specific subfolders is not supported. If the command could not be delivered to the device, this method will return an error; in particular, if the device is not subscribed, this method will return FAILED_PRECONDITION. Otherwise, this method will return OK. If the subscription is QoS 1, at least once delivery will be guaranteed; for QoS 0, no acknowledgment will be expected from the device. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
BindDeviceToGateway |
Associates the device with the gateway. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
UnbindDeviceFromGateway |
Deletes the association between the device and the gateway. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
See the individual methods for example code.
Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.
This class can be customized by passing in a custom instance of DeviceManagerSettings to create(). For example:
To customize credentials:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
DeviceManagerSettings deviceManagerSettings =
DeviceManagerSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
DeviceManagerClient deviceManagerClient = DeviceManagerClient.create(deviceManagerSettings);
To customize the endpoint:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
DeviceManagerSettings deviceManagerSettings =
DeviceManagerSettings.newBuilder().setEndpoint(myEndpoint).build();
DeviceManagerClient deviceManagerClient = DeviceManagerClient.create(deviceManagerSettings);
To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over the wire:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
DeviceManagerSettings deviceManagerSettings =
DeviceManagerSettings.newHttpJsonBuilder().build();
DeviceManagerClient deviceManagerClient = DeviceManagerClient.create(deviceManagerSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic classstatic classstatic classstatic class -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDeviceManagerClient(DeviceManagerSettings settings) Constructs an instance of DeviceManagerClient, using the given settings.protected -
Method Summary
Modifier and TypeMethodDescriptionbooleanawaitTermination(long duration, TimeUnit unit) Associates the device with the gateway.bindDeviceToGateway(RegistryName parent, String gatewayId, String deviceId) Associates the device with the gateway.bindDeviceToGateway(String parent, String gatewayId, String deviceId) Associates the device with the gateway.Associates the device with the gateway.final voidclose()static final DeviceManagerClientcreate()Constructs an instance of DeviceManagerClient with default settings.static final DeviceManagerClientcreate(DeviceManagerSettings settings) Constructs an instance of DeviceManagerClient, using the given settings.static final DeviceManagerClientcreate(DeviceManagerStub stub) Constructs an instance of DeviceManagerClient, using the given stub for making calls.final DevicecreateDevice(CreateDeviceRequest request) Creates a device in a device registry.final DevicecreateDevice(RegistryName parent, Device device) Creates a device in a device registry.final DevicecreateDevice(String parent, Device device) Creates a device in a device registry.Creates a device in a device registry.final DeviceRegistryCreates a device registry that contains devices.final DeviceRegistrycreateDeviceRegistry(LocationName parent, DeviceRegistry deviceRegistry) Creates a device registry that contains devices.final DeviceRegistrycreateDeviceRegistry(String parent, DeviceRegistry deviceRegistry) Creates a device registry that contains devices.Creates a device registry that contains devices.final voiddeleteDevice(DeleteDeviceRequest request) Deletes a device.final voiddeleteDevice(DeviceName name) Deletes a device.final voiddeleteDevice(String name) Deletes a device.final UnaryCallable<DeleteDeviceRequest,com.google.protobuf.Empty> Deletes a device.final voidDeletes a device registry configuration.final voidDeletes a device registry configuration.final voiddeleteDeviceRegistry(String name) Deletes a device registry configuration.final UnaryCallable<DeleteDeviceRegistryRequest,com.google.protobuf.Empty> Deletes a device registry configuration.final DevicegetDevice(DeviceName name) Gets details about a device.final DevicegetDevice(GetDeviceRequest request) Gets details about a device.final DeviceGets details about a device.final UnaryCallable<GetDeviceRequest,Device> Gets details about a device.final DeviceRegistryGets a device registry configuration.final DeviceRegistryGets a device registry configuration.final DeviceRegistrygetDeviceRegistry(String name) Gets a device registry configuration.Gets a device registry configuration.final PolicygetIamPolicy(ResourceName resource) Gets the access control policy for a resource.final PolicygetIamPolicy(GetIamPolicyRequest request) Gets the access control policy for a resource.final PolicygetIamPolicy(String resource) Gets the access control policy for a resource.Gets the access control policy for a resource.final DeviceManagerSettingsgetStub()booleanbooleanLists the last few versions of the device configuration in descending order (i.e.: newest first).Lists the last few versions of the device configuration in descending order (i.e.: newest first).Lists the last few versions of the device configuration in descending order (i.e.: newest first).Lists the last few versions of the device configuration in descending order (i.e.: newest first).Lists device registries.listDeviceRegistries(LocationName parent) Lists device registries.listDeviceRegistries(String parent) Lists device registries.Lists device registries.final UnaryCallable<ListDeviceRegistriesRequest,DeviceManagerClient.ListDeviceRegistriesPagedResponse> Lists device registries.listDevices(ListDevicesRequest request) List devices in a device registry.listDevices(RegistryName parent) List devices in a device registry.listDevices(String parent) List devices in a device registry.List devices in a device registry.List devices in a device registry.final ListDeviceStatesResponselistDeviceStates(DeviceName name) Lists the last few versions of the device state in descending order (i.e.: newest first).final ListDeviceStatesResponselistDeviceStates(ListDeviceStatesRequest request) Lists the last few versions of the device state in descending order (i.e.: newest first).final ListDeviceStatesResponselistDeviceStates(String name) Lists the last few versions of the device state in descending order (i.e.: newest first).Lists the last few versions of the device state in descending order (i.e.: newest first).final DeviceConfigmodifyCloudToDeviceConfig(DeviceName name, com.google.protobuf.ByteString binaryData) Modifies the configuration for the device, which is eventually sent from the Cloud IoT Core servers.final DeviceConfigModifies the configuration for the device, which is eventually sent from the Cloud IoT Core servers.final DeviceConfigmodifyCloudToDeviceConfig(String name, com.google.protobuf.ByteString binaryData) Modifies the configuration for the device, which is eventually sent from the Cloud IoT Core servers.Modifies the configuration for the device, which is eventually sent from the Cloud IoT Core servers.sendCommandToDevice(DeviceName name, com.google.protobuf.ByteString binaryData) Sends a command to the specified device.sendCommandToDevice(DeviceName name, com.google.protobuf.ByteString binaryData, String subfolder) Sends a command to the specified device.Sends a command to the specified device.sendCommandToDevice(String name, com.google.protobuf.ByteString binaryData) Sends a command to the specified device.sendCommandToDevice(String name, com.google.protobuf.ByteString binaryData, String subfolder) Sends a command to the specified device.Sends a command to the specified device.final PolicysetIamPolicy(ResourceName resource, Policy policy) Sets the access control policy on the specified resource.final PolicysetIamPolicy(SetIamPolicyRequest request) Sets the access control policy on the specified resource.final PolicysetIamPolicy(String resource, Policy policy) Sets the access control policy on the specified resource.Sets the access control policy on the specified resource.voidshutdown()voidtestIamPermissions(ResourceName resource, List<String> permissions) Returns permissions that a caller has on the specified resource.Returns permissions that a caller has on the specified resource.testIamPermissions(String resource, List<String> permissions) Returns permissions that a caller has on the specified resource.Returns permissions that a caller has on the specified resource.unbindDeviceFromGateway(RegistryName parent, String gatewayId, String deviceId) Deletes the association between the device and the gateway.Deletes the association between the device and the gateway.unbindDeviceFromGateway(String parent, String gatewayId, String deviceId) Deletes the association between the device and the gateway.Deletes the association between the device and the gateway.final DeviceupdateDevice(Device device, com.google.protobuf.FieldMask updateMask) Updates a device.final DeviceupdateDevice(UpdateDeviceRequest request) Updates a device.Updates a device.final DeviceRegistryupdateDeviceRegistry(DeviceRegistry deviceRegistry, com.google.protobuf.FieldMask updateMask) Updates a device registry configuration.final DeviceRegistryUpdates a device registry configuration.Updates a device registry configuration.
-
Constructor Details
-
DeviceManagerClient
Constructs an instance of DeviceManagerClient, using the given settings. This is protected so that it is easy to make a subclass, but otherwise, the static factory methods should be preferred.- Throws:
IOException
-
DeviceManagerClient
-
-
Method Details
-
create
Constructs an instance of DeviceManagerClient with default settings.- Throws:
IOException
-
create
Constructs an instance of DeviceManagerClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.- Throws:
IOException
-
create
Constructs an instance of DeviceManagerClient, using the given stub for making calls. This is for advanced usage - prefer using create(DeviceManagerSettings). -
getSettings
-
getStub
-
createDeviceRegistry
public final DeviceRegistry createDeviceRegistry(LocationName parent, DeviceRegistry deviceRegistry) Creates a device registry that contains devices.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build(); DeviceRegistry response = deviceManagerClient.createDeviceRegistry(parent, deviceRegistry); }- Parameters:
parent- Required. The project and cloud region where this device registry must be created. For example, `projects/example-project/locations/us-central1`.deviceRegistry- Required. The device registry. The field `name` must be empty. The server will generate that field from the device registry `id` provided and the `parent` field.- Throws:
ApiException- if the remote call fails
-
createDeviceRegistry
Creates a device registry that contains devices.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build(); DeviceRegistry response = deviceManagerClient.createDeviceRegistry(parent, deviceRegistry); }- Parameters:
parent- Required. The project and cloud region where this device registry must be created. For example, `projects/example-project/locations/us-central1`.deviceRegistry- Required. The device registry. The field `name` must be empty. The server will generate that field from the device registry `id` provided and the `parent` field.- Throws:
ApiException- if the remote call fails
-
createDeviceRegistry
Creates a device registry that contains devices.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { CreateDeviceRegistryRequest request = CreateDeviceRegistryRequest.newBuilder() .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) .setDeviceRegistry(DeviceRegistry.newBuilder().build()) .build(); DeviceRegistry response = deviceManagerClient.createDeviceRegistry(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
createDeviceRegistryCallable
public final UnaryCallable<CreateDeviceRegistryRequest,DeviceRegistry> createDeviceRegistryCallable()Creates a device registry that contains devices.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { CreateDeviceRegistryRequest request = CreateDeviceRegistryRequest.newBuilder() .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) .setDeviceRegistry(DeviceRegistry.newBuilder().build()) .build(); ApiFuture<DeviceRegistry> future = deviceManagerClient.createDeviceRegistryCallable().futureCall(request); // Do something. DeviceRegistry response = future.get(); } -
getDeviceRegistry
Gets a device registry configuration.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { RegistryName name = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); DeviceRegistry response = deviceManagerClient.getDeviceRegistry(name); }- Parameters:
name- Required. The name of the device registry. For example, `projects/example-project/locations/us-central1/registries/my-registry`.- Throws:
ApiException- if the remote call fails
-
getDeviceRegistry
Gets a device registry configuration.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { String name = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString(); DeviceRegistry response = deviceManagerClient.getDeviceRegistry(name); }- Parameters:
name- Required. The name of the device registry. For example, `projects/example-project/locations/us-central1/registries/my-registry`.- Throws:
ApiException- if the remote call fails
-
getDeviceRegistry
Gets a device registry configuration.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { GetDeviceRegistryRequest request = GetDeviceRegistryRequest.newBuilder() .setName(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) .build(); DeviceRegistry response = deviceManagerClient.getDeviceRegistry(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
getDeviceRegistryCallable
Gets a device registry configuration.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { GetDeviceRegistryRequest request = GetDeviceRegistryRequest.newBuilder() .setName(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) .build(); ApiFuture<DeviceRegistry> future = deviceManagerClient.getDeviceRegistryCallable().futureCall(request); // Do something. DeviceRegistry response = future.get(); } -
updateDeviceRegistry
public final DeviceRegistry updateDeviceRegistry(DeviceRegistry deviceRegistry, com.google.protobuf.FieldMask updateMask) Updates a device registry configuration.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build(); FieldMask updateMask = FieldMask.newBuilder().build(); DeviceRegistry response = deviceManagerClient.updateDeviceRegistry(deviceRegistry, updateMask); }- Parameters:
deviceRegistry- Required. The new values for the device registry. The `id` field must be empty, and the `name` field must indicate the path of the resource. For example, `projects/example-project/locations/us-central1/registries/my-registry`.updateMask- Required. Only updates the `device_registry` fields indicated by this mask. The field mask must not be empty, and it must not contain fields that are immutable or only set by the server. Mutable top-level fields: `event_notification_config`, `http_config`, `mqtt_config`, and `state_notification_config`.- Throws:
ApiException- if the remote call fails
-
updateDeviceRegistry
Updates a device registry configuration.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { UpdateDeviceRegistryRequest request = UpdateDeviceRegistryRequest.newBuilder() .setDeviceRegistry(DeviceRegistry.newBuilder().build()) .setUpdateMask(FieldMask.newBuilder().build()) .build(); DeviceRegistry response = deviceManagerClient.updateDeviceRegistry(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
updateDeviceRegistryCallable
public final UnaryCallable<UpdateDeviceRegistryRequest,DeviceRegistry> updateDeviceRegistryCallable()Updates a device registry configuration.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { UpdateDeviceRegistryRequest request = UpdateDeviceRegistryRequest.newBuilder() .setDeviceRegistry(DeviceRegistry.newBuilder().build()) .setUpdateMask(FieldMask.newBuilder().build()) .build(); ApiFuture<DeviceRegistry> future = deviceManagerClient.updateDeviceRegistryCallable().futureCall(request); // Do something. DeviceRegistry response = future.get(); } -
deleteDeviceRegistry
Deletes a device registry configuration.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { RegistryName name = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); deviceManagerClient.deleteDeviceRegistry(name); }- Parameters:
name- Required. The name of the device registry. For example, `projects/example-project/locations/us-central1/registries/my-registry`.- Throws:
ApiException- if the remote call fails
-
deleteDeviceRegistry
Deletes a device registry configuration.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { String name = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString(); deviceManagerClient.deleteDeviceRegistry(name); }- Parameters:
name- Required. The name of the device registry. For example, `projects/example-project/locations/us-central1/registries/my-registry`.- Throws:
ApiException- if the remote call fails
-
deleteDeviceRegistry
Deletes a device registry configuration.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { DeleteDeviceRegistryRequest request = DeleteDeviceRegistryRequest.newBuilder() .setName(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) .build(); deviceManagerClient.deleteDeviceRegistry(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
deleteDeviceRegistryCallable
public final UnaryCallable<DeleteDeviceRegistryRequest,com.google.protobuf.Empty> deleteDeviceRegistryCallable()Deletes a device registry configuration.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { DeleteDeviceRegistryRequest request = DeleteDeviceRegistryRequest.newBuilder() .setName(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) .build(); ApiFuture<Empty> future = deviceManagerClient.deleteDeviceRegistryCallable().futureCall(request); // Do something. future.get(); } -
listDeviceRegistries
public final DeviceManagerClient.ListDeviceRegistriesPagedResponse listDeviceRegistries(LocationName parent) Lists device registries.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); for (DeviceRegistry element : deviceManagerClient.listDeviceRegistries(parent).iterateAll()) { // doThingsWith(element); } }- Parameters:
parent- Required. The project and cloud region path. For example, `projects/example-project/locations/us-central1`.- Throws:
ApiException- if the remote call fails
-
listDeviceRegistries
public final DeviceManagerClient.ListDeviceRegistriesPagedResponse listDeviceRegistries(String parent) Lists device registries.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); for (DeviceRegistry element : deviceManagerClient.listDeviceRegistries(parent).iterateAll()) { // doThingsWith(element); } }- Parameters:
parent- Required. The project and cloud region path. For example, `projects/example-project/locations/us-central1`.- Throws:
ApiException- if the remote call fails
-
listDeviceRegistries
public final DeviceManagerClient.ListDeviceRegistriesPagedResponse listDeviceRegistries(ListDeviceRegistriesRequest request) Lists device registries.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { ListDeviceRegistriesRequest request = ListDeviceRegistriesRequest.newBuilder() .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) .setPageSize(883849137) .setPageToken("pageToken873572522") .build(); for (DeviceRegistry element : deviceManagerClient.listDeviceRegistries(request).iterateAll()) { // doThingsWith(element); } }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
listDeviceRegistriesPagedCallable
public final UnaryCallable<ListDeviceRegistriesRequest,DeviceManagerClient.ListDeviceRegistriesPagedResponse> listDeviceRegistriesPagedCallable()Lists device registries.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { ListDeviceRegistriesRequest request = ListDeviceRegistriesRequest.newBuilder() .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) .setPageSize(883849137) .setPageToken("pageToken873572522") .build(); ApiFuture<DeviceRegistry> future = deviceManagerClient.listDeviceRegistriesPagedCallable().futureCall(request); // Do something. for (DeviceRegistry element : future.get().iterateAll()) { // doThingsWith(element); } } -
listDeviceRegistriesCallable
public final UnaryCallable<ListDeviceRegistriesRequest,ListDeviceRegistriesResponse> listDeviceRegistriesCallable()Lists device registries.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { ListDeviceRegistriesRequest request = ListDeviceRegistriesRequest.newBuilder() .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) .setPageSize(883849137) .setPageToken("pageToken873572522") .build(); while (true) { ListDeviceRegistriesResponse response = deviceManagerClient.listDeviceRegistriesCallable().call(request); for (DeviceRegistry element : response.getDeviceRegistriesList()) { // doThingsWith(element); } String nextPageToken = response.getNextPageToken(); if (!Strings.isNullOrEmpty(nextPageToken)) { request = request.toBuilder().setPageToken(nextPageToken).build(); } else { break; } } } -
createDevice
Creates a device in a device registry.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { RegistryName parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); Device device = Device.newBuilder().build(); Device response = deviceManagerClient.createDevice(parent, device); }- Parameters:
parent- Required. The name of the device registry where this device should be created. For example, `projects/example-project/locations/us-central1/registries/my-registry`.device- Required. The device registration details. The field `name` must be empty. The server generates `name` from the device registry `id` and the `parent` field.- Throws:
ApiException- if the remote call fails
-
createDevice
Creates a device in a device registry.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { String parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString(); Device device = Device.newBuilder().build(); Device response = deviceManagerClient.createDevice(parent, device); }- Parameters:
parent- Required. The name of the device registry where this device should be created. For example, `projects/example-project/locations/us-central1/registries/my-registry`.device- Required. The device registration details. The field `name` must be empty. The server generates `name` from the device registry `id` and the `parent` field.- Throws:
ApiException- if the remote call fails
-
createDevice
Creates a device in a device registry.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { CreateDeviceRequest request = CreateDeviceRequest.newBuilder() .setParent(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) .setDevice(Device.newBuilder().build()) .build(); Device response = deviceManagerClient.createDevice(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
createDeviceCallable
Creates a device in a device registry.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { CreateDeviceRequest request = CreateDeviceRequest.newBuilder() .setParent(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) .setDevice(Device.newBuilder().build()) .build(); ApiFuture<Device> future = deviceManagerClient.createDeviceCallable().futureCall(request); // Do something. Device response = future.get(); } -
getDevice
Gets details about a device.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]"); Device response = deviceManagerClient.getDevice(name); }- Parameters:
name- Required. The name of the device. For example, `projects/p0/locations/us-central1/registries/registry0/devices/device0` or `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.- Throws:
ApiException- if the remote call fails
-
getDevice
Gets details about a device.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { String name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString(); Device response = deviceManagerClient.getDevice(name); }- Parameters:
name- Required. The name of the device. For example, `projects/p0/locations/us-central1/registries/registry0/devices/device0` or `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.- Throws:
ApiException- if the remote call fails
-
getDevice
Gets details about a device.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { GetDeviceRequest request = GetDeviceRequest.newBuilder() .setName( DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString()) .setFieldMask(FieldMask.newBuilder().build()) .build(); Device response = deviceManagerClient.getDevice(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
getDeviceCallable
Gets details about a device.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { GetDeviceRequest request = GetDeviceRequest.newBuilder() .setName( DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString()) .setFieldMask(FieldMask.newBuilder().build()) .build(); ApiFuture<Device> future = deviceManagerClient.getDeviceCallable().futureCall(request); // Do something. Device response = future.get(); } -
updateDevice
Updates a device.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { Device device = Device.newBuilder().build(); FieldMask updateMask = FieldMask.newBuilder().build(); Device response = deviceManagerClient.updateDevice(device, updateMask); }- Parameters:
device- Required. The new values for the device. The `id` and `num_id` fields must be empty, and the field `name` must specify the name path. For example, `projects/p0/locations/us-central1/registries/registry0/devices/device0`or `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.updateMask- Required. Only updates the `device` fields indicated by this mask. The field mask must not be empty, and it must not contain fields that are immutable or only set by the server. Mutable top-level fields: `credentials`, `blocked`, and `metadata`- Throws:
ApiException- if the remote call fails
-
updateDevice
Updates a device.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { UpdateDeviceRequest request = UpdateDeviceRequest.newBuilder() .setDevice(Device.newBuilder().build()) .setUpdateMask(FieldMask.newBuilder().build()) .build(); Device response = deviceManagerClient.updateDevice(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
updateDeviceCallable
Updates a device.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { UpdateDeviceRequest request = UpdateDeviceRequest.newBuilder() .setDevice(Device.newBuilder().build()) .setUpdateMask(FieldMask.newBuilder().build()) .build(); ApiFuture<Device> future = deviceManagerClient.updateDeviceCallable().futureCall(request); // Do something. Device response = future.get(); } -
deleteDevice
Deletes a device.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]"); deviceManagerClient.deleteDevice(name); }- Parameters:
name- Required. The name of the device. For example, `projects/p0/locations/us-central1/registries/registry0/devices/device0` or `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.- Throws:
ApiException- if the remote call fails
-
deleteDevice
Deletes a device.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { String name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString(); deviceManagerClient.deleteDevice(name); }- Parameters:
name- Required. The name of the device. For example, `projects/p0/locations/us-central1/registries/registry0/devices/device0` or `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.- Throws:
ApiException- if the remote call fails
-
deleteDevice
Deletes a device.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { DeleteDeviceRequest request = DeleteDeviceRequest.newBuilder() .setName( DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString()) .build(); deviceManagerClient.deleteDevice(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
deleteDeviceCallable
Deletes a device.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { DeleteDeviceRequest request = DeleteDeviceRequest.newBuilder() .setName( DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString()) .build(); ApiFuture<Empty> future = deviceManagerClient.deleteDeviceCallable().futureCall(request); // Do something. future.get(); } -
listDevices
List devices in a device registry.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { RegistryName parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); for (Device element : deviceManagerClient.listDevices(parent).iterateAll()) { // doThingsWith(element); } }- Parameters:
parent- Required. The device registry path. Required. For example, `projects/my-project/locations/us-central1/registries/my-registry`.- Throws:
ApiException- if the remote call fails
-
listDevices
List devices in a device registry.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { String parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString(); for (Device element : deviceManagerClient.listDevices(parent).iterateAll()) { // doThingsWith(element); } }- Parameters:
parent- Required. The device registry path. Required. For example, `projects/my-project/locations/us-central1/registries/my-registry`.- Throws:
ApiException- if the remote call fails
-
listDevices
List devices in a device registry.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { ListDevicesRequest request = ListDevicesRequest.newBuilder() .setParent(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) .addAllDeviceNumIds(new ArrayList<Long>()) .addAllDeviceIds(new ArrayList<String>()) .setFieldMask(FieldMask.newBuilder().build()) .setGatewayListOptions(GatewayListOptions.newBuilder().build()) .setPageSize(883849137) .setPageToken("pageToken873572522") .build(); for (Device element : deviceManagerClient.listDevices(request).iterateAll()) { // doThingsWith(element); } }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
listDevicesPagedCallable
public final UnaryCallable<ListDevicesRequest,DeviceManagerClient.ListDevicesPagedResponse> listDevicesPagedCallable()List devices in a device registry.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { ListDevicesRequest request = ListDevicesRequest.newBuilder() .setParent(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) .addAllDeviceNumIds(new ArrayList<Long>()) .addAllDeviceIds(new ArrayList<String>()) .setFieldMask(FieldMask.newBuilder().build()) .setGatewayListOptions(GatewayListOptions.newBuilder().build()) .setPageSize(883849137) .setPageToken("pageToken873572522") .build(); ApiFuture<Device> future = deviceManagerClient.listDevicesPagedCallable().futureCall(request); // Do something. for (Device element : future.get().iterateAll()) { // doThingsWith(element); } } -
listDevicesCallable
List devices in a device registry.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { ListDevicesRequest request = ListDevicesRequest.newBuilder() .setParent(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) .addAllDeviceNumIds(new ArrayList<Long>()) .addAllDeviceIds(new ArrayList<String>()) .setFieldMask(FieldMask.newBuilder().build()) .setGatewayListOptions(GatewayListOptions.newBuilder().build()) .setPageSize(883849137) .setPageToken("pageToken873572522") .build(); while (true) { ListDevicesResponse response = deviceManagerClient.listDevicesCallable().call(request); for (Device element : response.getDevicesList()) { // doThingsWith(element); } String nextPageToken = response.getNextPageToken(); if (!Strings.isNullOrEmpty(nextPageToken)) { request = request.toBuilder().setPageToken(nextPageToken).build(); } else { break; } } } -
modifyCloudToDeviceConfig
public final DeviceConfig modifyCloudToDeviceConfig(DeviceName name, com.google.protobuf.ByteString binaryData) Modifies the configuration for the device, which is eventually sent from the Cloud IoT Core servers. Returns the modified configuration version and its metadata.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]"); ByteString binaryData = ByteString.EMPTY; DeviceConfig response = deviceManagerClient.modifyCloudToDeviceConfig(name, binaryData); }- Parameters:
name- Required. The name of the device. For example, `projects/p0/locations/us-central1/registries/registry0/devices/device0` or `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.binaryData- Required. The configuration data for the device.- Throws:
ApiException- if the remote call fails
-
modifyCloudToDeviceConfig
public final DeviceConfig modifyCloudToDeviceConfig(String name, com.google.protobuf.ByteString binaryData) Modifies the configuration for the device, which is eventually sent from the Cloud IoT Core servers. Returns the modified configuration version and its metadata.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { String name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString(); ByteString binaryData = ByteString.EMPTY; DeviceConfig response = deviceManagerClient.modifyCloudToDeviceConfig(name, binaryData); }- Parameters:
name- Required. The name of the device. For example, `projects/p0/locations/us-central1/registries/registry0/devices/device0` or `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.binaryData- Required. The configuration data for the device.- Throws:
ApiException- if the remote call fails
-
modifyCloudToDeviceConfig
Modifies the configuration for the device, which is eventually sent from the Cloud IoT Core servers. Returns the modified configuration version and its metadata.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { ModifyCloudToDeviceConfigRequest request = ModifyCloudToDeviceConfigRequest.newBuilder() .setName( DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString()) .setVersionToUpdate(462348390) .setBinaryData(ByteString.EMPTY) .build(); DeviceConfig response = deviceManagerClient.modifyCloudToDeviceConfig(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
modifyCloudToDeviceConfigCallable
public final UnaryCallable<ModifyCloudToDeviceConfigRequest,DeviceConfig> modifyCloudToDeviceConfigCallable()Modifies the configuration for the device, which is eventually sent from the Cloud IoT Core servers. Returns the modified configuration version and its metadata.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { ModifyCloudToDeviceConfigRequest request = ModifyCloudToDeviceConfigRequest.newBuilder() .setName( DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString()) .setVersionToUpdate(462348390) .setBinaryData(ByteString.EMPTY) .build(); ApiFuture<DeviceConfig> future = deviceManagerClient.modifyCloudToDeviceConfigCallable().futureCall(request); // Do something. DeviceConfig response = future.get(); } -
listDeviceConfigVersions
Lists the last few versions of the device configuration in descending order (i.e.: newest first).Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]"); ListDeviceConfigVersionsResponse response = deviceManagerClient.listDeviceConfigVersions(name); }- Parameters:
name- Required. The name of the device. For example, `projects/p0/locations/us-central1/registries/registry0/devices/device0` or `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.- Throws:
ApiException- if the remote call fails
-
listDeviceConfigVersions
Lists the last few versions of the device configuration in descending order (i.e.: newest first).Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { String name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString(); ListDeviceConfigVersionsResponse response = deviceManagerClient.listDeviceConfigVersions(name); }- Parameters:
name- Required. The name of the device. For example, `projects/p0/locations/us-central1/registries/registry0/devices/device0` or `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.- Throws:
ApiException- if the remote call fails
-
listDeviceConfigVersions
public final ListDeviceConfigVersionsResponse listDeviceConfigVersions(ListDeviceConfigVersionsRequest request) Lists the last few versions of the device configuration in descending order (i.e.: newest first).Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { ListDeviceConfigVersionsRequest request = ListDeviceConfigVersionsRequest.newBuilder() .setName( DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString()) .setNumVersions(-315385036) .build(); ListDeviceConfigVersionsResponse response = deviceManagerClient.listDeviceConfigVersions(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
listDeviceConfigVersionsCallable
public final UnaryCallable<ListDeviceConfigVersionsRequest,ListDeviceConfigVersionsResponse> listDeviceConfigVersionsCallable()Lists the last few versions of the device configuration in descending order (i.e.: newest first).Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { ListDeviceConfigVersionsRequest request = ListDeviceConfigVersionsRequest.newBuilder() .setName( DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString()) .setNumVersions(-315385036) .build(); ApiFuture<ListDeviceConfigVersionsResponse> future = deviceManagerClient.listDeviceConfigVersionsCallable().futureCall(request); // Do something. ListDeviceConfigVersionsResponse response = future.get(); } -
listDeviceStates
Lists the last few versions of the device state in descending order (i.e.: newest first).Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]"); ListDeviceStatesResponse response = deviceManagerClient.listDeviceStates(name); }- Parameters:
name- Required. The name of the device. For example, `projects/p0/locations/us-central1/registries/registry0/devices/device0` or `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.- Throws:
ApiException- if the remote call fails
-
listDeviceStates
Lists the last few versions of the device state in descending order (i.e.: newest first).Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { String name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString(); ListDeviceStatesResponse response = deviceManagerClient.listDeviceStates(name); }- Parameters:
name- Required. The name of the device. For example, `projects/p0/locations/us-central1/registries/registry0/devices/device0` or `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.- Throws:
ApiException- if the remote call fails
-
listDeviceStates
Lists the last few versions of the device state in descending order (i.e.: newest first).Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { ListDeviceStatesRequest request = ListDeviceStatesRequest.newBuilder() .setName( DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString()) .setNumStates(1643330779) .build(); ListDeviceStatesResponse response = deviceManagerClient.listDeviceStates(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
listDeviceStatesCallable
public final UnaryCallable<ListDeviceStatesRequest,ListDeviceStatesResponse> listDeviceStatesCallable()Lists the last few versions of the device state in descending order (i.e.: newest first).Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { ListDeviceStatesRequest request = ListDeviceStatesRequest.newBuilder() .setName( DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString()) .setNumStates(1643330779) .build(); ApiFuture<ListDeviceStatesResponse> future = deviceManagerClient.listDeviceStatesCallable().futureCall(request); // Do something. ListDeviceStatesResponse response = future.get(); } -
setIamPolicy
Sets the access control policy on the specified resource. Replaces any existing policy.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { ResourceName resource = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); Policy policy = Policy.newBuilder().build(); Policy response = deviceManagerClient.setIamPolicy(resource, policy); }- Parameters:
resource- REQUIRED: The resource for which the policy is being specified. See the operation documentation for the appropriate value for this field.policy- REQUIRED: The complete policy to be applied to the `resource`. The size of the policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Cloud Platform services (such as Projects) might reject them.- Throws:
ApiException- if the remote call fails
-
setIamPolicy
Sets the access control policy on the specified resource. Replaces any existing policy.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { String resource = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString(); Policy policy = Policy.newBuilder().build(); Policy response = deviceManagerClient.setIamPolicy(resource, policy); }- Parameters:
resource- REQUIRED: The resource for which the policy is being specified. See the operation documentation for the appropriate value for this field.policy- REQUIRED: The complete policy to be applied to the `resource`. The size of the policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Cloud Platform services (such as Projects) might reject them.- Throws:
ApiException- if the remote call fails
-
setIamPolicy
Sets the access control policy on the specified resource. Replaces any existing policy.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { SetIamPolicyRequest request = SetIamPolicyRequest.newBuilder() .setResource(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) .setPolicy(Policy.newBuilder().build()) .setUpdateMask(FieldMask.newBuilder().build()) .build(); Policy response = deviceManagerClient.setIamPolicy(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
setIamPolicyCallable
Sets the access control policy on the specified resource. Replaces any existing policy.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { SetIamPolicyRequest request = SetIamPolicyRequest.newBuilder() .setResource(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) .setPolicy(Policy.newBuilder().build()) .setUpdateMask(FieldMask.newBuilder().build()) .build(); ApiFuture<Policy> future = deviceManagerClient.setIamPolicyCallable().futureCall(request); // Do something. Policy response = future.get(); } -
getIamPolicy
Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { ResourceName resource = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); Policy response = deviceManagerClient.getIamPolicy(resource); }- Parameters:
resource- REQUIRED: The resource for which the policy is being requested. See the operation documentation for the appropriate value for this field.- Throws:
ApiException- if the remote call fails
-
getIamPolicy
Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { String resource = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString(); Policy response = deviceManagerClient.getIamPolicy(resource); }- Parameters:
resource- REQUIRED: The resource for which the policy is being requested. See the operation documentation for the appropriate value for this field.- Throws:
ApiException- if the remote call fails
-
getIamPolicy
Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { GetIamPolicyRequest request = GetIamPolicyRequest.newBuilder() .setResource(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) .setOptions(GetPolicyOptions.newBuilder().build()) .build(); Policy response = deviceManagerClient.getIamPolicy(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
getIamPolicyCallable
Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { GetIamPolicyRequest request = GetIamPolicyRequest.newBuilder() .setResource(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) .setOptions(GetPolicyOptions.newBuilder().build()) .build(); ApiFuture<Policy> future = deviceManagerClient.getIamPolicyCallable().futureCall(request); // Do something. Policy response = future.get(); } -
testIamPermissions
public final TestIamPermissionsResponse testIamPermissions(ResourceName resource, List<String> permissions) Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a NOT_FOUND error.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { ResourceName resource = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); List<String> permissions = new ArrayList<>(); TestIamPermissionsResponse response = deviceManagerClient.testIamPermissions(resource, permissions); }- Parameters:
resource- REQUIRED: The resource for which the policy detail is being requested. See the operation documentation for the appropriate value for this field.permissions- The set of permissions to check for the `resource`. Permissions with wildcards (such as '*' or 'storage.*') are not allowed. For more information see [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).- Throws:
ApiException- if the remote call fails
-
testIamPermissions
public final TestIamPermissionsResponse testIamPermissions(String resource, List<String> permissions) Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a NOT_FOUND error.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { String resource = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString(); List<String> permissions = new ArrayList<>(); TestIamPermissionsResponse response = deviceManagerClient.testIamPermissions(resource, permissions); }- Parameters:
resource- REQUIRED: The resource for which the policy detail is being requested. See the operation documentation for the appropriate value for this field.permissions- The set of permissions to check for the `resource`. Permissions with wildcards (such as '*' or 'storage.*') are not allowed. For more information see [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).- Throws:
ApiException- if the remote call fails
-
testIamPermissions
Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a NOT_FOUND error.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { TestIamPermissionsRequest request = TestIamPermissionsRequest.newBuilder() .setResource(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) .addAllPermissions(new ArrayList<String>()) .build(); TestIamPermissionsResponse response = deviceManagerClient.testIamPermissions(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
testIamPermissionsCallable
public final UnaryCallable<TestIamPermissionsRequest,TestIamPermissionsResponse> testIamPermissionsCallable()Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a NOT_FOUND error.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { TestIamPermissionsRequest request = TestIamPermissionsRequest.newBuilder() .setResource(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) .addAllPermissions(new ArrayList<String>()) .build(); ApiFuture<TestIamPermissionsResponse> future = deviceManagerClient.testIamPermissionsCallable().futureCall(request); // Do something. TestIamPermissionsResponse response = future.get(); } -
sendCommandToDevice
public final SendCommandToDeviceResponse sendCommandToDevice(DeviceName name, com.google.protobuf.ByteString binaryData) Sends a command to the specified device. In order for a device to be able to receive commands, it must: 1) be connected to Cloud IoT Core using the MQTT protocol, and 2) be subscribed to the group of MQTT topics specified by /devices/{device-id}/commands/#. This subscription will receive commands at the top-level topic /devices/{device-id}/commands as well as commands for subfolders, like /devices/{device-id}/commands/subfolder. Note that subscribing to specific subfolders is not supported. If the command could not be delivered to the device, this method will return an error; in particular, if the device is not subscribed, this method will return FAILED_PRECONDITION. Otherwise, this method will return OK. If the subscription is QoS 1, at least once delivery will be guaranteed; for QoS 0, no acknowledgment will be expected from the device.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]"); ByteString binaryData = ByteString.EMPTY; SendCommandToDeviceResponse response = deviceManagerClient.sendCommandToDevice(name, binaryData); }- Parameters:
name- Required. The name of the device. For example, `projects/p0/locations/us-central1/registries/registry0/devices/device0` or `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.binaryData- Required. The command data to send to the device.- Throws:
ApiException- if the remote call fails
-
sendCommandToDevice
public final SendCommandToDeviceResponse sendCommandToDevice(String name, com.google.protobuf.ByteString binaryData) Sends a command to the specified device. In order for a device to be able to receive commands, it must: 1) be connected to Cloud IoT Core using the MQTT protocol, and 2) be subscribed to the group of MQTT topics specified by /devices/{device-id}/commands/#. This subscription will receive commands at the top-level topic /devices/{device-id}/commands as well as commands for subfolders, like /devices/{device-id}/commands/subfolder. Note that subscribing to specific subfolders is not supported. If the command could not be delivered to the device, this method will return an error; in particular, if the device is not subscribed, this method will return FAILED_PRECONDITION. Otherwise, this method will return OK. If the subscription is QoS 1, at least once delivery will be guaranteed; for QoS 0, no acknowledgment will be expected from the device.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { String name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString(); ByteString binaryData = ByteString.EMPTY; SendCommandToDeviceResponse response = deviceManagerClient.sendCommandToDevice(name, binaryData); }- Parameters:
name- Required. The name of the device. For example, `projects/p0/locations/us-central1/registries/registry0/devices/device0` or `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.binaryData- Required. The command data to send to the device.- Throws:
ApiException- if the remote call fails
-
sendCommandToDevice
public final SendCommandToDeviceResponse sendCommandToDevice(DeviceName name, com.google.protobuf.ByteString binaryData, String subfolder) Sends a command to the specified device. In order for a device to be able to receive commands, it must: 1) be connected to Cloud IoT Core using the MQTT protocol, and 2) be subscribed to the group of MQTT topics specified by /devices/{device-id}/commands/#. This subscription will receive commands at the top-level topic /devices/{device-id}/commands as well as commands for subfolders, like /devices/{device-id}/commands/subfolder. Note that subscribing to specific subfolders is not supported. If the command could not be delivered to the device, this method will return an error; in particular, if the device is not subscribed, this method will return FAILED_PRECONDITION. Otherwise, this method will return OK. If the subscription is QoS 1, at least once delivery will be guaranteed; for QoS 0, no acknowledgment will be expected from the device.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]"); ByteString binaryData = ByteString.EMPTY; String subfolder = "subfolder153561774"; SendCommandToDeviceResponse response = deviceManagerClient.sendCommandToDevice(name, binaryData, subfolder); }- Parameters:
name- Required. The name of the device. For example, `projects/p0/locations/us-central1/registries/registry0/devices/device0` or `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.binaryData- Required. The command data to send to the device.subfolder- Optional subfolder for the command. If empty, the command will be delivered to the /devices/{device-id}/commands topic, otherwise it will be delivered to the /devices/{device-id}/commands/{subfolder} topic. Multi-level subfolders are allowed. This field must not have more than 256 characters, and must not contain any MQTT wildcards ("+" or "#") or null characters.- Throws:
ApiException- if the remote call fails
-
sendCommandToDevice
public final SendCommandToDeviceResponse sendCommandToDevice(String name, com.google.protobuf.ByteString binaryData, String subfolder) Sends a command to the specified device. In order for a device to be able to receive commands, it must: 1) be connected to Cloud IoT Core using the MQTT protocol, and 2) be subscribed to the group of MQTT topics specified by /devices/{device-id}/commands/#. This subscription will receive commands at the top-level topic /devices/{device-id}/commands as well as commands for subfolders, like /devices/{device-id}/commands/subfolder. Note that subscribing to specific subfolders is not supported. If the command could not be delivered to the device, this method will return an error; in particular, if the device is not subscribed, this method will return FAILED_PRECONDITION. Otherwise, this method will return OK. If the subscription is QoS 1, at least once delivery will be guaranteed; for QoS 0, no acknowledgment will be expected from the device.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { String name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString(); ByteString binaryData = ByteString.EMPTY; String subfolder = "subfolder153561774"; SendCommandToDeviceResponse response = deviceManagerClient.sendCommandToDevice(name, binaryData, subfolder); }- Parameters:
name- Required. The name of the device. For example, `projects/p0/locations/us-central1/registries/registry0/devices/device0` or `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.binaryData- Required. The command data to send to the device.subfolder- Optional subfolder for the command. If empty, the command will be delivered to the /devices/{device-id}/commands topic, otherwise it will be delivered to the /devices/{device-id}/commands/{subfolder} topic. Multi-level subfolders are allowed. This field must not have more than 256 characters, and must not contain any MQTT wildcards ("+" or "#") or null characters.- Throws:
ApiException- if the remote call fails
-
sendCommandToDevice
Sends a command to the specified device. In order for a device to be able to receive commands, it must: 1) be connected to Cloud IoT Core using the MQTT protocol, and 2) be subscribed to the group of MQTT topics specified by /devices/{device-id}/commands/#. This subscription will receive commands at the top-level topic /devices/{device-id}/commands as well as commands for subfolders, like /devices/{device-id}/commands/subfolder. Note that subscribing to specific subfolders is not supported. If the command could not be delivered to the device, this method will return an error; in particular, if the device is not subscribed, this method will return FAILED_PRECONDITION. Otherwise, this method will return OK. If the subscription is QoS 1, at least once delivery will be guaranteed; for QoS 0, no acknowledgment will be expected from the device.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { SendCommandToDeviceRequest request = SendCommandToDeviceRequest.newBuilder() .setName( DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString()) .setBinaryData(ByteString.EMPTY) .setSubfolder("subfolder153561774") .build(); SendCommandToDeviceResponse response = deviceManagerClient.sendCommandToDevice(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
sendCommandToDeviceCallable
public final UnaryCallable<SendCommandToDeviceRequest,SendCommandToDeviceResponse> sendCommandToDeviceCallable()Sends a command to the specified device. In order for a device to be able to receive commands, it must: 1) be connected to Cloud IoT Core using the MQTT protocol, and 2) be subscribed to the group of MQTT topics specified by /devices/{device-id}/commands/#. This subscription will receive commands at the top-level topic /devices/{device-id}/commands as well as commands for subfolders, like /devices/{device-id}/commands/subfolder. Note that subscribing to specific subfolders is not supported. If the command could not be delivered to the device, this method will return an error; in particular, if the device is not subscribed, this method will return FAILED_PRECONDITION. Otherwise, this method will return OK. If the subscription is QoS 1, at least once delivery will be guaranteed; for QoS 0, no acknowledgment will be expected from the device.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { SendCommandToDeviceRequest request = SendCommandToDeviceRequest.newBuilder() .setName( DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString()) .setBinaryData(ByteString.EMPTY) .setSubfolder("subfolder153561774") .build(); ApiFuture<SendCommandToDeviceResponse> future = deviceManagerClient.sendCommandToDeviceCallable().futureCall(request); // Do something. SendCommandToDeviceResponse response = future.get(); } -
bindDeviceToGateway
public final BindDeviceToGatewayResponse bindDeviceToGateway(RegistryName parent, String gatewayId, String deviceId) Associates the device with the gateway.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { RegistryName parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); String gatewayId = "gatewayId-1354641793"; String deviceId = "deviceId1109191185"; BindDeviceToGatewayResponse response = deviceManagerClient.bindDeviceToGateway(parent, gatewayId, deviceId); }- Parameters:
parent- Required. The name of the registry. For example, `projects/example-project/locations/us-central1/registries/my-registry`.gatewayId- Required. The value of `gateway_id` can be either the device numeric ID or the user-defined device identifier.deviceId- Required. The device to associate with the specified gateway. The value of `device_id` can be either the device numeric ID or the user-defined device identifier.- Throws:
ApiException- if the remote call fails
-
bindDeviceToGateway
public final BindDeviceToGatewayResponse bindDeviceToGateway(String parent, String gatewayId, String deviceId) Associates the device with the gateway.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { String parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString(); String gatewayId = "gatewayId-1354641793"; String deviceId = "deviceId1109191185"; BindDeviceToGatewayResponse response = deviceManagerClient.bindDeviceToGateway(parent, gatewayId, deviceId); }- Parameters:
parent- Required. The name of the registry. For example, `projects/example-project/locations/us-central1/registries/my-registry`.gatewayId- Required. The value of `gateway_id` can be either the device numeric ID or the user-defined device identifier.deviceId- Required. The device to associate with the specified gateway. The value of `device_id` can be either the device numeric ID or the user-defined device identifier.- Throws:
ApiException- if the remote call fails
-
bindDeviceToGateway
Associates the device with the gateway.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { BindDeviceToGatewayRequest request = BindDeviceToGatewayRequest.newBuilder() .setParent(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) .setGatewayId("gatewayId-1354641793") .setDeviceId("deviceId1109191185") .build(); BindDeviceToGatewayResponse response = deviceManagerClient.bindDeviceToGateway(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
bindDeviceToGatewayCallable
public final UnaryCallable<BindDeviceToGatewayRequest,BindDeviceToGatewayResponse> bindDeviceToGatewayCallable()Associates the device with the gateway.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { BindDeviceToGatewayRequest request = BindDeviceToGatewayRequest.newBuilder() .setParent(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) .setGatewayId("gatewayId-1354641793") .setDeviceId("deviceId1109191185") .build(); ApiFuture<BindDeviceToGatewayResponse> future = deviceManagerClient.bindDeviceToGatewayCallable().futureCall(request); // Do something. BindDeviceToGatewayResponse response = future.get(); } -
unbindDeviceFromGateway
public final UnbindDeviceFromGatewayResponse unbindDeviceFromGateway(RegistryName parent, String gatewayId, String deviceId) Deletes the association between the device and the gateway.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { RegistryName parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); String gatewayId = "gatewayId-1354641793"; String deviceId = "deviceId1109191185"; UnbindDeviceFromGatewayResponse response = deviceManagerClient.unbindDeviceFromGateway(parent, gatewayId, deviceId); }- Parameters:
parent- Required. The name of the registry. For example, `projects/example-project/locations/us-central1/registries/my-registry`.gatewayId- Required. The value of `gateway_id` can be either the device numeric ID or the user-defined device identifier.deviceId- Required. The device to disassociate from the specified gateway. The value of `device_id` can be either the device numeric ID or the user-defined device identifier.- Throws:
ApiException- if the remote call fails
-
unbindDeviceFromGateway
public final UnbindDeviceFromGatewayResponse unbindDeviceFromGateway(String parent, String gatewayId, String deviceId) Deletes the association between the device and the gateway.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { String parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString(); String gatewayId = "gatewayId-1354641793"; String deviceId = "deviceId1109191185"; UnbindDeviceFromGatewayResponse response = deviceManagerClient.unbindDeviceFromGateway(parent, gatewayId, deviceId); }- Parameters:
parent- Required. The name of the registry. For example, `projects/example-project/locations/us-central1/registries/my-registry`.gatewayId- Required. The value of `gateway_id` can be either the device numeric ID or the user-defined device identifier.deviceId- Required. The device to disassociate from the specified gateway. The value of `device_id` can be either the device numeric ID or the user-defined device identifier.- Throws:
ApiException- if the remote call fails
-
unbindDeviceFromGateway
public final UnbindDeviceFromGatewayResponse unbindDeviceFromGateway(UnbindDeviceFromGatewayRequest request) Deletes the association between the device and the gateway.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { UnbindDeviceFromGatewayRequest request = UnbindDeviceFromGatewayRequest.newBuilder() .setParent(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) .setGatewayId("gatewayId-1354641793") .setDeviceId("deviceId1109191185") .build(); UnbindDeviceFromGatewayResponse response = deviceManagerClient.unbindDeviceFromGateway(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
unbindDeviceFromGatewayCallable
public final UnaryCallable<UnbindDeviceFromGatewayRequest,UnbindDeviceFromGatewayResponse> unbindDeviceFromGatewayCallable()Deletes the association between the device and the gateway.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { UnbindDeviceFromGatewayRequest request = UnbindDeviceFromGatewayRequest.newBuilder() .setParent(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) .setGatewayId("gatewayId-1354641793") .setDeviceId("deviceId1109191185") .build(); ApiFuture<UnbindDeviceFromGatewayResponse> future = deviceManagerClient.unbindDeviceFromGatewayCallable().futureCall(request); // Do something. UnbindDeviceFromGatewayResponse response = future.get(); } -
close
public final void close()- Specified by:
closein interfaceAutoCloseable
-
shutdown
public void shutdown()- Specified by:
shutdownin interfaceBackgroundResource
-
isShutdown
public boolean isShutdown()- Specified by:
isShutdownin interfaceBackgroundResource
-
isTerminated
public boolean isTerminated()- Specified by:
isTerminatedin interfaceBackgroundResource
-
shutdownNow
public void shutdownNow()- Specified by:
shutdownNowin interfaceBackgroundResource
-
awaitTermination
- Specified by:
awaitTerminationin interfaceBackgroundResource- Throws:
InterruptedException
-