@Override public List<CustomAPI> getAPIList(UUID subscriptionId, String serviceName) throws AzureCmdException { String[] cmd = new String[] { "mobile", "api", "list", "--json", "-s", subscriptionId.toString(), serviceName }; String json = AzureCommandHelper.getInstance().consoleExec(cmd); CustomJsonSlurper slurper = new CustomJsonSlurper(); List<Map<String, String>> tempRes = (List<Map<String, String>>) slurper.parseText(json); List<CustomAPI> res = new ArrayList<CustomAPI>(); for (Map<String, String> item : tempRes) { CustomAPI c = new CustomAPI(); c.setName(item.get("name")); CustomAPIPermissions permissions = new CustomAPIPermissions(); permissions.setPutPermission(PermissionItem.getPermitionType(item.get("put"))); permissions.setPostPermission(PermissionItem.getPermitionType(item.get("post"))); permissions.setGetPermission(PermissionItem.getPermitionType(item.get("get"))); permissions.setDeletePermission(PermissionItem.getPermitionType(item.get("delete"))); permissions.setPatchPermission(PermissionItem.getPermitionType(item.get("patch"))); c.setCustomAPIPermissions(permissions); res.add(c); } return res; }
@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; }