You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When creating a resource via the api one can link those using some attributes and a list of IDs. An example are logical-servers where you can pass the "servers" attribute with a list (array) of IDs of physical servers on which can run.
i.e. servers : [ 30 ] # 30 being the ID of the physical server
In the controller this is realized via:
if ($request->has('servers')) {
$logicalServer->servers()->sync($request->input('servers', []));
}
When I retrieve now all logical servers, the linking attributes (like "servers") is missing from the returned json, While the show() method seems to honor it via:
By default, when retrieving a list of logical servers via the API, Eloquent does not automatically include relationships. This is why the "servers" attribute is missing from the returned JSON.
Is it possible to add these lines in the index to get all servers :
The problem with modifying the code is obviously future updates, also it would be only for the servers not the other links. The problem with getting the servers one by one, beside the many calls themselves, is the DDOS protection which needs throttling of the calls. The only solution I found for the Mercator python library I wrote is a throttling function which is called after each call and after 50 (or so) calls it pauses for 60 seconds to avoid repeat calls errors.
Wouldn't it be possible to add code for links in each index and add a "retrieve-links" attribute or add an additional route like "logical-servers-with-links" (but not only for logical servers) to allow queries with and without the links ?
When creating a resource via the api one can link those using some attributes and a list of IDs. An example are logical-servers where you can pass the "servers" attribute with a list (array) of IDs of physical servers on which can run.
i.e. servers : [ 30 ] # 30 being the ID of the physical server
In the controller this is realized via:
if ($request->has('servers')) {
$logicalServer->servers()->sync($request->input('servers', []));
}
When I retrieve now all logical servers, the linking attributes (like "servers") is missing from the returned json, While the show() method seems to honor it via:
$logicalServer->servers = $logicalServer->servers()->pluck('id');
The text was updated successfully, but these errors were encountered: