Giter Club home page Giter Club logo

servicebot-gcp-pub-sub's Introduction

servicebot-gcp-pub-sub

A plugin for servicebot that allows to publish lifecycle events to Google Pub/Sub

Installation

The following actions are needed to enable this plugin:

  • Install the GCP NodeJS client library:
    npm install --save @google-cloud/pubsub
  • Copy the content of this repository to the correspondent servicebot directories.
  • Add the following lines in plugins/api-gateway/app.js:
    require("../../api/gcp-configs")(api)
    require("../../api/gcp-pub-subs")(api)

just after require("../../api/webhooks")(api), for instance.

  • finally register the plugin in config/pluginbot.config.js by adding:
    ...
    {"path" : `${PLUGIN_DIRECTORY}/gcp-pub-subs`},
    ...

to the list of base plugins.

Usage

First you create a least one valid GCP configuration. In this configuration you provide a service account key in JSON format together with your GCP project id. This service account should have the right permissions to operate Google Cloud Pub/Sub. You can create as many configurations as you want.

After a successful completion of the previous step you can add then a trigger, which you can associate with the available GCP configurations which will appear in a dropdown component. This trigger will publish a message to the topic set when the event set happens in servicebot. The message published is the servicebot event itself in JSON. The topic will be created if it doesn't exist.

That's all. You can make a basic test for your trigger by going to the correspondent actions button and clicking Test. This will attempt to create a new pubsub topic with a subscription attached to it and later delete both. Notice that the test may take a few seconds.

Servicebot events:

In version v0.11.163 the following are the events defined along with some simple description and whether their are implemented or not:

  • pre_provision. Called before a new subscription is created.
  • post_provision. Called after the new subscription is created.
  • pre_decommission. Called before removing a subscription.
  • post_decommission. Called after removing a subscription.
  • pre_reactivate. Called before a subscription change its status from cancelled to another status.
  • post_reactivate. Called after a subscription change its status due to an update in the payment plan.
  • pre_property_change. Called before a subscription changes any of its properties.
  • post_property_change. Called after a subscription changes any of its properties.
  • pre_payment_structure_change. Called before a new payment structure is applied to a subscription.
  • post_payment_structure_change. Called after a new payment structure is applied to a subscription.
  • [] post_seat_created.
  • [] post_seat_deleted.
  • post_cancellation_pending. Called just after the request for a subscription to be cancelled at a given day in the future.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.