@Generated(value="by gapic-generator") @BetaApi public class DeviceManagerClient extends Object implements BackgroundResource
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:
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);
Modifier and Type | Class and Description |
---|---|
static class |
DeviceManagerClient.ListDeviceRegistriesFixedSizeCollection |
static class |
DeviceManagerClient.ListDeviceRegistriesPage |
static class |
DeviceManagerClient.ListDeviceRegistriesPagedResponse |
static class |
DeviceManagerClient.ListDevicesFixedSizeCollection |
static class |
DeviceManagerClient.ListDevicesPage |
static class |
DeviceManagerClient.ListDevicesPagedResponse |
Modifier | Constructor and Description |
---|---|
protected |
DeviceManagerClient(DeviceManagerSettings settings)
Constructs an instance of DeviceManagerClient, using the given settings.
|
protected |
DeviceManagerClient(DeviceManagerStub stub) |
Modifier and Type | Method and Description |
---|---|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
com.google.cloud.iot.v1.BindDeviceToGatewayResponse |
bindDeviceToGateway(com.google.cloud.iot.v1.BindDeviceToGatewayRequest request)
Associates the device with the gateway.
|
com.google.cloud.iot.v1.BindDeviceToGatewayResponse |
bindDeviceToGateway(com.google.cloud.iot.v1.RegistryName parent,
String gatewayId,
String deviceId)
Associates the device with the gateway.
|
com.google.cloud.iot.v1.BindDeviceToGatewayResponse |
bindDeviceToGateway(String parent,
String gatewayId,
String deviceId)
Associates the device with the gateway.
|
UnaryCallable<com.google.cloud.iot.v1.BindDeviceToGatewayRequest,com.google.cloud.iot.v1.BindDeviceToGatewayResponse> |
bindDeviceToGatewayCallable()
Associates the device with the gateway.
|
void |
close() |
static DeviceManagerClient |
create()
Constructs an instance of DeviceManagerClient with default settings.
|
static DeviceManagerClient |
create(DeviceManagerSettings settings)
Constructs an instance of DeviceManagerClient, using the given settings.
|
static DeviceManagerClient |
create(DeviceManagerStub stub)
Constructs an instance of DeviceManagerClient, using the given stub for making calls.
|
com.google.cloud.iot.v1.Device |
createDevice(com.google.cloud.iot.v1.CreateDeviceRequest request)
Creates a device in a device registry.
|
com.google.cloud.iot.v1.Device |
createDevice(com.google.cloud.iot.v1.RegistryName parent,
com.google.cloud.iot.v1.Device device)
Creates a device in a device registry.
|
com.google.cloud.iot.v1.Device |
createDevice(String parent,
com.google.cloud.iot.v1.Device device)
Creates a device in a device registry.
|
UnaryCallable<com.google.cloud.iot.v1.CreateDeviceRequest,com.google.cloud.iot.v1.Device> |
createDeviceCallable()
Creates a device in a device registry.
|
com.google.cloud.iot.v1.DeviceRegistry |
createDeviceRegistry(com.google.cloud.iot.v1.CreateDeviceRegistryRequest request)
Creates a device registry that contains devices.
|
com.google.cloud.iot.v1.DeviceRegistry |
createDeviceRegistry(com.google.cloud.iot.v1.LocationName parent,
com.google.cloud.iot.v1.DeviceRegistry deviceRegistry)
Creates a device registry that contains devices.
|
com.google.cloud.iot.v1.DeviceRegistry |
createDeviceRegistry(String parent,
com.google.cloud.iot.v1.DeviceRegistry deviceRegistry)
Creates a device registry that contains devices.
|
UnaryCallable<com.google.cloud.iot.v1.CreateDeviceRegistryRequest,com.google.cloud.iot.v1.DeviceRegistry> |
createDeviceRegistryCallable()
Creates a device registry that contains devices.
|
void |
deleteDevice(com.google.cloud.iot.v1.DeleteDeviceRequest request)
Deletes a device.
|
void |
deleteDevice(com.google.cloud.iot.v1.DeviceName name)
Deletes a device.
|
void |
deleteDevice(String name)
Deletes a device.
|
UnaryCallable<com.google.cloud.iot.v1.DeleteDeviceRequest,Empty> |
deleteDeviceCallable()
Deletes a device.
|
void |
deleteDeviceRegistry(com.google.cloud.iot.v1.DeleteDeviceRegistryRequest request)
Deletes a device registry configuration.
|
void |
deleteDeviceRegistry(com.google.cloud.iot.v1.RegistryName name)
Deletes a device registry configuration.
|
void |
deleteDeviceRegistry(String name)
Deletes a device registry configuration.
|
UnaryCallable<com.google.cloud.iot.v1.DeleteDeviceRegistryRequest,Empty> |
deleteDeviceRegistryCallable()
Deletes a device registry configuration.
|
com.google.cloud.iot.v1.Device |
getDevice(com.google.cloud.iot.v1.DeviceName name)
Gets details about a device.
|
com.google.cloud.iot.v1.Device |
getDevice(com.google.cloud.iot.v1.GetDeviceRequest request)
Gets details about a device.
|
com.google.cloud.iot.v1.Device |
getDevice(String name)
Gets details about a device.
|
UnaryCallable<com.google.cloud.iot.v1.GetDeviceRequest,com.google.cloud.iot.v1.Device> |
getDeviceCallable()
Gets details about a device.
|
com.google.cloud.iot.v1.DeviceRegistry |
getDeviceRegistry(com.google.cloud.iot.v1.GetDeviceRegistryRequest request)
Gets a device registry configuration.
|
com.google.cloud.iot.v1.DeviceRegistry |
getDeviceRegistry(com.google.cloud.iot.v1.RegistryName name)
Gets a device registry configuration.
|
com.google.cloud.iot.v1.DeviceRegistry |
getDeviceRegistry(String name)
Gets a device registry configuration.
|
UnaryCallable<com.google.cloud.iot.v1.GetDeviceRegistryRequest,com.google.cloud.iot.v1.DeviceRegistry> |
getDeviceRegistryCallable()
Gets a device registry configuration.
|
com.google.iam.v1.Policy |
getIamPolicy(com.google.iam.v1.GetIamPolicyRequest request)
Gets the access control policy for a resource.
|
com.google.iam.v1.Policy |
getIamPolicy(com.google.cloud.iot.v1.RegistryName resource)
Gets the access control policy for a resource.
|
com.google.iam.v1.Policy |
getIamPolicy(String resource)
Gets the access control policy for a resource.
|
UnaryCallable<com.google.iam.v1.GetIamPolicyRequest,com.google.iam.v1.Policy> |
getIamPolicyCallable()
Gets the access control policy for a resource.
|
DeviceManagerSettings |
getSettings() |
DeviceManagerStub |
getStub() |
boolean |
isShutdown() |
boolean |
isTerminated() |
com.google.cloud.iot.v1.ListDeviceConfigVersionsResponse |
listDeviceConfigVersions(com.google.cloud.iot.v1.DeviceName name)
Lists the last few versions of the device configuration in descending order (i.e.: newest
first).
|
com.google.cloud.iot.v1.ListDeviceConfigVersionsResponse |
listDeviceConfigVersions(com.google.cloud.iot.v1.ListDeviceConfigVersionsRequest request)
Lists the last few versions of the device configuration in descending order (i.e.: newest
first).
|
com.google.cloud.iot.v1.ListDeviceConfigVersionsResponse |
listDeviceConfigVersions(String name)
Lists the last few versions of the device configuration in descending order (i.e.: newest
first).
|
UnaryCallable<com.google.cloud.iot.v1.ListDeviceConfigVersionsRequest,com.google.cloud.iot.v1.ListDeviceConfigVersionsResponse> |
listDeviceConfigVersionsCallable()
Lists the last few versions of the device configuration in descending order (i.e.: newest
first).
|
DeviceManagerClient.ListDeviceRegistriesPagedResponse |
listDeviceRegistries(com.google.cloud.iot.v1.ListDeviceRegistriesRequest request)
Lists device registries.
|
DeviceManagerClient.ListDeviceRegistriesPagedResponse |
listDeviceRegistries(com.google.cloud.iot.v1.LocationName parent)
Lists device registries.
|
DeviceManagerClient.ListDeviceRegistriesPagedResponse |
listDeviceRegistries(String parent)
Lists device registries.
|
UnaryCallable<com.google.cloud.iot.v1.ListDeviceRegistriesRequest,com.google.cloud.iot.v1.ListDeviceRegistriesResponse> |
listDeviceRegistriesCallable()
Lists device registries.
|
UnaryCallable<com.google.cloud.iot.v1.ListDeviceRegistriesRequest,DeviceManagerClient.ListDeviceRegistriesPagedResponse> |
listDeviceRegistriesPagedCallable()
Lists device registries.
|
DeviceManagerClient.ListDevicesPagedResponse |
listDevices(com.google.cloud.iot.v1.ListDevicesRequest request)
List devices in a device registry.
|
DeviceManagerClient.ListDevicesPagedResponse |
listDevices(com.google.cloud.iot.v1.RegistryName parent)
List devices in a device registry.
|
DeviceManagerClient.ListDevicesPagedResponse |
listDevices(String parent)
List devices in a device registry.
|
UnaryCallable<com.google.cloud.iot.v1.ListDevicesRequest,com.google.cloud.iot.v1.ListDevicesResponse> |
listDevicesCallable()
List devices in a device registry.
|
UnaryCallable<com.google.cloud.iot.v1.ListDevicesRequest,DeviceManagerClient.ListDevicesPagedResponse> |
listDevicesPagedCallable()
List devices in a device registry.
|
com.google.cloud.iot.v1.ListDeviceStatesResponse |
listDeviceStates(com.google.cloud.iot.v1.DeviceName name)
Lists the last few versions of the device state in descending order (i.e.: newest first).
|
com.google.cloud.iot.v1.ListDeviceStatesResponse |
listDeviceStates(com.google.cloud.iot.v1.ListDeviceStatesRequest request)
Lists the last few versions of the device state in descending order (i.e.: newest first).
|
com.google.cloud.iot.v1.ListDeviceStatesResponse |
listDeviceStates(String name)
Lists the last few versions of the device state in descending order (i.e.: newest first).
|
UnaryCallable<com.google.cloud.iot.v1.ListDeviceStatesRequest,com.google.cloud.iot.v1.ListDeviceStatesResponse> |
listDeviceStatesCallable()
Lists the last few versions of the device state in descending order (i.e.: newest first).
|
com.google.cloud.iot.v1.DeviceConfig |
modifyCloudToDeviceConfig(com.google.cloud.iot.v1.DeviceName name,
ByteString binaryData)
Modifies the configuration for the device, which is eventually sent from the Cloud IoT Core
servers.
|
com.google.cloud.iot.v1.DeviceConfig |
modifyCloudToDeviceConfig(com.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest request)
Modifies the configuration for the device, which is eventually sent from the Cloud IoT Core
servers.
|
com.google.cloud.iot.v1.DeviceConfig |
modifyCloudToDeviceConfig(String name,
ByteString binaryData)
Modifies the configuration for the device, which is eventually sent from the Cloud IoT Core
servers.
|
UnaryCallable<com.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest,com.google.cloud.iot.v1.DeviceConfig> |
modifyCloudToDeviceConfigCallable()
Modifies the configuration for the device, which is eventually sent from the Cloud IoT Core
servers.
|
com.google.cloud.iot.v1.SendCommandToDeviceResponse |
sendCommandToDevice(com.google.cloud.iot.v1.DeviceName name,
ByteString binaryData,
String subfolder)
Sends a command to the specified device.
|
com.google.cloud.iot.v1.SendCommandToDeviceResponse |
sendCommandToDevice(com.google.cloud.iot.v1.SendCommandToDeviceRequest request)
Sends a command to the specified device.
|
com.google.cloud.iot.v1.SendCommandToDeviceResponse |
sendCommandToDevice(String name,
ByteString binaryData,
String subfolder)
Sends a command to the specified device.
|
UnaryCallable<com.google.cloud.iot.v1.SendCommandToDeviceRequest,com.google.cloud.iot.v1.SendCommandToDeviceResponse> |
sendCommandToDeviceCallable()
Sends a command to the specified device.
|
com.google.iam.v1.Policy |
setIamPolicy(com.google.cloud.iot.v1.RegistryName resource,
com.google.iam.v1.Policy policy)
Sets the access control policy on the specified resource.
|
com.google.iam.v1.Policy |
setIamPolicy(com.google.iam.v1.SetIamPolicyRequest request)
Sets the access control policy on the specified resource.
|
com.google.iam.v1.Policy |
setIamPolicy(String resource,
com.google.iam.v1.Policy policy)
Sets the access control policy on the specified resource.
|
UnaryCallable<com.google.iam.v1.SetIamPolicyRequest,com.google.iam.v1.Policy> |
setIamPolicyCallable()
Sets the access control policy on the specified resource.
|
void |
shutdown() |
void |
shutdownNow() |
com.google.iam.v1.TestIamPermissionsResponse |
testIamPermissions(com.google.cloud.iot.v1.RegistryName resource,
List<String> permissions)
Returns permissions that a caller has on the specified resource.
|
com.google.iam.v1.TestIamPermissionsResponse |
testIamPermissions(String resource,
List<String> permissions)
Returns permissions that a caller has on the specified resource.
|
com.google.iam.v1.TestIamPermissionsResponse |
testIamPermissions(com.google.iam.v1.TestIamPermissionsRequest request)
Returns permissions that a caller has on the specified resource.
|
UnaryCallable<com.google.iam.v1.TestIamPermissionsRequest,com.google.iam.v1.TestIamPermissionsResponse> |
testIamPermissionsCallable()
Returns permissions that a caller has on the specified resource.
|
com.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse |
unbindDeviceFromGateway(com.google.cloud.iot.v1.RegistryName parent,
String gatewayId,
String deviceId)
Deletes the association between the device and the gateway.
|
com.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse |
unbindDeviceFromGateway(String parent,
String gatewayId,
String deviceId)
Deletes the association between the device and the gateway.
|
com.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse |
unbindDeviceFromGateway(com.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest request)
Deletes the association between the device and the gateway.
|
UnaryCallable<com.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest,com.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse> |
unbindDeviceFromGatewayCallable()
Deletes the association between the device and the gateway.
|
com.google.cloud.iot.v1.Device |
updateDevice(com.google.cloud.iot.v1.Device device,
FieldMask updateMask)
Updates a device.
|
com.google.cloud.iot.v1.Device |
updateDevice(com.google.cloud.iot.v1.UpdateDeviceRequest request)
Updates a device.
|
UnaryCallable<com.google.cloud.iot.v1.UpdateDeviceRequest,com.google.cloud.iot.v1.Device> |
updateDeviceCallable()
Updates a device.
|
com.google.cloud.iot.v1.DeviceRegistry |
updateDeviceRegistry(com.google.cloud.iot.v1.DeviceRegistry deviceRegistry,
FieldMask updateMask)
Updates a device registry configuration.
|
com.google.cloud.iot.v1.DeviceRegistry |
updateDeviceRegistry(com.google.cloud.iot.v1.UpdateDeviceRegistryRequest request)
Updates a device registry configuration.
|
UnaryCallable<com.google.cloud.iot.v1.UpdateDeviceRegistryRequest,com.google.cloud.iot.v1.DeviceRegistry> |
updateDeviceRegistryCallable()
Updates a device registry configuration.
|
protected DeviceManagerClient(DeviceManagerSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") protected DeviceManagerClient(DeviceManagerStub stub)
public static final DeviceManagerClient create() throws IOException
IOException
public static final DeviceManagerClient create(DeviceManagerSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public static final DeviceManagerClient create(DeviceManagerStub stub)
public final DeviceManagerSettings getSettings()
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public DeviceManagerStub getStub()
public final com.google.cloud.iot.v1.DeviceRegistry createDeviceRegistry(com.google.cloud.iot.v1.LocationName parent, com.google.cloud.iot.v1.DeviceRegistry deviceRegistry)
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build();
DeviceRegistry response = deviceManagerClient.createDeviceRegistry(parent, deviceRegistry);
}
parent
- The project and cloud region where this device registry must be created. For
example, `projects/example-project/locations/us-central1`.deviceRegistry
- 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.ApiException
- if the remote call failspublic final com.google.cloud.iot.v1.DeviceRegistry createDeviceRegistry(String parent, com.google.cloud.iot.v1.DeviceRegistry deviceRegistry)
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build();
DeviceRegistry response = deviceManagerClient.createDeviceRegistry(parent.toString(), deviceRegistry);
}
parent
- The project and cloud region where this device registry must be created. For
example, `projects/example-project/locations/us-central1`.deviceRegistry
- 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.ApiException
- if the remote call failspublic final com.google.cloud.iot.v1.DeviceRegistry createDeviceRegistry(com.google.cloud.iot.v1.CreateDeviceRegistryRequest request)
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build();
CreateDeviceRegistryRequest request = CreateDeviceRegistryRequest.newBuilder()
.setParent(parent.toString())
.setDeviceRegistry(deviceRegistry)
.build();
DeviceRegistry response = deviceManagerClient.createDeviceRegistry(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.cloud.iot.v1.CreateDeviceRegistryRequest,com.google.cloud.iot.v1.DeviceRegistry> createDeviceRegistryCallable()
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build();
CreateDeviceRegistryRequest request = CreateDeviceRegistryRequest.newBuilder()
.setParent(parent.toString())
.setDeviceRegistry(deviceRegistry)
.build();
ApiFuture<DeviceRegistry> future = deviceManagerClient.createDeviceRegistryCallable().futureCall(request);
// Do something
DeviceRegistry response = future.get();
}
public final com.google.cloud.iot.v1.DeviceRegistry getDeviceRegistry(com.google.cloud.iot.v1.RegistryName name)
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
RegistryName name = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]");
DeviceRegistry response = deviceManagerClient.getDeviceRegistry(name);
}
name
- The name of the device registry. For example,
`projects/example-project/locations/us-central1/registries/my-registry`.ApiException
- if the remote call failspublic final com.google.cloud.iot.v1.DeviceRegistry getDeviceRegistry(String name)
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
RegistryName name = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]");
DeviceRegistry response = deviceManagerClient.getDeviceRegistry(name.toString());
}
name
- The name of the device registry. For example,
`projects/example-project/locations/us-central1/registries/my-registry`.ApiException
- if the remote call failspublic final com.google.cloud.iot.v1.DeviceRegistry getDeviceRegistry(com.google.cloud.iot.v1.GetDeviceRegistryRequest request)
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
RegistryName name = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]");
GetDeviceRegistryRequest request = GetDeviceRegistryRequest.newBuilder()
.setName(name.toString())
.build();
DeviceRegistry response = deviceManagerClient.getDeviceRegistry(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.cloud.iot.v1.GetDeviceRegistryRequest,com.google.cloud.iot.v1.DeviceRegistry> getDeviceRegistryCallable()
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
RegistryName name = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]");
GetDeviceRegistryRequest request = GetDeviceRegistryRequest.newBuilder()
.setName(name.toString())
.build();
ApiFuture<DeviceRegistry> future = deviceManagerClient.getDeviceRegistryCallable().futureCall(request);
// Do something
DeviceRegistry response = future.get();
}
public final com.google.cloud.iot.v1.DeviceRegistry updateDeviceRegistry(com.google.cloud.iot.v1.DeviceRegistry deviceRegistry, FieldMask updateMask)
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
DeviceRegistry response = deviceManagerClient.updateDeviceRegistry(deviceRegistry, updateMask);
}
deviceRegistry
- 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
- 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`.ApiException
- if the remote call failspublic final com.google.cloud.iot.v1.DeviceRegistry updateDeviceRegistry(com.google.cloud.iot.v1.UpdateDeviceRegistryRequest request)
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
UpdateDeviceRegistryRequest request = UpdateDeviceRegistryRequest.newBuilder()
.setDeviceRegistry(deviceRegistry)
.setUpdateMask(updateMask)
.build();
DeviceRegistry response = deviceManagerClient.updateDeviceRegistry(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.cloud.iot.v1.UpdateDeviceRegistryRequest,com.google.cloud.iot.v1.DeviceRegistry> updateDeviceRegistryCallable()
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
UpdateDeviceRegistryRequest request = UpdateDeviceRegistryRequest.newBuilder()
.setDeviceRegistry(deviceRegistry)
.setUpdateMask(updateMask)
.build();
ApiFuture<DeviceRegistry> future = deviceManagerClient.updateDeviceRegistryCallable().futureCall(request);
// Do something
DeviceRegistry response = future.get();
}
public final void deleteDeviceRegistry(com.google.cloud.iot.v1.RegistryName name)
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
RegistryName name = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]");
deviceManagerClient.deleteDeviceRegistry(name);
}
name
- The name of the device registry. For example,
`projects/example-project/locations/us-central1/registries/my-registry`.ApiException
- if the remote call failspublic final void deleteDeviceRegistry(String name)
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
RegistryName name = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]");
deviceManagerClient.deleteDeviceRegistry(name.toString());
}
name
- The name of the device registry. For example,
`projects/example-project/locations/us-central1/registries/my-registry`.ApiException
- if the remote call failspublic final void deleteDeviceRegistry(com.google.cloud.iot.v1.DeleteDeviceRegistryRequest request)
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
RegistryName name = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]");
DeleteDeviceRegistryRequest request = DeleteDeviceRegistryRequest.newBuilder()
.setName(name.toString())
.build();
deviceManagerClient.deleteDeviceRegistry(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.cloud.iot.v1.DeleteDeviceRegistryRequest,Empty> deleteDeviceRegistryCallable()
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
RegistryName name = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]");
DeleteDeviceRegistryRequest request = DeleteDeviceRegistryRequest.newBuilder()
.setName(name.toString())
.build();
ApiFuture<Void> future = deviceManagerClient.deleteDeviceRegistryCallable().futureCall(request);
// Do something
future.get();
}
public final DeviceManagerClient.ListDeviceRegistriesPagedResponse listDeviceRegistries(com.google.cloud.iot.v1.LocationName parent)
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
for (DeviceRegistry element : deviceManagerClient.listDeviceRegistries(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent
- The project and cloud region path. For example,
`projects/example-project/locations/us-central1`.ApiException
- if the remote call failspublic final DeviceManagerClient.ListDeviceRegistriesPagedResponse listDeviceRegistries(String parent)
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
for (DeviceRegistry element : deviceManagerClient.listDeviceRegistries(parent.toString()).iterateAll()) {
// doThingsWith(element);
}
}
parent
- The project and cloud region path. For example,
`projects/example-project/locations/us-central1`.ApiException
- if the remote call failspublic final DeviceManagerClient.ListDeviceRegistriesPagedResponse listDeviceRegistries(com.google.cloud.iot.v1.ListDeviceRegistriesRequest request)
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
ListDeviceRegistriesRequest request = ListDeviceRegistriesRequest.newBuilder()
.setParent(parent.toString())
.build();
for (DeviceRegistry element : deviceManagerClient.listDeviceRegistries(request).iterateAll()) {
// doThingsWith(element);
}
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.cloud.iot.v1.ListDeviceRegistriesRequest,DeviceManagerClient.ListDeviceRegistriesPagedResponse> listDeviceRegistriesPagedCallable()
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
ListDeviceRegistriesRequest request = ListDeviceRegistriesRequest.newBuilder()
.setParent(parent.toString())
.build();
ApiFuture<ListDeviceRegistriesPagedResponse> future = deviceManagerClient.listDeviceRegistriesPagedCallable().futureCall(request);
// Do something
for (DeviceRegistry element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final UnaryCallable<com.google.cloud.iot.v1.ListDeviceRegistriesRequest,com.google.cloud.iot.v1.ListDeviceRegistriesResponse> listDeviceRegistriesCallable()
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
ListDeviceRegistriesRequest request = ListDeviceRegistriesRequest.newBuilder()
.setParent(parent.toString())
.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;
}
}
}
public final com.google.cloud.iot.v1.Device createDevice(com.google.cloud.iot.v1.RegistryName parent, com.google.cloud.iot.v1.Device device)
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);
}
parent
- The name of the device registry where this device should be created. For example,
`projects/example-project/locations/us-central1/registries/my-registry`.device
- The device registration details. The field `name` must be empty. The server
generates `name` from the device registry `id` and the `parent` field.ApiException
- if the remote call failspublic final com.google.cloud.iot.v1.Device createDevice(String parent, com.google.cloud.iot.v1.Device device)
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
RegistryName parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]");
Device device = Device.newBuilder().build();
Device response = deviceManagerClient.createDevice(parent.toString(), device);
}
parent
- The name of the device registry where this device should be created. For example,
`projects/example-project/locations/us-central1/registries/my-registry`.device
- The device registration details. The field `name` must be empty. The server
generates `name` from the device registry `id` and the `parent` field.ApiException
- if the remote call failspublic final com.google.cloud.iot.v1.Device createDevice(com.google.cloud.iot.v1.CreateDeviceRequest request)
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
RegistryName parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]");
Device device = Device.newBuilder().build();
CreateDeviceRequest request = CreateDeviceRequest.newBuilder()
.setParent(parent.toString())
.setDevice(device)
.build();
Device response = deviceManagerClient.createDevice(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.cloud.iot.v1.CreateDeviceRequest,com.google.cloud.iot.v1.Device> createDeviceCallable()
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
RegistryName parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]");
Device device = Device.newBuilder().build();
CreateDeviceRequest request = CreateDeviceRequest.newBuilder()
.setParent(parent.toString())
.setDevice(device)
.build();
ApiFuture<Device> future = deviceManagerClient.createDeviceCallable().futureCall(request);
// Do something
Device response = future.get();
}
public final com.google.cloud.iot.v1.Device getDevice(com.google.cloud.iot.v1.DeviceName name)
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]");
Device response = deviceManagerClient.getDevice(name);
}
name
- 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}`.ApiException
- if the remote call failspublic final com.google.cloud.iot.v1.Device getDevice(String name)
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]");
Device response = deviceManagerClient.getDevice(name.toString());
}
name
- 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}`.ApiException
- if the remote call failspublic final com.google.cloud.iot.v1.Device getDevice(com.google.cloud.iot.v1.GetDeviceRequest request)
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]");
GetDeviceRequest request = GetDeviceRequest.newBuilder()
.setName(name.toString())
.build();
Device response = deviceManagerClient.getDevice(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.cloud.iot.v1.GetDeviceRequest,com.google.cloud.iot.v1.Device> getDeviceCallable()
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]");
GetDeviceRequest request = GetDeviceRequest.newBuilder()
.setName(name.toString())
.build();
ApiFuture<Device> future = deviceManagerClient.getDeviceCallable().futureCall(request);
// Do something
Device response = future.get();
}
public final com.google.cloud.iot.v1.Device updateDevice(com.google.cloud.iot.v1.Device device, FieldMask updateMask)
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
Device device = Device.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
Device response = deviceManagerClient.updateDevice(device, updateMask);
}
device
- 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
- 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`ApiException
- if the remote call failspublic final com.google.cloud.iot.v1.Device updateDevice(com.google.cloud.iot.v1.UpdateDeviceRequest request)
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
Device device = Device.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
UpdateDeviceRequest request = UpdateDeviceRequest.newBuilder()
.setDevice(device)
.setUpdateMask(updateMask)
.build();
Device response = deviceManagerClient.updateDevice(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.cloud.iot.v1.UpdateDeviceRequest,com.google.cloud.iot.v1.Device> updateDeviceCallable()
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
Device device = Device.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
UpdateDeviceRequest request = UpdateDeviceRequest.newBuilder()
.setDevice(device)
.setUpdateMask(updateMask)
.build();
ApiFuture<Device> future = deviceManagerClient.updateDeviceCallable().futureCall(request);
// Do something
Device response = future.get();
}
public final void deleteDevice(com.google.cloud.iot.v1.DeviceName name)
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]");
deviceManagerClient.deleteDevice(name);
}
name
- 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}`.ApiException
- if the remote call failspublic final void deleteDevice(String name)
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]");
deviceManagerClient.deleteDevice(name.toString());
}
name
- 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}`.ApiException
- if the remote call failspublic final void deleteDevice(com.google.cloud.iot.v1.DeleteDeviceRequest request)
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]");
DeleteDeviceRequest request = DeleteDeviceRequest.newBuilder()
.setName(name.toString())
.build();
deviceManagerClient.deleteDevice(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.cloud.iot.v1.DeleteDeviceRequest,Empty> deleteDeviceCallable()
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]");
DeleteDeviceRequest request = DeleteDeviceRequest.newBuilder()
.setName(name.toString())
.build();
ApiFuture<Void> future = deviceManagerClient.deleteDeviceCallable().futureCall(request);
// Do something
future.get();
}
public final DeviceManagerClient.ListDevicesPagedResponse listDevices(com.google.cloud.iot.v1.RegistryName parent)
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
RegistryName parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]");
for (Device element : deviceManagerClient.listDevices(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent
- The device registry path. Required. For example,
`projects/my-project/locations/us-central1/registries/my-registry`.ApiException
- if the remote call failspublic final DeviceManagerClient.ListDevicesPagedResponse listDevices(String parent)
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
RegistryName parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]");
for (Device element : deviceManagerClient.listDevices(parent.toString()).iterateAll()) {
// doThingsWith(element);
}
}
parent
- The device registry path. Required. For example,
`projects/my-project/locations/us-central1/registries/my-registry`.ApiException
- if the remote call failspublic final DeviceManagerClient.ListDevicesPagedResponse listDevices(com.google.cloud.iot.v1.ListDevicesRequest request)
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
RegistryName parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]");
ListDevicesRequest request = ListDevicesRequest.newBuilder()
.setParent(parent.toString())
.build();
for (Device element : deviceManagerClient.listDevices(request).iterateAll()) {
// doThingsWith(element);
}
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.cloud.iot.v1.ListDevicesRequest,DeviceManagerClient.ListDevicesPagedResponse> listDevicesPagedCallable()
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
RegistryName parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]");
ListDevicesRequest request = ListDevicesRequest.newBuilder()
.setParent(parent.toString())
.build();
ApiFuture<ListDevicesPagedResponse> future = deviceManagerClient.listDevicesPagedCallable().futureCall(request);
// Do something
for (Device element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final UnaryCallable<com.google.cloud.iot.v1.ListDevicesRequest,com.google.cloud.iot.v1.ListDevicesResponse> listDevicesCallable()
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
RegistryName parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]");
ListDevicesRequest request = ListDevicesRequest.newBuilder()
.setParent(parent.toString())
.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;
}
}
}
public final com.google.cloud.iot.v1.DeviceConfig modifyCloudToDeviceConfig(com.google.cloud.iot.v1.DeviceName name, ByteString binaryData)
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]");
ByteString binaryData = ByteString.copyFromUtf8("");
DeviceConfig response = deviceManagerClient.modifyCloudToDeviceConfig(name, binaryData);
}
name
- 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
- The configuration data for the device.ApiException
- if the remote call failspublic final com.google.cloud.iot.v1.DeviceConfig modifyCloudToDeviceConfig(String name, ByteString binaryData)
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]");
ByteString binaryData = ByteString.copyFromUtf8("");
DeviceConfig response = deviceManagerClient.modifyCloudToDeviceConfig(name.toString(), binaryData);
}
name
- 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
- The configuration data for the device.ApiException
- if the remote call failspublic final com.google.cloud.iot.v1.DeviceConfig modifyCloudToDeviceConfig(com.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest request)
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]");
ByteString binaryData = ByteString.copyFromUtf8("");
ModifyCloudToDeviceConfigRequest request = ModifyCloudToDeviceConfigRequest.newBuilder()
.setName(name.toString())
.setBinaryData(binaryData)
.build();
DeviceConfig response = deviceManagerClient.modifyCloudToDeviceConfig(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest,com.google.cloud.iot.v1.DeviceConfig> modifyCloudToDeviceConfigCallable()
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]");
ByteString binaryData = ByteString.copyFromUtf8("");
ModifyCloudToDeviceConfigRequest request = ModifyCloudToDeviceConfigRequest.newBuilder()
.setName(name.toString())
.setBinaryData(binaryData)
.build();
ApiFuture<DeviceConfig> future = deviceManagerClient.modifyCloudToDeviceConfigCallable().futureCall(request);
// Do something
DeviceConfig response = future.get();
}
public final com.google.cloud.iot.v1.ListDeviceConfigVersionsResponse listDeviceConfigVersions(com.google.cloud.iot.v1.DeviceName name)
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]");
ListDeviceConfigVersionsResponse response = deviceManagerClient.listDeviceConfigVersions(name);
}
name
- 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}`.ApiException
- if the remote call failspublic final com.google.cloud.iot.v1.ListDeviceConfigVersionsResponse listDeviceConfigVersions(String name)
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]");
ListDeviceConfigVersionsResponse response = deviceManagerClient.listDeviceConfigVersions(name.toString());
}
name
- 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}`.ApiException
- if the remote call failspublic final com.google.cloud.iot.v1.ListDeviceConfigVersionsResponse listDeviceConfigVersions(com.google.cloud.iot.v1.ListDeviceConfigVersionsRequest request)
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]");
ListDeviceConfigVersionsRequest request = ListDeviceConfigVersionsRequest.newBuilder()
.setName(name.toString())
.build();
ListDeviceConfigVersionsResponse response = deviceManagerClient.listDeviceConfigVersions(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.cloud.iot.v1.ListDeviceConfigVersionsRequest,com.google.cloud.iot.v1.ListDeviceConfigVersionsResponse> listDeviceConfigVersionsCallable()
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]");
ListDeviceConfigVersionsRequest request = ListDeviceConfigVersionsRequest.newBuilder()
.setName(name.toString())
.build();
ApiFuture<ListDeviceConfigVersionsResponse> future = deviceManagerClient.listDeviceConfigVersionsCallable().futureCall(request);
// Do something
ListDeviceConfigVersionsResponse response = future.get();
}
public final com.google.cloud.iot.v1.ListDeviceStatesResponse listDeviceStates(com.google.cloud.iot.v1.DeviceName name)
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]");
ListDeviceStatesResponse response = deviceManagerClient.listDeviceStates(name);
}
name
- 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}`.ApiException
- if the remote call failspublic final com.google.cloud.iot.v1.ListDeviceStatesResponse listDeviceStates(String name)
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]");
ListDeviceStatesResponse response = deviceManagerClient.listDeviceStates(name.toString());
}
name
- 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}`.ApiException
- if the remote call failspublic final com.google.cloud.iot.v1.ListDeviceStatesResponse listDeviceStates(com.google.cloud.iot.v1.ListDeviceStatesRequest request)
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]");
ListDeviceStatesRequest request = ListDeviceStatesRequest.newBuilder()
.setName(name.toString())
.build();
ListDeviceStatesResponse response = deviceManagerClient.listDeviceStates(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.cloud.iot.v1.ListDeviceStatesRequest,com.google.cloud.iot.v1.ListDeviceStatesResponse> listDeviceStatesCallable()
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]");
ListDeviceStatesRequest request = ListDeviceStatesRequest.newBuilder()
.setName(name.toString())
.build();
ApiFuture<ListDeviceStatesResponse> future = deviceManagerClient.listDeviceStatesCallable().futureCall(request);
// Do something
ListDeviceStatesResponse response = future.get();
}
public final com.google.iam.v1.Policy setIamPolicy(com.google.cloud.iot.v1.RegistryName resource, com.google.iam.v1.Policy policy)
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
RegistryName resource = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]");
Policy policy = Policy.newBuilder().build();
Policy response = deviceManagerClient.setIamPolicy(resource, policy);
}
resource
- REQUIRED: The resource for which the policy is being specified. `resource` is
usually specified as a path. For example, a Project resource is specified as
`projects/{project}`.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.ApiException
- if the remote call failspublic final com.google.iam.v1.Policy setIamPolicy(String resource, com.google.iam.v1.Policy policy)
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
RegistryName resource = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]");
Policy policy = Policy.newBuilder().build();
Policy response = deviceManagerClient.setIamPolicy(resource.toString(), policy);
}
resource
- REQUIRED: The resource for which the policy is being specified. `resource` is
usually specified as a path. For example, a Project resource is specified as
`projects/{project}`.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.ApiException
- if the remote call failspublic final com.google.iam.v1.Policy setIamPolicy(com.google.iam.v1.SetIamPolicyRequest request)
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
ResourceName resource = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]");
Policy policy = Policy.newBuilder().build();
SetIamPolicyRequest request = SetIamPolicyRequest.newBuilder()
.setResource(resource.toString())
.setPolicy(policy)
.build();
Policy response = deviceManagerClient.setIamPolicy(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.iam.v1.SetIamPolicyRequest,com.google.iam.v1.Policy> setIamPolicyCallable()
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
ResourceName resource = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]");
Policy policy = Policy.newBuilder().build();
SetIamPolicyRequest request = SetIamPolicyRequest.newBuilder()
.setResource(resource.toString())
.setPolicy(policy)
.build();
ApiFuture<Policy> future = deviceManagerClient.setIamPolicyCallable().futureCall(request);
// Do something
Policy response = future.get();
}
public final com.google.iam.v1.Policy getIamPolicy(com.google.cloud.iot.v1.RegistryName resource)
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
RegistryName resource = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]");
Policy response = deviceManagerClient.getIamPolicy(resource);
}
resource
- REQUIRED: The resource for which the policy is being requested. `resource` is
usually specified as a path. For example, a Project resource is specified as
`projects/{project}`.ApiException
- if the remote call failspublic final com.google.iam.v1.Policy getIamPolicy(String resource)
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
RegistryName resource = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]");
Policy response = deviceManagerClient.getIamPolicy(resource.toString());
}
resource
- REQUIRED: The resource for which the policy is being requested. `resource` is
usually specified as a path. For example, a Project resource is specified as
`projects/{project}`.ApiException
- if the remote call failspublic final com.google.iam.v1.Policy getIamPolicy(com.google.iam.v1.GetIamPolicyRequest request)
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
ResourceName resource = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]");
GetIamPolicyRequest request = GetIamPolicyRequest.newBuilder()
.setResource(resource.toString())
.build();
Policy response = deviceManagerClient.getIamPolicy(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.iam.v1.GetIamPolicyRequest,com.google.iam.v1.Policy> getIamPolicyCallable()
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
ResourceName resource = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]");
GetIamPolicyRequest request = GetIamPolicyRequest.newBuilder()
.setResource(resource.toString())
.build();
ApiFuture<Policy> future = deviceManagerClient.getIamPolicyCallable().futureCall(request);
// Do something
Policy response = future.get();
}
public final com.google.iam.v1.TestIamPermissionsResponse testIamPermissions(com.google.cloud.iot.v1.RegistryName resource, List<String> permissions)
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
RegistryName resource = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]");
List<String> permissions = new ArrayList<>();
TestIamPermissionsResponse response = deviceManagerClient.testIamPermissions(resource, permissions);
}
resource
- REQUIRED: The resource for which the policy detail is being requested.
`resource` is usually specified as a path. For example, a Project resource is specified as
`projects/{project}`.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).ApiException
- if the remote call failspublic final com.google.iam.v1.TestIamPermissionsResponse testIamPermissions(String resource, List<String> permissions)
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
RegistryName resource = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]");
List<String> permissions = new ArrayList<>();
TestIamPermissionsResponse response = deviceManagerClient.testIamPermissions(resource.toString(), permissions);
}
resource
- REQUIRED: The resource for which the policy detail is being requested.
`resource` is usually specified as a path. For example, a Project resource is specified as
`projects/{project}`.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).ApiException
- if the remote call failspublic final com.google.iam.v1.TestIamPermissionsResponse testIamPermissions(com.google.iam.v1.TestIamPermissionsRequest request)
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
ResourceName resource = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]");
List<String> permissions = new ArrayList<>();
TestIamPermissionsRequest request = TestIamPermissionsRequest.newBuilder()
.setResource(resource.toString())
.addAllPermissions(permissions)
.build();
TestIamPermissionsResponse response = deviceManagerClient.testIamPermissions(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.iam.v1.TestIamPermissionsRequest,com.google.iam.v1.TestIamPermissionsResponse> testIamPermissionsCallable()
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
ResourceName resource = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]");
List<String> permissions = new ArrayList<>();
TestIamPermissionsRequest request = TestIamPermissionsRequest.newBuilder()
.setResource(resource.toString())
.addAllPermissions(permissions)
.build();
ApiFuture<TestIamPermissionsResponse> future = deviceManagerClient.testIamPermissionsCallable().futureCall(request);
// Do something
TestIamPermissionsResponse response = future.get();
}
public final com.google.cloud.iot.v1.SendCommandToDeviceResponse sendCommandToDevice(com.google.cloud.iot.v1.DeviceName name, ByteString binaryData, String subfolder)
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]");
ByteString binaryData = ByteString.copyFromUtf8("");
String subfolder = "";
SendCommandToDeviceResponse response = deviceManagerClient.sendCommandToDevice(name, binaryData, subfolder);
}
name
- 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
- 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.ApiException
- if the remote call failspublic final com.google.cloud.iot.v1.SendCommandToDeviceResponse sendCommandToDevice(String name, ByteString binaryData, String subfolder)
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]");
ByteString binaryData = ByteString.copyFromUtf8("");
String subfolder = "";
SendCommandToDeviceResponse response = deviceManagerClient.sendCommandToDevice(name.toString(), binaryData, subfolder);
}
name
- 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
- 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.ApiException
- if the remote call failspublic final com.google.cloud.iot.v1.SendCommandToDeviceResponse sendCommandToDevice(com.google.cloud.iot.v1.SendCommandToDeviceRequest request)
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]");
ByteString binaryData = ByteString.copyFromUtf8("");
SendCommandToDeviceRequest request = SendCommandToDeviceRequest.newBuilder()
.setName(name.toString())
.setBinaryData(binaryData)
.build();
SendCommandToDeviceResponse response = deviceManagerClient.sendCommandToDevice(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.cloud.iot.v1.SendCommandToDeviceRequest,com.google.cloud.iot.v1.SendCommandToDeviceResponse> sendCommandToDeviceCallable()
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]");
ByteString binaryData = ByteString.copyFromUtf8("");
SendCommandToDeviceRequest request = SendCommandToDeviceRequest.newBuilder()
.setName(name.toString())
.setBinaryData(binaryData)
.build();
ApiFuture<SendCommandToDeviceResponse> future = deviceManagerClient.sendCommandToDeviceCallable().futureCall(request);
// Do something
SendCommandToDeviceResponse response = future.get();
}
public final com.google.cloud.iot.v1.BindDeviceToGatewayResponse bindDeviceToGateway(com.google.cloud.iot.v1.RegistryName parent, String gatewayId, String deviceId)
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
RegistryName parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]");
String gatewayId = "";
String deviceId = "";
BindDeviceToGatewayResponse response = deviceManagerClient.bindDeviceToGateway(parent, gatewayId, deviceId);
}
parent
- The name of the registry. For example,
`projects/example-project/locations/us-central1/registries/my-registry`.gatewayId
- The value of `gateway_id` can be either the device numeric ID or the
user-defined device identifier.deviceId
- 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.ApiException
- if the remote call failspublic final com.google.cloud.iot.v1.BindDeviceToGatewayResponse bindDeviceToGateway(String parent, String gatewayId, String deviceId)
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
RegistryName parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]");
String gatewayId = "";
String deviceId = "";
BindDeviceToGatewayResponse response = deviceManagerClient.bindDeviceToGateway(parent.toString(), gatewayId, deviceId);
}
parent
- The name of the registry. For example,
`projects/example-project/locations/us-central1/registries/my-registry`.gatewayId
- The value of `gateway_id` can be either the device numeric ID or the
user-defined device identifier.deviceId
- 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.ApiException
- if the remote call failspublic final com.google.cloud.iot.v1.BindDeviceToGatewayResponse bindDeviceToGateway(com.google.cloud.iot.v1.BindDeviceToGatewayRequest request)
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
RegistryName parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]");
String gatewayId = "";
String deviceId = "";
BindDeviceToGatewayRequest request = BindDeviceToGatewayRequest.newBuilder()
.setParent(parent.toString())
.setGatewayId(gatewayId)
.setDeviceId(deviceId)
.build();
BindDeviceToGatewayResponse response = deviceManagerClient.bindDeviceToGateway(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.cloud.iot.v1.BindDeviceToGatewayRequest,com.google.cloud.iot.v1.BindDeviceToGatewayResponse> bindDeviceToGatewayCallable()
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
RegistryName parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]");
String gatewayId = "";
String deviceId = "";
BindDeviceToGatewayRequest request = BindDeviceToGatewayRequest.newBuilder()
.setParent(parent.toString())
.setGatewayId(gatewayId)
.setDeviceId(deviceId)
.build();
ApiFuture<BindDeviceToGatewayResponse> future = deviceManagerClient.bindDeviceToGatewayCallable().futureCall(request);
// Do something
BindDeviceToGatewayResponse response = future.get();
}
public final com.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse unbindDeviceFromGateway(com.google.cloud.iot.v1.RegistryName parent, String gatewayId, String deviceId)
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
RegistryName parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]");
String gatewayId = "";
String deviceId = "";
UnbindDeviceFromGatewayResponse response = deviceManagerClient.unbindDeviceFromGateway(parent, gatewayId, deviceId);
}
parent
- The name of the registry. For example,
`projects/example-project/locations/us-central1/registries/my-registry`.gatewayId
- The value of `gateway_id` can be either the device numeric ID or the
user-defined device identifier.deviceId
- 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.ApiException
- if the remote call failspublic final com.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse unbindDeviceFromGateway(String parent, String gatewayId, String deviceId)
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
RegistryName parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]");
String gatewayId = "";
String deviceId = "";
UnbindDeviceFromGatewayResponse response = deviceManagerClient.unbindDeviceFromGateway(parent.toString(), gatewayId, deviceId);
}
parent
- The name of the registry. For example,
`projects/example-project/locations/us-central1/registries/my-registry`.gatewayId
- The value of `gateway_id` can be either the device numeric ID or the
user-defined device identifier.deviceId
- 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.ApiException
- if the remote call failspublic final com.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse unbindDeviceFromGateway(com.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest request)
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
RegistryName parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]");
String gatewayId = "";
String deviceId = "";
UnbindDeviceFromGatewayRequest request = UnbindDeviceFromGatewayRequest.newBuilder()
.setParent(parent.toString())
.setGatewayId(gatewayId)
.setDeviceId(deviceId)
.build();
UnbindDeviceFromGatewayResponse response = deviceManagerClient.unbindDeviceFromGateway(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest,com.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse> unbindDeviceFromGatewayCallable()
Sample code:
try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
RegistryName parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]");
String gatewayId = "";
String deviceId = "";
UnbindDeviceFromGatewayRequest request = UnbindDeviceFromGatewayRequest.newBuilder()
.setParent(parent.toString())
.setGatewayId(gatewayId)
.setDeviceId(deviceId)
.build();
ApiFuture<UnbindDeviceFromGatewayResponse> future = deviceManagerClient.unbindDeviceFromGatewayCallable().futureCall(request);
// Do something
UnbindDeviceFromGatewayResponse response = future.get();
}
public final void close()
close
in interface AutoCloseable
public void shutdown()
shutdown
in interface BackgroundResource
public boolean isShutdown()
isShutdown
in interface BackgroundResource
public boolean isTerminated()
isTerminated
in interface BackgroundResource
public void shutdownNow()
shutdownNow
in interface BackgroundResource
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException
awaitTermination
in interface BackgroundResource
InterruptedException
Copyright © 2019 Google LLC. All rights reserved.