Skip to content

Commit 22715c4

Browse files
Update subscription documentation (#276)
* Update docs about subscription fields and API examples * Fix curl example with backendurl parameter
1 parent 38f4f0a commit 22715c4

File tree

2 files changed

+74
-60
lines changed

2 files changed

+74
-60
lines changed

wiki/markdown/add-subscription.md

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@ description of the elements available on this form.
88
</kbd>
99

1010
## Load Subscription Template
11-
In this dropdown list, options are given to
12-
select a specific template for the subscription form. Currently, the following
13-
options are listed: Jenkins Pipeline Parametrized Job Trigger, REST POST and
14-
Mail Trigger.
11+
In this dropdown list, options are given to select a specific template for
12+
the subscription. Currently, the following options are listed:
13+
Jenkins Pipeline Parametrized Job Trigger, REST POST and Mail Trigger.
1514

1615
## SubscriptionName
1716
A field to give a name to the current subscription. Only
@@ -22,28 +21,30 @@ letters, underscore and numbers are allowed in this field.
2221
</kbd>
2322

2423
## NotificationType
25-
There are two options: REST POST and
26-
Mail Trigger, depending on how a subscriber want to be notified when a
27-
subscription is fulfilled. If Notification type MAIL is selected an email
28-
subject may be entered, but it is optional.
24+
When the subscription is fulfilled there are two types of notifications:
25+
REST POST and mail notification. If Notification type MAIL is selected an
26+
email subject may be entered, but it is optional. Eiffel Intelligence will
27+
use the configured email subject from Eiffel Intelligence back-end
28+
application.properties if nothing is specified in the subscription.
2929

3030
## RestPostMediaType
31-
Options for selecting a
32-
specific form content type. The options available in the list depends on the
33-
selected template type.
31+
Options for selecting a specific form content type. This is only when the
32+
notification type REST POST is selected. The options available are:
33+
'application/json' and 'application/x-www-form-urlencoded'.
3434

3535
## NotificationMessage
36-
It is used to send a message to a specific client. The
37-
format of the message depends on the options selected in the NotificationMessage
36+
It is used to send a message to a specific client. The format of the
37+
message depends on the options selected in the NotificationMessage
3838
and RestPostMediaType. A button, “Add Key/Value pair”, in this field may be
39-
used to add more messages, if the selected RestPostBodyMediaType is FORM/POST
40-
parameters.
39+
used to add more parameters, if the selected RestPostBodyMediaType is
40+
'application/x-www-form-urlencoded'. If the RestPostBodyMediaType is
41+
'application/json' only one json object is allowed in the notificationMessage.
4142

4243
## NotificationMeta
43-
Is the selected subscriber to notify when a subscription
44-
is triggered. It could be an email address such as `example@mail.com` or a url
45-
like `host.com/endpoint`. If you wish to trigger Jenkins job when a subscription
46-
is fulfilled then the url for the job could be set as the notificationMeta.
44+
Is the selected subscriber to notify when a subscription is fulfilled. It
45+
could be an email address such as `example@mail.com` or a url like
46+
`host.com/endpoint`. If you wish to trigger a Jenkins job when a
47+
subscription is fulfilled then the url for the job could be set as the notificationMeta.
4748
Parameters such as a Jenkins job-token can be included in this field.
4849
**Note**: The job-token should not be mistaken for the API token that is
4950
used as a password for authentication against the entire jenkins instance.
@@ -53,7 +54,9 @@ used as a password for authentication against the entire jenkins instance.
5354
</kbd>
5455

5556
## Authentication
56-
A list to select authentication type.
57+
A list to select authentication type. These credentials should be used by
58+
Eiffel Intelligence to perform the HTTP POST notification towards an external
59+
API.
5760
* NO_AUTH: _No Authentication used_
5861
* BASIC_AUTH: _Username and password will be Base 64 encoded_
5962
* BASIC_AUTH_JENKINS_CSRF: Jenkins CSRF Protection (crumb), _Username and password will
@@ -72,12 +75,13 @@ the notification will be triggered only the first time when requirements are
7275
fulfilled. It doesn't matter if you have multiple requirements, it will only be triggered once.
7376

7477
## Requirement and Conditions
75-
It is used to add a requirement, which need to
76-
be fulfilled before a subscription is triggered. Requirement is added in the form
77-
of a condition (with a specific format). More than one conditions may be added
78-
under one requirement by using “Add Condition” button. It should be noted
79-
that conditions under one requirement are connected by logical “AND”.
80-
Thus all conditions udder one requirement need to be satisfied before a subscription
81-
is triggered. More than one requirements may be added by “Add Requirement” button.
82-
Requirements are connected by logical “OR”.
78+
It is used to add requirements and conditions, which need to be fulfilled.
79+
A requirement should contain at least one condition (with a specific format).
80+
More than one conditions may be added under one requirement by using the
81+
“Add Condition” button. It should be noted that conditions under one
82+
requirement are connected by a logical “AND”. Thus all conditions under
83+
one requirement need to be satisfied before a subscription is fulfilled.
84+
More than one requirements may be added with the “Add Requirement” button.
85+
Requirements are connected by a logical “OR”.
86+
8387
**_More information about how to write Requirement and Conditions can be found [here](https://github.com/eiffel-community/eiffel-intelligence/blob/master/wiki/markdown/subscriptions.md#writing-requirements-and-conditions)._**

wiki/markdown/curl-examples.md

Lines changed: 42 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22

33
## Introduction
44

5-
The front-end has a bridge functionality that is built in as a part of the front-end's web server and handles requests coming from the web GUI towards any of the back-ends configured.
6-
The `/backends` endpoint is the only additional endpoint which does not exist in [Eiffel Intelligence backend](https://github.com/eiffel-community/eiffel-intelligence).
7-
The front-end may also be used by other tools such as CURL or any kind of program that can make HTTP(S) requests.
8-
Below are some examples of using CURL towards different endpoints, together with example responses.
9-
Most endpoints are also documented in the [Eiffel Intelligence backend repository](https://github.com/eiffel-community/eiffel-intelligence/tree/master/wiki/markdown)
5+
The front-end has a bridge functionality that is built in as a part of the front-end's web server
6+
and handles requests coming from the web GUI towards any of the configured Eiffel Intelligence back-ends.
7+
The `/backends` endpoint is the only additional endpoint which does not exist in [Eiffel Intelligence back-end](https://github.com/eiffel-community/eiffel-intelligence).
8+
The front-end may also be used by other tools such as CURL or any kind of program that can make HTTP(S)
9+
requests. Below are some examples of using CURL towards different endpoints, together with example
10+
responses. Most endpoints are also documented in the [Eiffel Intelligence back-end repository](https://github.com/eiffel-community/eiffel-intelligence/tree/master/wiki/markdown)
1011

1112
**Note**: If you have multiple url parameters, you need to add quotation mark around the entire query. For example:
1213

@@ -24,21 +25,23 @@ Most endpoints are also documented in the [Eiffel Intelligence backend repositor
2425
* [/subscriptions](#subscriptions)
2526

2627
#### Specified back-end
27-
As a user of the front-end you may want to specify your own back-end URL if you do not want to use the default back-end.
28-
This is possible to do by injecting the back-end URL as a query parameter.
29-
The parameters key should be `backendurl` then enter the full HTTP URL you wish to use. This back-end instance does not have to be specified in the list of available instances.
30-
31-
An example of a way to add such parameter is examplified below, note that the "?" indicates that parameters has been added to the front-end url.
32-
`localhost:8080` is the front-end url, and we want to access the context path /authentication but on URL `http://127.0.0.1:8090/` that is the back-end we wish to use.
28+
As a user of the front-end you may want to specify your own back-end URL if you do not want to use the
29+
default back-end. This is possible to do by injecting the back-end URL as a query parameter. The
30+
parameters key should be `backendurl` then enter the full HTTP URL you wish to use. This back-end
31+
instance does not have to be specified in the list of available instances.
3332

33+
An example of a way to add such parameter is exemplified below, note that the "?" indicates that
34+
parameters has been added to the front-end url.`localhost:8080` is the front-end url, and we want to
35+
access the context path /authentication but on URL `http://127.0.0.1:8090/` that is the back-end we wish to use.
3436

3537
curl -X GET http://localhost:8080/authentication?backendurl="http://127.0.0.1:8090/"
3638

37-
Example with Tomcat:
39+
Example with Eiffel Intelligence front-end deployed with Tomcat, and the
40+
context path /eifrontend/:
3841

3942
curl -X GET http://localhost:8080/eifrontend/authentication?backendurl="http://127.0.0.1:8090/eibackend/"
4043

41-
This way of entering the `backendurl` may be the easiest way. It works with GET, POST and PUT requests. Currently entering just a back-end name is not supported.
44+
This way of entering the `backendurl` may be the easiest way. It works with all CRUD operations.
4245

4346
**Note: It is not possible to add the `backendurl` parameter as a JSON parameter.**
4447

@@ -67,7 +70,7 @@ This way of entering the `backendurl` may be the easiest way. It works with GET,
6770
</tr>
6871
</table>
6972

70-
A curl call with the command:
73+
A curl request with the command:
7174

7275
curl -X GET http://localhost:8080/authentication
7376

@@ -119,14 +122,17 @@ This command would return a JSON object containing the status of the back-end an
119122
</tr>
120123
</table>
121124

122-
While the web GUI may use the back-end instances list and select different back-ends in an easy way, a user that uses the front-end without the included web GUI may need to specify a back-end URL. This may be done by adding a `backendurl` parameter to the request.
125+
While the web GUI may use the back-end instances list and select different back-ends in an easy way,
126+
a user that uses the front-end without the included web GUI may need to specify a back-end URL. This
127+
may be done by adding a `backendurl` parameter to the request.
123128

124-
Note that for users where the front-end and back-end is running with the help of Tomcat there will be context paths used.
129+
Note that for users where the front-end and back-end is deployed with Tomcat there will be context paths used.
125130

126131
#### Default back-end
127132

128-
The front-end can be configured to use a default back-end, this means that if no back-end is specified when making a HTTP request to the front-end the default back-end will be used.
129-
If you want to see a list of back-ends and see if there is a default back-end set, you may use the command:
133+
The front-end can be configured to use a default back-end, this means that if no back-end is specified
134+
when making a HTTP request to the front-end the default back-end will be used. If you want to see a
135+
list of back-ends and see if there is a default back-end set, you may use the command:
130136

131137
###### Example GET request using curl:
132138

@@ -140,12 +146,15 @@ If you want to see a list of back-ends and see if there is a default back-end se
140146

141147
curl -X GET http://localhost:8080/backends
142148

143-
The default back-end should have the key `defaultBackend` set to `true`. If the JSON list ends up empty there are no back-ends specified in the front-end. If there is no JSON object with the key set to true there is no default back-end.
149+
The default back-end should have the key `defaultBackend` set to `true`. If the JSON list ends up
150+
empty there are no back-ends specified in the front-end. If there is no JSON object with the key set
151+
to true there is no default back-end.
144152

145153
__Note:__ `name` must be unique.
146154

147-
Only one back-end instance can be added at a time.
148-
Even with different names all elements must be unique, you may not have two or more elements with the same `host`, `port`, `contextPath` or `https` value, one of these three keys must be different. Only the `contextPath` key may be left empty.
155+
Only one back-end instance can be added at a time. Even with different names all elements must be
156+
unique, you may not have two or more elements with the same `host`, `port`, `contextPath` or `https`
157+
value, one of these three keys must be different. Only the `contextPath` key may be left empty.
149158

150159
###### Example of __valid__ back-end list:
151160

@@ -158,7 +167,8 @@ Even with different names all elements must be unique, you may not have two or m
158167
]
159168

160169
All entries has different `names`.
161-
Second entry has different `host`, third entry has different `port`, third entry has different `contextPath`, fifth entry has `https` changed to true.
170+
Second entry has different `host`, third entry has different `port`, third entry has different `contextPath`,
171+
fifth entry has `https` changed to true.
162172

163173
###### Example of __invalid__ back-end list:
164174

@@ -168,7 +178,8 @@ Second entry has different `host`, third entry has different `port`, third entry
168178
{"name":"My Back-End 2","host":"localhost","port":8090,"contextPath":"","https":false,"defaultBackend":false}
169179
]
170180

171-
The second entry is invalid due to having the same name as the first entry. The third entry is invalid due to having the same value in all fields as the first entry.
181+
The second entry is invalid due to having the same name as the first entry. The third entry is invalid
182+
due to having the same value in all fields as the first entry.
172183

173184
## <a id="templates" />/templates
174185

@@ -195,7 +206,8 @@ The second entry is invalid due to having the same name as the first entry. The
195206
</tr>
196207
</table>
197208

198-
The Eiffel Intelligence front-end supports these endpoints. More information can be found in the [Eiffel Intelligence back-end documentation](https://github.com/eiffel-community/eiffel-intelligence/blob/master/wiki/markdown/templates.md)
209+
The Eiffel Intelligence front-end supports these endpoints. More information can be found in the
210+
[Eiffel Intelligence back-end documentation](https://github.com/eiffel-community/eiffel-intelligence/blob/master/wiki/markdown/templates.md)
199211

200212
#### Some curl examples
201213

@@ -207,7 +219,8 @@ This command returns a list of predefined template events.
207219

208220
curl -X GET -H "Content-type: application/json" http://localhost:8080/templates/events
209221

210-
This command returns a list of several subscriptions. It is also possible to specify a file in which to save the downloaded objects in to.
222+
This command returns a list of several subscriptions. It is also possible to specify a file in which
223+
to save the downloaded objects to.
211224

212225
curl -X GET -H "Content-type: application/json" localhost:8080/templates/subscriptions --output myFile.json
213226

@@ -352,19 +365,20 @@ Example curl commands to these endpoints [can be found here](https://github.com/
352365
</table>
353366

354367
The `/subscriptions` endpoint can be called with `GET`, `POST`, `PUT` and `DELETE`.
355-
More information, and examples, on the `/subscriptions` API can be found [here](https://github.com/eiffel-community/eiffel-intelligence/tree/master/wiki/markdown/subscription-API.md).
368+
More information, and examples, on the `/subscriptions` API can be found in the [Eiffel Intelligence back-end documentation](https://github.com/eiffel-community/eiffel-intelligence/tree/master/wiki/markdown/subscription-API.md).
356369

357370
A `POST` request with subscriptions in a file may look as the following example.
358371

359372
curl -X POST -d @file_containing_list_of_json_objects -H "Content-Type: application/json" \
360373
http://localhost:8080/subscriptions?backendurl="http://127.0.0.1:8090/"
361374

362-
Here is an example using this endpoint and the result it gives in case we have the templated subscriptions added.
375+
Here is an example using this endpoint and the result it gives if template subscriptions exists.
363376
The `backendurl` parameters is passed in to use a specified instance instead of the default back-end instance.
364377

365378
curl -X GET http://localhost:8080/subscriptions?backendurl="http://127.0.0.1:8090/"
366379

367-
The back-end used is running on localhost and port 8080. EI front-end forwards the request to 127.0.0.1 and port 8090 as requested in the query parameters and the result is as follows:
380+
The back-end used is running on localhost and port 8080. EI front-end forwards the request to 127.0.0.1
381+
and port 8090 as requested in the query parameters and the result is a list of existing subscriptions:
368382

369383
[
370384
{
@@ -393,7 +407,6 @@ The back-end used is running on localhost and port 8080. EI front-end forwards t
393407
"userName":"functionalUser",
394408
"password":"",
395409
"ldapUserName":"",
396-
"notificationMessageKeyValuesAuth":[],
397410
"_id":{
398411
"$oid":"5c012117aeb9d61aed160a2c"
399412
},
@@ -424,7 +437,6 @@ The back-end used is running on localhost and port 8080. EI front-end forwards t
424437
"subscriptionName":"Subscription2",
425438
"password":"",
426439
"ldapUserName":"",
427-
"notificationMessageKeyValuesAuth":[],
428440
"_id":{
429441
"$oid":"5c012117aeb9d61aed160a2d"
430442
},
@@ -455,11 +467,9 @@ The back-end used is running on localhost and port 8080. EI front-end forwards t
455467
"subscriptionName":"Subscription3_Mail_Notification",
456468
"password":"",
457469
"ldapUserName":"",
458-
"notificationMessageKeyValuesAuth":[],
459470
"_id":{
460471
"$oid":"5c012117aeb9d61aed160a2e"
461472
},
462473
"authenticationType":"NO_AUTH"
463474
}
464475
]
465-

0 commit comments

Comments
 (0)