When using the REST API, I can delete a model, but when I query the model handle again, the model does not show deleted. Why is this?

Document ID : KB000125373
Last Modified Date : 28/01/2019
Show Technical Document Details
Question:
Why can I still see a model handle in Spectrum after using REST API to delete the model successfully?

Method     Request URL
Delete      http://<OneClick Server>:<port>/spectrum/restful/model/0x10006d2

Response
<delete-model-response>
<error>Success</error>
</delete-model-response>

Method     Request URL
Get           http://<OneClick Server>:<port>/spectrum/restful/model/0x10006d2

Response (model still exists)
<model-response-list total-models="1" throttle="1" error="EndOfResults">
<model-responses>
<model mh="0x10006d2" />
</model-responses>
</model-response-list>

As you can see the model does not show deleted and is still visible via REST API.
 
Environment:
Spectrum 10.2.x
Spectrum 10.3.x
Answer:
When a model is deleted, it is not deleted automatically, but is put on a model destruction list.  The model will not be visible in OneClick but it can be viewed by the REST API, which is why it is still showing up.  A stop of the SpectroSERVER will trigger the models in the model destruction list to be destroyed, and therefore after the SpectroSERVER has been restarted, then the model will no longer be visible, even with REST API.

After a SpectroSERVER stop and restart

Method     Request URL
Get           http://<OneClick Server>:<port>/spectrum/restful/model/0x10006d2

Response  (Expected Results)
<model-response-list total-models="1" throttle="1" error="EndOfResults">
<model-responses>
<model error="NoSuchModel" mh="0x10006d2" />
</model-responses>
</model-response-list>