Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
134 lines (90 sloc) 6.1 KB

NgsiV2.AttributeValueApi

All URIs are relative to http://orion.lab.fiware.org:1026/v2

Method HTTP request Description
getAttributeValue GET /entities/{entityId}/attrs/{attrName}/value
updateAttributeValue PUT /entities/{entityId}/attrs/{attrName}/value

getAttributeValue

AttributeValue getAttributeValue(entityId, attrName, opts)

This operation returns the `value` property with the value of the attribute. * If attribute value is JSON Array or Object: * If `Accept` header can be expanded to `application/json` or `text/plain` return the value as a JSON with a response type of application/json or text/plain (whichever is the first in `Accept` header or `application/json` in the case of `Accept: /`). * Else return a HTTP error "406 Not Acceptable: accepted MIME types: application/json, text/plain" * If attribute value is a string, number, null or boolean: * If `Accept` header can be expanded to text/plain return the value as text. In case of a string, citation marks are used at the begining and end. * Else return a HTTP error "406 Not Acceptable: accepted MIME types: text/plain" Response: * Successful operation uses 200 OK. * Errors use a non-2xx and (optionally) an error payload. See subsection on "Error Responses" for more details.

Example

var NgsiV2 = require('ngsi_v2');
var defaultClient = NgsiV2.ApiClient.instance;

// Configure API key authorization: fiware_token
var fiware_token = defaultClient.authentications['fiware_token'];
fiware_token.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//fiware_token.apiKeyPrefix = 'Token';

var apiInstance = new NgsiV2.AttributeValueApi();

var entityId = "entityId_example"; // String | Id of the entity in question

var attrName = "attrName_example"; // String | Name of the attribute to be retrieved.

var opts = { 
  'type': "type_example" // String | Entity type, to avoid ambiguity in the case there are several entities with the same entity id.
};

var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
};
apiInstance.getAttributeValue(entityId, attrName, opts, callback);

Parameters

Name Type Description Notes
entityId String Id of the entity in question
attrName String Name of the attribute to be retrieved.
type String Entity type, to avoid ambiguity in the case there are several entities with the same entity id. [optional]

Return type

AttributeValue

Authorization

fiware_token

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json, plain/text

updateAttributeValue

updateAttributeValue(entityId, attrName, body, opts)

The request payload is the new attribute value. * If the request payload MIME type is `application/json`, then the value of the attribute is set to the JSON object or array coded in the payload (if the payload is not a valid JSON document, then an error is returned). * If the request payload MIME type is `text/plain`, then the following algorithm is applied to the payload: * If the payload starts and ends with citation-marks (`"`), the value is taken as a string (the citation marks themselves are not considered part of the string) * If `true` or `false`, the value is taken as a boolean. * If `null`, the value is taken as null. * If these first three tests 'fail', the text is interpreted as a number. * If not a valid number, then an error is returned and the attribute's value is unchanged. The payload MIME type in the request is specified in the `Content-Type` HTTP header. Response: * Successful operation uses 204 No Content * Errors use a non-2xx and (optionally) an error payload. See subsection on "Error Responses" for more details.

Example

var NgsiV2 = require('ngsi_v2');
var defaultClient = NgsiV2.ApiClient.instance;

// Configure API key authorization: fiware_token
var fiware_token = defaultClient.authentications['fiware_token'];
fiware_token.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//fiware_token.apiKeyPrefix = 'Token';

var apiInstance = new NgsiV2.AttributeValueApi();

var entityId = "entityId_example"; // String | Id of the entity to be updated.

var attrName = "attrName_example"; // String | Attribute name.

var body = new NgsiV2.AttributeValue(); // AttributeValue | JSON AttributeValue Representation

var opts = { 
  'type': "type_example" // String | Entity type, to avoid ambiguity in the case there are several entities with the same entity id.
};

var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully.');
  }
};
apiInstance.updateAttributeValue(entityId, attrName, body, opts, callback);

Parameters

Name Type Description Notes
entityId String Id of the entity to be updated.
attrName String Attribute name.
body AttributeValue JSON AttributeValue Representation
type String Entity type, to avoid ambiguity in the case there are several entities with the same entity id. [optional]

Return type

null (empty response body)

Authorization

fiware_token

HTTP request headers

  • Content-Type: application/json, plain/text
  • Accept: application/json