Skip to content

REST: Templates related API

ddurnev edited this page Jun 19, 2013 · 17 revisions

List available environment templates

Lists only template names and versions.

Path: /rest/projects/(projectId)/templates

Type: GET

Example results:

   [{
        "name":"Erlang",
        "version":"0.1"
    },
    {
        "name":"XWiki",
        "version":"0.1"
    }]

Path parameters:

Parameter Type Description
projectId Number id of the project.

Get template content

Path: /rest/projects/(projectId)/templates/(templateName)/v(templateVersion)?format=src

Type: GET

Path parameters:

Parameter Type Description
projectId Number id of the project.
templateName String name of the template
templateVersion Number version of the template

Example results

Get template description

Returns template name, version and create, destroy workflow names and array of all workflow names.

Path: /rest/projects/(projectId)/templates/(templateName)/v(templateVersion)

Type: GET

Path parameters:

Parameter Type Description
projectId Number id of the project.
templateName String name of the template
templateVersion Number version of the template

Example results:

{
    "name": "Erlang",
    "version": "0.1",
    "createWorkflow": "create",
    "destroyWorkflow":"destroy",
    "workflows":["create","scale-up","destroy"]
}

Get workflow description

Returns workflow name, and its variables descriptions. Also a map of variable groups(if exist) is returned: keys are internal group names and values are group parameters objects(include description, required, etc).

Path: /rest/projects/(projectId)/templates/(templateName)/v(templateVersion)/(workflow)?configurationId=(configId)

Type: GET

Path parameters:

Parameter Type Description
projectId Number id of the project.
templateName String name of the template
templateVersion Number version of the template
workflow String Name of the requested workflow
configId Number Id of the environment configuration which should be used to evaluate variables possible values, etc. Is mandatory in case of several environment configurations exist. If only one environment configuration exists then it is not required.

Example results:

{
"result": {
  "name":"create",
  "variables":[{
    "name":"nodesCount",
    "type":"Integer",
    "description":"Erlang worker nodes count",
    "optional":false,
    "defaultValue":null
  }],
  "varGroups": {
    "group1": {"desc":"Test Group","required":true,"defVariable":"nodesCount"}
  }
},
"isSuccess":true
}

Partial apply: get values for dependent variables

Partial apply returns list of variables ( with possible values ) that can be calculated based provided values. I.e. if B depends on A and C depends on B: if only A is provided, the result will contain possible values for A and B, if A and B are provided, all three variables will be returned

Path: /rest/projects/(projectId)/templates/(templateName)/v(templateVersion)/(workflow)

Type: POST

Request body: JSON array of variables (variables part of create environment request)

Path parameters:

Parameter Type Description
projectId Number Id of the project
templateName String name of the template
templateVersion Number version of the template
workflow String workflow name

Example request:

{"variables": { "imageId": 1 } }

Example response (there is variables dependent from imageId in example request):

[
        {
           "name":"imageId",
           "description":"image",
           "values": [1,2]
        },
	{
           "name":"nodesCount",
           "description":"XWiki nodes count",
	   "optional": true,
	   "defaultValue": null,
           "values": [1,2,3]
         }
]
Clone this wiki locally