Skip to main content
  • Place orders quickly and easily
  • View orders and track your shipping status
  • Create and access a list of your products
  • Manage your Dell EMC sites, products, and product-level contacts using Company Administration.

Dell Unity™ Family Unisphere® Management REST API Programmer's Guide

PDF

Defining new attributes from existing attributes

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.

Syntax

As the first parameter on the request URI:

?fields=<new_attr_name>::<new_attr_expr>,<attr1>,<attr2>,...

As a subsequent parameter on the request URI:

&fields=<new_attr_name>::<new_attr_expr>,<attr1>,<attr2>,...

where <new_attr_expr> is defined by the following syntax using Backus-Naur Form (BNF):

new_attr_expr ::= unary_expr 
             | bool_expr
             | cond_expr
             | arith_expr

unary_expr ::= constant_value
             | attribute_name
             | '(' new_attr_expr ')'
             | concat_expr
             | FunctionName ‘(‘unary_expr‘)’

FunctionName : ‘@count’
             | ‘@enum’
             | ‘@enumString’
             | ‘@sum’
             | ‘@str’
             
bool_expr ::= and_bool_expr
             | bool_expr 'or' and_bool_expr
             | bool_expr '||' and_bool_expr

and_bool_expr ::= simple_bool_expr
             | and_bool_expr 'and' and_bool_expr 
             | and_bool_expr '&&' and_bool_expr


simple_bool_expr ::= cmp_expr
             | unary_expr
             | 'not' unary_expr
             | '!' unary_expr

cmp_expr ::= unary_expr comparator unary_expr
             | lk_expr
             | in_expr

lk_expr ::= attribute_name 'lk' constant_value

in_expr ::= attribute_name in_items_expr ')'

in_items_expr ::= 'in' '(' constant_value
             | in_items_expr ',' constant_value

cond_expr ::= bool_expr '?'' new_attr_expr : new_attr_expr

arith_expr ::= high_priority_arith_expr
             | arith_expr ['+'|'-'] high_priority_arith_expr

high_priority_arith_expr ::= unary_expr
             | high_priority_arith_expr ['*'|'/'] unary_expr

concat_expr ::= concat_prefix_expr ')'

concat_prefix_expr ::=  '(' concat_items_expr ',' concat_items_expr
                     | concat_prefix_expr ',' concat_items_expr

concat_items_expr ::= unary_expr
             | new_attr_expr

In the syntax for <new_attr_expression>:

  • attribute_name is the name of an attribute of the resource type you are querying. You can use dot notation to specify this.
  • constant_value is one of the following:
    • Double quoted constant string
    • Constant number, both integer and float, in decimal or hexadecimal format
    • Boolean constant: true/false/True/False/TRUE/FALSE
    • null/Null/NULL
    • 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.

Header
 Accept: application/json 
Content-Type: application/json
Request
GET https://10.108.53.165/api/types/pool/instances
?fields=sizeUsed,sizeTotal,percent::sizeUsed*100/sizeTotal
&compact=true&with_entrycount=true
Response body for a successful response
{
  "@base": "https://10.108.53.165/api/types/pool/instances
    ?fields=sizeUsed,sizeTotal,percent::sizeUsed*100/sizeTotal,
    id&per_page=2000&compact=true",
  "updated": "2016-06-02T02:54:05.489Z",
  "links": [
    {
      "rel": "self",
      "href": "&page=1"
    }
  ],
  "entryCount": 1,
  "entries": [
    {
      "content": {
        "id": "pool_1",
        "sizeTotal": 118916907008,
        "sizeUsed": 15837691904,
        "percent": 13.318284
      }
    }
  ]
} 

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.

Header
Accept: application/json 
Content-Type: application/json
Request
GET https://10.108.53.165/api/types/storageResource/instances
?fields=type,lunName::type eq 8 ? name : "" 
&compact=true&with_entrycount=true
Response body for a successful response
{
  "@base": "https://10.108.53.165/api/types/storageResource/instances?fields=type,lunName::type eq 8 ? name : \"\",id&per_page=2000&compact=true",
  "updated": "2016-06-02T02:58:32.695Z",
  "links": [
    {
      "rel": "self",
      "href": "&page=1"
    }
  ],
  "entryCount": 3,
  "entries": [
    {
      "content": {
        "id": "res_1",
        "type": 1,
        "lunName": ""
      }
    },
    {
      "content": {
        "id": "res_2",
        "type": 1,
        "lunName": ""
      }
    },
    {
      "content": {
        "id": "sv_1",
        "type": 8,
        "lunName": "LUN00"
      }
    }
  ]
}
 

Example 3 - Defining a new attribute using a concatenation expression

The following example defines a new attribute called newName by concatenating the value of name with the value of type.

Header
Accept: application/json 
Content-Type: application/json
Request
GET https://10.108.53.216/api/types/storageResource/instances?fields=name,type,newName::@concat(name, type) &compact=true
Response body for a successful response
{
  "@base": "https://10.108.53.216/api/types/storageResource/instances?fields=name,type,newName::@concat(name,type),id&per_page=2000&compact=true",
  "updated": "2015-10-28T14:51:23.427Z",
  "links": [
    {
      "rel": "self",
      "href": "&page=1"
    }
  ],
  "entries": [
    {
      "content": {
        "id": "res_1",
        "type": 1,
        "name": "FileSystem1",
        "newName": "FileSystem11"
      }
    },
    {
      "content": {
        "id": "sv_1",
        "type": 8,
        "name": "LUNPersonal",
        "newName": "LUNPersonal8"
      }
    },
    {
      "content": {
        "id": "sv_2",
        "type": 8,
        "name": "LUNCorporate",
        "newName": "LUNCorporate8"
      }
    }
  ]
}

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.

Header
Accept: application/json 
Content-Type: application/json
Request
GET https://10.108.49.220/api/types/pool/instances
?fields=id,tiers.name,newProp::
@concatList(tiers.name,separator=",",order="desc") 
&compact=true
Response body for a successful response
{
  "@base": "https://10.108.49.220/api/types/pool/instances?fields=id,tiers.name,newProp::@concatList(tiers.name,separator=\",\",order=\"desc\")&per_page=2000&compact=true",
  "updated": "2016-06-02T03:07:13.424Z",
  "links": [
    {
      "rel": "self",
      "href": "&page=1"
    }
  ],
  "entryCount": 1,
  "entries": [
    {
      "content": {
        "id": "pool_1",
        "tiers": [
          {
            "name": "Extreme Performance"
          },
          {
            "name": "Performance"
          },
          {
            "name": "Capacity"
          }
        ],
        "newProp": "Performance,Extreme Performance,Capacity"
      }
    }

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.

Header
Accept: application/json 
Content-Type: application/json
Request
GET https://10.108.53.165/api/types/disk/instances?fields=id,
newProp::@enum(tierType)&filter=tierType != 0 &compact=true
&with_entrycount=true
Response body for a successful response
{
  "@base": "https://10.108.53.165/api/types/disk/instances?filter=tierType != 0 &fields=id,newProp::@enum(tierType)&per_page=2000&compact=true",
  "updated": "2016-06-02T03:02:42.236Z",
  "links": [
    {
      "rel": "self",
      "href": "&page=1"
    }
  ],
  "entryCount": 7,
  "entries": [
    {
      "content": {
        "id": "dpe_disk_0",
        "newProp": "Performance"
      }
    },
    {
      "content": {
        "id": "dpe_disk_1",
        "newProp": "Performance"
      }
    },
    {
      "content": {
        "id": "dpe_disk_2",
        "newProp": "Performance"
      }
    },
    {
      "content": {
        "id": "dpe_disk_3",
        "newProp": "Performance"
      }
    },
    {
      "content": {
        "id": "dpe_disk_4",
        "newProp": "Performance"
      }
    },
    {
      "content": {
        "id": "dpe_disk_5",
        "newProp": "Performance"
      }
    },
    {
      "content": {
        "id": "dpe_disk_6",
        "newProp": "Performance"
      }
    }
  ]
}

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.

Header
Accept: application/json 
Content-Type: application/json
accept-language: en_US
Request
GET https://10.103.73.73/api/types/capabilityProfile
/instances?fields=se::@enumString(spaceEfficiencies)
&compact=true&with_entrycount=true
Response body for a successful response
{
  "@base": "https://10.103.73.73/api/types/capabilityProfile/instances?fields=se::@enumString(spaceEfficiencies),id&per_page=2000&compact=true",
  "updated": "2016-06-02T03:09:44.668Z",
  "links": [
    {
      "rel": "self",
      "href": "&page=1"
    }
  ],
  "entryCount": 1,
  "entries": [
    {
      "content": {
        "id": "cp_1",
        "se": [
          "Thin",
          "Thick"
        ]
      }
    }
  ]
}

Rate this content

Accurate
Useful
Easy to understand
Was this article helpful?
0/3000 characters
  Please provide ratings (1-5 stars).
  Please provide ratings (1-5 stars).
  Please provide ratings (1-5 stars).
  Please select whether the article was helpful or not.
  Comments cannot contain these special characters: <>()\