Skip to content
Open
1 change: 1 addition & 0 deletions samples/api-reference-doc-snippets/app-profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const snippets = {

const request = {
name: `projects/${projectId}/instances/${instanceId}/appProfiles/${appProfileId}`,
// ignoreWarnings: true, // uncomment this line to ignore warnings
};

instanceAdminClient
Expand Down
9 changes: 8 additions & 1 deletion samples/api-reference-doc-snippets/backups.create.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,19 @@ async function main(
// const backupId = 'YOUR_BACKUP_ID';
const projectId = await tableAdminClient.getProjectId();

const seconds = Math.floor(
new Date(Date.now() + 7 * 60 * 60 * 1000).getTime() / 1000,
// 7 hours from now
);
const request = {
parent: `projects/${projectId}/instances/${instanceId}/clusters/${clusterId}`,
backupId: backupId,
backup: {
sourceTable: `projects/${projectId}/instances/${instanceId}/tables/${tableId}`,
expireTime: new Date(Date.now() + 7 * 60 * 60 * 1000), // 7 hours from now
expireTime: {
seconds,
nanos: 0,
},
},
};

Expand Down
9 changes: 8 additions & 1 deletion samples/api-reference-doc-snippets/backups.update.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,17 @@ async function main(
// const backupId = 'YOUR_BACKUP_ID';
const projectId = await tableAdminClient.getProjectId();

const seconds = Math.floor(
new Date(Date.now() + 7 * 60 * 60 * 1000).getTime() / 1000,
// 7 hours from now
);
const request = {
backup: {
name: `projects/${projectId}/instances/${instanceId}/clusters/${clusterId}/backups/${backupId}`,
expireTime: new Date(Date.now() + 24 * 60 * 60 * 1000), // 24 hours
expireTime: {
seconds,
nanos: 0,
},
},
updateMask: {
paths: ['expire_time'],
Expand Down
4 changes: 2 additions & 2 deletions samples/api-reference-doc-snippets/family.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ const snippets = {
},
setMetadata: async (instanceId, tableId, familyId) => {
// [START bigtable_api_set_family_meta]
const {BigtableTableAdminClient, GCRuleMaker} =
require('@google-cloud/bigtable').v2;
const {GCRuleMaker} = require('@google-cloud/bigtable');
const {BigtableTableAdminClient} = require('@google-cloud/bigtable').v2;
const adminClient = new BigtableTableAdminClient();
const projectId = await adminClient.getProjectId();

Expand Down
4 changes: 3 additions & 1 deletion samples/api-reference-doc-snippets/instance.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ const snippets = {
};

// creates a new Instance
const [newInstance, operation] =
const [operation, newInstance] =
await instanceAdminClient.createInstance(options);
await operation.promise();
console.log(`Created Instance: ${newInstance.name}`);
// let operations = result[1];
// let apiResponse = result[2];
// [END bigtable_api_create_instance]
Expand Down
4 changes: 2 additions & 2 deletions samples/api-reference-doc-snippets/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -468,11 +468,11 @@ const snippets = {
let isConsistent = false;
while (!isConsistent) {
// 2. Check for consistency
const [consistent] = adminClient.checkConsistency({
const consistent = await adminClient.checkConsistency({
name: `projects/${projectId}/instances/${instanceId}/tables/${tableId}`,
consistencyToken: token,
});
isConsistent = consistent;
isConsistent = consistent[0].consistent;

if (isConsistent) {
console.log('Data is consistent!');
Expand Down
15 changes: 7 additions & 8 deletions samples/instances.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ async function runInstanceOperations(instanceID, clusterID) {
};

// Create production instance with given options
const [prodInstance, operation] =
const [operation, prodInstance] =
await instanceAdminClient.createInstance(instanceOptions);
await operation.promise();
console.log(`Created Instance: ${prodInstance.name}`);
Expand Down Expand Up @@ -136,18 +136,17 @@ async function createDevInstance(instanceID, clusterID) {
labels: {'dev-label': 'dev-label'},
type: 'DEVELOPMENT',
},
clusters: [
{
id: clusterID,
clusters: {
[clusterID]: {
location: `projects/${projectId}/locations/us-central1-f`,
serveNodes: 1,
// serveNodes: 1 // This cannot be specified for development instances
defaultStorageType: 'HDD',
},
],
},
};

// Create development instance with given options
const [instance, operation] =
const [operation, instance] =
await instanceAdminClient.createInstance(options);
await operation.promise();
console.log(`Created development instance: ${instance.name}`);
Expand Down Expand Up @@ -203,7 +202,7 @@ async function addCluster(instanceID, clusterID) {
},
};

const [cluster, operation] =
const [operation, cluster] =
await instanceAdminClient.createCluster(clusterOptions);
await operation.promise();
console.log(`Cluster created: ${cluster.name}`);
Expand Down
4 changes: 3 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import {
import {google} from '../protos/protos';
import {ServiceError} from 'google-gax';
import * as v2 from './v2';
import {GCRuleMaker} from './gc-rule-maker';
import {PassThrough, Duplex} from 'stream';
import grpcGcpModule = require('grpc-gcp');
import {ClusterUtils} from './utils/cluster';
Expand Down Expand Up @@ -1138,6 +1139,7 @@ module.exports = Bigtable;
module.exports.v2 = v2;
module.exports.Bigtable = Bigtable;
module.exports.SqlTypes = SqlTypes;
module.exports.GCRuleMaker = GCRuleMaker;

export {v2};
export {protos};
Expand Down Expand Up @@ -1363,5 +1365,5 @@ export {
WaitForReplicationCallback,
WaitForReplicationResponse,
} from './table';
export {GCRuleMaker} from './gc-rule-maker';
export {GCRuleMaker};
export {SqlTypes};
Loading