Use the
fields request parameter in a collection query to define a new attribute from an expression associated with one or more existing attributes. You can use the new attributes in filter and order by clauses to filter and sort responses.
NOTE The processing of complex requests can be slow or can fail.
The supported expressions are:
Boolean expressions, which include comparison and boolean operators, as described in the Syntax section.
Conditional expression with a format of
" < expr_a > ? < expr_b > : < expr_c > ". The evaluation of
<expr_a> leads to return of the value of
<expr_b> if true, or
<expr_c> if false.
Arithmetic expressions with the supported operators +,-,*,/. These can include the following types of expressions:
Count expression, where you can apply the count function
"@count(prop_name)" to a list type attribute
"prop_name" and get the number of elements in the list returned.
Concatenation expression, where you can apply
"@concat(...)" where
"..." represents variable-length arguments that can be one or more attribute names, constant strings, or numbers. The concatenation expression results in a string that is a concatenation of the string values of all of the arguments. You cannot specify a reference attribute in a concatenation expression.
Comparators are the same as those used in the
filter expression and share the same semantics and limitations.
NOTE
Define the new attribute explicitly in the
fields request parameter.
Calculate the new attribute definition from existing attributes or constants. A cascaded definition, in which a new attribute is calculated from other new attributes, is not supported.
You cannot define a new attribute from an expression that contains a new attribute, or a new attribute whose name conflicts with an existing attribute.
Example 1 - Defining a new attribute using an arithmetic expression
The following example defines a new attribute called
percent by calculating the percent of used pool space compared to the total pool space.
Example 2 - Defining a new attribute using a conditional expression
The following example defines a new attribute called
lunName. This attribute will display the LUN name for a
storageResource instance if it has a
type of
8 (lun). Otherwise, the
lunName attribute will contain an empty string value.
Example 4 - Defining a new attribute by concatenating elements from a list into a single string value
The following example defines a new attribute called
newProp for
pool resources by concatenating the values of the
tiers.name attribute. It concatenates these values in descending order and separates them with commas.
Example 5 - Defining a new attribute by using the text value of an attribute defined as an enum
The following example defines a new attribute called
newProp for each
disk resource by using the text value of the
tierType attribute, which is an enum.
Example 6 - Defining a new attribute by using the localized text value of an attribute defined as an enum
The following example defines a new attribute for the
capabilityProfile resource type called
se by using the localized text of the
spaceEfficiencies attribute, which is a collection enum. In this example, the text is localized to American English.