text: /**
   * Triggered from a message on a Cloud Pub/Sub topic.
   *
   * @param {!Object} event Event payload.
   * @param {!Object} context Metadata for the event.
   */
  'use strict';
  
  //const sendgrid = require('sendgrid');
  const sgMail = require('@sendgrid/mail');
  const {SecretManagerServiceClient} = require('@google-cloud/secret-manager');
  
  exports.sccPubSub = async (event, context) => {
    const message = event.data
      ? Buffer.from(event.data, 'base64').toString()
      : '';
    console.log(message);
  
    // Instantiates a client
    const secretName = process.env.SENDGRID_API_KEY_SECRET_NAME;
    const client = new SecretManagerServiceClient();
  
    //function accessSecretVersion() {
      const [version] = await client.accessSecretVersion({
        name: secretName,
      });
  
      // Extract the payload as a string.
      const apikey = version.payload.data.toString();
  
      // WARNING: Do not print the secret in a production environment - this
      // snippet is showing how to access the secret material.
      console.info(`apikey: ${apikey}`);
    //}
    //accessSecretVersion();
  
    sgMail.setApiKey(apikey);
    var emails = process.env.EMAIL_TO.split(";");
  
    const msg = {
      to: emails,
      from: process.env.EMAIL_FROM,
      subject: 'GCP SCC Finging Notification (swiftmed)',
      text: message,
      html: '<strong>'+ message +'</strong>',
    };
    // JSON.parse(message).video
    sgMail.send(msg);
  };
  