The Governance REST API is an API that is supported by WSO2 Governance Registry. The Governance REST API uses the GET, POST, PUT, and DELETE operations of the well-defined HTTP protocol to perform CRUD operations on the governance registry. You can use any REST client to send API requests, such as Google Chrome's Advanced REST client.
Info |
---|
At the moment REST API only supports configurable governance artifacts and has limited support for Content artifacts such as WSDL and Policy. |
The Governance REST API is secured with Basic Auth access token. You can invoke the rest API with Basic Auth header as follows:
Authorization: Basic YWRtaW46YWRtaW4=
where the format is Authorization: Basic {base64encoded(username:password)}
You must send valid HTTP BasicAuth credentials when invoking the REST API as shown below.
...
Create a new asset
Syntax | POST /governance/<asset_short_name_s> <payload>
Here the payload should be in JSON format. Following are the required attributes. Payload format is as follows: Code Block |
---|
{ name: "Artifact Name", type: "Artifact Type", version: “Version Number", Attribute-N: “Attribute-N” value } |
|
---|
Example | Code Block |
---|
| POST https://localhost:9443 /governance/restservices { name: "TestRESTService", type: "restservice", context: "/test", version: "1.0.0" } |
|
---|
Sample cURL Command | Code Block |
---|
| curl -X POST -H "Authorization: Basic YWRtaW46YWRtaW4=" -H "Content-Type: application/json" -H "Cache-Control: no-cache" -d '{
"name":"TestRESTService",
"type":"restservice",
"context":"/test",
"version":"1.0.0"
}' "https://localhost:9443/governance/restservices" -i -k |
|
---|
Response | If the artifact creation is successful, the server will return HTTP 200 code along with the “location” header pointing to the newly created artifact. If there is an issue creating a new artifact, it will return an appropriate error code. For example, the above example may return the following: HTTP 200
Location: https://localhost:9443/governance/restservices/3ec1dcd9-66d8-41da-a0d2-ec171df64cc3
|
---|
...
Syntax | Syntax 1: GET /governance/endpoints <payload> Tip |
---|
It is also possible to create an endpoint and associate it with other types of artifacts such as REST services or SOAP services as presented in Syntax 2 below. |
Syntax 2: GET /governance/endpoints/restservices/<UUID> <payload> GET /governance/endpoints/restservices?Query <payload>
Here the payload should be in JSON format.Following are the required attributes: Payload format is as follows: Code Block |
---|
| {name: "endpoint-1",
type: "endpoint",
version: "1.0.0",
address: "https://localhost:9443",
environment: "QA"
} |
|
---|
Example(s) | Code Block |
---|
language | java |
---|
title | Example 1 |
---|
| POST https://localhost:9443/governance/endpoints/ { name: "endpoint-1", type: "endpoint", version: "1.0.0", address: "https://localhost:9443", environment: "QA" } |
Code Block |
---|
language | java |
---|
title | Example 2 |
---|
| POST https://localhost:9443/governance/endpoints/restservices/cea0c482-4280-4837-8126-3fd97cdc0a41
{
name: "endpoint-2",
type: "endpoint",
version: "1.0.0",
address: "https://localhost:9443",
environment: "QA"
} |
Code Block |
---|
language | java |
---|
title | Example 3 |
---|
| POST https://localhost:9443/governance/endpoints/restservices?name=TestRESTService2&version=1.0.0
{
name: "endpoint-3",
type: "endpoint",
version: "1.0.0",
address: "https://localhost:9443",
environment: "QA"
} |
|
---|
Sample cURL Command(s) | Code Block |
---|
language | java |
---|
title | Sample cURL Command 1 |
---|
| curl -X POST -H "Authorization: Basic YWRtaW46YWRtaW4=" -H "Content-Type: application/json" -H "Cache-Control: no-cache" -d '{ "name":"endpoint-1", "type":"endpoint", "version":"1.0.0", "address":"https://localhost:9443", "environment":"QA" } |
Code Block |
---|
language | java |
---|
title | Sample cURL Command 2 |
---|
| curl -X POST -H "Authorization: Basic YWRtaW46YWRtaW4=" -H "Content-Type: application/json" -H "Cache-Control: no-cache" -d '{ "name":"endpoint-2", "type":"endpoint", "version":"1.0.0", "address":"https://localhost:9443", "environment":"QA" }' "https://localhost:9443/governance/endpoints/restservices/cae93ba9-9543-43be-9f30-bb96cec3c443" -i -k |
Code Block |
---|
language | java |
---|
title | Sample cURL Command 3 |
---|
| curl -X POST -H "Authorization: Basic YWRtaW46YWRtaW4=" -H "Content-Type: application/json" -H "Cache-Control: no-cache" -d '{ "name":"endpoint-2", "type":"endpoint", "version":"1.0.0", "address":"https://localhost:9443", "environment":"QA" }' "https://localhost:9443/governance/endpoints/restservices?name=TestRESTService4" -i -k |
|
---|
Response | If the artifact creation is successful, the server will return HTTP 201 code along with the “location” header pointing to the newly created artifact. If there is an issue creating the new artifact, it will return an appropriate error code. |
---|
Delete an endpoint
Syntax | DELETE /governance/endpoints/uuid |
---|
Example | DELETE https://localhost:9443/governance/endpoints/73cc7077-d723-44a5-98e5-945795e518e8 |
---|
Sample cURL Command | curl -X DELETE -H "Authorization: Basic YWRtaW46YWRtaW4=" -H "Cache-Control: no-cache" "https://localhost:9443/governance/endpoints/6652d672-d7f5-4a13-9d6f-9a6eb85675a5"-i -k
|
---|
...
Get an endpoint of an artifact instance instance
Syntax | GET /governance/<asset_short_name_s>/<id>/endpoints |
---|
Example | GET https://localhost:9443/governance/restservices/cea0c482-4280-4837-8126-3fd97cdc0a41/endpoints |
---|
Sample cURL Command | curl -X GET -H "Authorization: Basic YWRtaW46YWRtaW4=" -H "Cache-Control: no-cache" "https://localhost:9443/governance/restservices/cae93ba9-9543-43be-9f30-bb96cec3c443/endpoints" -i -k
|
---|