Skip to content

Latest commit

 

History

History
421 lines (316 loc) · 7.92 KB

File metadata and controls

421 lines (316 loc) · 7.92 KB

NGSI entity

This custom node is a simple node that allows to create, read, upsert or delete an NGSIv2 entity.

Contents

Details

Create an entity

It allows to create a NGSIv2 entity.

Properties

  • name: A name for a node instance
  • Context Broker: An endpoint of a context broker
  • ServicePath: FIWARE Service Path
  • Action type: create
  • Representation: normalized or keyValues
  • Encode / Decode forbidden chars: off or on

Input

payload JSON Object

A msg.payload should contain an entity to create.

{
  "id": "E",
  "type": "T",
  "temperature": {
    "type": "Number",
    "value": 25,
    "metadata": {
      "TimeInstant": {
        "type": "DateTime",
        "value": "2023-02-10T20:33:53.199Z"
      }
    }
  },
  "relativeHumidity": {
    "type": "Number",
    "value": 45,
    "metadata": {}
  },
  "atmosphericPressure": {
    "type": "Number",
    "value": 1003.5,
    "metadata": {}
  }
}

Output

statusCode Number

A msg.statusCode contains a status code.

201

Read an entity

It allows to read a NGSIv2 entity.

Properties

  • name: A name for a node instance
  • Context Broker: An endpoint of a context broker
  • ServicePath: FIWARE Service Path
  • Action type: read
  • Entity id: id of an entity to be read
  • Entity type: type of an entity to be read
  • attributes: list of attributes of an entity to be read
  • Representation: normalized or keyValues
  • Date Modified: retrieve attribute and metadata of dateModified
  • Encode / Decode forbidden chars: off or on

Input

payload string or JSON Object

A msg.payload should contain an entity Id to read the NGSI v2 entity.

urn:ngsi-ld:Building:store001

A msg.payload should contain a condition to read the NGSI v2 entity.

{
  "id": "urn:ngsi-ld:Building:store001",
  "type": "Building",
  "attrs": "humidity",
  "keyValues": true,
  "dateModified": false
}

Output

payload JSON Object

A msg.payload contains the NGSIv2 entity.

{
  "id": "E1",
  "type": "T",
  "humidity": {
    "type": "Number",
    "value": 51,
    "metadata": {}
  },
  "temperature": {
    "type": "Number",
    "value": 25,
    "metadata": {}
  }
}

statusCode Number

A msg.statusCode contains a status code.

200

Upsert an entity

It allows to upsert a NGSIv2 entity.

Properties

  • name: A name for a node instance
  • Context Broker: An endpoint of a context broker
  • ServicePath: FIWARE Service Path
  • Action type: upsert
  • Representation: normalized or keyValues
  • Encode / Decode forbidden chars: off or on

Input

payload JSON Object

A msg.payload should contain an entity to upsert.

{
  "id": "E",
  "type": "T",
  "temperature": {
    "type": "Number",
    "value": 25,
    "metadata": {
      "TimeInstant": {
        "type": "DateTime",
        "value": "2023-02-10T20:33:53.199Z"
      }
    }
  },
  "relativeHumidity": {
    "type": "Number",
    "value": 45,
    "metadata": {}
  },
  "atmosphericPressure": {
    "type": "Number",
    "value": 1003.5,
    "metadata": {}
  }
}

Output

statusCode Number

A msg.statusCode contains a status code.

204

Delete an entity

It allows to delete a NGSIv2 entity.

Properties

  • name: A name for a node instance
  • Context Broker: An endpoint of a context broker
  • ServicePath: FIWARE Service Path
  • Action type: delete
  • Entity id: id of an entity to be deleted
  • Entity type: type of an entity to be deleted
  • Encode / Decode forbidden chars: off or on

Input

payload string or JSON Object

A msg.payload should contain an entity Id to delete the NGSI v2 entity.

urn:ngsi-ld:Building:store001

A msg.payload should contain a condition to delete the NGSI v2 entity.

{
  "id": "urn:ngsi-ld:Building:store001",
  "type": "Building",
}

Output

statusCode Number

A msg.statusCode contains a status code.

204

Use value of actionType in payload

It allows to create, read, upsert or delete a NGSIv2 entity.

Properties

  • name: A name for a node instance
  • Context Broker: An endpoint of a context broker
  • ServicePath: FIWARE Service Path
  • Action type: value of actionType in payload
  • Entity id: Id of an entity to be created, read, upserted or deleted
  • Entity type: Type of an entity to be created, read, upserted or deleted
  • Representation: normalized or keyValues
  • Date Modified: retrieve attribute and metadata of dateModified
  • Encode / Decode forbidden chars: off or on

Input (create)

payload JSON Object

When creating an entity, a msg.payload should contain a JSON Object with actionType and entity.

{
  "actionType": "create",
  "entity": {
    "id": "E",
    "type": "T",
    "temperature": {
      "type": "Number",
      "value": 25,
      "metadata": {
        "TimeInstant": {
          "type": "DateTime",
          "value": "2023-02-10T20:33:53.199Z"
        }
      }
    },
    "relativeHumidity": {
      "type": "Number",
      "value": 45,
      "metadata": {}
    },
    "atmosphericPressure": {
      "type": "Number",
      "value": 1003.5,
      "metadata": {}
    }
  }
}

Output (create)

statusCode Number

A msg.statusCode contains a status code.

201

Input (read)

payload JSON Object

When reading an entity, a msg.payload should contain a JSON Object with actionType and related information the entity to be read.

{
  "actionType": "read",
  "id": "E",
  "type": "T"
}

Output (read)

payload JSON Object

A msg.payload contains an object representing the entity.

{
  "type":"Number",
  "value":45,
  "metadata":{}
}

statusCode Number

A msg.statusCode contains a status code.

200

Input (upsert)

payload JSON Object

When upserting an entity, a msg.payload should contain a JSON Object with actionType and entity.

{
  "actionType": "upsert",
  "entity": {
    "id": "E",
    "type": "T",
    "temperature": {
      "type": "Number",
      "value": 29,
      "metadata": {
        "TimeInstant": {
          "type": "DateTime",
          "value": "2023-02-10T20:33:53.199Z"
        }
      }
    },
    "relativeHumidity": {
      "type": "Number",
      "value": 58,
      "metadata": {}
    },
    "atmosphericPressure": {
      "type": "Number",
      "value": 1234.5,
      "metadata": {}
    }
  }
}

Output (upsert)

statusCode Number

A msg.statusCode contains a status code.

204

Input (delete)

payload JSON Object

When deleting an entity, a msg.payload should contain a JSON Object with actionType and related information the entity to be deleted.

{
  "actionType": "delete",
  "id": "E",
  "type": "T"
}

Output (delete)

statusCode Number

A msg.statusCode contains a status code.

204