How to use google-proto-files - 10 common examples

To help you get started, we’ve selected a few google-proto-files examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github actions-on-google / actions-on-google-testing-nodejs / src / actions-on-google.ts View on Github external
const DEFAULT_LOCALE = SUPPORTED_LOCALES[0]

i18n.configure({
    locales: SUPPORTED_LOCALES,
    fallbacks: FALLBACK_LOCALES,
    directory: __dirname + '/locales',
    defaultLocale: DEFAULT_LOCALE,
})

const INTENT_NAMES = {
  NEW_SURFACE: 'actions.intent.NEW_SURFACE',
  SIGN_IN: 'actions.intent.SIGN_IN',
}

const PROTO_ROOT_DIR = protoFiles.getProtoPath('..')
const embeddedAssistantPb = grpc.load({
    root: PROTO_ROOT_DIR,
    file: path.relative(PROTO_ROOT_DIR, protoFiles['embeddedAssistant'].v1alpha2),
}).google.assistant.embedded.v1alpha2

const latlngPb = grpc.load({
    root: PROTO_ROOT_DIR,
    file: path.relative(PROTO_ROOT_DIR, protoFiles['embeddedAssistant'].v1alpha2),
}).google.type.LatLng

/* Unexported AoG types */
interface AogSuggestion {
    title: string
}

interface AogOptionInfo {
github googleapis / nodejs-proto-files / samples / quickstart.js View on Github external
async function quickstart() {
  // Get a directory path by executing as a function
  const files = protos.getProtoPath('logging', 'v2');
  console.log(files);
  // node_modules/google-proto-files/google/logging/v2

  // Get a path to the entry proto file for a specific API version
  console.log(protos.pubsub.v1);
  // node_modules/google-proto-files/google/pubsub/v1/pubsub.proto

  // Load a proto which depends on google common protos.
  const root1 = await protos.load('./cloudcats.proto');
  const service1 = root1.lookup('example.MyService');
  console.log(service1);

  // Load protos synchronously
  const root2 = protos.loadSync('./cloudcats.proto');
  const service2 = root2.lookup('example.MyService');
  console.log(service2);
github googleapis / nodejs-proto-files / samples / quickstart.js View on Github external
async function quickstart() {
  // Get a directory path by executing as a function
  const files = protos.getProtoPath('logging', 'v2');
  console.log(files);
  // node_modules/google-proto-files/google/logging/v2

  // Get a path to the entry proto file for a specific API version
  console.log(protos.pubsub.v1);
  // node_modules/google-proto-files/google/pubsub/v1/pubsub.proto

  // Load a proto which depends on google common protos.
  const root1 = await protos.load('./cloudcats.proto');
  const service1 = root1.lookup('example.MyService');
  console.log(service1);

  // Load protos synchronously
  const root2 = protos.loadSync('./cloudcats.proto');
  const service2 = root2.lookup('example.MyService');
  console.log(service2);
}
quickstart();
github googleapis / nodejs-proto-files / samples / quickstart.js View on Github external
// Get a directory path by executing as a function
  const files = protos.getProtoPath('logging', 'v2');
  console.log(files);
  // node_modules/google-proto-files/google/logging/v2

  // Get a path to the entry proto file for a specific API version
  console.log(protos.pubsub.v1);
  // node_modules/google-proto-files/google/pubsub/v1/pubsub.proto

  // Load a proto which depends on google common protos.
  const root1 = await protos.load('./cloudcats.proto');
  const service1 = root1.lookup('example.MyService');
  console.log(service1);

  // Load protos synchronously
  const root2 = protos.loadSync('./cloudcats.proto');
  const service2 = root2.lookup('example.MyService');
  console.log(service2);
}
quickstart();
github googleapis / nodejs-proto-files / samples / quickstart.js View on Github external
async function quickstart() {
  // Get a directory path by executing as a function
  const files = protos.getProtoPath('logging', 'v2');
  console.log(files);
  // node_modules/google-proto-files/google/logging/v2

  // Get a path to the entry proto file for a specific API version
  console.log(protos.pubsub.v1);
  // node_modules/google-proto-files/google/pubsub/v1/pubsub.proto

  // Load a proto which depends on google common protos.
  const root1 = await protos.load('./cloudcats.proto');
  const service1 = root1.lookup('example.MyService');
  console.log(service1);

  // Load protos synchronously
  const root2 = protos.loadSync('./cloudcats.proto');
  const service2 = root2.lookup('example.MyService');
  console.log(service2);
}
quickstart();
github googleapis / nodejs-speech / samples / recognize_streaming.js View on Github external
'use strict';

var async = require('async');
var fs = require('fs');
var path = require('path');
var grpc = require('grpc');
var googleProtoFiles = require('google-proto-files');
var googleAuth = require('google-auto-auth');
var Transform = require('stream').Transform;

// [START proto]
var PROTO_ROOT_DIR = googleProtoFiles('..');

var protoDescriptor = grpc.load({
  root: PROTO_ROOT_DIR,
  file: path.relative(PROTO_ROOT_DIR, googleProtoFiles.speech.v1beta1)
}, 'proto', {
  binaryAsBase64: true,
  convertFieldsToCamelCase: true
});
var speechProto = protoDescriptor.google.cloud.speech.v1beta1;
// [END proto]

// [START authenticating]
function getSpeechService (host, callback) {
  var googleAuthClient = googleAuth({
    scopes: [
      'https://www.googleapis.com/auth/cloud-platform'
    ]
  });

  googleAuthClient.getAuthClient(function (err, authClient) {
github TheAdrianProject / AdrianSmartAssistant / Library / googleSpeech / stream.js View on Github external
var fs = require('fs');
var cursor = ansi(process.stdout);

//Lets require/import the HTTP module
var http = require('http');
var url = require("url");

//Lets define a port we want to listen to
const PORT=9950;

// [START proto]
var PROTO_ROOT_DIR = googleProtoFiles('..');
var mic = null;
var protoDescriptor = grpc.load({
      root: PROTO_ROOT_DIR,
      file: path.relative(PROTO_ROOT_DIR, googleProtoFiles.speech.v1beta1)
    }, 'proto', {
      binaryAsBase64: true,
      convertFieldsToCamelCase: true
    });

var speechProto = protoDescriptor.google.cloud.speech.v1beta1;
// [END proto]

//We need a function which handles requests and send response
function handleRequest(request, response){

    var method = url.parse(request.url).query;

    if (method=="startListening"){

        //var reqestCommand = "GOOGLE SPEACH DEAMON : Start Recognition";
github googlesamples / assistant-sdk-nodejs / google-assistant-grpc / googleassistant.js View on Github external
* 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.
 */

'use strict';
const path = require('path');
const grpc = require('grpc');
const protoFiles = require('google-proto-files');
const resolve = require('resolve');
const GoogleAuth = require('google-auth-library');

const PROTO_ROOT_DIR = protoFiles('..');
const embedded_assistant_pb = grpc.load({
    root: PROTO_ROOT_DIR,
    file: path.relative(PROTO_ROOT_DIR, protoFiles.embeddedAssistant.v1alpha2)
}).google.assistant.embedded.v1alpha2;

class GoogleAssistant {
    constructor(credentials) {
        GoogleAssistant.prototype.endpoint_ = "embeddedassistant.googleapis.com";
        this.client = this.createClient_(credentials);
        this.locale = "en-US";
        this.deviceModelId = 'default';
        this.deviceInstanceId = 'default';
    }
    createClient_(credentials) {
        const sslCreds = grpc.credentials.createSsl();
        // https://github.com/google/google-auth-library-nodejs/blob/master/ts/lib/auth/refreshclient.ts
        const auth = new GoogleAuth();
        const refresh = new auth.UserRefreshClient();
        refresh.fromJSON(credentials, function (res) { });
github googleapis / google-cloud-node / test / bigtable / index.js View on Github external
it('should inherit from GrpcService', function() {
      assert(bigtable instanceof GrpcService);

      var calledWith = bigtable.calledWith_[0];

      assert.strictEqual(calledWith.baseUrl, 'bigtable.googleapis.com');
      assert.strictEqual(calledWith.service, 'bigtable');
      assert.strictEqual(calledWith.apiVersion, 'v1');

      assert.deepEqual(calledWith.protoServices, {
        BigtableService: googleProtoFiles.bigtable.v1,
        BigtableTableService: {
          path: googleProtoFiles.bigtable.admin,
          service: 'bigtable.admin.table'
        }
      });

      assert.deepEqual(calledWith.scopes, [
        'https://www.googleapis.com/auth/bigtable.admin',
        'https://www.googleapis.com/auth/bigtable.data'
      ]);
    });
  });
github googleapis / google-cloud-node / test / bigtable / index.js View on Github external
it('should inherit from GrpcService', function() {
      assert(bigtable instanceof GrpcService);

      var calledWith = bigtable.calledWith_[0];

      assert.strictEqual(calledWith.baseUrl, 'bigtable.googleapis.com');
      assert.strictEqual(calledWith.service, 'bigtable');
      assert.strictEqual(calledWith.apiVersion, 'v1');

      assert.deepEqual(calledWith.protoServices, {
        BigtableService: googleProtoFiles.bigtable.v1,
        BigtableTableService: {
          path: googleProtoFiles.bigtable.admin,
          service: 'bigtable.admin.table'
        }
      });

      assert.deepEqual(calledWith.scopes, [
        'https://www.googleapis.com/auth/bigtable.admin',
        'https://www.googleapis.com/auth/bigtable.data'
      ]);
    });
  });