/*
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.m.examples.bigtable;

// [START bigtable_quickstart_veneer]

import com.google.api.gax.rpc.NotFoundException;
import com.google.cloud.bigtable.data.v2.BigtableDataClient;
import com.google.cloud.bigtable.data.v2.BigtableDataSettings;
import com.google.cloud.bigtable.data.v2.models.Row;
import com.google.cloud.bigtable.data.v2.models.RowCell;

public class Quickstart {

  public static void quickstart(String projectId, String instanceId, String tableId) {
    // String projectId = "my-project-id";
    // String instanceId = "my-instance-id";
    // String tableId = "my-table-id";

    BigtableDataSettings settings =
        BigtableDataSettings.newBuilder().setProjectId(projectId).setInstanceId(instanceId).build();

    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    try (BigtableDataClient dataClient = BigtableDataClient.create(settings)) {
      System.out.println("\nReading a single row by row key");
      Row row = dataClient.readRow(tableId, "r1");
      System.out.println("Row: " + row.getKey().toStringUtf8());
      for (RowCell cell : row.getCells()) {
        System.out.printf(
            "Family: %s    Qualifier: %s    Value: %s%n",
            cell.getFamily(), cell.getQualifier().toStringUtf8(), cell.getValue().toStringUtf8());
      }
    } catch (NotFoundException e) {
      System.err.println("Failed to read from a non-existent table: " + e.getMessage());
    } catch (Exception e) {
      System.out.println("Error during quickstart: \n" + e.toString());
    }
  }
}
// [END bigtable_quickstart_veneer]

@@ -993,80 +993,34 @@
 oid 
-quickstart(String projectId, String instanceId, String tableId
+main(String... args
 ) %7B%0A   
- //
  Str
@@ -1035,19 +1035,35 @@
 ectId = 
-%22my
+args%5B0%5D;  // my-gcp
 -project
@@ -1065,25 +1065,20 @@
 oject-id
-%22;
 %0A   
- //
  String 
@@ -1090,19 +1090,39 @@
 nceId = 
-%22my
+args%5B1%5D; // my-bigtable
 -instanc
@@ -1129,17 +1129,12 @@
 e-id
-%22;
 %0A   
- //
  Str
@@ -1151,23 +1151,184 @@
 d = 
-%22my-table-id%22;%0A
+args%5B2%5D;    // my-bigtable-table-id%0A%0A    quickstart(projectId, instanceId, tableId);%0A  %7D%0A%0A  public static void quickstart(String projectId, String instanceId, String tableId) %7B
 %0A   

update quickstart to have main (#490)