Skip to content

Commit 1deef20

Browse files
committed
Update Blog “getting-started-with-the-hpe-greenlake-cloud-eventing-framework”
1 parent 1426374 commit 1deef20

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

content/blog/getting-started-with-the-hpe-greenlake-cloud-eventing-framework.md

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ li {
1818

1919
## Polling API or subscribing to events: That IS the question
2020

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.
2222

2323
## It's a publisher/subscriber world
2424

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.
2626

2727
The following diagram illustrates the mechanism by which this works:
2828

@@ -47,7 +47,7 @@ Additional requirements for writing a webhook handler for HPE GreenLake include:
4747

4848
## Taking the challenge
4949

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:
5151

5252
```json
5353
{
@@ -66,15 +66,13 @@ From the picture above, you can see that the webhook handler is a piece of code
6666

6767
> > *Example of a challenge payload*
6868
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.
7070

7171
* Status code: **200**
7272
* JSON body: **{ "verification" : "<CHALLENGE-RESPONSE>" }**
7373
* Header: **content-type: application/json**
7474

75-
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.
7876
7977
### Processing events as they arrive
8078

@@ -243,7 +241,7 @@ You can also verify that in the **Google sheets** module, the content of the pay
243241

244242
![Google sheet property mapping ](/img/googlesheet-set.jpg "Google sheet property mapping ")
245243

246-
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.
247245

248246
![Row was added in Google sheet](/img/google-row-visible.jpg "Row was added in Google sheet")
249247

@@ -270,9 +268,9 @@ If the webhook response is the expected one, then the webhook is placed in **Act
270268

271269
### It’s time to subscribe to events
272270

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.
274272

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.
276274

277275
```markdown
278276
com.hpe.greenlake.audit-log.v1.logs.created
@@ -281,11 +279,6 @@ com.hpe.greenlake.subscriptions.v1.expiring-subscriptions
281279

282280
![Subscribing to events](/img/subscribe.jpg "Subscribing to events")
283281

284-
285-
<img src="/img/subscribe.jpg" width="50%" height="50%" alt="Subscribing to events" title="Subscribing to events">
286-
287-
288-
289282
Once you select **Subscribe to event**, your webhook handler is now registered to receive these types of events.
290283

291284
![Event subscribed](/img/event-subscribed.jpg "Event subscribed")

static/img/subscribe.jpg

-64.7 KB
Loading

0 commit comments

Comments
 (0)