changes.
| h1. Get all resources in the system |
| |
| h2. Syntax |
| Resources in the system can be accessed using http GET method through below url: |
| {code}http://localhost:8810/rest/resources{code} |
| The response is of mime type _application/xml_ and the content is XML representation of all resources in the system. |
| |
| h2. Security |
| You will need to use http BASIC authentication to login as administrator. |
| |
| h2. Demo |
| Below [curl|http://curl.haxx.se/] command demonstrates how to get all resources: |
| {code}curl -u admin:admin http://localhost:8810/rest/resources{code} |
| |
| h1. Access resource by id |
| |
| h2. Syntax |
| Resource can be accessed by id using http GET method through below url: |
| {code}http://localhost:8810/rest/resources/<resource id>{code} |
| The response is of mime type _application/xml_ and the content is XML representation of the resource. |
| |
| h2. Security |
| You will need to use http BASIC authentication to login as administrator. |
| |
| h2. Demo |
| Below [curl|http://curl.haxx.se/] command demonstrates how to get resource of id _1_: |
| {code}curl -u admin:admin http://localhost:8810/rest/resources/1{code} |
| |
| h1. Update resource |
| |
| h2. Syntax |
| Resource can be updated by posting xml representation of the resource to below url: |
| {code}http://localhost:8810/rest/resources{code} |
| Normally you do not need to create the XML from scratch: you may retrieve XML representation of the resource using http GET method, modify certain parts of the XML and post back to above url. |
| The response is of mime type _text/plain_ and the content is string representation of the resource id being updated. |
| |
| h2. Security |
| You will need to use http BASIC authentication to login as administrator. |
| |
| h2. Demo |
| | We will use [curl|http://curl.haxx.se/] to demonstrate how to modify description of resource _db_: |
| # Get id of resource _db_ with [id service|retrieve object identifier] |
| {code}curl http://localhost/rest/ids?resource_name=db{code} |
| | We will use [curl|http://curl.haxx.se/] to demonstrate how to modify description of resource _ubuntu_: |
| # Get id of resource _ubuntu_ with [id service|retrieve object identifier] |
| {code}curl http://localhost/rest/ids?resource_name=ubuntu{code} |
| Assume returned id is _1_. |
| | # Retrieve xml representation of resource _db_ into a temp file using below command: |
| | # Retrieve xml representation of resource _ubuntu_ into a temp file using below command: |
| {code}curl -u admin:admin http://localhost:8810/rest/resources/1 > tempfile.xml{code} |
| # Edit _tempfile.xml_ and change _description_ element to desired value (or add the _description_ element if it does not already exist). |
| # Post back modified content using below command: |
| {code}curl -X POST -u admin:admin -d@tempfile.xml http://localhost:8810/rest/resources{code} |
| |
| h1. Create resource |
| |
| h2. Syntax |
| Resource can be created by posting XML representation of the resource to below url: |
| {code}http://localhost:8810/rest/resources{code} |
| Please note that the posted XML should NOT contain the _id_ element; otherwise, QuickBuild will treat the post as an updating to the resource with that id. |
| Normally you do not need to create the XML from scratch: you may retrieve XML representation of a templating resource using http GET method, remove the _id_ element, modify certain parts and post back to above url. |
| The response is of mime type _text/plain_ and the content is string representation of the newly created resource id. |
| |
| h2. Security |
| You will need to use http BASIC authentication to login as administrator. |
| |
| h2. Demo |
| We will use [curl|http://curl.haxx.se/] to demonstrate how to create a new resource _suse_ by copying the existing resource _ubuntu_. |
| # Get id of resource _ubuntu_ with [id service|retrieve object identifier] |
| {code}curl http://localhost/rest/ids?resource_name=ubuntu{code} |
| Assume returned id is _1_. |
| # Retrieve xml representation of resource _ubuntu_ into a temp file using below command: |
| {code}curl -u admin:admin http://localhost:8810/rest/resources/1 > tempfile.xml{code} |
| # Edit _tempfile.xml_, remove the _id_ element, and change the _name_ element to be _suse_ |
| # Post back modified content using below command: |
| {code}curl -X POST -u admin:admin -d@tempfile.xml http://localhost:8810/rest/resources{code} |
| |
| h1. Delete resource |
| |
| h2. Syntax |
| Resource can be deleted using http DELETE method through below url: |
| {code}http://localhost:8810/rest/resources/<resource id>{code} |
| Here _<resource id>_ stands for id of the resource to be deleted. |
| |
| h2. Security |
| You will need to use http BASIC authentication to login as administrator. |
| |
| h2. Demo |
| Below [curl|http://curl.haxx.se/] command demonstrates how to delete the resource with id _2_: |
| {code}curl -X DELETE -u admin:admin http://localhost:8810/rest/resources/2{code} |