@Override public Table showTableDetails(UUID subscriptionId, String serviceName, String tableName) throws AzureCmdException { String[] cmd = new String[] { "mobile", "table", "show", "--json", "-s", subscriptionId.toString(), serviceName, tableName }; String json = AzureCommandHelper.getInstance().consoleExec(cmd); CustomJsonSlurper slurper = new CustomJsonSlurper(); Map<String, Object> tempRes = (Map<String, Object>) slurper.parseText(json); Table t = new Table(); Map<String, Object> tableData = (Map<String, Object>) tempRes.get("table"); t.setName(tableData.get("name").toString()); t.setSelfLink(tableData.get("selflink").toString()); Map<String, String> per = (Map<String, String>) tempRes.get("permissions"); TablePermissions tablePermissions = new TablePermissions(); tablePermissions.setInsert(PermissionItem.getPermitionType(per.get("insert"))); tablePermissions.setUpdate(PermissionItem.getPermitionType(per.get("update"))); tablePermissions.setRead(PermissionItem.getPermitionType(per.get("read"))); tablePermissions.setDelete(PermissionItem.getPermitionType(per.get("delete"))); t.setTablePermissions(tablePermissions); for (Map<String, Object> column : (List<Map<String, Object>>) tempRes.get("columns")) { Column c = new Column(); c.setName(column.get("name").toString()); c.setType(column.get("type").toString()); c.setSelfLink(column.get("selflink").toString()); c.setIndexed((Boolean) column.get("indexed")); c.setZumoIndex((Boolean) column.get("zumoIndex")); t.getColumns().add(c); } for (Map<String, Object> script : (List<Map<String, Object>>) tempRes.get("scripts")) { Script s = new Script(); s.setOperation(script.get("operation").toString()); s.setBytes((Integer) script.get("sizeBytes")); s.setSelfLink(script.get("selflink").toString()); s.setName(String.format("%s.%s", tableData.get("name"), script.get("operation").toString())); t.getScripts().add(s); } return t; }
@Override public void createTable( UUID subscriptionId, String serviceName, String tableName, TablePermissions permissions) throws AzureCmdException { String[] cmd; if (permissions == null) cmd = new String[] { "mobile", "table", "create", "-v", "-s", subscriptionId.toString(), serviceName, tableName }; else cmd = new String[] { "mobile", "table", "create", "-v", "-p", permissions.toString(), "-s", subscriptionId.toString(), serviceName, tableName }; AzureCommandHelper.getInstance().consoleExec(cmd); }