Add current droplet guid in apps relationships
gmllt opened this issue · 3 comments
Issue
There is no way to bundle current droplets and applications using /v3/apps
and /v3/droplets
.
Context
The only way to retrieve the current droplet of an application via the API is to go through the /v3/apps/:app_guid/droplets/current
or /v3/apps/:app_guid/relationships/current_droplet
endpoints.
In a context where we want to retrieve all the applications (more than 3000 in my case) and their current droplet, it is therefore necessary to make one request per application (more than 3000 requests).
Possible Fix
Add relationship information with a current droplet in API responses displaying apps.
{
...,
"relationships": {
"current_droplet": {
"data": {
"guid": "<droplet-guid>"
}
}
},
...
}
This can be added quickly by making the droplet_guid
field of the apps
table visible via the API, but this field is not updated when the current droplet is deleted and at this point, I don't know how to handle this correctly in the DeleteActionJob.
Example :
- I push a new application
- I delete the droplet
- The
droplet_guid
field in the database is still here, even if the droplet no longer exists.
[...] this field is not updated when the current droplet is deleted [...]
The question is, if it should be allowed to delete the current droplet at all?
@stephanme @Gerg @sethboyles - I think it might make sense to add a check to DELETE /v3/droplets/:guid
that prevents the deletion of the "current droplet". What do you think?
I've created a PR (#3926) that clears the droplet_guid
of an app when the corresponding droplet gets deleted.
I've created a PR (#3960) that prevents the deletion of the current app droplet.