Constraints can do different things, depending on the context they're used in:
- In the context of a
Location, access to the location is only allowed if the given constraint applies. - In the context of a
Trip, constraints can be used to define constraints that have to be met during the trip, e.g. if the temperature in a refrigerated trailer has to stay below a given maximum during the trip. - In the context of a
Shipment, constraints can be used to e.g. define minimum or maximum temperatures for shipments, or date time constraints for delivery.
Since OTM5.2 the timeWindowConstraint is supported which allows you to give (optionally) both the start and end time of the window between which something needs to occur. This replaces the old style where you had to use an and constraint in combination with the startDateTimeConstraint and endDateTimeConstraint. Since the new solution is shorter and simpler the startDateTimeConstraint and endDateTimeConstraint are deprecated.
Note that constraints can be nested and combined using the andConstraint, orConstraint and notConstraint.
- Mock serverhttps://otm-api-spec.redocly.app/_mock/api/5.9/otm/api/v5/constraints/{UUID}
- https://example.comhttps://example.com/api/v5/constraints/{UUID}
curl -i -X GET \
'https://otm-api-spec.redocly.app/_mock/api/5.9/otm/api/v5/constraints/{UUID}' \
-H 'Authorization: Bearer <YOUR_TOKEN_HERE>'Returned the entity with the provided UUID
Uniquely identifies this entity. A URI can be assigned by the client to indicate where more information can be retrieved. Note that every entity always has a unique EntityId. However since, OTM5.2 it is not required to send it in the request. One can be generated for you by the server.
Name of the entity. For display purposes and search only.
The last modified date of this entity. If none is given the creation date is used instead.
The context events provides some optional information about the events that can provide additional information on the current state of this entity.
For example: your system might send ETA information for the arrival of a vehicle on a location. To make it clear what caused this ETA to be updated, we can include some information about what caused this ETA update by including an event as context. If your ETA update was caused by a location update, this event can be included as context. If the ETA was caused by a traffic accident on the route of the vehicle, you can include that event in the context.
{ "and": [ { … }, { … }, { … } ], "type": "andConstraint" }
The enforceability of the constraint. Indicates whether or not the constraint is a suggestion/preference or something that is mandatory to adhere to.
External attributes are a simple way to add information in an OpenTripModel message that could not fit into one of the OTM fields otherwise. The externalAttributes member is meant for additional meta data and/or additional ID's of an entity. This can also help to identify an OTM entity in a system by the ID of that system.
Please, use this with caution: having too many external attributes can be a sign of not using OpenTripModel as it was intended.
{ "id": "89a7bb4d-8720-4db9-aef7-4c3309186c3e", "name": "Example combined constraint", "value": { "and": [ … ], "type": "andConstraint" } }