- 2.53.0 (latest)
- 2.52.0
- 2.51.0
- 2.49.0
- 2.48.0
- 2.47.0
- 2.46.0
- 2.45.0
- 2.44.0
- 2.43.0
- 2.42.0
- 2.41.0
- 2.40.0
- 2.39.0
- 2.37.0
- 2.36.0
- 2.35.0
- 2.34.0
- 2.33.0
- 2.32.0
- 2.31.0
- 2.30.0
- 2.29.0
- 2.28.0
- 2.27.0
- 2.24.0
- 2.23.0
- 2.22.0
- 2.21.0
- 2.20.0
- 2.19.0
- 2.18.0
- 2.17.0
- 2.16.0
- 2.15.0
- 2.14.0
- 2.13.0
- 2.12.0
- 2.11.0
- 2.9.0
- 2.8.0
- 2.7.0
- 2.6.0
- 2.5.0
- 2.4.0
- 2.3.6
- 2.2.1
- 2.1.7
public class DeviceManagerClient implements BackgroundResource
Service Description: Internet of Things (IoT) service. Securely connect and manage IoT devices.
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:
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().
The surface of this class includes several types of Java methods for each of the API's methods:
- A "flattened" method. With this type of method, the fields of the request type have been converted into function parameters. It may be the case that not all fields are available as parameters, and not every API method will have a flattened method entry point.
- A "request object" method. This type of method only takes one parameter, a request object, which must be constructed before the call. Not every API method will have a request object method.
- A "callable" method. This type of method takes no parameters and returns 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:
DeviceManagerSettings deviceManagerSettings =
DeviceManagerSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
DeviceManagerClient deviceManagerClient = DeviceManagerClient.create(deviceManagerSettings);
To customize the endpoint:
DeviceManagerSettings deviceManagerSettings =
DeviceManagerSettings.newBuilder().setEndpoint(myEndpoint).build();
DeviceManagerClient deviceManagerClient = DeviceManagerClient.create(deviceManagerSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
Implements
BackgroundResourceStatic Methods
create()
public static final DeviceManagerClient create()
Constructs an instance of DeviceManagerClient with default settings.
Type | Description |
DeviceManagerClient |
Type | Description |
IOException |
create(DeviceManagerSettings settings)
public static final DeviceManagerClient create(DeviceManagerSettings settings)
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.
Name | Description |
settings | DeviceManagerSettings |
Type | Description |
DeviceManagerClient |
Type | Description |
IOException |
create(DeviceManagerStub stub)
public static final DeviceManagerClient create(DeviceManagerStub stub)
Constructs an instance of DeviceManagerClient, using the given stub for making calls. This is for advanced usage - prefer using create(DeviceManagerSettings).
Name | Description |
stub | DeviceManagerStub |
Type | Description |
DeviceManagerClient |
Constructors
DeviceManagerClient(DeviceManagerSettings settings)
protected DeviceManagerClient(DeviceManagerSettings settings)
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.
Name | Description |
settings | DeviceManagerSettings |
DeviceManagerClient(DeviceManagerStub stub)
protected DeviceManagerClient(DeviceManagerStub stub)
Name | Description |
stub | DeviceManagerStub |
Methods
awaitTermination(long duration, TimeUnit unit)
public boolean awaitTermination(long duration, TimeUnit unit)
Name | Description |
duration | long |
unit | TimeUnit |
Type | Description |
boolean |
Type | Description |
InterruptedException |
bindDeviceToGateway(BindDeviceToGatewayRequest request)
public final BindDeviceToGatewayResponse bindDeviceToGateway(BindDeviceToGatewayRequest request)
Associates the device with the gateway.
Sample code:
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);
}
Name | Description |
request | BindDeviceToGatewayRequest The request object containing all of the parameters for the API call. |
Type | Description |
BindDeviceToGatewayResponse |
bindDeviceToGateway(RegistryName parent, String gatewayId, String deviceId)
public final BindDeviceToGatewayResponse bindDeviceToGateway(RegistryName parent, String gatewayId, String deviceId)
Associates the device with the gateway.
Sample code:
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);
}
Name | Description |
parent | RegistryName Required. The name of the registry. For example,
|
gatewayId | String Required. The value of |
deviceId | String Required. The device to associate with the specified gateway. The value of
|
Type | Description |
BindDeviceToGatewayResponse |
bindDeviceToGateway(String parent, String gatewayId, String deviceId)
public final BindDeviceToGatewayResponse bindDeviceToGateway(String parent, String gatewayId, String deviceId)
Associates the device with the gateway.
Sample code:
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);
}
Name | Description |
parent | String Required. The name of the registry. For example,
|
gatewayId | String Required. The value of |
deviceId | String Required. The device to associate with the specified gateway. The value of
|
Type | Description |
BindDeviceToGatewayResponse |
bindDeviceToGatewayCallable()
public final UnaryCallable<BindDeviceToGatewayRequest,BindDeviceToGatewayResponse> bindDeviceToGatewayCallable()
Associates the device with the gateway.
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
BindDeviceToGatewayRequest request =
BindDeviceToGatewayRequest.newBuilder()
.setParent(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString())
.setGatewayId("gatewayId-1354641793")
.setDeviceId("deviceId1109191185")
.build();
ApiFuture
Type | Description |
UnaryCallable<BindDeviceToGatewayRequest,BindDeviceToGatewayResponse> |
close()
public final void close()
createDevice(CreateDeviceRequest request)
public final Device createDevice(CreateDeviceRequest request)
Creates a device in a device registry.
Sample code:
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);
}
Name | Description |
request | CreateDeviceRequest The request object containing all of the parameters for the API call. |
Type | Description |
Device |
createDevice(RegistryName parent, Device device)
public final Device createDevice(RegistryName parent, Device device)
Creates a device in a device registry.
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
RegistryName parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]");
Device device = Device.newBuilder().build();
Device response = deviceManagerClient.createDevice(parent, device);
}
Name | Description |
parent | RegistryName Required. The name of the device registry where this device should be created.
For example, |
device | Device Required. The device registration details. The field |
Type | Description |
Device |
createDevice(String parent, Device device)
public final Device createDevice(String parent, Device device)
Creates a device in a device registry.
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
String parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString();
Device device = Device.newBuilder().build();
Device response = deviceManagerClient.createDevice(parent, device);
}
Name | Description |
parent | String Required. The name of the device registry where this device should be created.
For example, |
device | Device Required. The device registration details. The field |
Type | Description |
Device |
createDeviceCallable()
public final UnaryCallable<CreateDeviceRequest,Device> createDeviceCallable()
Creates a device in a device registry.
Sample code:
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();
}
Type | Description |
UnaryCallable<CreateDeviceRequest,Device> |
createDeviceRegistry(CreateDeviceRegistryRequest request)
public final DeviceRegistry createDeviceRegistry(CreateDeviceRegistryRequest request)
Creates a device registry that contains devices.
Sample code:
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);
}
Name | Description |
request | CreateDeviceRegistryRequest The request object containing all of the parameters for the API call. |
Type | Description |
DeviceRegistry |
createDeviceRegistry(LocationName parent, DeviceRegistry deviceRegistry)
public final DeviceRegistry createDeviceRegistry(LocationName parent, DeviceRegistry deviceRegistry)
Creates a device registry that contains devices.
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build();
DeviceRegistry response = deviceManagerClient.createDeviceRegistry(parent, deviceRegistry);
}
Name | Description |
parent | LocationName Required. The project and cloud region where this device registry must be
created. For example, |
deviceRegistry | DeviceRegistry Required. The device registry. The field |
Type | Description |
DeviceRegistry |
createDeviceRegistry(String parent, DeviceRegistry deviceRegistry)
public final DeviceRegistry createDeviceRegistry(String parent, DeviceRegistry deviceRegistry)
Creates a device registry that contains devices.
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build();
DeviceRegistry response = deviceManagerClient.createDeviceRegistry(parent, deviceRegistry);
}
Name | Description |
parent | String Required. The project and cloud region where this device registry must be
created. For example, |
deviceRegistry | DeviceRegistry Required. The device registry. The field |
Type | Description |
DeviceRegistry |
createDeviceRegistryCallable()
public final UnaryCallable<CreateDeviceRegistryRequest,DeviceRegistry> createDeviceRegistryCallable()
Creates a device registry that contains devices.
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
CreateDeviceRegistryRequest request =
CreateDeviceRegistryRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setDeviceRegistry(DeviceRegistry.newBuilder().build())
.build();
ApiFuture
Type | Description |
UnaryCallable<CreateDeviceRegistryRequest,DeviceRegistry> |
deleteDevice(DeleteDeviceRequest request)
public final void deleteDevice(DeleteDeviceRequest request)
Deletes a device.
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
DeleteDeviceRequest request =
DeleteDeviceRequest.newBuilder()
.setName(
DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString())
.build();
deviceManagerClient.deleteDevice(request);
}
Name | Description |
request | DeleteDeviceRequest The request object containing all of the parameters for the API call. |
deleteDevice(DeviceName name)
public final void deleteDevice(DeviceName name)
Deletes a device.
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]");
deviceManagerClient.deleteDevice(name);
}
Name | Description |
name | DeviceName Required. The name of the device. For example,
|
deleteDevice(String name)
public final void deleteDevice(String name)
Deletes a device.
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
String name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString();
deviceManagerClient.deleteDevice(name);
}
Name | Description |
name | String Required. The name of the device. For example,
|
deleteDeviceCallable()
public final UnaryCallable<DeleteDeviceRequest,Empty> deleteDeviceCallable()
Deletes a device.
Sample code:
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();
}
Type | Description |
UnaryCallable<DeleteDeviceRequest,Empty> |
deleteDeviceRegistry(DeleteDeviceRegistryRequest request)
public final void deleteDeviceRegistry(DeleteDeviceRegistryRequest request)
Deletes a device registry configuration.
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
DeleteDeviceRegistryRequest request =
DeleteDeviceRegistryRequest.newBuilder()
.setName(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString())
.build();
deviceManagerClient.deleteDeviceRegistry(request);
}
Name | Description |
request | DeleteDeviceRegistryRequest The request object containing all of the parameters for the API call. |
deleteDeviceRegistry(RegistryName name)
public final void deleteDeviceRegistry(RegistryName name)
Deletes a device registry configuration.
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
RegistryName name = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]");
deviceManagerClient.deleteDeviceRegistry(name);
}
Name | Description |
name | RegistryName Required. The name of the device registry. For example,
|
deleteDeviceRegistry(String name)
public final void deleteDeviceRegistry(String name)
Deletes a device registry configuration.
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
String name = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString();
deviceManagerClient.deleteDeviceRegistry(name);
}
Name | Description |
name | String Required. The name of the device registry. For example,
|
deleteDeviceRegistryCallable()
public final UnaryCallable<DeleteDeviceRegistryRequest,Empty> deleteDeviceRegistryCallable()
Deletes a device registry configuration.
Sample code:
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();
}
Type | Description |
UnaryCallable<DeleteDeviceRegistryRequest,Empty> |
getDevice(DeviceName name)
public final Device getDevice(DeviceName name)
Gets details about a device.
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]");
Device response = deviceManagerClient.getDevice(name);
}
Name | Description |
name | DeviceName Required. The name of the device. For example,
|
Type | Description |
Device |
getDevice(GetDeviceRequest request)
public final Device getDevice(GetDeviceRequest request)
Gets details about a device.
Sample code:
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);
}
Name | Description |
request | GetDeviceRequest The request object containing all of the parameters for the API call. |
Type | Description |
Device |
getDevice(String name)
public final Device getDevice(String name)
Gets details about a device.
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
String name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString();
Device response = deviceManagerClient.getDevice(name);
}
Name | Description |
name | String Required. The name of the device. For example,
|
Type | Description |
Device |
getDeviceCallable()
public final UnaryCallable<GetDeviceRequest,Device> getDeviceCallable()
Gets details about a device.
Sample code:
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();
}
Type | Description |
UnaryCallable<GetDeviceRequest,Device> |
getDeviceRegistry(GetDeviceRegistryRequest request)
public final DeviceRegistry getDeviceRegistry(GetDeviceRegistryRequest request)
Gets a device registry configuration.
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
GetDeviceRegistryRequest request =
GetDeviceRegistryRequest.newBuilder()
.setName(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString())
.build();
DeviceRegistry response = deviceManagerClient.getDeviceRegistry(request);
}
Name | Description |
request | GetDeviceRegistryRequest The request object containing all of the parameters for the API call. |
Type | Description |
DeviceRegistry |
getDeviceRegistry(RegistryName name)
public final DeviceRegistry getDeviceRegistry(RegistryName name)
Gets a device registry configuration.
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
RegistryName name = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]");
DeviceRegistry response = deviceManagerClient.getDeviceRegistry(name);
}
Name | Description |
name | RegistryName Required. The name of the device registry. For example,
|
Type | Description |
DeviceRegistry |
getDeviceRegistry(String name)
public final DeviceRegistry getDeviceRegistry(String name)
Gets a device registry configuration.
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
String name = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString();
DeviceRegistry response = deviceManagerClient.getDeviceRegistry(name);
}
Name | Description |
name | String Required. The name of the device registry. For example,
|
Type | Description |
DeviceRegistry |
getDeviceRegistryCallable()
public final UnaryCallable<GetDeviceRegistryRequest,DeviceRegistry> getDeviceRegistryCallable()
Gets a device registry configuration.
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
GetDeviceRegistryRequest request =
GetDeviceRegistryRequest.newBuilder()
.setName(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString())
.build();
ApiFuture
Type | Description |
UnaryCallable<GetDeviceRegistryRequest,DeviceRegistry> |
getIamPolicy(ResourceName resource)
public final Policy getIamPolicy(ResourceName resource)
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:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
ResourceName resource = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]");
Policy response = deviceManagerClient.getIamPolicy(resource);
}
Name | Description |
resource | com.google.api.resourcenames.ResourceName REQUIRED: The resource for which the policy is being requested. See the operation documentation for the appropriate value for this field. |
Type | Description |
com.google.iam.v1.Policy |
getIamPolicy(GetIamPolicyRequest request)
public final Policy getIamPolicy(GetIamPolicyRequest request)
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:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
GetIamPolicyRequest request =
GetIamPolicyRequest.newBuilder()
.setResource(
DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString())
.setOptions(GetPolicyOptions.newBuilder().build())
.build();
Policy response = deviceManagerClient.getIamPolicy(request);
}
Name | Description |
request | com.google.iam.v1.GetIamPolicyRequest The request object containing all of the parameters for the API call. |
Type | Description |
com.google.iam.v1.Policy |
getIamPolicy(String resource)
public final Policy getIamPolicy(String resource)
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:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
String resource =
DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString();
Policy response = deviceManagerClient.getIamPolicy(resource);
}
Name | Description |
resource | String REQUIRED: The resource for which the policy is being requested. See the operation documentation for the appropriate value for this field. |
Type | Description |
com.google.iam.v1.Policy |
getIamPolicyCallable()
public final UnaryCallable<GetIamPolicyRequest,Policy> 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:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
GetIamPolicyRequest request =
GetIamPolicyRequest.newBuilder()
.setResource(
DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString())
.setOptions(GetPolicyOptions.newBuilder().build())
.build();
ApiFuture<Policy> future = deviceManagerClient.getIamPolicyCallable().futureCall(request);
// Do something.
Policy response = future.get();
}
Type | Description |
UnaryCallable<com.google.iam.v1.GetIamPolicyRequest,com.google.iam.v1.Policy> |
getSettings()
public final DeviceManagerSettings getSettings()
Type | Description |
DeviceManagerSettings |
getStub()
public DeviceManagerStub getStub()
Type | Description |
DeviceManagerStub |
isShutdown()
public boolean isShutdown()
Type | Description |
boolean |
isTerminated()
public boolean isTerminated()
Type | Description |
boolean |
listDeviceConfigVersions(DeviceName name)
public final ListDeviceConfigVersionsResponse listDeviceConfigVersions(DeviceName name)
Lists the last few versions of the device configuration in descending order (i.e.: newest first).
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]");
ListDeviceConfigVersionsResponse response =
deviceManagerClient.listDeviceConfigVersions(name);
}
Name | Description |
name | DeviceName Required. The name of the device. For example,
|
Type | Description |
ListDeviceConfigVersionsResponse |
listDeviceConfigVersions(ListDeviceConfigVersionsRequest request)
public final ListDeviceConfigVersionsResponse listDeviceConfigVersions(ListDeviceConfigVersionsRequest request)
Lists the last few versions of the device configuration in descending order (i.e.: newest first).
Sample code:
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);
}
Name | Description |
request | ListDeviceConfigVersionsRequest The request object containing all of the parameters for the API call. |
Type | Description |
ListDeviceConfigVersionsResponse |
listDeviceConfigVersions(String name)
public final ListDeviceConfigVersionsResponse listDeviceConfigVersions(String name)
Lists the last few versions of the device configuration in descending order (i.e.: newest first).
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
String name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString();
ListDeviceConfigVersionsResponse response =
deviceManagerClient.listDeviceConfigVersions(name);
}
Name | Description |
name | String Required. The name of the device. For example,
|
Type | Description |
ListDeviceConfigVersionsResponse |
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:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
ListDeviceConfigVersionsRequest request =
ListDeviceConfigVersionsRequest.newBuilder()
.setName(
DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString())
.setNumVersions(-315385036)
.build();
ApiFuture
Type | Description |
UnaryCallable<ListDeviceConfigVersionsRequest,ListDeviceConfigVersionsResponse> |
listDeviceRegistries(ListDeviceRegistriesRequest request)
public final DeviceManagerClient.ListDeviceRegistriesPagedResponse listDeviceRegistries(ListDeviceRegistriesRequest request)
Lists device registries.
Sample code:
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);
}
}
Name | Description |
request | ListDeviceRegistriesRequest The request object containing all of the parameters for the API call. |
Type | Description |
DeviceManagerClient.ListDeviceRegistriesPagedResponse |
listDeviceRegistries(LocationName parent)
public final DeviceManagerClient.ListDeviceRegistriesPagedResponse listDeviceRegistries(LocationName parent)
Lists device registries.
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
for (DeviceRegistry element : deviceManagerClient.listDeviceRegistries(parent).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
parent | LocationName Required. The project and cloud region path. For example,
|
Type | Description |
DeviceManagerClient.ListDeviceRegistriesPagedResponse |
listDeviceRegistries(String parent)
public final DeviceManagerClient.ListDeviceRegistriesPagedResponse listDeviceRegistries(String parent)
Lists device registries.
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
for (DeviceRegistry element : deviceManagerClient.listDeviceRegistries(parent).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
parent | String Required. The project and cloud region path. For example,
|
Type | Description |
DeviceManagerClient.ListDeviceRegistriesPagedResponse |
listDeviceRegistriesCallable()
public final UnaryCallable<ListDeviceRegistriesRequest,ListDeviceRegistriesResponse> listDeviceRegistriesCallable()
Lists device registries.
Sample code:
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.getResponsesList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
Type | Description |
UnaryCallable<ListDeviceRegistriesRequest,ListDeviceRegistriesResponse> |
listDeviceRegistriesPagedCallable()
public final UnaryCallable<ListDeviceRegistriesRequest,DeviceManagerClient.ListDeviceRegistriesPagedResponse> listDeviceRegistriesPagedCallable()
Lists device registries.
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
ListDeviceRegistriesRequest request =
ListDeviceRegistriesRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture
Type | Description |
UnaryCallable<ListDeviceRegistriesRequest,ListDeviceRegistriesPagedResponse> |
listDeviceStates(DeviceName name)
public final ListDeviceStatesResponse listDeviceStates(DeviceName name)
Lists the last few versions of the device state in descending order (i.e.: newest first).
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]");
ListDeviceStatesResponse response = deviceManagerClient.listDeviceStates(name);
}
Name | Description |
name | DeviceName Required. The name of the device. For example,
|
Type | Description |
ListDeviceStatesResponse |
listDeviceStates(ListDeviceStatesRequest request)
public final ListDeviceStatesResponse listDeviceStates(ListDeviceStatesRequest request)
Lists the last few versions of the device state in descending order (i.e.: newest first).
Sample code:
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);
}
Name | Description |
request | ListDeviceStatesRequest The request object containing all of the parameters for the API call. |
Type | Description |
ListDeviceStatesResponse |
listDeviceStates(String name)
public final ListDeviceStatesResponse listDeviceStates(String name)
Lists the last few versions of the device state in descending order (i.e.: newest first).
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
String name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString();
ListDeviceStatesResponse response = deviceManagerClient.listDeviceStates(name);
}
Name | Description |
name | String Required. The name of the device. For example,
|
Type | Description |
ListDeviceStatesResponse |
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:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
ListDeviceStatesRequest request =
ListDeviceStatesRequest.newBuilder()
.setName(
DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString())
.setNumStates(1643330779)
.build();
ApiFuture
Type | Description |
UnaryCallable<ListDeviceStatesRequest,ListDeviceStatesResponse> |
listDevices(ListDevicesRequest request)
public final DeviceManagerClient.ListDevicesPagedResponse listDevices(ListDevicesRequest request)
List devices in a device registry.
Sample code:
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);
}
}
Name | Description |
request | ListDevicesRequest The request object containing all of the parameters for the API call. |
Type | Description |
DeviceManagerClient.ListDevicesPagedResponse |
listDevices(RegistryName parent)
public final DeviceManagerClient.ListDevicesPagedResponse listDevices(RegistryName parent)
List devices in a device registry.
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
RegistryName parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]");
for (Device element : deviceManagerClient.listDevices(parent).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
parent | RegistryName Required. The device registry path. Required. For example,
|
Type | Description |
DeviceManagerClient.ListDevicesPagedResponse |
listDevices(String parent)
public final DeviceManagerClient.ListDevicesPagedResponse listDevices(String parent)
List devices in a device registry.
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
String parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString();
for (Device element : deviceManagerClient.listDevices(parent).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
parent | String Required. The device registry path. Required. For example,
|
Type | Description |
DeviceManagerClient.ListDevicesPagedResponse |
listDevicesCallable()
public final UnaryCallable<ListDevicesRequest,ListDevicesResponse> listDevicesCallable()
List devices in a device registry.
Sample code:
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.getResponsesList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
Type | Description |
UnaryCallable<ListDevicesRequest,ListDevicesResponse> |
listDevicesPagedCallable()
public final UnaryCallable<ListDevicesRequest,DeviceManagerClient.ListDevicesPagedResponse> listDevicesPagedCallable()
List devices in a device registry.
Sample code:
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);
}
}
Type | Description |
UnaryCallable<ListDevicesRequest,ListDevicesPagedResponse> |
modifyCloudToDeviceConfig(DeviceName name, ByteString binaryData)
public final DeviceConfig modifyCloudToDeviceConfig(DeviceName name, 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:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]");
ByteString binaryData = ByteString.EMPTY;
DeviceConfig response = deviceManagerClient.modifyCloudToDeviceConfig(name, binaryData);
}
Name | Description |
name | DeviceName Required. The name of the device. For example,
|
binaryData | ByteString Required. The configuration data for the device. |
Type | Description |
DeviceConfig |
modifyCloudToDeviceConfig(ModifyCloudToDeviceConfigRequest request)
public final DeviceConfig modifyCloudToDeviceConfig(ModifyCloudToDeviceConfigRequest request)
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:
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);
}
Name | Description |
request | ModifyCloudToDeviceConfigRequest The request object containing all of the parameters for the API call. |
Type | Description |
DeviceConfig |
modifyCloudToDeviceConfig(String name, ByteString binaryData)
public final DeviceConfig modifyCloudToDeviceConfig(String name, 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:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
String name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString();
ByteString binaryData = ByteString.EMPTY;
DeviceConfig response = deviceManagerClient.modifyCloudToDeviceConfig(name, binaryData);
}
Name | Description |
name | String Required. The name of the device. For example,
|
binaryData | ByteString Required. The configuration data for the device. |
Type | Description |
DeviceConfig |
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:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
ModifyCloudToDeviceConfigRequest request =
ModifyCloudToDeviceConfigRequest.newBuilder()
.setName(
DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString())
.setVersionToUpdate(462348390)
.setBinaryData(ByteString.EMPTY)
.build();
ApiFuture
Type | Description |
UnaryCallable<ModifyCloudToDeviceConfigRequest,DeviceConfig> |
sendCommandToDevice(DeviceName name, ByteString binaryData)
public final SendCommandToDeviceResponse sendCommandToDevice(DeviceName name, 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:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]");
ByteString binaryData = ByteString.EMPTY;
SendCommandToDeviceResponse response =
deviceManagerClient.sendCommandToDevice(name, binaryData);
}
Name | Description |
name | DeviceName Required. The name of the device. For example,
|
binaryData | ByteString Required. The command data to send to the device. |
Type | Description |
SendCommandToDeviceResponse |
sendCommandToDevice(DeviceName name, ByteString binaryData, String subfolder)
public final SendCommandToDeviceResponse sendCommandToDevice(DeviceName name, 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:
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);
}
Name | Description |
name | DeviceName Required. The name of the device. For example,
|
binaryData | ByteString Required. The command data to send to the device. |
subfolder | String 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. |
Type | Description |
SendCommandToDeviceResponse |
sendCommandToDevice(SendCommandToDeviceRequest request)
public final SendCommandToDeviceResponse sendCommandToDevice(SendCommandToDeviceRequest request)
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:
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);
}
Name | Description |
request | SendCommandToDeviceRequest The request object containing all of the parameters for the API call. |
Type | Description |
SendCommandToDeviceResponse |
sendCommandToDevice(String name, ByteString binaryData)
public final SendCommandToDeviceResponse sendCommandToDevice(String name, 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:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
String name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString();
ByteString binaryData = ByteString.EMPTY;
SendCommandToDeviceResponse response =
deviceManagerClient.sendCommandToDevice(name, binaryData);
}
Name | Description |
name | String Required. The name of the device. For example,
|
binaryData | ByteString Required. The command data to send to the device. |
Type | Description |
SendCommandToDeviceResponse |
sendCommandToDevice(String name, ByteString binaryData, String subfolder)
public final SendCommandToDeviceResponse sendCommandToDevice(String name, 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:
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);
}
Name | Description |
name | String Required. The name of the device. For example,
|
binaryData | ByteString Required. The command data to send to the device. |
subfolder | String 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. |
Type | Description |
SendCommandToDeviceResponse |
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:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
SendCommandToDeviceRequest request =
SendCommandToDeviceRequest.newBuilder()
.setName(
DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString())
.setBinaryData(ByteString.EMPTY)
.setSubfolder("subfolder153561774")
.build();
ApiFuture
Type | Description |
UnaryCallable<SendCommandToDeviceRequest,SendCommandToDeviceResponse> |
setIamPolicy(ResourceName resource, Policy policy)
public final Policy setIamPolicy(ResourceName resource, Policy policy)
Sets the access control policy on the specified resource. Replaces any existing policy.
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
ResourceName resource = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]");
Policy policy = Policy.newBuilder().build();
Policy response = deviceManagerClient.setIamPolicy(resource, policy);
}
Name | Description |
resource | com.google.api.resourcenames.ResourceName REQUIRED: The resource for which the policy is being specified. See the operation documentation for the appropriate value for this field. |
policy | com.google.iam.v1.Policy REQUIRED: The complete policy to be applied to the |
Type | Description |
com.google.iam.v1.Policy |
setIamPolicy(SetIamPolicyRequest request)
public final Policy setIamPolicy(SetIamPolicyRequest request)
Sets the access control policy on the specified resource. Replaces any existing policy.
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
SetIamPolicyRequest request =
SetIamPolicyRequest.newBuilder()
.setResource(
DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString())
.setPolicy(Policy.newBuilder().build())
.build();
Policy response = deviceManagerClient.setIamPolicy(request);
}
Name | Description |
request | com.google.iam.v1.SetIamPolicyRequest The request object containing all of the parameters for the API call. |
Type | Description |
com.google.iam.v1.Policy |
setIamPolicy(String resource, Policy policy)
public final Policy setIamPolicy(String resource, Policy policy)
Sets the access control policy on the specified resource. Replaces any existing policy.
Sample code:
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);
}
Name | Description |
resource | String REQUIRED: The resource for which the policy is being specified. See the operation documentation for the appropriate value for this field. |
policy | com.google.iam.v1.Policy REQUIRED: The complete policy to be applied to the |
Type | Description |
com.google.iam.v1.Policy |
setIamPolicyCallable()
public final UnaryCallable<SetIamPolicyRequest,Policy> setIamPolicyCallable()
Sets the access control policy on the specified resource. Replaces any existing policy.
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
SetIamPolicyRequest request =
SetIamPolicyRequest.newBuilder()
.setResource(
DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString())
.setPolicy(Policy.newBuilder().build())
.build();
ApiFuture<Policy> future = deviceManagerClient.setIamPolicyCallable().futureCall(request);
// Do something.
Policy response = future.get();
}
Type | Description |
UnaryCallable<com.google.iam.v1.SetIamPolicyRequest,com.google.iam.v1.Policy> |
shutdown()
public void shutdown()
shutdownNow()
public void shutdownNow()
testIamPermissions(ResourceName resource, List<String> permissions)
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:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
ResourceName resource = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]");
List<String> permissions = new ArrayList<>();
TestIamPermissionsResponse response =
deviceManagerClient.testIamPermissions(resource, permissions);
}
Name | Description |
resource | com.google.api.resourcenames.ResourceName REQUIRED: The resource for which the policy detail is being requested. See the operation documentation for the appropriate value for this field. |
permissions | List<String> The set of permissions to check for the |
Type | Description |
com.google.iam.v1.TestIamPermissionsResponse |
testIamPermissions(TestIamPermissionsRequest request)
public final TestIamPermissionsResponse testIamPermissions(TestIamPermissionsRequest request)
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:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
TestIamPermissionsRequest request =
TestIamPermissionsRequest.newBuilder()
.setResource(
DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString())
.addAllPermissions(new ArrayList<String>())
.build();
TestIamPermissionsResponse response = deviceManagerClient.testIamPermissions(request);
}
Name | Description |
request | com.google.iam.v1.TestIamPermissionsRequest The request object containing all of the parameters for the API call. |
Type | Description |
com.google.iam.v1.TestIamPermissionsResponse |
testIamPermissions(String resource, List<String> permissions)
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:
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);
}
Name | Description |
resource | String REQUIRED: The resource for which the policy detail is being requested. See the operation documentation for the appropriate value for this field. |
permissions | List<String> The set of permissions to check for the |
Type | Description |
com.google.iam.v1.TestIamPermissionsResponse |
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:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
TestIamPermissionsRequest request =
TestIamPermissionsRequest.newBuilder()
.setResource(
DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString())
.addAllPermissions(new ArrayList<String>())
.build();
ApiFuture
Type | Description |
UnaryCallable<com.google.iam.v1.TestIamPermissionsRequest,com.google.iam.v1.TestIamPermissionsResponse> |
unbindDeviceFromGateway(RegistryName parent, String gatewayId, String deviceId)
public final UnbindDeviceFromGatewayResponse unbindDeviceFromGateway(RegistryName parent, String gatewayId, String deviceId)
Deletes the association between the device and the gateway.
Sample code:
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);
}
Name | Description |
parent | RegistryName Required. The name of the registry. For example,
|
gatewayId | String Required. The value of |
deviceId | String Required. The device to disassociate from the specified gateway. The value of
|
Type | Description |
UnbindDeviceFromGatewayResponse |
unbindDeviceFromGateway(UnbindDeviceFromGatewayRequest request)
public final UnbindDeviceFromGatewayResponse unbindDeviceFromGateway(UnbindDeviceFromGatewayRequest request)
Deletes the association between the device and the gateway.
Sample code:
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);
}
Name | Description |
request | UnbindDeviceFromGatewayRequest The request object containing all of the parameters for the API call. |
Type | Description |
UnbindDeviceFromGatewayResponse |
unbindDeviceFromGateway(String parent, String gatewayId, String deviceId)
public final UnbindDeviceFromGatewayResponse unbindDeviceFromGateway(String parent, String gatewayId, String deviceId)
Deletes the association between the device and the gateway.
Sample code:
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);
}
Name | Description |
parent | String Required. The name of the registry. For example,
|
gatewayId | String Required. The value of |
deviceId | String Required. The device to disassociate from the specified gateway. The value of
|
Type | Description |
UnbindDeviceFromGatewayResponse |
unbindDeviceFromGatewayCallable()
public final UnaryCallable<UnbindDeviceFromGatewayRequest,UnbindDeviceFromGatewayResponse> unbindDeviceFromGatewayCallable()
Deletes the association between the device and the gateway.
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
UnbindDeviceFromGatewayRequest request =
UnbindDeviceFromGatewayRequest.newBuilder()
.setParent(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString())
.setGatewayId("gatewayId-1354641793")
.setDeviceId("deviceId1109191185")
.build();
ApiFuture
Type | Description |
UnaryCallable<UnbindDeviceFromGatewayRequest,UnbindDeviceFromGatewayResponse> |
updateDevice(Device device, FieldMask updateMask)
public final Device updateDevice(Device device, FieldMask updateMask)
Updates a device.
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
Device device = Device.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
Device response = deviceManagerClient.updateDevice(device, updateMask);
}
Name | Description |
device | Device Required. The new values for the device. The |
updateMask | FieldMask Required. Only updates the |
Type | Description |
Device |
updateDevice(UpdateDeviceRequest request)
public final Device updateDevice(UpdateDeviceRequest request)
Updates a device.
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
UpdateDeviceRequest request =
UpdateDeviceRequest.newBuilder()
.setDevice(Device.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
Device response = deviceManagerClient.updateDevice(request);
}
Name | Description |
request | UpdateDeviceRequest The request object containing all of the parameters for the API call. |
Type | Description |
Device |
updateDeviceCallable()
public final UnaryCallable<UpdateDeviceRequest,Device> updateDeviceCallable()
Updates a device.
Sample code:
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();
}
Type | Description |
UnaryCallable<UpdateDeviceRequest,Device> |
updateDeviceRegistry(DeviceRegistry deviceRegistry, FieldMask updateMask)
public final DeviceRegistry updateDeviceRegistry(DeviceRegistry deviceRegistry, FieldMask updateMask)
Updates a device registry configuration.
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
DeviceRegistry response =
deviceManagerClient.updateDeviceRegistry(deviceRegistry, updateMask);
}
Name | Description |
deviceRegistry | DeviceRegistry Required. The new values for the device registry. The |
updateMask | FieldMask Required. Only updates the |
Type | Description |
DeviceRegistry |
updateDeviceRegistry(UpdateDeviceRegistryRequest request)
public final DeviceRegistry updateDeviceRegistry(UpdateDeviceRegistryRequest request)
Updates a device registry configuration.
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
UpdateDeviceRegistryRequest request =
UpdateDeviceRegistryRequest.newBuilder()
.setDeviceRegistry(DeviceRegistry.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
DeviceRegistry response = deviceManagerClient.updateDeviceRegistry(request);
}
Name | Description |
request | UpdateDeviceRegistryRequest The request object containing all of the parameters for the API call. |
Type | Description |
DeviceRegistry |
updateDeviceRegistryCallable()
public final UnaryCallable<UpdateDeviceRegistryRequest,DeviceRegistry> updateDeviceRegistryCallable()
Updates a device registry configuration.
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
UpdateDeviceRegistryRequest request =
UpdateDeviceRegistryRequest.newBuilder()
.setDeviceRegistry(DeviceRegistry.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
ApiFuture
Type | Description |
UnaryCallable<UpdateDeviceRegistryRequest,DeviceRegistry> |