This was a burning issue I had while implementing a client to retrieve association related data. In this post, I will be rewriting WSO2 official documentation for Association registry REST API. Without further a due let's send some requests and get some response :).
The following terms explain the meaning of the query parameters passed with the following REST URIs.
Please note that the { start page } and { number of records } parameters can take any value greater than or equal to 0. The { start page } and { number of records } begins with 1. If both of them are 0, then all the associations are retrieved.
The following terms explain the meaning of the query parameters passed with the following REST URIs.
Parameter
|
Explanation
|
---|---|
path | Path of the resource(a.k.a. registry path). |
type | Type of association. By default, Governance Registry has 8 types of association, such as usedBy, ownedBy... |
start | Start page number. |
size | Number of associations to be fetched. |
target | Target resource path(a.k.a. registry path). |
Please note that the { start page } and { number of records } parameters can take any value greater than or equal to 0. The { start page } and { number of records } begins with 1. If both of them are 0, then all the associations are retrieved.
Get all the Associations on a Resource
Attributes
|
Values
|
---|---|
HTTP Method
| GET |
Request URI | /resource/1.0.0/associations?path={ resource path }&start={ start page }&size={ number of records } |
HTTP Request Header | Authorization: Basic { base64encoded(username:password) } |
Response | It retrieves all the associations posted on the specific resource. |
Response | HTTP 200 OK |
Response Type | application/json |
Sample Request and Response
Get Associations of Specific Type on a Given Resource
Attributes
|
Values
|
---|---|
HTTP Method
| GET |
Request URI | /resource/1.0.0/associations?path={ resource path }&type={ association type } |
HTTP Request Header | Authorization: Basic { base64encoded(username:password) } |
Description
| It retrieves all the associations for the specific type of the given resource |
Response | HTTP 200 OK |
Response Type | application/json |
Sample Request and Response
Add Associations to a Resource
- Using a Json pay load
Attributes
|
Values
|
---|---|
HTTP Method
| POST |
Request URI | /resource/1.0.0/associations?path={resource path} |
HTTP Request Header |
Authorization: Basic { base64encoded(username:password) }
Content-Type: application/json
|
Payload | [{ "type":"<type of the association>","target":"<valid resource path>"}] |
Description
| It adds the array of associations passed as the payload for the source resource |
Response | HTTP 204 No Content. |
Response Type | application/json |
2. Using Query Params
Attributes
|
Values
|
---|---|
HTTP Method
| POST |
Request URI | /resource/1.0.0/associations?path={resource path}&targetPath={target resource}&type={assocation type} |
HTTP Request Header |
Authorization: Basic { base64encoded(username:password) }
Content-Type: application/json
|
Response | HTTP 204 No Content. |
Response Type | application/json |
Delete Associations on a Given Resource
Attributes
|
Values
|
---|---|
HTTP Method
| DELETE |
Request URI | /resource/1.0.0/association?path={resource path}&targetPath={target path}&type={association type} |
Description
| It deletes the association between the source and target resources for the given association type. |
Response | HTTP 204 No Content. |
Response Type | application/json |
Again this is a detailed version of WSO2 official documentation. This concludes the post.
Comments
Post a Comment