The Governance REST API is one of many APIs supported by WSO2 Governance Registry. Read more on Supported APIs and Standards for a complete list of APIs supported by WSO2 Governance Registry.
...
Info |
---|
At the moment REST API only supports configurable governance artifacts. Support for Content artifacts such as WSDL and Policy are limited. Future versions of REST API will equally support both types of artifacts. |
You must send valid HTTP BasicAuth credentials when invoking the REST API.
See the sections below for information relating to invoking the REST API after generating the access token and some sample requests and complete URI formats:
Assets
Endpoints
Panel |
---|
borderColor | #FFFFFF | bgColor | #FFFFFF |
---|
| Anchor |
---|
assets | assets | AssetsFollowing are the REST API functions that are related to assets. |
Localtabgroup |
---|
| Localtab |
---|
id | tab1 |
---|
title | Get a list of available artifact types |
---|
| |
Localtab |
---|
id | tab2 |
---|
title | Get a list of assets of a certain type |
---|
| Syntax | Warning |
---|
WSO2 G-Reg does not support date range searches in Governance REST API. |
Query | Descriptions |
---|
xyz | Looks for artifacts with name 'xyz '. Info |
---|
- You can give only the value like above or give the field name and the value in a key-value pair for fields of the
Overview table in the asset RXT file. (e.g. name=xyz ) - However, to find assets with a specific value for a field in a table other than the
Overview table, the search query should be: encode(table_name:field_name)=encode(value) For example, if the table is docLinks , the field is documentType and the value is 'the rest1 '. The final URI query parameter should be: docLinks%3AdocumentType=the%20rest1 - If you have spaces or any special characters such as underscore or slash in the key of the key-value pair of your query URL, you need to encode it using a URL encoder.
|
| xyz&version=1.3.5 | Looks for artifacts with name 'xyz ' and version 1.3.5. | tags=abc | Searches artifacts with tag 'abc'. | lcState=development&lcName=ServiceLifeCycle | Searches artifacts with an associated life cycle name ServiceLifeCycle with state 'development '. | country=usa | Looks for all the artifacts having attribute country with value 'usa'. This internally handles whether country is an RXT attribute or a property. | version=1.3.5&mediaType=application/vnd.wso2-soap-service+xml | Searches only soap services with version 1.3.5. |
|
---|
Example(s) | |
---|
Sample cURL Command(s) | |
---|
|
Localtab |
---|
id | tab3 |
---|
title | Get an individual asset of a certain type |
---|
| |
Localtab |
---|
id | tab4 |
---|
title | Create a new asset |
---|
| Syntax | POST /governance/<asset_short_name_s> <payload>
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
|
---|
|
Localtab |
---|
id | tab5 |
---|
title | Update an existing asset |
---|
| Syntax | PUT /governance/<asset_short_name_s>/uuid<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 |
---|
| PUT https://localhost:9443 /governance/restservices/324dsdwa535
{
name: "TestRESTService",
type: "restservice",
context: "/test-new",
version: "1.0.0",
} |
|
---|
Sample cURL Command | Code Block |
---|
| curl -X PUT -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",
"description": "Discription added by Rest API"
}' " https://localhost:9443/governance/restservices/97bdb275-2b09-4744-b29f-125cf2c8e387 " -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. |
---|
|
Localtab |
---|
id | tab6 |
---|
title | Delete an asset |
---|
| |
Localtab |
---|
id | tab7 |
---|
title | Get lifecycle state of an asset |
---|
| Syntax | GET /governance/<RXT_short_name_s>/uuid/states GET /governance/<RXT_short_name_s>/uuid/states?lc=LCName
|
---|
Example(s) | |
---|
Sample cURL Command(s) | |
---|
|
Localtab |
---|
id | tab8 |
---|
title | Update lifecycle state of an asset |
---|
| Syntax | PUT /governance/<RXT_short_name_s>/uuid/states < payload>
Payload format is as follows: Code Block |
---|
| {lc: "Lifecycle name",
action: "Promote",
check_item_N : "value_N",
} |
|
---|
Example | |
---|
Sample cURL Command | Code Block |
---|
| curl -X PUT -H "Authorization: Basic YWRtaW46YWRtaW4=" -H "Content-Type: application/json" -H "Cache-Control: no-cache" -d '{
"lc":"ServiceLifeCycle",
"action":"Promote",
"item_0":"true",
"item_1":"true",
"item_2":"true"
}' "https://localhost:9443/governance/restservices/cae93ba9-9543-43be-9f30-bb96cec3c443/states" -i -k |
|
---|
|
|
|
Endpoints
Panel |
---|
borderColor | #FFFFFF |
---|
bgColor | #FFFFFF |
---|
|
Following are the REST API functions that are related to assets. Localtabgroup |
---|
| Localtab |
---|
id | tab9 |
---|
title | Get all endpoints |
---|
| |
Localtab |
---|
id | tab10 |
---|
title | Get an individual endpoint |
---|
| |
Localtab |
---|
id | tab11 |
---|
title | Create new endpoint |
---|
| 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: |
---|
Example(s) | Code Block |
---|
language | java |
---|
title | Example 1 |
---|
| |
Code Block |
---|
language | java |
---|
title | Example 2 |
---|
| |
Code Block |
---|
language | java |
---|
title | Example 3 |
---|
| |
|
---|
Sample cURL Command(s) | Code Block |
---|
language | java |
---|
title | Sample cURL Command 1 |
---|
| |
Code Block |
---|
language | java |
---|
title | Sample cURL Command 2 |
---|
| |
Code Block |
---|
language | java |
---|
title | Sample cURL Command 3 |
---|
| |
|
---|
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. |
---|
|
Localtab |
---|
id | tab12 |
---|
title | Delete an endpoint |
---|
| |
Localtab |
---|
id | tab13 |
---|
title | Get the status of an endpoint |
---|
| |
Localtab |
---|
id | tab14 |
---|
title | Activate an endpoint |
---|
| |
Localtab |
---|
id | tab15 |
---|
title | Deactivate an endpoint |
---|
| |
Localtab |
---|
id | tab16 |
---|
title | Get an endpoint of a certain artifact instance |
---|
| |
|
|