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.

125 lines
4.2 KiB

9 years ago
  1. {% extends "base.html" %}
  2. {% load compress humanize staticfiles hc_extras %}
  3. {% block title %}Add Webhook - {% site_name %}{% endblock %}
  4. {% block content %}
  5. <div class="row">
  6. <div class="col-sm-12">
  7. <h1>Webhook</h1>
  8. <p>Runs a HTTP GET or HTTP POST to your specified URL when a check
  9. goes up or down. Uses GET by default, and uses POST if you specify
  10. any POST data.</p>
  11. <p>You can use the following variables in webhook URLs:</p>
  12. <table class="table webhook-variables">
  13. <tr>
  14. <th class="variable-column">Variable</th>
  15. <td>Will be replaced with…</td>
  16. </tr>
  17. <tr>
  18. <th><code>$CODE</code></th>
  19. <td>The UUID code of the check</td>
  20. </tr>
  21. <tr>
  22. <th><code>$NAME</code></th>
  23. <td>Name of the check</td>
  24. </tr>
  25. <tr>
  26. <th><code>$NOW</code></th>
  27. <td>
  28. Current UTC time in ISO8601 format.
  29. Example: "{{ now }}"
  30. </td>
  31. </tr>
  32. <tr>
  33. <th><code>$STATUS</code></th>
  34. <td>Check's current status ("up" or "down")</td>
  35. </tr>
  36. <tr>
  37. <th><code>$TAG1, $TAG2, …</code></th>
  38. <td>Value of the first tag, the second tag, …</td>
  39. </tr>
  40. </table>
  41. <p>For example, a callback URL using variables might look like so:
  42. <pre>http://requestb.in/1hhct291?message=<strong>$NAME</strong>:<strong>$STATUS</strong></pre>
  43. <p>
  44. After encoding and replacing the variables, {% site_name %} would then call:
  45. </p>
  46. <pre>http://requestb.in/1hhct291?message=<strong>My%20Check</strong>:<strong>down</strong></pre>
  47. <h2>Integration Settings</h2>
  48. <form method="post" class="form-horizontal">
  49. {% csrf_token %}
  50. <input type="hidden" name="kind" value="webhook" />
  51. <div class="form-group {{ form.value_down.css_classes }}">
  52. <label class="col-sm-2 control-label">URL for "down" events</label>
  53. <div class="col-sm-10">
  54. <input
  55. type="text"
  56. class="form-control"
  57. name="value_down"
  58. placeholder="http://..."
  59. value="{{ form.value_down.value|default:"" }}">
  60. {% if form.value_down.errors %}
  61. <div class="help-block">
  62. {{ form.value_down.errors|join:"" }}
  63. </div>
  64. {% endif %}
  65. </div>
  66. </div>
  67. <div class="form-group {{ form.value_up.css_classes }}">
  68. <label class="col-sm-2 control-label">URL for "up" events</label>
  69. <div class="col-sm-10">
  70. <input
  71. type="text"
  72. class="form-control"
  73. name="value_up"
  74. placeholder="http://..."
  75. value="{{ form.value_up.value|default:"" }}">
  76. {% if form.value_up.errors %}
  77. <div class="help-block">
  78. {{ form.value_up.errors|join:"" }}
  79. </div>
  80. {% endif %}
  81. </div>
  82. </div>
  83. <div class="form-group {{ form.post_data.css_classes }}">
  84. <label class="col-sm-2 control-label">POST data</label>
  85. <div class="col-sm-10">
  86. <input
  87. type="text"
  88. class="form-control"
  89. name="post_data"
  90. placeholder='{"status": "$STATUS"}'
  91. value="{{ form.post_data.value|default:"" }}">
  92. {% if form.post_data.errors %}
  93. <div class="help-block">
  94. {{ form.post_data.errors|join:"" }}
  95. </div>
  96. {% endif %}
  97. </div>
  98. </div>
  99. <div class="form-group">
  100. <div class="col-sm-offset-2 col-sm-10">
  101. <button type="submit" class="btn btn-primary">Save Integration</button>
  102. </div>
  103. </div>
  104. </form>
  105. </div>
  106. </div>
  107. {% endblock %}
  108. {% block scripts %}
  109. {% compress js %}
  110. <script src="{% static 'js/jquery-2.1.4.min.js' %}"></script>
  111. <script src="{% static 'js/bootstrap.min.js' %}"></script>
  112. {% endcompress %}
  113. {% endblock %}