use of com.google.api.services.cloudiot.v1.model.UnbindDeviceFromGatewayResponse in project java-docs-samples by GoogleCloudPlatform.
the class DeviceRegistryExample method unbindDeviceFromGateway.
protected static void unbindDeviceFromGateway(String projectId, String cloudRegion, String registryName, String deviceId, String gatewayId) throws GeneralSecurityException, IOException {
// [START iot_unbind_device_from_gateway]
GoogleCredentials credential = GoogleCredentials.getApplicationDefault().createScoped(CloudIotScopes.all());
JsonFactory jsonFactory = JacksonFactory.getDefaultInstance();
HttpRequestInitializer init = new HttpCredentialsAdapter(credential);
final CloudIot service = new CloudIot.Builder(GoogleNetHttpTransport.newTrustedTransport(), jsonFactory, init).setApplicationName(APP_NAME).build();
final String registryPath = String.format("projects/%s/locations/%s/registries/%s", projectId, cloudRegion, registryName);
UnbindDeviceFromGatewayRequest request = new UnbindDeviceFromGatewayRequest();
request.setDeviceId(deviceId);
request.setGatewayId(gatewayId);
UnbindDeviceFromGatewayResponse response = service.projects().locations().registries().unbindDeviceFromGateway(registryPath, request).execute();
System.out.println(String.format("Device unbound: %s", response.toPrettyString()));
// [END iot_unbind_device_from_gateway]
}
Aggregations