I'm looking for the best practices on RESTful API design for the following use case:
Domain Object Vehicle:
class Vehicle {
private String vehicleType;
private String colour;
private String transmission;
private String yearOfIssue;
}
An example object:
Vehicle = {vehicleType : 'Car', colour : 'Red', transmission : 'Automatic', yearOfIssue : '2008'};
In this domain model, there is no single field unique identifier (e.g. vehicleId), but rather all fields of the object together form the primary key (this constraint is there in the database layer).
We have no flexibility to alter this domain model to add a single field unique identifier.
So my question is as follows - If I want to add a simple REST API on top of this domain object that provides simple functionality to CREATE, UPDATE, DELETE and GET Vehicles, what is the best practice for the PATH endpoints for these methods?
Following the above example, if the domain model were to have a single field unique identifier vehicleId, then I can imagine the following endpoints:
GET /vehicles/:vehicleId
PUT /vehicles/:vehicleId
DELETE /vehicles/:vehicleId
I'm not aware of a pattern that exists similar to this for composite keys as:
GET /vehicles/:vehicleTypecolourtransmissionyearOfIssue
GET /vehicles/CarRedAutomatic2008
seems incorrect.
Any advice on a good pattern to follow for this use case would be greatly appreciated.
Thanks