Im new to REST API design and I was wondering how one goes about designing for a problem defined as below. I have also outlined what I have in mind currently but obviously I see many problems with it
Cluster
has Alerts
Alerts
are instances of Alert_Type
Alert_Type
can be assigned to Cluster(s)
. In this case the Cluster
is Registered for Alerts
of Alert_Type
Alert_Type
can also be assigned to no Cluster
Alert
of instance Alert_Type
occurs in a Cluster
, some action
occurs if and only if Alert_Type
is registered with a Cluster
and Alert_Type
existsFor purposes of this question I am concerned with the REST API design and routes for the Alert_Type
Object and Cluster
Object
These are a subset of REST actions I can perform on Cluster
Object:
POST: Create a new Cluster
Object. In the object a field called registered_alerts
could contain the Alert_Type
objects registered for this Cluster
DELETE: Delete an existing Cluster
Object
GET (on /alert_types) : Will return a list of Alert_Type
objects registered with this Cluster
These are a subset of REST actions I can perform on Alert_Type
Object:
POST: Create a new Alert_Type
object.
DELETE: Delete an existing Alert_Type
object
GET: Get an existing Alert_Type
object
Now my questions:
Cluster
and Alert_Type
objects - I
know its not good design to duplicate the Alert_Type
objects in
the Cluster
objects. So maybe I should generate an id for each
Alert_Type
object and require that the Cluster
POST send an id
instead? And then maintain a list of id's in the Cluster
ObjectCluster
POST has a bunch of Alert_Type
ID's some that are
valid and some that are not, how do I handle that?Alert_Type
must be generated at the server,
and returned back in the response of the POST of Alert_Type
-
whats the correct way to do this in a REST compatible way ?Cluster
ID's in
the Alert_Type
objects? The only reason i can see the need for
this is when an Alert_Type
is deleted - and then that should
update the Cluster
objects that are watching for this Alert_Type
I try to give you a response for every point:
Hope can i help.