Skip to content
logoBack to home screen

REST API - CRUD on Entity Properties

The /rest/v2/entities endpoint allows you to perform CRUD operations on entity properties.

General

This endpoint contains the APIs used for working with entity properties.

The URL for working with properties is always: /rest/v2/properties/<accessName>/<entity.TypeSignature>/<id>(/<partition>)/<property>

URL PartDescription
accessNameName of the access that contains the entity.
entity.TypeSignatureType signature (or simple name, if only one entity type with this name in the access) of the entity to query.
idid of the entity
partitionPartition of the entity, if there are more than one entities with the same id in the access. This parameter is optional.

GET

The GET method returns the value of the property.

Endpoint Configuration

  • Projection

    ItemDescription
    URL Parameterprojection=<...>
    Header Parametergm-projection=<...>
    Typeenvelope or value
    Default Valuevalue
    Descriptionenvelope: returns the entire PropertyQueryResult
    value: returns the value of the property, encoded in the required mimeType
  • Write Empty Properties

    ItemDescription
    URL Parameterwrite-empty-properties=<...>
    Header Parametergm-write-empty-properties=<...>
    TypeBoolean
    Default Valuefalse
    DescriptionWhen this flag is set to true, the marshaller returns all properties that are set to null or are empty (for maps, sets and lists)
  • Stabilize Order

    ItemDescription
    URL Parameterstabilize-order=<...>
    Header Parametergm-stabilize-order=<...>
    TypeBoolean
    Default Valuefalse
    DescriptionWhen this flag is set to true, the marshaller ensures that properties in different instances of the same entity are always in the same order. This is especially useful when you return empty properties using the writeEmptyProperties parameter.
  • Prettiness

    ItemDescription
    URL Parameterprettiness=<...>
    Header Parametergm-prettiness=<...>
    Typenone, low, med or high
    Default Valuemid
    DescriptionThis property represents the level of prettiness used when writing the assembly back to the body of the response.
    Each implementation of the marshaller may use this value slightly differently, but as a rule of thumb, none contains no new lines or indentation information and should only be used to minimize the size of the body and high provides the best possible indentation for humans to read.
  • Depth

    ItemDescription
    URL Parameterdepth=<...>
    Header Parametergm-depth=<...>
    Typeshallow - returns only the first level
    reachable - returns the whole assembly
    number >= 0 - returns the provided level, starting at 0
    Default Value3
    DescriptionFor complex assemblies, this property specifies how deep the returned assembly should be traversed before being returned. This property is a simplified TraversingCriterion.
  • Entity Recurrence Depth

    ItemDescription
    URL Parameterentity-recurrence-depth=<...>
    Header Parametergm-entity-recurrence-depth=<...>
    Typenumber >= -1 - returns the provided level, starting at 0
    Default Value0
    DescriptionFor complex entities which have recurrent entities (entities that appear more than once in the returned JSON), this property specifies how deep the returned recurrent entity should be traversed before being returned. This property is used to avoid _id and _ref in the returned JSON.

The entity-recurrence-depth parameter is applied after the depth parameter.

  • Type Explicitness

    ItemDescription
    URL Parametertype-explicitness=<...>
    Header Parametergm-type-explicitness=<...>
    Typeauto, always, entities or polymorphic
    Default Valueauto
    DescriptionThis property is used to decide whether _type is present in marshalled JSON.

    This property is only available in JSON marshaller.

    auto - _type is always returned for entity types and properties that are not known simple types (String, integer, etc).
    always - _type is always returned for every element
    entities - _type is always returned for entity types and properties that are not known simple types (String, integer, etc).
    polymorphic - _type is returned for every element if the actual type cannot be established from the context.
  • Identity Management Mode

    ItemDescription
    URL Parameteridentity-management-mode=<...>
    Header Parametergm-identity-management-mode=<...>
    Typeoff, auto, _id or id
    Default Valueauto
    DescriptionRepresents how duplicates of objects should be unmarshalled.

    auto - Depending on the parsed assembly, the marshaller automatically detects the identification information and uses it for identity management.
    off - No identity management.
    _id - The internally generated _id information is used, if available.
    id - The id property is used, if available.

POST

The POST method can be used to edit collection properties, i.e. map, set or list properties.

If you use this method on a non-collection property, a 400 Bad request is thrown.

This method supports adding elements to collections (default behavior) or removing elements from collections (with URL parameter remove=true or Header gm-remove=true).

Below you can find the possibilities for the content of the body of the method and their effect depending on the remove property and the type of of the property (list, set or map):

Body ContentRemoveProperty Type - ListProperty Type - SetProperty Type - Map
single valueempty or falseAdd the value to the listAdds the value to the set.400: The body should contain a map
single valuetrue400: body must be a map<int, value>Removes the value from the set.400: The body should contain a map
list<value>empty or falseAdd the values to the end of the list.Adds the values to the set.400: The body should contain a map
list<value>true400: Body must be a map<int, value>Removes the values from the set.400: The body should contain a map
map<key,value>empty or falseKeys must be of type integer.

Inserts the value at the given positions.
If the key is bigger than the size of the list, the value is added at the end of the list.
400: The body should contain value or list of valuesPuts the given values in the map.
map<key,value>trueKeys must be of type integer.

Removes the values at the given position. If the value in the list at provided position (key) is not the same as the value given in the body, the value is removed from the list.
400: The body should contain value or list of valuesRemoves the values for the given keys.
  • Changing a complex property

    In this example you will add Frank and another person with ID 28 as friends of John's. If you wanted to remove some of John's friends, you should provide the endpoint parameter remove=true (or header gm-remove value true) in your call and provide the values to be removed in the body.

    • Method: POST
    • URL: http://localhost:8080/tribefire-services/rest/v2/properties/demo.PersonAccess/Person/{id}/friends?sessionId=xxx
    • Headers:
      • Accept: application/json
      • Content-Type: application/json
    • Body:
    
    {
      "_type": "map",
      "value": [
        {
          "key": 0,
          "value": {
            "_type": "tribefire.demo.model.data.Person",
            "id": {
              "_type": "long",
              "value": 1
            }
          }
        },
        {
          "key": 1,
          "value": {
            "_type": "tribefire.demo.model.data.Person",
            "id": {
              "_type": "long",
              "value": 28
            }
          }
        }
      ]
    }
    
    

    This call returns:

    true
    

Endpoint Configuration

  • Remove

    ItemDescription
    URL Parameterremove=<...>
    Header Parametergm-remove=<...>
    TypeBoolean
    Default Valuefalse
    DescriptionWhen set to true, removes the values in the body from the collection instead of adding them.
  • Projection

    ItemDescription
    URL Parameterprojection=<...>
    Header Parametergm-projection=<...>
    Typeenvelope or success
    Default Valuesuccess
    DescriptionReturn type for the call.

    envelope: returns the entire ManipulationResponse
    success: returns the value true
  • Write Empty Properties

    ItemDescription
    URL Parameterwrite-empty-properties=<...>
    Header Parametergm-write-empty-properties=<...>
    TypeBoolean
    Default Valuefalse
    DescriptionWhen this flag is set to true, the marshaller returns all properties that are set to null or are empty (for maps, sets and lists)
  • Prettiness

    ItemDescription
    URL Parameterprettiness=<...>
    Header Parametergm-prettiness=<...>
    Typenone, low, med or high
    Default Valuemid
    DescriptionThis property represents the level of prettiness used when writing the assembly back to the body of the response.
    Each implementation of the marshaller may use this value slightly differently, but as a rule of thumb, none contains no new lines or indentation information and should only be used to minimize the size of the body and high provides the best possible indentation for humans to read.
  • Stabilize Order

    ItemDescription
    URL Parameterstabilize-order=<...>
    Header Parametergm-stabilize-order=<...>
    TypeBoolean
    Default Valuefalse
    DescriptionWhen this flag is set to true, the marshaller ensures that properties in different instances of the same entity are always in the same order. This is especially useful when you return empty properties using the writeEmptyProperties parameter.
  • Depth

    ItemDescription
    URL Parameterdepth=<...>
    Header Parametergm-depth=<...>
    Typeshallow - returns only the first level
    reachable - returns the whole assembly
    number >= 0 - returns the provided level, starting at 0
    Default Value3
    DescriptionFor complex assemblies, this property specifies how deep the returned assembly should be traversed before being returned. This property is a simplified TraversingCriterion.
  • Entity Recurrence Depth

    ItemDescription
    URL Parameterentity-recurrence-depth=<...>
    Header Parametergm-entity-recurrence-depth=<...>
    Typenumber >= -1 - returns the provided level, starting at 0
    Default Value0
    DescriptionFor complex entities which have recurrent entities (entities that appear more than once in the returned JSON), this property specifies how deep the returned recurrent entity should be traversed before being returned. This property is used to avoid _id and _ref in the returned JSON.

The entity-recurrence-depth parameter is applied after the depth parameter.

  • Type Explicitness

    ItemDescription
    URL Parametertype-explicitness=<...>
    Header Parametergm-type-explicitness=<...>
    Typeauto, always, entities or polymorphic
    Default Valueauto
    DescriptionThis property is used to decide whether _type is present in marshalled JSON.

    This property is only available in JSON marshaller.

    auto - _type is always returned for entity types and properties that are not known simple types (String, integer, etc).
    always - _type is always returned for every element
    entities - _type is always returned for entity types and properties that are not known simple types (String, integer, etc).
    polymorphic - _type is returned for every element if the actual type cannot be established from the context.
  • Identity Management Mode

    ItemDescription
    URL ParameteridentityManagementMode=<...>
    Header Parametergm-identityManagementMode=<...>
    Typeoff, auto, _id or id
    Default Valueauto
    DescriptionRepresents how duplicates of objects should be unmarshalled.

    auto - Depending on the parsed assembly, the marshaller automatically detects the identification information and uses it for identity management.
    off - No identity management.
    _id - The internally generated _id information is used, if available.
    id - The id property is used, if available.

PUT and PATCH

The PUT and PATCH methods can be used to set the value of the property to the value provided in the body of the call.

You can call those methods on properties of types:

  • list
  • set
  • map

Calling those methods on one of the above property type replaces the content of the collection by the content passed in the body.

This API is idempotent, which means you can call it multiple times, but the result does not change after the initial call.

  • Changing a simple property

    In this example we will add Frank as a friend of John's. We are posting the {id} parameter value 2 in the URL, because 2 is Frank's ID:

    • Method: PUT or PATCH
    • URL: http://localhost:8080/tribefire-services/rest/v2/properties/demo.PersonAccess/Person/{id}/name?sessionId=xxx
    • Headers:
      • Accept: application/json
      • Content-Type: application/json
    • Body:
    "Bar"
    

    This call returns:

    true
    

Endpoint Configuration

  • Projection

    ItemDescription
    URL Parameterprojection=<...>
    Header Parametergm-projection=<...>
    Typeenvelope or success
    Default Valuesuccess
    DescriptionReturn type for the call.

    envelope: returns the entire ManipulationResponse
    success: returns the value true
  • Write Empty Properties

    ItemDescription
    URL Parameterwrite-empty-properties=<...>
    Header Parametergm-write-empty-properties=<...>
    TypeBoolean
    Default Valuefalse
    DescriptionWhen this flag is set to true, the marshaller returns all properties that are set to null or are empty (for maps, sets and lists)
  • Prettiness

    ItemDescription
    URL Parameterprettiness=<...>
    Header Parametergm-prettiness=<...>
    Typenone, low, med or high
    Default Valuemid
    DescriptionThis property represents the level of prettiness used when writing the assembly back to the body of the response.
    Each implementation of the marshaller may use this value slightly differently, but as a rule of thumb, none contains no new lines or indentation information and should only be used to minimize the size of the body and high provides the best possible indentation for humans to read.
  • Stabilize Order

    ItemDescription
    URL Parameterstabilize-order=<...>
    Header Parametergm-stabilize-order=<...>
    TypeBoolean
    Default Valuefalse
    DescriptionWhen this flag is set to true, the marshaller ensures that properties in different instances of the same entity are always in the same order. This is especially useful when you return empty properties using the writeEmptyProperties parameter.
  • Depth

    ItemDescription
    URL Parameterdepth=<...>
    Header Parametergm-depth=<...>
    Typeshallow - returns only the first level
    reachable - returns the whole assembly
    number >= 0 - returns the provided level, starting at 0
    Default Value3
    DescriptionFor complex assemblies, this property specifies how deep the returned assembly should be traversed before being returned. This property is a simplified TraversingCriterion.
  • Entity Recurrence Depth

    ItemDescription
    URL Parameterentity-recurrence-depth=<...>
    Header Parametergm-entity-recurrence-depth=<...>
    Typenumber >= -1 - returns the provided level, starting at 0
    Default Value0
    DescriptionFor complex entities which have recurrent entities (entities that appear more than once in the returned JSON), this property specifies how deep the returned recurrent entity should be traversed before being returned. This property is used to avoid _id and _ref in the returned JSON.

The entity-recurrence-depth parameter is applied after the depth parameter.

  • Type Explicitness

    ItemDescription
    URL Parametertype-explicitness=<...>
    Header Parametergm-type-explicitness=<...>
    Typeauto, always, entities or polymorphic
    Default Valueauto
    DescriptionThis property is used to decide whether _type is present in marshalled JSON.

    This property is only available in JSON marshaller.

    auto - _type is always returned for entity types and properties that are not known simple types (String, integer, etc).
    always - _type is always returned for every element
    entities - _type is always returned for entity types and properties that are not known simple types (String, integer, etc).
    polymorphic - _type is returned for every element if the actual type cannot be established from the context.
  • Identity Management Mode

    ItemDescription
    URL ParameteridentityManagementMode=<...>
    Header Parametergm-identityManagementMode=<...>
    Typeoff, auto, _id or id
    Default Valueauto
    DescriptionRepresents how duplicates of objects should be unmarshalled.

    auto - Depending on the parsed assembly, the marshaller automatically detects the identification information and uses it for identity management.
    off - No identity management.
    _id - The internally generated _id information is used, if available.
    id - The id property is used, if available.

DELETE

The DELETE method can be used to set the value of a property to null or the default empty value.

Property Type | Default Empty Value boolean | false int
long
float
double
decimal | 0 date
entity
enum
object
string | null list
set
map | empty collection

Endpoint Configuration

  • Projection

    ItemDescription
    URL Parameterprojection=<...>
    Header Parametergm-projection=<...>
    Typeenvelope or success
    Default Valuesuccess
    DescriptionReturn type for the call.

    envelope: returns the entire ManipulationResponse
    success: returns the value true
  • Write Empty Properties

    ItemDescription
    URL Parameterwrite-empty-properties=<...>
    Header Parametergm-write-empty-properties=<...>
    TypeBoolean
    Default Valuefalse
    DescriptionWhen this flag is set to true, the marshaller returns all properties that are set to null or are empty (for maps, sets and lists)
  • Prettiness

    ItemDescription
    URL Parameterprettiness=<...>
    Header Parametergm-prettiness=<...>
    Typenone, low, med or high
    Default Valuemid
    DescriptionThis property represents the level of prettiness used when writing the assembly back to the body of the response.
    Each implementation of the marshaller may use this value slightly differently, but as a rule of thumb, none contains no new lines or indentation information and should only be used to minimize the size of the body and high provides the best possible indentation for humans to read.
  • Stabilize Order

    ItemDescription
    URL Parameterstabilize-order=<...>
    Header Parametergm-stabilize-order=<...>
    TypeBoolean
    Default Valuefalse
    DescriptionWhen this flag is set to true, the marshaller ensures that properties in different instances of the same entity are always in the same order. This is especially useful when you return empty properties using the writeEmptyProperties parameter.
  • Depth

    ItemDescription
    URL Parameterdepth=<...>
    Header Parametergm-depth=<...>
    Typeshallow - returns only the first level
    reachable - returns the whole assembly
    number >= 0 - returns the provided level, starting at 0
    Default Value3
    DescriptionFor complex assemblies, this property specifies how deep the returned assembly should be traversed before being returned. This property is a simplified TraversingCriterion.
  • Entity Recurrence Depth

    ItemDescription
    URL Parameterentity-recurrence-depth=<...>
    Header Parametergm-entity-recurrence-depth=<...>
    Typenumber >= -1 - returns the provided level, starting at 0
    Default Value0
    DescriptionFor complex entities which have recurrent entities (entities that appear more than once in the returned JSON), this property specifies how deep the returned recurrent entity should be traversed before being returned. This property is used to avoid _id and _ref in the returned JSON.

The entity-recurrence-depth parameter is applied after the depth parameter.

  • Type Explicitness

    ItemDescription
    URL Parametertype-explicitness=<...>
    Header Parametergm-type-explicitness=<...>
    Typeauto, always, entities or polymorphic
    Default Valueauto
    DescriptionThis property is used to decide whether _type is present in marshalled JSON.

    This property is only available in JSON marshaller.

    auto - _type is always returned for entity types and properties that are not known simple types (String, integer, etc).
    always - _type is always returned for every element
    entities - _type is always returned for entity types and properties that are not known simple types (String, integer, etc).
    polymorphic - _type is returned for every element if the actual type cannot be established from the context.
  • Identity Management Mode

    ItemDescription
    URL ParameteridentityManagementMode=<...>
    Header Parametergm-identityManagementMode=<...>
    Typeoff, auto, _id or id
    Default Valueauto
    DescriptionRepresents how duplicates of objects should be unmarshalled.

    auto - Depending on the parsed assembly, the marshaller automatically detects the identification information and uses it for identity management.
    off - No identity management.
    _id - The internally generated _id information is used, if available.
    id - The id property is used, if available.

Try it Out

If you want to experiment with the API for yourself, use our integrated Swagger UI.

For more information, see Using Swagger UI.