@Override
  public List<Table> getTableList(UUID subscriptionId, String serviceName)
      throws AzureCmdException {

    String[] cmd =
        new String[] {
          "mobile", "table", "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<Table> res = new ArrayList<Table>();
    for (Map<String, String> item : tempRes) {
      Table t = new Table();
      t.setName(item.get("name"));
      t.setSelfLink(item.get("selflink"));

      res.add(t);
    }

    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;
  }
  @Override
  public List<Service> getServiceList(UUID subscriptionId) throws AzureCmdException {

    String[] cmd = new String[] {"mobile", "list", "--json", "-s", subscriptionId.toString()};

    String json = AzureCommandHelper.getInstance().consoleExec(cmd);

    CustomJsonSlurper slurper = new CustomJsonSlurper();
    List<Map<String, Object>> tempRes = (List<Map<String, Object>>) slurper.parseText(json);

    List<Service> res = new ArrayList<Service>();
    for (Map<String, Object> item : tempRes) {
      Service ser = new Service();

      ser.setName((String) item.get("name"));
      ser.setType((String) item.get("type"));
      ser.setState((String) item.get("state"));
      ser.setSelfLink((String) item.get("selflink"));
      ser.setAppUrl((String) item.get("applicationUrl"));
      ser.setAppKey((String) item.get("applicationKey"));
      ser.setMasterKey((String) item.get("masterKey"));
      ser.setWebspace((String) item.get("webspace"));
      ser.setRegion((String) item.get("region"));
      ser.setMgmtPortalLink((String) item.get("managementPortalLink"));
      ser.setSubcriptionId(subscriptionId);

      for (Map<String, String> table : (List<Map<String, String>>) item.get("tables")) {
        Table t = new Table();
        t.setName(table.get("name"));
        t.setSelfLink(table.get("selflink"));
        ser.getTables().add(t);
      }
      res.add(ser);
    }

    return res;
  }