This documentation relates to QuickBuild 9.0.x
Select here if you are using a different version

Interact with Resources

Get all resources in the system

Syntax

Resources in the system can be accessed using http GET method through below url:

http://localhost:8810/rest/resources

The response is of mime type application/xml and the content is XML representation of all resources in the system.

Security

You will need to use http BASIC authentication to login as administrator.

Demo

Below curl command demonstrates how to get all resources:

curl -u admin:admin http://localhost:8810/rest/resources

Access resource by id

Syntax

Resource can be accessed by id using http GET method through below url:

http://localhost:8810/rest/resources/<resource id>

The response is of mime type application/xml and the content is XML representation of the resource.

Security

You will need to use http BASIC authentication to login as administrator.

Demo

Below curl command demonstrates how to get resource of id 1:

curl -u admin:admin http://localhost:8810/rest/resources/1

Get total resource count across nodes

Syntax

Total resource count across different nodes can be retrieved using http GET method through below url:

http://localhost:8810/rest/resources/<resource id>/total

Here <resource id> stands for id of the resource.

Security

You will need to use http BASIC authentication to login as administrator.

Demo

Below curl command demonstrates how to get total resource count across different nodes for resource id 2:

curl -u admin:admin http://localhost:8810/rest/resources/2/total

Get available resource count across nodes

Syntax

Available resource count across different nodes can be retrieved using http GET method through below url:

http://localhost:8810/rest/resources/<resource id>/available

Here <resource id> stands for id of the resource.

Security

You will need to use http BASIC authentication to login as administrator.

Demo

Below curl command demonstrates how to get available resource count across different nodes for resource id 2:

curl -u admin:admin http://localhost:8810/rest/resources/2/available

Update resource

Syntax

Resource can be updated by posting xml representation of the resource to below url:

http://localhost:8810/rest/resources

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.

Security

You will need to use http BASIC authentication to login as administrator.

Demo

We will use curl to demonstrate how to modify description of resource ubuntu:

  1. Get id of resource ubuntu with id service
    curl http://localhost/rest/ids?resource_name=ubuntu

    Assume returned id is 1.

  2. Retrieve xml representation of resource ubuntu into a temp file using below command:
    curl -u admin:admin http://localhost:8810/rest/resources/1 > tempfile.xml
  3. Edit tempfile.xml and change description element to desired value (or add the description element if it does not already exist).
  4. Post back modified content using below command:
    curl -X POST -u admin:admin -d@tempfile.xml http://localhost:8810/rest/resources

Create resource

Syntax

Resource can be created by posting XML representation of the resource to below url:

http://localhost:8810/rest/resources

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.

Security

You will need to use http BASIC authentication to login as administrator.

Demo

We will use curl to demonstrate how to create a new resource suse by copying the existing resource ubuntu.

  1. Get id of resource ubuntu with id service
    curl http://localhost/rest/ids?resource_name=ubuntu

    Assume returned id is 1.

  2. Retrieve xml representation of resource ubuntu into a temp file using below command:
    curl -u admin:admin http://localhost:8810/rest/resources/1 > tempfile.xml
  3. Edit tempfile.xml, remove the id element, and change the name element to be suse
  4. Post back modified content using below command:
    curl -X POST -u admin:admin -d@tempfile.xml http://localhost:8810/rest/resources

Delete resource

Syntax

Resource can be deleted using http DELETE method through below url:

http://localhost:8810/rest/resources/<resource id>

Here <resource id> stands for id of the resource to be deleted.

Security

You will need to use http BASIC authentication to login as administrator.

Demo

Below curl command demonstrates how to delete the resource with id 2:

curl -X DELETE -u admin:admin http://localhost:8810/rest/resources/2

Labels:

Enter labels to add to this page:
Wait Image 
Looking for a label? Just start typing.