Search in sources :

Example 1 with UnbindDeviceFromGatewayResponse

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]
}
Also used : CloudIot(com.google.api.services.cloudiot.v1.CloudIot) HttpCredentialsAdapter(com.google.auth.http.HttpCredentialsAdapter) UnbindDeviceFromGatewayRequest(com.google.api.services.cloudiot.v1.model.UnbindDeviceFromGatewayRequest) JsonFactory(com.google.api.client.json.JsonFactory) GoogleCredentials(com.google.auth.oauth2.GoogleCredentials) UnbindDeviceFromGatewayResponse(com.google.api.services.cloudiot.v1.model.UnbindDeviceFromGatewayResponse) HttpRequestInitializer(com.google.api.client.http.HttpRequestInitializer)

Aggregations

HttpRequestInitializer (com.google.api.client.http.HttpRequestInitializer)1 JsonFactory (com.google.api.client.json.JsonFactory)1 CloudIot (com.google.api.services.cloudiot.v1.CloudIot)1 UnbindDeviceFromGatewayRequest (com.google.api.services.cloudiot.v1.model.UnbindDeviceFromGatewayRequest)1 UnbindDeviceFromGatewayResponse (com.google.api.services.cloudiot.v1.model.UnbindDeviceFromGatewayResponse)1 HttpCredentialsAdapter (com.google.auth.http.HttpCredentialsAdapter)1 GoogleCredentials (com.google.auth.oauth2.GoogleCredentials)1