Syntax
<name> <term>
Where <name> is the name of the definition and <term> is a term, for example:
short_description "Limit the total number of VMs running in a project."
Terms can be literal values like in the example above, function calls, certain reserved words or in some cases references to other definitions.
Definitions may also be composite definitions of the form:
<name> <term> [, <property>: <string literal>] do
<property> <term>
<property> <term>
…
end
Where <property> is the name of a definition property, for example:
parameter "max_instances" do
type "number"
label "Maximum number of instances"
end
or
resources "instances", type: "rs_cm.instances" do
cloud_href href(@clouds)
state "operational"
end
Click the appropriate link to learn more about definitions for:
• | Comments |
• | Reserved Words |
• | String Literals |
• | Number Literals |
• | Array Literals |
• | Object Literals |
Comments start with the character #. They may appear at the end of a line or on a new line:
short_description "Limit number of VMs." # Note: only works on cloud X
# Comment on a new line
The Policy Template Language also defines a few reserved words that make it possible to retrieve contextual information or iterate over data collections. The list of complete reserved words and their usage is described in the Reserved Word Reference. For example rs_org_id returns the ID of the RightScale organization.
A string literal begins and ends with a double or single-quote mark. Double-quoted string expressions are subject to backslash notation. A single-quoted string expression isn't; except for \' and \.
For more information, see:
• | Backslash Notation |
• | Multiline String Literals |
Also called escape characters, backslashes are used to insert special characters in a string.
Example:
"this is a\ntwo line string"
"this string has \"quotes\" in it"
Escape Sequence |
Meaning |
\n |
newline |
\s |
space |
\r |
carriage return |
\t |
tab |
\” |
double quote character |
\’ |
single quote character |
\ |
backslash |
Multi-line string literals can be defined with here documents, where the delimiter can be any string:
<<END
on the one ton temple bell
a moon-moth, folded into sleep,
sits still.
END
The syntax begins with << and is followed immediately by the delimiter. To end the string, the delimiter appears alone on a line.
A number literal can be a integer such as 5 or a floating point number such as 5.5.
Arrays are defined using square brackets and commas to separate the elements:
["a", "b", "c"]
[1, 2, 3]
["a", [1, "b"]]
Objects are defined using curly braces and colons to separate keys and values:
{
"a": 1,
"b": "c",
"d": [2, 3],
"e": {
"f": 4
}
}