1
0
mirror of synced 2025-12-21 10:57:10 -05:00

[Shipping 10.23.20] add webhook config REST API (#16144)

* add webhook config REST API

* add versioning for dotcom/2.23+

* check for empty parameters with request bodies

* add latest rest-api-operation module

* Apply suggestions from code review

Co-authored-by: jmarlena <6732600+jmarlena@users.noreply.github.com>
This commit is contained in:
Rachael Sewell
2020-10-26 17:25:09 -07:00
committed by GitHub
parent 6c62a5920d
commit 13c33d4039
9 changed files with 30 additions and 13 deletions

View File

@@ -14,6 +14,9 @@ Now that we understand [the basics of webhooks][webhooks-overview], let's go thr
Creating a webhook is a two-step process. You'll first need to set up how you want your webhook to behave through {% data variables.product.product_name %}--what events should it listen to. After that, you'll set up your server to receive and manage the payload.
{% data reusables.webhooks.webhooks-rest-api-links %}
### Setting up a Webhook
You can install webhooks on an organization or on a specific repository.

View File

@@ -12,6 +12,7 @@ versions:
Once your server is configured to receive payloads, it'll listen for any payload sent to the endpoint you configured. For security reasons, you probably want to limit requests to those coming from GitHub. There are a few ways to go about this--for example, you could opt to allow requests from GitHub's IP address--but a far easier method is to set up a secret token and validate the information.
{% data reusables.webhooks.webhooks-rest-api-links %}
### Setting your secret token

View File

@@ -61,3 +61,12 @@ Be sure to replace stubbed endpoints with production endpoints before deploying
{% endfor %}
{% endif %}
{% if currentVersion == "free-pro-team@latest" or currentVersion ver_gt "enterprise-server@2.22" %}
## Webhooks
{% for operation in currentRestOperations %}
{% if operation.subcategory == 'webhooks' %}{% include rest_operation %}{% endif %}
{% endfor %}
{% endif %}

View File

@@ -56,5 +56,5 @@ For more best practices, [see our guide](/guides/best-practices-for-integrators/
{% data variables.product.product_name %} will send along several HTTP headers to differentiate between event types and payload identifiers. See [webhook headers](/webhooks/event-payloads/#delivery-headers) for details.
{% for operation in currentRestOperations %}
{% if operation.subcategory == 'hooks' %}{% include rest_operation %}{% endif %}
{% if operation.subcategory == 'webhooks' %}{% include rest_operation %}{% endif %}
{% endfor %}

View File

@@ -288,7 +288,7 @@ The Repository Webhooks API allows repository admins to manage the post-receive
If you would like to set up a single webhook to receive events from all of your organization's repositories, see our API documentation for [Organization Webhooks](/rest/reference/orgs#webhooks).
{% for operation in currentRestOperations %}
{% if operation.subcategory == 'hooks' %}{% include rest_operation %}{% endif %}
{% if operation.subcategory == 'webhooks' %}{% include rest_operation %}{% endif %}
{% endfor %}
### Receiving Webhooks

View File

@@ -0,0 +1,4 @@
You can use the repository, organization, and app webhook REST APIs to create, update, delete, and ping webhooks. {% if currentVersion == "free-pro-team@latest" or currentVersion ver_gt "enterprise-server@2.22" %}You can also use the REST API to change the configuration of the webhook. For example, you can modify the payload URL, content type, SSL verification, and secret. {% endif %}For more information, see:
- [Repository Webhooks REST API](/rest/reference/repos#webhooks)
- [Organization Webhooks REST API](/rest/reference/orgs#webhooks){% if currentVersion == "free-pro-team@latest" or currentVersion ver_gt "enterprise-server@2.22" %}
- [GitHub App Webhooks REST API](/rest/reference/apps#webhooks){% endif %}

View File

@@ -7,7 +7,7 @@
</div>
<pre><code><span class="bg-blue text-white rounded-1 px-2 py-1" style="text-transform: uppercase">{{operation.verb}}</span> {{operation.requestPath}}</code></pre>
<div>
{% if operation.parameters.size > 0 %}
{% if operation.parameters.size > 0 or operation.bodyParameters.size > 0 %}
<h4 id="{{operation.slug}}--parameters">
<a href="#{{operation.slug}}--parameters">{% data ui.products.rest.reference.parameters %}</a>
</h4>

18
package-lock.json generated
View File

@@ -1156,9 +1156,9 @@
}
},
"@github/rest-api-operations": {
"version": "3.1.4",
"resolved": "https://registry.npmjs.org/@github/rest-api-operations/-/rest-api-operations-3.1.4.tgz",
"integrity": "sha512-3BCTMhl9UhT0eKGNJvgawnsL7818Ivs15qptB1zApXyYN2qc2FQ+M4PBydGrkQ/ZFdc0x7iT7zIKb2G8peIULQ=="
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/@github/rest-api-operations/-/rest-api-operations-3.2.0.tgz",
"integrity": "sha512-DOEASW/Ec95Fz8eswIC0kX9jtdHiWiDax2opIozg5IqhJKtrjJ3LxehcGPND2XAGeduhmlwssoXPZzlAI4GGqA=="
},
"@hapi/address": {
"version": "2.1.4",
@@ -4206,7 +4206,7 @@
},
"browserify-aes": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz",
"resolved": "http://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz",
"integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==",
"requires": {
"buffer-xor": "^1.0.3",
@@ -4240,7 +4240,7 @@
},
"browserify-rsa": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz",
"resolved": "http://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz",
"integrity": "sha1-IeCr+vbyApzy+vsTNWenAdQTVSQ=",
"requires": {
"bn.js": "^4.1.0",
@@ -5657,7 +5657,7 @@
},
"create-hash": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz",
"resolved": "http://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz",
"integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==",
"requires": {
"cipher-base": "^1.0.1",
@@ -5669,7 +5669,7 @@
},
"create-hmac": {
"version": "1.1.7",
"resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz",
"resolved": "http://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz",
"integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==",
"requires": {
"cipher-base": "^1.0.3",
@@ -6396,7 +6396,7 @@
},
"diffie-hellman": {
"version": "5.0.3",
"resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz",
"resolved": "http://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz",
"integrity": "sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==",
"requires": {
"bn.js": "^4.1.0",
@@ -19071,7 +19071,7 @@
},
"sha.js": {
"version": "2.4.11",
"resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz",
"resolved": "http://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz",
"integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==",
"requires": {
"inherits": "^2.0.1",

View File

@@ -16,7 +16,7 @@
"@github-docs/data-directory": "^1.2.0",
"@github-docs/frontmatter": "^1.3.1",
"@github-docs/render-content": "^5.2.0",
"@github/rest-api-operations": "^3.1.4",
"@github/rest-api-operations": "^3.2.0",
"@octokit/rest": "^16.38.1",
"@primer/css": "^15.1.0",
"@primer/octicons": "^11.0.0",