Skip to content

Commit

Permalink
added code-review change requests
Browse files Browse the repository at this point in the history
  • Loading branch information
vijay-qlogic committed Jul 10, 2018
1 parent 25bb4d6 commit 6c11f2a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 72 deletions.
42 changes: 21 additions & 21 deletions samples/document-snippets/instance.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
const Bigtable = require('@google-cloud/bigtable');
const bigtableClient = new Bigtable();

function newInstance(instanceId) {
function createInstance(instanceId) {
// [START bigtable_create_instance]
const instance = bigtableClient.instance(instanceId);

Expand Down Expand Up @@ -53,15 +53,15 @@ function newInstance(instanceId) {
// let operations = result[1];
// let apiResponse = result[2];

console.log(`Created Instance: ${newInstance.name}`);
console.log(`Created Instance: ${newInstance.id}`);
})
.catch(err => {
console.error('Error creating prod-instance:', err);
});
// [END bigtable_create_instance]
}

function newCluster(clusterId, instanceId) {
function createCluster(instanceId, clusterId) {
// [START bigtable_create_cluster]
const instance = bigtableClient.instance(instanceId);

Expand All @@ -77,16 +77,16 @@ function newCluster(clusterId, instanceId) {
const newCluster = result[0];
// const operations = result[1];
// const apiResponse = result[2];
console.log(`Cluster created: ${newCluster.name}`);
console.log(`Cluster created: ${newCluster.id}`);
})
.catch(err => {
console.error('Error creating cluster: ', err);
});
// [END bigtable_create_cluster]
}

function newAppProfile(appProfileId, clusterId, instanceId) {
// [START bigtable_create_appProfile]
function createAppProfile(instanceId, clusterId, appProfileId) {
// [START bigtable_create_app_profile]
const instance = bigtableClient.instance(instanceId);
const cluster = instance.cluster(clusterId);

Expand All @@ -103,10 +103,10 @@ function newAppProfile(appProfileId, clusterId, instanceId) {
}
console.log(`App-Profile created: ${appProfile.name}`);
});
// [END bigtable_create_appProfile]
// [END bigtable_create_app_profile]
}

function newTable(tableId, instanceId) {
function createTable(instanceId, tableId) {
// [START bigtable_create_table]
const instance = bigtableClient.instance(instanceId);

Expand Down Expand Up @@ -213,7 +213,7 @@ function getAppProfiles(instanceId) {
function getMetaData(instanceId) {
const instance = bigtableClient.instance(instanceId);

// [START bigtable_get_imeta]
// [START bigtable_get_instance_metadata]
instance
.getMetadata()
.then(result => {
Expand All @@ -224,7 +224,7 @@ function getMetaData(instanceId) {
.catch(err => {
console.error('Error geting Metadata: ', err);
});
// [END bigtable_get_imeta]
// [END bigtable_get_instance_metadata]
}

function getTables(instanceId) {
Expand All @@ -247,7 +247,7 @@ function getTables(instanceId) {
console.log(`Tables:`);
let tables = result[0];
tables.forEach(t => {
console.log(t.name);
console.log(t.id);
});
})
.catch(err => {
Expand All @@ -256,10 +256,10 @@ function getTables(instanceId) {
// [END bigtable_get_tables]
}

function setMetaData(instanceId) {
function updateInstance(instanceId) {
const instance = bigtableClient.instance(instanceId);

// [START bigtable_set_meta]
// [START bigtable_set_meta_data]
let metadata = {
displayName: 'updated-name',
};
Expand All @@ -272,7 +272,7 @@ function setMetaData(instanceId) {
.catch(err => {
console.error('Error in Set MetaData: ', err);
});
// [END bigtable_set_meta]
// [END bigtable_set_meta_data]
}

function delInstance(instanceId) {
Expand All @@ -295,27 +295,27 @@ require(`yargs`)

// create Instance
.command(`new-instance`, `Creates an Instance`, {}, argv =>
newInstance(argv.instance)
createInstance(argv.instance)
)
.example(`node $0 new-instance --instance [instanceid]`)

// create Cluster
.command(`new-cluster`, `Creates a Cluster`, {}, argv =>
newCluster(argv.cluster, argv.instance)
createCluster(argv.instance, argv.cluster)
)
.example(`node $0 new-cluster --cluster [clusterId] --instance [instanceid]`)

// create App-Profile
.command(`new-app-profile`, `Creates an AppProfile`, {}, argv =>
newAppProfile(argv.appProfile, argv.cluster, argv.instance)
createAppProfile(argv.instance, argv.cluster, argv.appProfile)
)
.example(
`node $0 new-app-profile --appProfile [appProfileId]--cluster [clusterId] --instance [instanceId]`
)

// create Table
.command(`new-table`, `Creates a Table`, {}, argv =>
newTable(argv.table, argv.instance)
createTable(argv.instance, argv.table)
)
.example(`node $0 new-table --table [tableId] --instance [instanceId]`)

Expand Down Expand Up @@ -356,10 +356,10 @@ require(`yargs`)
.example(`node $0 get-tables --instance [instanceid]`)

// set metaData for Instance
.command(`set-meta`, `Set Instance MetaData`, {}, argv =>
setMetaData(argv.instance)
.command(`update-instance`, `Set Instance MetaData`, {}, argv =>
updateInstance(argv.instance)
)
.example(`node $0 set-meta --instance [instanceid]`)
.example(`node $0 update-instance --instance [instanceid]`)

// delete Instance
.command(`del-instance`, `Delete an Instance`, {}, argv =>
Expand Down
57 changes: 6 additions & 51 deletions src/instance.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ Please use the format 'my-instance' or '${
* @param {Cluster} callback.appProfile The newly created app profile.
*
* @example <caption>include:samples/document-snippets/instance.js</caption>
* region_tag:bigtable_create_appProfile
* region_tag:bigtable_create_app_profile
*/
createAppProfile(id, options, callback) {
if (is.function(options)) {
Expand Down Expand Up @@ -565,7 +565,7 @@ Please use the format 'my-instance' or '${
* @param {object} callback.metadata The metadata.
*
* @example <caption>include:samples/document-snippets/instance.js</caption>
* region_tag:bigtable_get_imeta
* region_tag:bigtable_get_instance_metadata
*/
getMetadata(gaxOptions, callback) {
if (is.fn(gaxOptions)) {
Expand Down Expand Up @@ -611,38 +611,8 @@ Please use the format 'my-instance' or '${
* @param {Table[]} callback.tables List of all Tables.
* @param {object} callback.apiResponse The full API response.
*
* @example
* const Bigtable = require('@google-cloud/bigtable');
* const bigtable = new Bigtable();
* const instance = bigtable.instance('my-instance');
*
* instance.getTables(function(err, tables) {
* if (!err) {
* // `tables` is an array of Table objects.
* }
* });
*
* //-
* // To control how many API requests are made and page through the results
* // manually, set `autoPaginate` to false.
* //-
* const callback = function(err, tables, nextQuery, apiResponse) {
* if (nextQuery) {
* // More results exist.
* instance.getTables(nextQuery, calback);
* }
* };
*
* instance.getTables({
* autoPaginate: false
* }, callback);
*
* //-
* // If the callback is omitted, we'll return a Promise.
* //-
* instance.getTables().then(function(data) {
* const tables = data[0];
* });
* @example <caption>include:samples/document-snippets/instance.js</caption>
* region_tag:bigtable_get_tables
*/
getTables(options, callback) {
if (is.function(options)) {
Expand Down Expand Up @@ -692,23 +662,8 @@ Please use the format 'my-instance' or '${
* request.
* @param {object} callback.apiResponse The full API response.
*
* @example
* const Bigtable = require('@google-cloud/bigtable');
* const bigtable = new Bigtable();
* const instance = bigtable.instance('my-instance');
*
* var metadata = {
* displayName: 'updated-name'
* };
*
* instance.setMetadata(metadata, function(err, apiResponse) {});
*
* //-
* // If the callback is omitted, we'll return a Promise.
* //-
* instance.setMetadata(metadata).then(function(data) {
* var apiResponse = data[0];
* });
* @example <caption>include:samples/document-snippets/instance.js</caption>
* region_tag:bigtable_set_meta_data
*/
setMetadata(metadata, gaxOptions, callback) {
if (is.fn(gaxOptions)) {
Expand Down

0 comments on commit 6c11f2a

Please sign in to comment.