Package: webhooksimple
WebhookSimpleA simple framework/cli tool to setup and sync (Webex Teams) API webhooksFree software: MIT licenseDocumentation:https://webhooksimple.readthedocs.io.FeaturesCreate, update and delete (webex teams) webhooks from a yaml fileModular architecture makes it suitable for other APIs as wellHow to UseWebhookSimple is a simple (and open source) python framework/command line tool that allows you to quickly describe your desired Webex Teams web hooks and then creates or synchronises them for you.WebhookSimple requires two files from you.vars.ymlandhooks.ymlvars.ymlspecifies the different variables whilehooks.ymllets you specify the web hooks itself.A web hook always looks like this  (inhooks.yml)---hooks:-name:test hook 1resource:"messages"event:"created"target_url:"https://your_url_here"Make sure that thenameof your web hook is always unique since this is what webhookSimple will use to identify and synchronise your webhooks.  Your ::vars.yml::must includeanadapterthat specifies the kind of api we are interacting with as well as the authentication details. Leave this to the providedparser.WebexTeamsWebhookManagerfor now and add the access token in the correct spot.vars.yml:# vars file. The adapter section **needs** to be hereadapter:name:WebexTeamsWebhookManagerauthentication:access_token:your access token hereparameters:# Add your variables from here onurls:-https://www.cisco.com-https://www.google.comYou can nowsetup,purge,list,exportorsyncyour webhooks.setupwilldeleteall webhooks currently present for this bot and create new ones based on thehooks.ymlfile.syncwill update all existing webhooks based on thenameattribute and create those not present. It willnotdelete webhooks that are registered on the server.purgewill delete all webhooks without creating new oneslistwill list all webhooks currently registeredexportwill save all your currently active webhooks to a .yml fileInvoke the module by running$lshooks.ymlvars.yml$python3-mwebhooksimplesetupTaking it one step furtherSetting up web hook from a command line and based of a configuration file is already pretty cool and convenient. But what if we have ten webhooks and need to update the target_url on all of them? We’d have to manually edit all the web hook entries in ::hooks.yml::. This is where the ::vars.yml:: file comes into play. ::hooks.yml:: is not a simple configuration file but rather aJinja2template of a configuration file. What you can do is this:vars.yml---# Note: Adapter part (see above) omited for bravityurl_prefix:https://my_url_basehooks.yml:---hooks:-name:test hook 1resource:"messages"event:"created"target_url:"https://{{url_prefix}}/messages"But this is not all. Those that worked with jinja2 before probably already know what is coming next. You can also add some (generator) logic here. Lets say we want to create a debug and a production version of our web hook. We can do this by doing the following:vars.yml:---# Note: Adapter part (see above) omited for bravityenvs:-name:productionurl:https://my_production_prefix-name:developmenturl:https://my_development_prefixhooks.yml:---hooks:{%for env in envs %}-name:{{env.name}}message hookresource:"message"event:"created"target_url:{{env.url}}/messages{%endfor %}Or you want to setup the same web hook for different urls. This would look something like thisvars.yml:---# Note: Adapter part (see above) omited for bravityurls:-https://url_number_1-https://url_number_2-https://url_number_3hooks.yml:---hooks:{%for url in urls %}-name:"hookfor{{url}}"resource:"message"event:"created"target_url:{{url}}{%endfor %}Happy programming! You can get WebhookSimple by running$pip3installwebhooksimpleYou have questions or found a bug? Feel free to hit me up on twitter@squ4rks.CreditsThis package was created withCookiecutterand theaudreyr/cookiecutter-pypackageproject template.History0.1.0 (2019-07-12)First release on PyPI.