Calem Blogs

Blogs of CalemEAM

How to Include Class Attributes in API Fetch

​Class attributes are dynamic attributes relevant to an asset, or a location used as a configuration element (CE). For instance, an computer server asset may include memory size and CPU model while a truck tire asset may include minimum and maximum pressure values. See this blog for more information about class attributes.

Class attributes are not included by default when fetching data by Calem Enterprise APIs. For instance, a data fetch API call results in 500 records selected. These records will not include class attributes. A new query parameter is added to include class attributes. Adding this parameter may cause the API call to take longer time since Calem Enterprise needs to fill out class attributes for each record selected. 

  • "ctg" is the new query parameter. Its value of "1" (number one) will include class attributes in data fetch.
  • The code snippet (in PHP) below shows how this parameter is used in data search
    • "w" is the query string
    • "o" is the order by clause
    • "l" is the limit clause
    • "ctg" is the parameter to include class attributes
    • "$auth" is the authorization token calculated - see Calem Enterprise API Guide for more info.
//Fetch locations with location name starting with CTR
//Order by location ascending
//Get only 5 records starting from the 5th record
//Include class attriburtes in the data fetch
$w=urlencode("cm_location.location like 'CTR%'");
$o=urlencode("location ASC");
$l=urlencode("5,5");
$ctg=urlencode("1");

$response = \Httpful\Request::get('http://localhost/CalemEnt/trunk/api/search/cm_location?'
 .'w='.$w.'&o='.$o.'&l='.$l."&ctg=".$ctg)
 ->addHeader('Authorization', $auth)->send();
 

The response data is encoded in JSON. Category attributes (ending with "_wxyz" such as "_4859") are included as shown in the example below. 

{
...
"site_id_":"Site_001",
"company_id_":"CO_001",
"categorization_id_":"Linux",
"linux_core_4859":"linux_core_0104",
"linux_version_4859":"linux_version_0104",
"memory_gb_7958":"1104",
...
} 
Limit Editing to Approved Changes
How to Manage Asset and Location Status from Work ...

By accepting you will be accessing a service provided by a third-party external to https://eam.calemeam.com/