Add initial support for $expand in system.Memory() #408
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a proposal of how to handle '$expand' redfish odata queries. Related issue: #340
Note: creating PR to get early feedback if general approach is valid, things to be added to this PR:
MetricsAssumptions, I've made:
Because of above, I'd like to introduce the 'expand feature' with 'functional options' approach.
There's a new
common/odata.gofile with 2 'options' functions responsible for controlling the expand value and level (ref: redfish spec).Draft of this PR supports 'expand' only for
system.Memory()and 'expands' onlyMetrics. It's possible to us it as it was (system.Memory()) or with expand option (system.Memory(common.WithExpand(common.ExpandOptionPeriod))). By default, no 'expand' is used, so we won't change the default behavior.Memorystruct was changed, andmetricsvar type is changed fromcommon.LinktoMemoryMetrics. In case the expand is not used forsystem.Memory(),memory.Metrics()call will make a call to redfish API.Tested with Redfish mockup server and real device.
Please let me know if above approach is ok or if you have any suggestions how to do it differently.
Something I'm not sure how to tackle right now...
Following my use case (get system's memory and it's metrics):
system.Memory()encapsulate '2 levels' above: it send request to API to get 'memory collection' and then 'memory item'Both of the requests can handle expand parameter. Let's assume Redfish API supports only 1 level for expand.
If we do
system.Memory(common.WithExpand(common.ExpandOptionPeriod)), should gofish pass $expand param:Or should it be possible to decide when invoking
system.Memory()I assumed, when we use
system.Memory()and get in response[]Memorywe're interested inMemoryresource and that's what expanded in this 'draft' PR. (tbh: that's what I'm interested in my use case - getting metrics for all 'memory items')With this approach we don't change anything in
GetCollectionObjects(except 'optional' list ofQueryOptionin the definition)If we'd like to support that at 'memory collection' request, it will get more dificult and complex and would need more changes to those 'generic' functions (GetCollectionObjects -> CollectList -> GetCollection etc).
Let me know what you think and how you suggest to approach that.