examples/iot-nirvana/client/src/main/java/com/google/cloud/demo/iot/nirvana/client/IotDeviceMgr.java
/**
   * Generate the Cloud IoT Core service.
   *
   * @return Instance of {@link CloudIot}
   * @throws ClientException
   */
Generate the Cloud IoT Core service.
Generate the Cloud IoT Core service .
private CloudIot createCloudIotService() throws ClientException {
    try {
      GoogleCredential credential =
          GoogleCredential.getApplicationDefault().createScoped(CloudIotScopes.all());
      JsonFactory jsonFactory = JacksonFactory.getDefaultInstance();
      HttpRequestInitializer init = new RetryHttpInitializerWrapper(credential);
      CloudIot service =
          new CloudIot.Builder(GoogleNetHttpTransport.newTrustedTransport(), jsonFactory, init)
              .setApplicationName(APP_NAME_API)
              .build();
      return service;
    } catch (IOException e) {
      String message =
          String.format("Failed to create Cloud IoT Core service. Cause : %s", e.getMessage());
      LogUtils.logError(LOGGER, DEVICE_MGR_LOGGING_RESOURCE, getGcpProjectId(), message);
      throw new ClientException(message, e);
    } catch (GeneralSecurityException e) {
      String message =
          String.format("Failed to create Cloud IoT Core service. Cause : %s", e.getMessage());
      LogUtils.logError(LOGGER, DEVICE_MGR_LOGGING_RESOURCE, getGcpProjectId(), message);
      throw new ClientException(message, e);
    }
  }
private CloudIot createCloudIotService ( ) throws ClientException { try { GoogleCredential credential = GoogleCredential . getApplicationDefault ( ) . createScoped ( CloudIotScopes . all ( ) ) ; JsonFactory jsonFactory = JacksonFactory . getDefaultInstance ( ) ; HttpRequestInitializer init = new RetryHttpInitializerWrapper ( credential ) ; CloudIot service = new CloudIot . Builder ( GoogleNetHttpTransport . newTrustedTransport ( ) , jsonFactory , init ) . setApplicationName ( APP_NAME_API ) . build ( ) ; return service ; } catch ( IOException e ) { String message = String . format ( "Failed to create Cloud IoT Core service. Cause : %s" , e . getMessage ( ) ) ; LogUtils . logError ( LOGGER , DEVICE_MGR_LOGGING_RESOURCE , getGcpProjectId ( ) , message ) ; throw new ClientException ( message , e ) ; } catch ( GeneralSecurityException e ) { String message = String . format ( "Failed to create Cloud IoT Core service. Cause : %s" , e . getMessage ( ) ) ; LogUtils . logError ( LOGGER , DEVICE_MGR_LOGGING_RESOURCE , getGcpProjectId ( ) , message ) ; throw new ClientException ( message , e ) ; } }
Generate the Cloud IoT Core service.
Generate the Cloud IoT Core service .