Skip to main content
Version: 2.7

Entity Collections

The entity collection node must be created using the /nodes URL. Once created, the /entities URL can be used to manipulate the content of the collection.

Get the Entity Schema

Gets the entity schema of a collection. The schema describes fields and data types:

HTTP Method:GET
HTTP Url:entities/collection
HTTP Query-Parameter:id: Id of the collection as System.Guid
Request Content-Typetext/xml
Request Body-
Response Content-Typetext/xml
Response ContentSchema

Example:

GET http://localhost:8081/entities/collection?id=f9a4300a-654b-42cf-9f54-f866184b7352

Response Body:

<HumanOS.Stream>
<EntitySchema>
<Field>
<Name>FirstName</Name>
<DataType>System.String</DataType>
<IsKey>false</IsKey>
</Field>
<Field>
<Name>LastName</Name>
<DataType>System.String</DataType>
<IsKey>false</IsKey>
<DefaultValue>0</DefaultValue>
</Field>
<Field>
<Name>Id</Name>
<DataType>System.Guid</DataType>
<IsKey>true</IsKey>
</Field>
</EntitySchema>
</HumanOS.Stream>

Adding Entities

Adds entities to the collection. The call fails if an entity with its key already exists in the collection.

HTTP MethodPOST
HTTP Url:entities/collection
HTTP Query-Parameter:id: Id of the collection as System.Guid
Request Content-Typetext/xml; text/json
Request BodyStream of entities to add
Response Content-Typetext/text
Response Content“OK”

Example:

POST http://localhost:8081/entities/collection?id=f9a4300a-654b-42cf-9f54-f866184b7352

Request Body:

<HumanOS.Stream>
<EntityCollection>
<Entity>
<Id>{16BB1E9F-ACFA-4D42-8DE6-3598C7C79DC6}</Id>
<LastName>Hadorn</LastName>
<FirstName>Benjamin</FirstName>
</Entity>
<Entity>
<Id>{41F6F2F4-F420-4457-BBCF-BD610FD39342}</Id>
<LastName>Hadorn</LastName>
<FirstName>Matthias</FirstName>
</Entity>
</EntityCollection>
</HumanOS.Stream>

Updating Entities

Adds entities to the collection. The call fails if an entity with its key already exists in the collection.

HTTP MethodPATCH
HTTP Url:entities/collection
HTTP Query-Parameter:id: Id of the collection as System.Guid
Request Content-Typetext/xml; text/json
Request BodyStream of entities to update
Response Content-Typetext/text
Response Content“OK”

Example:

PATCH http://localhost:8081/entities/collection?id=f9a4300a-654b-42cf-9f54-f866184b7352

Request Body:

<HumanOS.Stream>
<EntityCollection>
<Entity>
<Id>{16BB1E9F-ACFA-4D42-8DE6-3598C7C79DC6}</Id>
<LastName>Hadorn</LastName>
<FirstName>Benjamin</FirstName>
</Entity>
<Entity>
<Id>{41F6F2F4-F420-4457-BBCF-BD610FD39342}</Id>
<LastName>Hadorn</LastName>
<FirstName>Matthias</FirstName>
</Entity>
</EntityCollection>
</HumanOS.Stream>

Remove Entities

Removes entities from the collection.

HTTP MethodDELETE
HTTP Url:entities/collection
HTTP Query-Parameter:id: Id of the collection as System.Guid
Request Content-Typetext/xml; text/json
Request BodyStream of entities ids
Response Content-Typetext/text
Response Content“OK”

Example:

DELETE http://localhost:8081/entities/collection?id=f9a4300a-654b-42cf-9f54-f866184b7352

Request Body:

<HumanOS.Stream>
<EntityCollection>
<Entity>
<Id>{16BB1E9F-ACFA-4D42-8DE6-3598C7C79DC6}</Id>
</Entity>
<Entity>
<Id>{41F6F2F4-F420-4457-BBCF-BD610FD39342}</Id>
</Entity>
</EntityCollection>
</HumanOS.Stream>

Get All Entities

Gets all entities of an entity collection:

HTTP MethodGET
HTTP Url:entities/all
HTTP Query-Parameter:id: Id of the collection as System.Guid
Request Content-Type-
Request Body-
Response Content-Typetext/xml; text/json
Response ContentEntity stream

Example:

GET http://localhost:8081/entities/all?id=f9a4300a-654b-42cf-9f54-f866184b7352

Query Entities

Queries a subset of the entity collection

HTTP Method:GET
HTTP Url:entities/query
HTTP Query-Parameter:id: Id of the collection as System.Guid
Request Content-Typetext/xml
Request BodyQuery and filter criteria
Response Content-Typetext/xml
Response ContentEntity stream

Example:

POST http://localhost:8081/entities/query?id=f9a4300a-654b-42cf-9f54-f866184b7352

Request Body:

<HumanOS.Stream>
<EntityQuery>
<Expression type="binary" op="AND">
<Expression type="unary" op="NOT">
<Expression type="field" name="HasChildren"/>
</Expression>
<Expression type="binary" op="EQ">
<Expression type="field" name="FirstName"/>
<Expression type="const" datatype="System.String">Hans</Expression>
</Expression>
</Expression>
</EntityQuery>
</HumanOS.Stream>

This is translated to: n => !n.HasChildren && n.FirstName == "Hans"

Response Body:

<HumanOS.Stream>
<EntityCollection>
<Entity>
<Id>{16BB1E9F-ACFA-4D42-8DE6-3598C7C79DC6}</Id>
<LastName>Muster</LastName>
<FirstName>Hans</FirstName>
<HasChildren>false</HasChildren>
</Entity>
</HumanOS.Stream>

Query Language

The query language accepts only Boolean expressions.

Expression :== 		BinaryExpression | UnaryExpression | Constant | Field
BinaryExpression:== <Expression type=”binary” op=”[Binary_Operation]”>
[Expression]
[Expression]
</Expression>
UnaryExpression:== <Expression type=”unary” op=”[Unary_Operation]”>
[Expression]
</Expression>
Constant :== <Expression type=”const” datatype=”[DataType]”>
[Value]
</Expression>
Field :== <Expression type=”field” name=”[Name]”/>
Binary_Operation:== “EQ” | “NEQ” | “GT” | “LT” | “LE” | “GE” | “AND” | “OR”
Unary_Operation:== “NOT”
Value:== Number | Text
DataType:== {C# System Type}
Name:== {Field name}

Example 1:

n => n.FirstName == “Benjamin”
<HumanOS.Stream>
<EntityQuery>
<Expression type="binary" op="EQ">
<Expression type="field" name="FirstName"/>
<Expression type="const" datatype="System.String">Benjamin</Expression>
</Expression>
</EntityQuery>
</HumanOS.Stream>

Example 2:

n => n.Age > 39
<HumanOS.Stream>
<EntityQuery>
<Expression type="binary" op="GT">
<Expression type="field" name="Age"/>
<Expression type="const" datatype="System.Int32">39</Expression>
</Expression>
</EntityQuery>
</HumanOS.Stream>

Example 3:

n => n.Age <= 40 || n.LastName == “Hadorn”
<HumanOS.Stream>
<EntityQuery>
<Expression type="binary" op="OR">
<Expression type="binary" op="LE">
<Expression type="field" name="Age"/>
<Expression type="const" datatype="System.Int32">40</Expression>
</Expression>
<Expression type="binary" op="EQ">
<Expression type="field" name="LastName"/>
<Expression type="const" datatype="System.String">Hadorn</Expression>
</Expression>
</Expression>
</EntityQuery>
</HumanOS.Stream>