|
22 | 22 | - [Signature](#signature)
|
23 | 23 | - [ClientCA](#clientca)
|
24 | 24 | - [Config Parameters](#config-parameters-object)
|
| 25 | + - [Define a token to access dispatcher](#define-a-token-to-access-dispatcher) |
25 | 26 |
|
26 | 27 | # Open API Integration
|
27 | 28 | [OpenAPI](https://www.openapis.org/) is the name of the initiative behind defining Swagger specification which describe a REST web-API.
|
@@ -128,6 +129,7 @@ Make some examples:
|
128 | 129 | | x-exosite-info | string | `'someInfo'` | An operationId reference triggered by Murano to retrieve a subscription informations to return to the users. |
|
129 | 130 | | x-exosite-update | string | `'someUpdate'` | An operationId reference triggered by Murano when a user update the service configuration for this solution. |
|
130 | 131 | | x-exosite-gc | string | `'someGc'` | An operationId reference triggered by Murano when a user un-subscribe to this service. Including when the related solution is deleted. |
|
| 132 | +| x-exosite-token | string | `'mysecrettoken'` | Token used when this service is trying to make a call to dispatcher public API. Include a header: `authorization: <service-alias> <token-value>` when making a request to public dispatcher API. | |
131 | 133 | | x-exosite-config-parameters | [object] | [[`Config Parameters Object`](#config-parameters-object)] | An array of parameters (JSON schema) defining the data set in the service Configuration parameters field for this serviceconfig.(Service configuration parameters are used as default value during operation call from Lua script) |
|
132 | 134 |
|
133 | 135 | #### Optional Fields
|
@@ -743,3 +745,64 @@ paths:
|
743 | 745 | The definitions section can be used by reference objects in order re-use specification code. If elements of the spec are copied and pasted more than once, they can be set here and reused.
|
744 | 746 |
|
745 | 747 | ----
|
| 748 | +
|
| 749 | +#### Define a Token to Access Dispatcher |
| 750 | +We allow services, which are published on Exosite Marketplace, to access [dispatcher APIs](https://pegasus-dispatcher.hosted.exosite.io) using a security Token as defined in below steps. |
| 751 | +
|
| 752 | +##### Step 1: define `x-exosite-token` |
| 753 | +In `schema`, add a attribute called `x-exosite-token`, the value needs to be a **secure token** provided when accessing the Murano Service API. |
| 754 | +
|
| 755 | +An example (refer to this [minimalservice.yaml](./examples/minimalservice.yaml)): |
| 756 | +```yaml |
| 757 | +# ... |
| 758 | +################################################################################ |
| 759 | +# API Information # |
| 760 | +################################################################################ |
| 761 | +# ... |
| 762 | +x-exosite-token: "myprivatetoken" |
| 763 | +# ... |
| 764 | +``` |
| 765 | + |
| 766 | +Once the service swagger has been published and processed, the token will be removed and will not be accessible from Murano anymore. |
| 767 | +So you MUST keep it securely saved. If you forget it you can overload the current token by updating the service swagger definition. |
| 768 | + |
| 769 | +##### Step 2: call dispatcher |
| 770 | + |
| 771 | +Add the `authorization` header with value `<service alias> <token value>` (Example: `authorization: minimalservice myprivatetoken`) for all calls to the Murano Service API endpoints. |
| 772 | + |
| 773 | +- 2.1 call Event Trigger |
| 774 | + |
| 775 | + base_url = https://service-api.hosted.exosite.io |
| 776 | + |
| 777 | + `GET/POST <base_url>/api/v1/trigger/:context_id/:service_alias/:event_type` |
| 778 | + |
| 779 | + - context_id: the solution_id |
| 780 | + - service_alias: which service you want to call, eg: tsdb |
| 781 | + - event_type: which event to call, eg: export |
| 782 | + |
| 783 | +- 2.2 call Service Logs / Metrics |
| 784 | + |
| 785 | + `GET/POST <base_url>/ws/service/:service/log` |
| 786 | + |
| 787 | + `GET/POST <base_url>/ws/service/:service/metric/:metric` |
| 788 | + |
| 789 | + If you want to use metric, please remember to define the `x-exosite-usage-metrics` along with `x-exosite-token`, if you don't define this, your connection to the metric endpoint will get rejected. |
| 790 | + |
| 791 | + An example of metrics definition: |
| 792 | + |
| 793 | + ```yaml |
| 794 | + x-exosite-usage-metrics: |
| 795 | + bandwidth: |
| 796 | + name: Data size downloaded |
| 797 | + description: The number of bytes downloaded over a calendar month by devices of this product. |
| 798 | + type: counter |
| 799 | + unit: byte |
| 800 | + categories: |
| 801 | + in: Data uploaded |
| 802 | + out: Data downloaded |
| 803 | + size: |
| 804 | + name: Data size stored |
| 805 | + description: The number of bytes stored for this product. |
| 806 | + type: gauge |
| 807 | + unit: byte |
| 808 | + ``` |
0 commit comments