Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Reverted from v. 13

...

...

...

Info
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.

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.

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.
Image Removed 

See the sections below for information on sample requests and complete URI formats used when invoking the REST APIs after generating the access token:

Table of Contents
maxLevel3
minLevel3

Assets

Panel
borderColor#FFFFFF
bgColor#FFFFFF
Localtabgroup
verticaltrue
Localtabidtab1titleGet a list of available artifact types
base64encoded(username:password)} 
idtab2title

 

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.  

Security Requirements

You must send valid HTTP BasicAuth credentials when invoking the REST API.

Image Added 

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:

 

Table of Contents
minLevel4

Assets

  1. Get list of available artifact types

     

    Syntax  GET /governance/types/
    ExampleGET https://localhost:9443/governance/types/
    Sample cURL Commandcurl -X GET -H "Authorization: Basic YWRtaW46YWRtaW4=" -H "Cache-Control: no-cache" "https://localhost:9443/governance/types/" -i -k
Localtab
  1. Get
a
  1. list of assets of
a
  1. certain type

     

    Syntax  
    • GET /governance/<asset_short_name_s>
    • GET /governance/<asset_short_name_s>
?query 

 

Warning

WSO2 G-Reg does not support date range searches in Governance REST API.

QueryDescriptionsxyz
    • ?query 
    Supported Query Format
    • xyz  - Looks for artifacts with

name 'xyz'.
    • 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
    • name xyz with version 1.3.5

.
    • tags=

abc 
    • 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
    • an rxt attribute or a property.

    • version=1.3.5&mediaType=application/vnd.wso2-soap-service+xml
Searches
    •  - searches only soap services with version 1.3.
5
    •  
    Warning

    WSO2 G-Reg does not support date range searches in Governance REST API.


    Example
(s)
GET https
    • GET https://localhost:9443//governance/restservices
GET https
    • GET https://localhost:9443//governance/restservices?name=restservice1 
GET https
    • GET https://localhost:9443//governance/ restservices?name=restservice1&version=1.0.0
    • GET https://localhost:9443/governance/restservices?docLinks%3AdocumentComment=rest1%20is%20a%20simple%20API
    Sample cURL Command
(s)
    • curl -X GET -H "Authorization: Basic YWRtaW46YWRtaW4=" -H "Cache-Control: no-cache" "https://localhost:9443/governance/restservices"
-i -k

curl -X GET
    • -
H "Authorization: Basic YWRtaW46YWRtaW4=" -H "Cache-Control: no-cache" "https://localhost:9443/governance/restservices?name=WarrantyClaimService" -
    • i
-k
    • curl -X GET -H "Authorization: Basic YWRtaW46YWRtaW4=" -H "Cache-Control: no
-cache" " https://localhost:9443/governance/restservices?name=WarrantyClaimService&version=1.0.0 " -i -k Localtab
idtab3
title Get an individual asset of a certain type
Syntax  GET /governance/<asset_short_name_s>/UUID  ExampleGET
    • -cache" "https://localhost:9443/
/
    • governance/restservices
/3245se24553  Sample cURL Command
    • ?name=WarrantyClaimService" -i -k
    • curl -X GET -H "Authorization: Basic YWRtaW46YWRtaW4=" -H "Cache-Control: no-cache" "https://localhost:9443/governance/restservices
/cae93ba9-9543-43be-9f30-bb96cec3c443" -i -k Localtab
idtab4
titleCreate a new asset
Syntax  POST
    • ?name=WarrantyClaimService&version=1.0.0" -i -k
  1. Get an individual asset of certain type

     

    Syntax  GET  /governance/<asset_short_name_s>
<payload>

The payload should be in JSON format. Following are the required attributes.

  • name
  • version
  • type

Payload format is as follows:

 

Code Block
{
name: "Artifact Name",
type: "Artifact Type",
version: “Version Number",
Attribute-N: “Attribute-N” value
} 
Example Code Block
languagejava
POST
  1. /UUID 
    ExampleGET   https://localhost:9443 /governance/restservices/3245se24553  
    Sample cURL Command

    curl -X GET -H "Cache-Control: no-cache" "https://localhost:9443

{ name: "TestRESTService", type: "restservice", context: "/test", version: "1.0.0" }Sample cURL Command
Code Block
languagejava
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
idtab5
titleUpdate 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: 

 

Code Block
{
name: "Artifact Name",
type: "Artifact Type",
version: “Version Number",
Attribute-N: “Attribute-N” value
}
Example
Code Block
languagejava
PUT   https://localhost:9443 /governance/restservices/324dsdwa535   
{
name: "TestRESTService",
type: "restservice",
context: "/test-new",
version: "1.0.0",
}
Sample cURL Command Code Block
languagejava
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" }' "
  1. Create a new asset 

     

    Syntax  POST  /governance/<asset_short_name_s> <payload>
    ExampleHere the payload should be in JSON format. Following are the required attributes.
    • name
    • version
    • type

    Payload format is as follows:

    Code Block
    {
    name: "Artifact Name",
    type: "Artifact Type",
    version: “Version Number",
    Attribute-N: “Attribute-N” value
    } 

    For example;

    Code Block
    languagejava
    POST   https://localhost:9443 /governance/restservices      
    {
    name: "TestRESTService",
    type: "restservice",
    context: "/test",
    version: "1.0.0"
    }
    Sample cURL Command

    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

  2. Update an existing asset

     

    Syntax  PUT /governance/<asset_short_name_s>/uuid<payload>
    ExampleHere the payload should be in JSON format. Following are the required attributes.
    • name
    • version
    • type

    Payload format is as follows: 

    Code Block
    {
    name: "Artifact Name",
    type: "Artifact Type",
    version: “Version Number",
    Attribute-N: “Attribute-N” value
    }

    For example;

    Code Block
    languagejava
    PUT   https://localhost:9443 /governance/restservices/
97bdb275-2b09-4744-b29f-125cf2c8e387 " -i -kResponseIf 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
idtab6
titleDelete an asset
Syntax  DELETE /governance/<asset_short_name_s>/UUID ExampleDELETE https://localhost:9443/ /governance/restservices/3245se24553Sample cURL Commandcurl -X DELETE -H "Authorization: Basic YWRtaW46YWRtaW4=" -H "Cache-Control: no-cache" "Syntax  
  • GET /governance/<RXT_short_name_s>/uuid/states
  • GET /governance/<RXT_short_name_s>/uuid/states?lc=LCName 
Example(s)
  • GET https://localhost:9443//governance/restservices/44dadw4/states
  • GET https://localhost:9443//governance/restservices/44dadw4/states?lc=ServiceLifeCycle
Sample cURL Command(s)curl -X GET -H "Authorization: Basic YWRtaW46YWRtaW4=" -H "Cache-Control: no-cache" "
  1. 324dsdwa535   
    {
    name: "TestRESTService",
    type: "restservice",
    context: "/test-new",
    version: "1.0.0",
    }
    Sample cURL Command

    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

Localtab
idtab7
titleGet lifecycle state of an asset
  1. ResponseIf 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.
  2. Delete an asset

     

    Syntax  DELETE  /governance/<asset_short_name_s>/UUID 
    ExampleDELETE   https://localhost:9443 /governance/restservices/
cae93ba9-9543-43be-9f30-bb96cec3c443/states" -i -k
  1. 3245se24553
    Sample cURL Commandcurl -X
GET
  1. DELETE -H "Authorization: Basic YWRtaW46YWRtaW4=" -H "Cache-Control: no-cache" "https://localhost:9443/governance/restservices/
cae93ba9954343be9f30-bb96cec3c443/states?lc=ServiceLifeCycleidtab8titleUpdate Localtab
  1. Get lifecycle state of an asset

     

    Syntax  
PUT  
    • GET /governance/<RXT_short_name_s>/uuid/states
    • GET /governance/<RXT_short_name_s>/uuid/states
<payload>

Payload format is as follows: 

Code Block
languagejava
{lc: "Lifecycle name",
 action: "Promote",
 check_item_N : "value_N",                 
} 
Example Code Block
languagejava
PUT
    • ?lc=LCName 
    Example
    Sample cURL Command
/cea0c482-4280-4837-8126-3fd97cdc0a41/states { lc: "ServiceLifeCycle", action: "Promote", item_0 : "true", item_1 : "true", item_2 : "true" }Sample cURL Command
Code Block
languagejava
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
Localtabgroup
verticaltrue
Localtab
idtab9
titleGet all endpoints
Syntax  GET
  1. 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"

    }
    Sample cURL Command

    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

  1. Get all endpoints
     
    Syntax  GET  /governance/endpoints
    ExampleGET  https://localhost:9443/governance/endpoints
    Sample cURL Commandcurl -X GET -H "Authorization: Basic YWRtaW46YWRtaW4=" -H "Cache-Control: no-cache"   "https://localhost:9443/governance/endpoints"
-i -k Localtabidtab10title
  1. -i -k

  2. Get an individual endpoint

     
    Syntax  GET  /governance/endpoints/UUID
    ExampleGET https://localhost:9443/governance/endpoints/c7d6ed67-f2f5-409f-97f2-ddff9b6bc07b
     
    Sample cURL Commandcurl -X GET -H "Authorization: Basic YWRtaW46YWRtaW4=" -H "Cache-Control: no-cache" "https://localhost:9443/governance/endpoints/c413e38b-16fa-4c49-ac03-927f878e8e59" -i -k
Localtabid
tab11title

  1. Create new
endpoint
  1. endpoint 

     

    Syntax  

    Syntax 1: GET  

GET
  1. /governance/endpoints

<payload>  
  1.  <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> 
    •  <payload> 
    • GET /governance/endpoints/restservices?Query
<payload> 
    •  <payload> 
    ExampleHere the payload should be in JSON format.Following are the required attributes:
    • name
    • version
    • type

    Payload format is as follows:

 
  1. Code Block
 
  1. {
    name: "
endpoint-1
  1. Artifact Name",
    type: "endpoint",
    version: 
"1.0.0", address: "https://localhost:9443
  1. “Version Number",
    
environment
  1. Attribute-N: 
"QA"
  1. “Attribute-N” value
    }
Example(s)
  1. Code Block
    languagejava
    titleExample 1
    POST  https://localhost:9443/governance/endpoints/ 
    {
    name: "endpoint-1",
    type: "endpoint",
    version: "1.0.0",
    address: "https://localhost:9443",
    environment: "QA"
    }
Code Blocklanguagejavatitle
  1. {

  1. name:

  1. "endpoint-2",

  1. type:

  1. "endpoint",

  1. version:

  1. "1.0.0",

  1. address:

  1. environment:

  1. "QA"

} Code Blocklanguagejavatitle
  1. }

    Example 3:
 POST {
  1.   

    {

    name:

  1. "endpoint-3",

  1. type:

  1. "endpoint",

  1. version:

  1. "1.0.0",

  1. address:

  1. environment:

  1. "QA"

  1. }

    Sample cURL Command

    Sample cURL Command

(s)
  1. 1:

    Code Block
    languagejava
titleSample cURL Command 1  curl
  1. curl -X POST -H "Authorization: Basic YWRtaW46YWRtaW4=" -H "Content-Type: application/json" -H "Cache-Control: no-cache" -d '{
  1. 
     "name":"endpoint-1",
  1. 
     "type":"endpoint",
  1. 
     "version":"1.0.0",
  1. 
     "address":"https://localhost:9443",
  1. 
     "environment
":"QA" }' "https://localhost:9443/governance/endpoints" -i -k
  1. ":"QA"
    }

     

    Sample cURL Command 2:

    Code Block
    languagejava
titleSample cURL Command 2
  1. 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 -
  1. k


    Sample cURL Command 3:

    Code Block
    languagejava
titleSample cURL Command 3 curl
  1. 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
    ResponseIf 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.  
Localtabidtab12titleDelete an endpoint
  1. Delete an endpoint

    Syntax - 

    Example -   

     

    Syntax  DELETE   /governance/endpoints/
uuid 
  1. uuid 
    ExampleDELETE 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

Localtabidtab13title
  1. Get
the status of
  1. an endpoint status

     

    Syntax  GET  /governance/endpoints/<uuid>/states
    ExampleGET https://localhost:9443/governance/endpoints/c7d6ed67-f2f5-409f-97f2-ddff9b6bc07b/states 
     
    Sample cURL Command

    curl -X GET -H "Authorization: Basic YWRtaW46YWRtaW4=" -H "Cache-Control: no-cache" "https://localhost:9443/governance/endpoints/6652d672-d7f5-4a13-9d6f-9a6eb85675a5/states" -i -k

Localtabidtab14title

  1. Activate an endpoint

     

    Syntax  POST  /governance/endpoints/activate/<uuid> 
    ExamplePOST https://localhost:9443/governance/endpoints/activate/c7d6ed67-f2f5-409f-97f2-ddff9b6bc07b  
     
    Sample cURL Command

    curl -X POST -H "Authorization: Basic YWRtaW46YWRtaW4=" -H "Cache-Control: no-cache" "https://localhost:9443/governance/endpoints/activate/6652d672-d7f5-4a13-9d6f-9a6eb85675a5"  -i -k

Localtabidtab15title
  1. Deactivate an endpoint

     

    Syntax  POST  /governance/endpoints/deactivate/<uuid> 
    ExamplePOST https://localhost:9443/governance/endpoints/deactivate/c7d6ed67-f2f5-409f-97f2-ddff9b6bc07b  
    Sample cURL Command

    curl -X GET -H "Authorization: Basic YWRtaW46YWRtaW4=" -H "Cache-Control: no-cache" "https://localhost:9443/governance/endpoints/deactivate/6652d672-d7f5-4a13-9d6f-9a6eb85675a5" -i -k

Localtabidtab16title

  1. Get an endpoint
of an
  1. belong to a certain artifact instance   

     

    Syntax  GET  /governance/<asset_short_name_s>/<id>/endpoints
    ExampleGET 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