You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/blog/getting-started-with-the-hpe-greenlake-cloud-eventing-framework.md
+8-15Lines changed: 8 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,11 +18,11 @@ li {
18
18
19
19
## Polling API or subscribing to events: That IS the question
20
20
21
-
In one of my previous blog posts, I used the HPE GreenLake API to query the audit log and, if anything appeared in the audit log over the course of the last few minutes, I arranged for it to be displayed on screen. To do this, I had to continuously poll the API at a regular polling interval. While this works, it is not ideal, since it is not real time, and you might get notified of an important event after, at max, your polling interval. A better approach that is often available on software platforms is called events, also referred to as webhooks. HPE GreenLake cloud provides this functionality and, in this post, I will explain how to leverage it.
21
+
In one of my previous blog posts, I used the HPE GreenLake API to query the audit log and, if anything appeared in the audit log over the course of a few minutes, I arranged for it to be displayed on screen. To do this, I had to continuously poll the API at a regular polling interval. While this method works, it is not ideal, since it is not done in real time, and you might get notified of an important event after, at max, your polling interval. A better approach that is often available on software platforms is called events, also referred to as webhooks. HPE GreenLake cloud provides this functionality and, in this post, I will explain how to leverage it.
22
22
23
23
## It's a publisher/subscriber world
24
24
25
-
HPE GreenLake cloud provides an eventing framework in which event publishers (any of the HPE GreenLake cloud services) can register event types with the platform, and event subscribers can declare what event types they would like to subscribe to. After they establish a security handshake, HPE GreenLake forwards selected events to the subscriber in a close-to-real-time mode. No polling is necessary as the event handler (webhook) will be notified asynchronously.
25
+
HPE GreenLake cloud provides an eventing framework in which event publishers (any of the HPE GreenLake cloud services) can register event types with the platform and event subscribers can declare what event types they would like to subscribe to. After they establish a security handshake, HPE GreenLake forwards selected events to the subscriber in a close-to-real-time mode. No polling is necessary as the event handler (webhook) will be notified asynchronously.
26
26
27
27
The following diagram illustrates the mechanism by which this works:
28
28
@@ -47,7 +47,7 @@ Additional requirements for writing a webhook handler for HPE GreenLake include:
47
47
48
48
## Taking the challenge
49
49
50
-
From the picture above, you can see that the webhook handler is a piece of code that runs outside of the HPE GreenLake cloud, possibly posing a security risk. In order to avoid calling a rogue code, HPE GreenLake will establish a trust relationship with the webhook handler by issuing a challenge request and expecting a very specific response. The challenge is an HTTP POST request that is sent to the webhook handler (via its URL) with a payload containing a **challengeRequest** as shown below:
50
+
From the illustration above, you can see that the webhook handler is a piece of code that runs outside of the HPE GreenLake cloud, possibly posing a security risk. In order to avoid calling a rogue code, HPE GreenLake will establish a trust relationship with the webhook handler by issuing a challenge request and expecting a very specific response. The challenge is an HTTP POST request that is sent to the webhook handler (via its URL) with a payload containing a **challengeRequest** as shown below:
51
51
52
52
```json
53
53
{
@@ -66,15 +66,13 @@ From the picture above, you can see that the webhook handler is a piece of code
66
66
67
67
> > *Example of a challenge payload*
68
68
69
-
The mission of the challenge handler is to provide the correct answer to the challenge in a timely fashion and with an HTTP response in the following form:
69
+
The mission of the challenge handler is to provide the correct answer to the challenge in a timely fashion and with an HTTP response in the following form, where **<CHALLENGE-RESPONSE>** is the computed [SHA-256](https://en.wikipedia.org/wiki/SHA-2)[HMAC](https://en.wikipedia.org/wiki/HMAC) (Hash-based Message Authentication Code) of the **challengeRequest** provided in the input payload.
Where **<CHALLENGE-RESPONSE>** is the computed [SHA-256](https://en.wikipedia.org/wiki/SHA-2)[HMAC](https://en.wikipedia.org/wiki/HMAC) (Hash-based Message Authentication Code) of the **challengeRequest** provided in the input payload.
76
-
77
-
There are [online ways](https://www.devglan.com/online-tools/hmac-sha256-online) to generate SHA256 MAC encodings and test different options. But what you need to remember is that you have to provide a hexadecimal format of the hash, and that a secret key is used as a “salt” for the calculation of that hash. That secret key is shared by HPE GreenLake cloud and the webhook handler.
75
+
> Note: There are [online ways](https://www.devglan.com/online-tools/hmac-sha256-online) to generate SHA256 MAC encodings and test different options but what you need to remember is that you have to provide a hexadecimal format of the hash and that a secret key is used as a “salt” for the calculation of that hash. That secret key is shared by HPE GreenLake cloud and the webhook handler.
78
76
79
77
### Processing events as they arrive
80
78
@@ -243,7 +241,7 @@ You can also verify that in the **Google sheets** module, the content of the pay
Finally verify that your Google sheet was updated and a new row was added using the payload content, as shown in my Google sheet below.
244
+
Finally, verify that your Google sheet was updated and a new row was added using the payload content, as shown in my Google sheet below.
247
245
248
246

249
247
@@ -270,9 +268,9 @@ If the webhook response is the expected one, then the webhook is placed in **Act
270
268
271
269
### It’s time to subscribe to events
272
270
273
-
From the web console, you can now **subscribe to events** available from the HPE GreenLake services. You can find the list of those already available from the [HPE GreenLake Developer Portal](https://developer.greenlake.hpe.com/docs/greenlake/services/event/public/ui/#finding-events-on-hpe-greenlake-developer-portal). The list will grow over time as new services adopt this eventing framework.
271
+
From the web console, you can now subscribe to events available from the HPE GreenLake services. You can find the list of those already available from the [HPE GreenLake Developer Portal](https://developer.greenlake.hpe.com/docs/greenlake/services/event/public/ui/#finding-events-on-hpe-greenlake-developer-portal). The list will grow over time as new services adopt this eventing framework.
274
272
275
-
Select your webhook from the list and select Subscribe to event. Select the source Service manager (there is only HPE GreenLake Platform for now), then cut/paste the event name from the [event catalog](https://developer.greenlake.hpe.com/docs/greenlake/services/#event-catalog). For example:
273
+
Select your webhook from the list and select **Subscribe to event**. Select the source **Service manager** (there is only HPE GreenLake Platform for now), then cut/paste the **Event type** from the [event catalog](https://developer.greenlake.hpe.com/docs/greenlake/services/#event-catalog). The following show two examples of event type.
0 commit comments