code: public ApplicationDefinition createApplication(ApplicationDefinition appDef) {
          Utils.require(!m_restClient.isClosed(), "Client has been closed");
          Utils.require(appDef != null, "appDef");
          Utils.require(appDef.getAppName() != null && appDef.getAppName().length() > 0,
                        "Application must have a 'name' defined");
          
          try {
              // Serialize as a JSON message and convert to bytes.
              byte[] body = null;
              body = Utils.toBytes(appDef.toDoc().toJSON());
              
              // Send a POST request to the "/_applications"
              StringBuilder uri = new StringBuilder(Utils.isEmpty(m_apiPrefix) ? "" : "/" + m_apiPrefix);          			
              uri.append("/_applications/");
              
              RESTResponse response =
                  m_restClient.sendRequest(HttpMethod.POST, uri.toString(), ContentType.APPLICATION_JSON, body);
              m_logger.debug("defineApplication() response: {}", response.toString());
              throwIfErrorResponse(response);
              return getAppDef(appDef.getAppName());
          } catch (Exception e) {
              throw new RuntimeException(e);
          }
      }
docs: Create a new application in the connected Doradus server as defined in the given
  {@link ApplicationDefinition} object. If the given application already exists, its
  schema is replaced with the given definition. If the application is new, it is
  created in the tenant defined by the current user credentials. The
  {@link ApplicationDefinition} for the same application is returned, updated with
  any system-assigned defaults. An exception is thrown if an error occurs.
  
  @param appDef    {@link ApplicationDefinition} of application to create or update.
  @return          {@link ApplicationDefinition} of same application, updated with
  any system-assigned defaults.
  @see #setCredentials(Credentials)