Governance REST API
The Governance REST API basically facilitates the capability to perform the CRUD operations via the well-defined HTTP protocol. The REST API uses the GET, POST, PUT, and DELETE operations of the well-defined HTTP protocol to do the CRUD operation via any REST Client. Google Chrome's Advanced REST client is one of the client tools used to test the functionality of the Governance REST API.
Authorization: Basic YWRtaW46YWRtaW4=
where the format is Authorization: Basic {base64encoded(username:password)}
Security Requirements
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
Get list of available artifact types
Syntax -GET /governance/types/
Example -GET https://localhost:9443/governance/types/
Get list of assets of certain type
Syntax -
GET /governance/<asset_short_name_s>
GET /governance/<asset_short_name_s>?query
Supported query format:
xyz
- Looks for artifacts with name xyz- 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 isdocLinks
, the field isdocumentType
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.
- 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
xyz&version=1.3.5
- Looks for artifacts with name xyz with version 1.3.5tags=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
Examples -
GET https://localhost:9443/governance/restservices
GET https://localhost:9443/governance/restservices?name=restservice1GET https://localhost:9443/governance/restservices?name=restservice1&version=1.0.0
GET https://localhost:9443/governance/restservices?docLinks%3AdocumentComment=rest1%20is%20a%20simple%20API
WSO2 G-Reg does not support date range searches in Governance REST API.
Get an individual asset of certain type
Syntax -GET /governance/<asset_short_name_s>/UUID
Example -GET https://localhost:9443/governance/restservices/3245se24553
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.- name
- version
- type
Payload format is as follows:
{ name: "Artifact Name", type: "Artifact Type", version: “Version Number", Attribute-N: “Attribute-N” value }
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.
Example -POST https://localhost:9443/governance/restservices
{
name: "TestRESTService",
type: "restservice",
context: "/test",
version: "1.0.0"
}
This may return the following:
HTTP 200
Location: https://localhost:9443/governance/restservices/3ec1dcd9-66d8-41da-a0d2-ec171df64cc3
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.- name
- version
- type
Payload format is as follows:
{ name: "Artifact Name", type: "Artifact Type", version: “Version Number", Attribute-N: “Attribute-N” value }
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.
Example -
PUT https://localhost:9443/governance/restservices/324dsdwa535
{
name: "TestRESTService",
type: "restservice",
context: "/test-new",
version: "1.0.0",
}
Delete an asset
Syntax -DELETE /governance/<asset_short_name_s>/UUID
Example -DELETE https://localhost:9443/governance/restservices/3245se24553
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
Examples -GET https://localhost:9443/governance/restservices/44dadw4/states
GET https://localhost:9443/governance/restservices/44dadw4/states?lc=ServiceLifeCycle
Update lifecycle change of an asset
Syntax -PUT /governance/<RXT_short_name_s>/uuid/states payload
Payload format
{
lc: "Lifecycle name",
action: "Promote",
check_item_N : "value_N",
}
Example -PUT https://localhost:9443/governance/restservices/cea0c482-4280-4837-8126-3fd97cdc0a41/states
{
lc: "ServiceLifeCycle",action: "Promote",
item_0 : "true",
item_1 : "true",
item_2 : "true"
}
Endpoints
Get all endpoints
Syntax -
GET
/governance/endpoints
Example -
GET https://localhost:9443/governance/endpoints
Get an individual endpoint
Syntax -GET /governance/endpoints/UUID
Example -GET https://localhost:9443/governance/endpoints/c7d6ed67-f2f5-409f-97f2-ddff9b6bc07b
Create new endpoint
Syntax -
POST
/governance/endpoints <payload>
Here the payload should be in JSON format.Following are the required attributes:- name
- version
- type
Payload format is as follows:
{ name: "Artifact Name", type: "endpoint", version: “Version Number", Attribute-N: “Attribute-N” value }
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.
Example -POST https://localhost:9443/governance/endpoints/
{
name: "endpoint-1",
type: "endpoint",
version: "1.0.0",
address: "https://localhost:9443",
environment: "QA"
}
It is also possible to create an endpoint and associate it with othertypesofartifact such as REST services or SOAP services.Syntax -
POST /governance/endpoints/restservices/<UUID> <payload>
POST /governance/endpoints/restservices?Query <payload>
Examples -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"
}
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"
}
Delete an endpoint
Syntax -
DELETE /governance/endpoints/uuid
Example -
DELETE https://localhost:9443/governance/endpoints/73cc7077-d723-44a5-98e5-945795e518e8
Get an endpoint status
Syntax -GET /governance/endpoints/<uuid>/states
Example -GET https://localhost:9443/governance/endpoints/c7d6ed67-f2f5-409f-97f2-ddff9b6bc07b/states
Activate an endpoint
Syntax -POST /governance/endpoints/activate/<uuid>
Example -POST https://localhost:9443/governance/endpoints/activate/c7d6ed67-f2f5-409f-97f2-ddff9b6bc07b
Deactivate an endpoint
Syntax -POST /governance/endpoints/deactivate/<uuid>
Example -POST https://localhost:9443/governance/endpoints/deactivate/c7d6ed67-f2f5-409f-97f2-ddff9b6bc07b
Get endpoint belong to a certain artifact instance
Syntax -GET /governance/<asset_short_name_s>/<id>/endpoints
Example -POST https://localhost:9443/governance/restservices/cea0c482-4280-4837-8126-3fd97cdc0a41/endpoints