diff --git a/src/v1/database_admin_client.js b/src/v1/database_admin_client.js index 1729cd0cf..fa1688672 100644 --- a/src/v1/database_admin_client.js +++ b/src/v1/database_admin_client.js @@ -125,16 +125,11 @@ class DatabaseAdminClient { }; let protoFilesRoot = new gax.GoogleProtoFilesRoot(); protoFilesRoot = protobuf.loadSync( - path.join( - __dirname, - '..', - '..', - 'protos', - 'google/spanner/admin/database/v1/spanner_database_admin.proto' - ), + path.join(__dirname, '..', '..', 'protos', 'google/spanner/admin/database/v1/spanner_database_admin.proto'), protoFilesRoot ); + // This API contains "long-running operations", which return a // an Operation object that allows for tracking of the operation, // rather than holding a request open. @@ -216,8 +211,7 @@ class DatabaseAdminClient { } ), defaults[methodName], - this._descriptors.page[methodName] || - this._descriptors.longrunning[methodName] + this._descriptors.page[methodName] || this._descriptors.longrunning[methodName] ); } } @@ -409,7 +403,7 @@ class DatabaseAdminClient { request, options ); - } + }; /** * Creates a new Cloud Spanner database and starts to prepare it for serving. @@ -998,7 +992,9 @@ class DatabaseAdminClient { * @returns {String} - A string representing the project. */ matchProjectFromInstanceName(instanceName) { - return this._pathTemplates.instancePathTemplate.match(instanceName).project; + return this._pathTemplates.instancePathTemplate + .match(instanceName) + .project; } /** @@ -1009,7 +1005,8 @@ class DatabaseAdminClient { * @returns {String} - A string representing the instance. */ matchInstanceFromInstanceName(instanceName) { - return this._pathTemplates.instancePathTemplate.match(instanceName) + return this._pathTemplates.instancePathTemplate + .match(instanceName) .instance; } @@ -1021,7 +1018,9 @@ class DatabaseAdminClient { * @returns {String} - A string representing the project. */ matchProjectFromDatabaseName(databaseName) { - return this._pathTemplates.databasePathTemplate.match(databaseName).project; + return this._pathTemplates.databasePathTemplate + .match(databaseName) + .project; } /** @@ -1032,7 +1031,8 @@ class DatabaseAdminClient { * @returns {String} - A string representing the instance. */ matchInstanceFromDatabaseName(databaseName) { - return this._pathTemplates.databasePathTemplate.match(databaseName) + return this._pathTemplates.databasePathTemplate + .match(databaseName) .instance; } @@ -1044,9 +1044,11 @@ class DatabaseAdminClient { * @returns {String} - A string representing the database. */ matchDatabaseFromDatabaseName(databaseName) { - return this._pathTemplates.databasePathTemplate.match(databaseName) + return this._pathTemplates.databasePathTemplate + .match(databaseName) .database; } } + module.exports = DatabaseAdminClient; diff --git a/src/v1/instance_admin_client.js b/src/v1/instance_admin_client.js index d52c05147..0ecc0498a 100644 --- a/src/v1/instance_admin_client.js +++ b/src/v1/instance_admin_client.js @@ -121,7 +121,9 @@ class InstanceAdminClient { // identifiers to uniquely identify resources within the API. // Create useful helper objects for these. this._pathTemplates = { - projectPathTemplate: new gax.PathTemplate('projects/{project}'), + projectPathTemplate: new gax.PathTemplate( + 'projects/{project}' + ), instanceConfigPathTemplate: new gax.PathTemplate( 'projects/{project}/instanceConfigs/{instance_config}' ), @@ -147,16 +149,11 @@ class InstanceAdminClient { }; let protoFilesRoot = new gax.GoogleProtoFilesRoot(); protoFilesRoot = protobuf.loadSync( - path.join( - __dirname, - '..', - '..', - 'protos', - 'google/spanner/admin/instance/v1/spanner_instance_admin.proto' - ), + path.join(__dirname, '..', '..', 'protos', 'google/spanner/admin/instance/v1/spanner_instance_admin.proto'), protoFilesRoot ); + // This API contains "long-running operations", which return a // an Operation object that allows for tracking of the operation, // rather than holding a request open. @@ -239,8 +236,7 @@ class InstanceAdminClient { } ), defaults[methodName], - this._descriptors.page[methodName] || - this._descriptors.longrunning[methodName] + this._descriptors.page[methodName] || this._descriptors.longrunning[methodName] ); } } @@ -434,7 +430,7 @@ class InstanceAdminClient { request, options ); - } + }; /** * Gets information about a particular instance configuration. @@ -672,7 +668,7 @@ class InstanceAdminClient { request, options ); - } + }; /** * Gets information about a particular instance. @@ -1283,7 +1279,9 @@ class InstanceAdminClient { * @returns {String} - A string representing the project. */ matchProjectFromProjectName(projectName) { - return this._pathTemplates.projectPathTemplate.match(projectName).project; + return this._pathTemplates.projectPathTemplate + .match(projectName) + .project; } /** @@ -1294,9 +1292,9 @@ class InstanceAdminClient { * @returns {String} - A string representing the project. */ matchProjectFromInstanceConfigName(instanceConfigName) { - return this._pathTemplates.instanceConfigPathTemplate.match( - instanceConfigName - ).project; + return this._pathTemplates.instanceConfigPathTemplate + .match(instanceConfigName) + .project; } /** @@ -1307,9 +1305,9 @@ class InstanceAdminClient { * @returns {String} - A string representing the instance_config. */ matchInstanceConfigFromInstanceConfigName(instanceConfigName) { - return this._pathTemplates.instanceConfigPathTemplate.match( - instanceConfigName - ).instance_config; + return this._pathTemplates.instanceConfigPathTemplate + .match(instanceConfigName) + .instance_config; } /** @@ -1320,7 +1318,9 @@ class InstanceAdminClient { * @returns {String} - A string representing the project. */ matchProjectFromInstanceName(instanceName) { - return this._pathTemplates.instancePathTemplate.match(instanceName).project; + return this._pathTemplates.instancePathTemplate + .match(instanceName) + .project; } /** @@ -1331,9 +1331,11 @@ class InstanceAdminClient { * @returns {String} - A string representing the instance. */ matchInstanceFromInstanceName(instanceName) { - return this._pathTemplates.instancePathTemplate.match(instanceName) + return this._pathTemplates.instancePathTemplate + .match(instanceName) .instance; } } + module.exports = InstanceAdminClient; diff --git a/src/v1/spanner_client.js b/src/v1/spanner_client.js index 6c923845b..c3849bba3 100644 --- a/src/v1/spanner_client.js +++ b/src/v1/spanner_client.js @@ -125,9 +125,7 @@ class SpannerClient { // Some of the methods on this service provide streaming responses. // Provide descriptors for these. this._descriptors.stream = { - executeStreamingSql: new gax.StreamDescriptor( - gax.StreamType.SERVER_STREAMING - ), + executeStreamingSql: new gax.StreamDescriptor(gax.StreamType.SERVER_STREAMING), streamingRead: new gax.StreamDescriptor(gax.StreamType.SERVER_STREAMING), }; @@ -182,8 +180,7 @@ class SpannerClient { } ), defaults[methodName], - this._descriptors.page[methodName] || - this._descriptors.stream[methodName] + this._descriptors.page[methodName] || this._descriptors.stream[methodName] ); } } @@ -511,7 +508,7 @@ class SpannerClient { request, options ); - } + }; /** * Ends a session, releasing server resources associated with it. @@ -1435,7 +1432,9 @@ class SpannerClient { * @returns {String} - A string representing the project. */ matchProjectFromDatabaseName(databaseName) { - return this._pathTemplates.databasePathTemplate.match(databaseName).project; + return this._pathTemplates.databasePathTemplate + .match(databaseName) + .project; } /** @@ -1446,7 +1445,8 @@ class SpannerClient { * @returns {String} - A string representing the instance. */ matchInstanceFromDatabaseName(databaseName) { - return this._pathTemplates.databasePathTemplate.match(databaseName) + return this._pathTemplates.databasePathTemplate + .match(databaseName) .instance; } @@ -1458,7 +1458,8 @@ class SpannerClient { * @returns {String} - A string representing the database. */ matchDatabaseFromDatabaseName(databaseName) { - return this._pathTemplates.databasePathTemplate.match(databaseName) + return this._pathTemplates.databasePathTemplate + .match(databaseName) .database; } @@ -1470,7 +1471,9 @@ class SpannerClient { * @returns {String} - A string representing the project. */ matchProjectFromSessionName(sessionName) { - return this._pathTemplates.sessionPathTemplate.match(sessionName).project; + return this._pathTemplates.sessionPathTemplate + .match(sessionName) + .project; } /** @@ -1481,7 +1484,9 @@ class SpannerClient { * @returns {String} - A string representing the instance. */ matchInstanceFromSessionName(sessionName) { - return this._pathTemplates.sessionPathTemplate.match(sessionName).instance; + return this._pathTemplates.sessionPathTemplate + .match(sessionName) + .instance; } /** @@ -1492,7 +1497,9 @@ class SpannerClient { * @returns {String} - A string representing the database. */ matchDatabaseFromSessionName(sessionName) { - return this._pathTemplates.sessionPathTemplate.match(sessionName).database; + return this._pathTemplates.sessionPathTemplate + .match(sessionName) + .database; } /** @@ -1503,8 +1510,11 @@ class SpannerClient { * @returns {String} - A string representing the session. */ matchSessionFromSessionName(sessionName) { - return this._pathTemplates.sessionPathTemplate.match(sessionName).session; + return this._pathTemplates.sessionPathTemplate + .match(sessionName) + .session; } } + module.exports = SpannerClient; diff --git a/synth.metadata b/synth.metadata index 9d1562720..8077a5102 100644 --- a/synth.metadata +++ b/synth.metadata @@ -1,5 +1,5 @@ { - "updateTime": "2019-02-13T12:25:28.245272Z", + "updateTime": "2019-02-16T12:21:04.483545Z", "sources": [ { "generator": { @@ -12,8 +12,8 @@ "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "ca61898878f0926dd9dcc68ba90764f17133efe4", - "internalRef": "233680013" + "sha": "1a4f0f12777dc2f8bf2c2ce84438329639c75e29", + "internalRef": "234149430" } }, { diff --git a/test/gapic-v1.js b/test/gapic-v1.js index 597d8dac8..55a0b616a 100644 --- a/test/gapic-v1.js +++ b/test/gapic-v1.js @@ -46,11 +46,7 @@ describe('InstanceAdminClient', () => { }; // Mock Grpc layer - client._innerApiCalls.listInstanceConfigs = ( - actualRequest, - options, - callback - ) => { + client._innerApiCalls.listInstanceConfigs = (actualRequest, options, callback) => { assert.deepStrictEqual(actualRequest, request); callback(null, expectedResponse.instanceConfigs); }; @@ -98,10 +94,7 @@ describe('InstanceAdminClient', () => { }); // Mock request - const formattedName = client.instanceConfigPath( - '[PROJECT]', - '[INSTANCE_CONFIG]' - ); + const formattedName = client.instanceConfigPath('[PROJECT]', '[INSTANCE_CONFIG]'); const request = { name: formattedName, }; @@ -134,10 +127,7 @@ describe('InstanceAdminClient', () => { }); // Mock request - const formattedName = client.instanceConfigPath( - '[PROJECT]', - '[INSTANCE_CONFIG]' - ); + const formattedName = client.instanceConfigPath('[PROJECT]', '[INSTANCE_CONFIG]'); const request = { name: formattedName, }; @@ -181,11 +171,7 @@ describe('InstanceAdminClient', () => { }; // Mock Grpc layer - client._innerApiCalls.listInstances = ( - actualRequest, - options, - callback - ) => { + client._innerApiCalls.listInstances = (actualRequest, options, callback) => { assert.deepStrictEqual(actualRequest, request); callback(null, expectedResponse.instances); }; @@ -321,24 +307,17 @@ describe('InstanceAdminClient', () => { }; // Mock Grpc layer - client._innerApiCalls.createInstance = mockLongRunningGrpcMethod( - request, - expectedResponse - ); + client._innerApiCalls.createInstance = mockLongRunningGrpcMethod(request, expectedResponse); - client - .createInstance(request) - .then(responses => { - const operation = responses[0]; - return operation.promise(); - }) - .then(responses => { - assert.deepStrictEqual(responses[0], expectedResponse); - done(); - }) - .catch(err => { - done(err); - }); + client.createInstance(request).then(responses => { + const operation = responses[0]; + return operation.promise(); + }).then(responses => { + assert.deepStrictEqual(responses[0], expectedResponse); + done(); + }).catch(err => { + done(err); + }); }); it('invokes createInstance with error', done => { @@ -358,26 +337,18 @@ describe('InstanceAdminClient', () => { }; // Mock Grpc layer - client._innerApiCalls.createInstance = mockLongRunningGrpcMethod( - request, - null, - error - ); - - client - .createInstance(request) - .then(responses => { - const operation = responses[0]; - return operation.promise(); - }) - .then(() => { - assert.fail(); - }) - .catch(err => { - assert(err instanceof Error); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - done(); - }); + client._innerApiCalls.createInstance = mockLongRunningGrpcMethod(request, null, error); + + client.createInstance(request).then(responses => { + const operation = responses[0]; + return operation.promise(); + }).then(() => { + assert.fail(); + }).catch(err => { + assert(err instanceof Error); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + done(); + }); }); it('has longrunning decoder functions', () => { @@ -385,14 +356,8 @@ describe('InstanceAdminClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); - assert( - client._descriptors.longrunning.createInstance - .responseDecoder instanceof Function - ); - assert( - client._descriptors.longrunning.createInstance - .metadataDecoder instanceof Function - ); + assert(client._descriptors.longrunning.createInstance.responseDecoder instanceof Function); + assert(client._descriptors.longrunning.createInstance.metadataDecoder instanceof Function); }); }); @@ -424,24 +389,17 @@ describe('InstanceAdminClient', () => { }; // Mock Grpc layer - client._innerApiCalls.updateInstance = mockLongRunningGrpcMethod( - request, - expectedResponse - ); + client._innerApiCalls.updateInstance = mockLongRunningGrpcMethod(request, expectedResponse); - client - .updateInstance(request) - .then(responses => { - const operation = responses[0]; - return operation.promise(); - }) - .then(responses => { - assert.deepStrictEqual(responses[0], expectedResponse); - done(); - }) - .catch(err => { - done(err); - }); + client.updateInstance(request).then(responses => { + const operation = responses[0]; + return operation.promise(); + }).then(responses => { + assert.deepStrictEqual(responses[0], expectedResponse); + done(); + }).catch(err => { + done(err); + }); }); it('invokes updateInstance with error', done => { @@ -459,26 +417,18 @@ describe('InstanceAdminClient', () => { }; // Mock Grpc layer - client._innerApiCalls.updateInstance = mockLongRunningGrpcMethod( - request, - null, - error - ); - - client - .updateInstance(request) - .then(responses => { - const operation = responses[0]; - return operation.promise(); - }) - .then(() => { - assert.fail(); - }) - .catch(err => { - assert(err instanceof Error); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - done(); - }); + client._innerApiCalls.updateInstance = mockLongRunningGrpcMethod(request, null, error); + + client.updateInstance(request).then(responses => { + const operation = responses[0]; + return operation.promise(); + }).then(() => { + assert.fail(); + }).catch(err => { + assert(err instanceof Error); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + done(); + }); }); it('has longrunning decoder functions', () => { @@ -486,14 +436,8 @@ describe('InstanceAdminClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); - assert( - client._descriptors.longrunning.updateInstance - .responseDecoder instanceof Function - ); - assert( - client._descriptors.longrunning.updateInstance - .metadataDecoder instanceof Function - ); + assert(client._descriptors.longrunning.updateInstance.responseDecoder instanceof Function); + assert(client._descriptors.longrunning.updateInstance.metadataDecoder instanceof Function); }); }); @@ -734,6 +678,7 @@ describe('InstanceAdminClient', () => { }); }); }); + }); function mockSimpleGrpcMethod(expectedRequest, response, error) { @@ -757,11 +702,12 @@ function mockLongRunningGrpcMethod(expectedRequest, response, error) { return new Promise((resolve, reject) => { if (error) { reject(error); - } else { + } + else { resolve([response]); } }); - }, + } }; return Promise.resolve([mockOperation]); };