@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;
  }
  public static List<SqlStatement> getAlterTableStatements(
      AlterTableVisitor alterTableVisitor,
      Database database,
      String catalogName,
      String schemaName,
      String tableName)
      throws DatabaseException {

    DatabaseSnapshot snapshot = null; // todo
    List<SqlStatement> statements = new ArrayList<SqlStatement>();

    Table table = null;
    try {
      table =
          SnapshotGeneratorFactory.getInstance()
              .createSnapshot(
                  (Table)
                      new Table().setName(tableName).setSchema(new Schema(new Catalog(null), null)),
                  database);
    } catch (InvalidExampleException e) {
      throw new UnexpectedLiquibaseException(e);
    }

    List<ColumnConfig> createColumns = new Vector<ColumnConfig>();
    List<ColumnConfig> copyColumns = new Vector<ColumnConfig>();
    if (table != null) {
      for (Column column : table.getColumns()) {
        ColumnConfig new_column = new ColumnConfig(column);
        if (alterTableVisitor.createThisColumn(new_column)) {
          createColumns.add(new_column);
        }
        ColumnConfig copy_column = new ColumnConfig(column);
        if (alterTableVisitor.copyThisColumn(copy_column)) {
          copyColumns.add(copy_column);
        }
      }
    }
    for (ColumnConfig column : alterTableVisitor.getColumnsToAdd()) {
      if (alterTableVisitor.createThisColumn(column)) {
        createColumns.add(column);
      }
      if (alterTableVisitor.copyThisColumn(column)) {
        copyColumns.add(column);
      }
    }

    List<Index> newIndices = new Vector<Index>();
    for (Index index :
        new ArrayList<
            Index>()) { // todo SnapshotGeneratorFactory.getInstance().getGenerator(Index.class,
                        // database).get(new Schema(new Catalog(null), schemaName), database)) {
      if (index.getTable().getName().equalsIgnoreCase(tableName)) {
        if (alterTableVisitor.createThisIndex(index)) {
          newIndices.add(index);
        }
      }
    }

    // rename table
    String temp_table_name = tableName + "_temporary";
    statements.add(new RenameTableStatement(catalogName, schemaName, tableName, temp_table_name));
    // create temporary table
    CreateTableChange ct_change_tmp = new CreateTableChange();
    ct_change_tmp.setSchemaName(schemaName);
    ct_change_tmp.setTableName(tableName);
    for (ColumnConfig column : createColumns) {
      ct_change_tmp.addColumn(column);
    }
    statements.addAll(Arrays.asList(ct_change_tmp.generateStatements(database)));
    // copy rows to temporary table
    statements.add(new CopyRowsStatement(temp_table_name, tableName, copyColumns));
    // delete original table
    statements.add(new DropTableStatement(catalogName, schemaName, temp_table_name, false));
    // validate indices
    statements.add(new ReindexStatement(catalogName, schemaName, tableName));
    // add remaining indices
    for (Index index_config : newIndices) {
      statements.add(
          new CreateIndexStatement(
              index_config.getName(),
              catalogName,
              schemaName,
              tableName,
              index_config.isUnique(),
              index_config.getAssociatedWithAsString(),
              index_config.getColumns().toArray(new String[index_config.getColumns().size()])));
    }

    return statements;
  }