Skip to content

Commit

Permalink
Fix sample code and add proto type export
Browse files Browse the repository at this point in the history
  • Loading branch information
swcloud committed Jun 23, 2017
1 parent 202da06 commit 557cb28
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 34 deletions.
18 changes: 18 additions & 0 deletions packages/language/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ var gapic = {
v1: require('./v1'),
v1beta2: require('./v1beta2')
};
var gaxGrpc = require('google-gax').grpc();

const VERSION = require('../package.json').version;

Expand Down Expand Up @@ -73,6 +74,23 @@ function languageV1beta2(options) {
return client;
}

var v1Protos = {};

extend(v1Protos, gaxGrpc.load([{
root: require('google-proto-files')('..'),
file: 'google/cloud/language/v1/language_service.proto'
}]).google.cloud.language.v1);

var v1beta2Protos = {};

extend(v1beta2Protos, gaxGrpc.load([{
root: require('google-proto-files')('..'),
file: 'google/cloud/language/v1beta2/language_service.proto'
}]).google.cloud.language.v1beta2);

module.exports = languageV1;
module.exports.types = v1Protos;
module.exports.v1 = languageV1;
module.exports.v1.types = v1Protos;
module.exports.v1beta2 = languageV1beta2;
module.exports.v1beta2.types = v1beta2Protos;
43 changes: 27 additions & 16 deletions packages/language/src/v1/language_service_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,6 @@ var ALL_SCOPES = [
* Provides text analysis operations such as sentiment analysis and entity
* recognition.
*
* This will be created through a builder function which can be obtained by the module.
* See the following example of how to initialize the module and how to access to the builder.
* @see {@link languageServiceClient}
*
* @example
* var languageV1 = require('@google-cloud/language').v1({
* // optional auth parameters.
* });
* var client = languageV1.languageServiceClient();
*
* @class
*/
Expand Down Expand Up @@ -149,7 +140,12 @@ LanguageServiceClient.prototype.getProjectId = function(callback) {
*
* @example
*
* var client = languageV1.languageServiceClient();
* var language = require('@google-cloud/language');
*
* var client = language.v1({
* // optional auth parameters.
* });
*
* var document = {};
* client.analyzeSentiment({document: document}).then(function(responses) {
* var response = responses[0];
Expand Down Expand Up @@ -198,9 +194,14 @@ LanguageServiceClient.prototype.analyzeSentiment = function(request, options, ca
*
* @example
*
* var client = languageV1.languageServiceClient();
* var language = require('@google-cloud/language');
*
* var client = language.v1({
* // optional auth parameters.
* });
*
* var document = {};
* var encodingType = languageV1.EncodingType.NONE;
* var encodingType = language.v1.types.EncodingType.NONE;
* var request = {
* document: document,
* encodingType: encodingType
Expand Down Expand Up @@ -252,9 +253,14 @@ LanguageServiceClient.prototype.analyzeEntities = function(request, options, cal
*
* @example
*
* var client = languageV1.languageServiceClient();
* var language = require('@google-cloud/language');
*
* var client = language.v1({
* // optional auth parameters.
* });
*
* var document = {};
* var encodingType = languageV1.EncodingType.NONE;
* var encodingType = language.v1.types.EncodingType.NONE;
* var request = {
* document: document,
* encodingType: encodingType
Expand Down Expand Up @@ -309,10 +315,15 @@ LanguageServiceClient.prototype.analyzeSyntax = function(request, options, callb
*
* @example
*
* var client = languageV1.languageServiceClient();
* var language = require('@google-cloud/language');
*
* var client = language.v1({
* // optional auth parameters.
* });
*
* var document = {};
* var features = {};
* var encodingType = languageV1.EncodingType.NONE;
* var encodingType = language.v1.types.EncodingType.NONE;
* var request = {
* document: document,
* features: features,
Expand Down
52 changes: 34 additions & 18 deletions packages/language/src/v1beta2/language_service_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,6 @@ var ALL_SCOPES = [
* Provides text analysis operations such as sentiment analysis and entity
* recognition.
*
* This will be created through a builder function which can be obtained by the module.
* See the following example of how to initialize the module and how to access to the builder.
* @see {@link languageServiceClient}
*
* @example
* var languageV1beta2 = require('@google-cloud/language').v1beta2({
* // optional auth parameters.
* });
* var client = languageV1beta2.languageServiceClient();
*
* @class
*/
Expand Down Expand Up @@ -151,7 +142,12 @@ LanguageServiceClient.prototype.getProjectId = function(callback) {
*
* @example
*
* var client = languageV1beta2.languageServiceClient();
* var language = require('@google-cloud/language');
*
* var client = language.v1beta2({
* // optional auth parameters.
* });
*
* var document = {};
* client.analyzeSentiment({document: document}).then(function(responses) {
* var response = responses[0];
Expand Down Expand Up @@ -200,9 +196,14 @@ LanguageServiceClient.prototype.analyzeSentiment = function(request, options, ca
*
* @example
*
* var client = languageV1beta2.languageServiceClient();
* var language = require('@google-cloud/language');
*
* var client = language.v1beta2({
* // optional auth parameters.
* });
*
* var document = {};
* var encodingType = languageV1beta2.EncodingType.NONE;
* var encodingType = language.v1beta2.types.EncodingType.NONE;
* var request = {
* document: document,
* encodingType: encodingType
Expand Down Expand Up @@ -253,9 +254,14 @@ LanguageServiceClient.prototype.analyzeEntities = function(request, options, cal
*
* @example
*
* var client = languageV1beta2.languageServiceClient();
* var language = require('@google-cloud/language');
*
* var client = language.v1beta2({
* // optional auth parameters.
* });
*
* var document = {};
* var encodingType = languageV1beta2.EncodingType.NONE;
* var encodingType = language.v1beta2.types.EncodingType.NONE;
* var request = {
* document: document,
* encodingType: encodingType
Expand Down Expand Up @@ -307,9 +313,14 @@ LanguageServiceClient.prototype.analyzeEntitySentiment = function(request, optio
*
* @example
*
* var client = languageV1beta2.languageServiceClient();
* var language = require('@google-cloud/language');
*
* var client = language.v1beta2({
* // optional auth parameters.
* });
*
* var document = {};
* var encodingType = languageV1beta2.EncodingType.NONE;
* var encodingType = language.v1beta2.types.EncodingType.NONE;
* var request = {
* document: document,
* encodingType: encodingType
Expand Down Expand Up @@ -364,10 +375,15 @@ LanguageServiceClient.prototype.analyzeSyntax = function(request, options, callb
*
* @example
*
* var client = languageV1beta2.languageServiceClient();
* var language = require('@google-cloud/language');
*
* var client = language.v1beta2({
* // optional auth parameters.
* });
*
* var document = {};
* var features = {};
* var encodingType = languageV1beta2.EncodingType.NONE;
* var encodingType = language.v1beta2.types.EncodingType.NONE;
* var request = {
* document: document,
* features: features,
Expand Down

0 comments on commit 557cb28

Please sign in to comment.