You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

143 lines
4.1 KiB

  1. .. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
  2. :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
  3. :alt: License: AGPL-3
  4. =======
  5. Webhook
  6. =======
  7. Module to receive `webhook events <https://en.wikipedia.org/wiki/Webhook>`_.
  8. This module invoke methods to process webhook events.
  9. Configuration
  10. =============
  11. You will need create a new module to add your logic to process the events with methods called:
  12. *def run_CONSUMER_EVENT\**
  13. Example with gihub consumer and push event.
  14. .. code-block:: python
  15. @api.one
  16. def run_github_push_task(self):
  17. # You will have all request data in
  18. # variable: self.env.request
  19. pass
  20. Where CONSUMER is the name of you webhook consumer. e.g. github (Extract from field *name* of *webhook* model)
  21. Where EVENT is the name of the event from webhook *request* data.
  22. Where *\** is your particular method to process this event.
  23. To configure a new webhook you need add all ip or subnet address (with *ip/integer*) owned by your webhook consumer in webhook.address model as data.
  24. Example with github:
  25. .. code-block:: xml
  26. <!--webhook github data of remote address-->
  27. <record model="webhook.address" id="webhook_address_github">
  28. <field name="name">192.30.252.0/22</field>
  29. <field name="webhook_id" ref="webhook_github"/>
  30. </record>
  31. You need to add a python code to extract event name from webhook request info into `python_code_get_event` field of webhook model.
  32. You can get all full data of request webhook from variable `request`
  33. Example with github:
  34. .. code-block:: xml
  35. <!--webhook github data-->
  36. <record model="webhook" id="webhook_github">
  37. <field name="name">github</field>
  38. <field name="python_code_get_event">request.httprequest.headers.get('X-Github-Event')</field>
  39. </record>
  40. Full example of create a new webhook configuration data.
  41. .. code-block:: xml
  42. <?xml version="1.0" encoding="UTF-8"?>
  43. <openerp>
  44. <data>
  45. <!--webhook github data-->
  46. <record model="webhook" id="webhook_github">
  47. <field name="name">github</field>
  48. <field name="python_code_get_event">request.httprequest.headers.get('X-Github-Event')</field>
  49. </record>
  50. <!--webhook github data of remote address-->
  51. <record model="webhook.address" id="webhook_address_github">
  52. <field name="name">192.30.252.0/22</field>
  53. <field name="webhook_id" ref="webhook_github"/>
  54. </record>
  55. </data>
  56. </openerp>
  57. .. figure:: path/to/local/image.png
  58. :alt: alternative description
  59. :width: 600 px
  60. Usage
  61. =====
  62. To use this module, you need to:
  63. #. Go to your customer webhook configuration from 3rd-party applications
  64. and use the odoo webhook url HOST/webhook/NAME_WEBHOOK
  65. .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
  66. :alt: Try me on Runbot
  67. :target: https://runbot.odoo-community.org/runbot/{repo_id}/{branch}
  68. .. repo_id is available in https://github.com/OCA/maintainer-tools/blob/master/tools/repos_with_ids.txt
  69. .. branch is "8.0" for example
  70. Bug Tracker
  71. ===========
  72. Bugs are tracked on `GitHub Issues
  73. <https://github.com/OCA/server-tools/issues>`_. In case of trouble, please
  74. check there if your issue has already been reported. If you spotted it first,
  75. help us smash it by providing detailed and welcomed feedback.
  76. Credits
  77. =======
  78. Images
  79. ------
  80. * Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.
  81. Contributors
  82. ------------
  83. * Moisés López <moylop260@vauxoo.com>
  84. Funders
  85. -------
  86. The development of this module has been financially supported by:
  87. * Vauxoo
  88. Maintainer
  89. ----------
  90. .. image:: https://odoo-community.org/logo.png
  91. :alt: Odoo Community Association
  92. :target: https://odoo-community.org
  93. This module is maintained by the OCA.
  94. OCA, or the Odoo Community Association, is a nonprofit organization whose
  95. mission is to support the collaborative development of Odoo features and
  96. promote its widespread use.
  97. To contribute to this module, please visit https://odoo-community.org.