I’ve got a HATEOAS rest api which is returning data like:
{
"_links": {
"build": {
"href": "http://localhost:8080/vulcan-service/v1/deploys/1/build"
},
"deploy": {
"href": "http://localhost:8080/vulcan-service/v1/deploys/1"
},
"previousBuild": {
"href": "http://localhost:8080/vulcan-service/v1/deploys/1/previousBuild"
},
"self": {
"href": "http://localhost:8080/vulcan-service/v1/deploys/1"
},
"stack": {
"href": "http://localhost:8080/vulcan-service/v1/deploys/1/stack"
}
},
"deployTaskDef": null,
"endedAt": 1510003796000,
"log": null,
"startedAt": 1510003696000,
"startedBy": "jsteel",
"successful": true
}
I’d like to define the deploy
model such that it pulls in the stack
property if present, by invoking GET /vulcan-service/v1/deploys/1/stack
. This will return a 404 if the property is ‘null’.
Am I going down the wrong path by looking at somehow using Stack.Ref.type
here? It’s not quite the same as it doesn’t exist in the main object, but I could perhaps shoehorn it in via can-connect::parseInstanceData() ?
e.g.
const Deploy = DefineMap.extend({
seal: false
}, {
id: 'any',
stack: { type: Stack.Ref.type }
});