Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to query individually an entry #341

Open
Arno500 opened this issue May 20, 2024 · 1 comment
Open

Allow to query individually an entry #341

Arno500 opened this issue May 20, 2024 · 1 comment

Comments

@Arno500
Copy link

Arno500 commented May 20, 2024

I know it should not be done 80% of the time, but in specific cases I think there would be value in allowing to query only one element of a collection.

When we only need to change the state of one subelement when we know the naming/numbering is constant, forcing to query all the n entries is essentially a waste of time.

This can currently be bypassed by doing something like this:

var outlet gofishTypes.Outlet
err := rPdu.Get(rPdu.GetClient(), rPdu.ODataID "/Outlets/" outletId.String(), &outlet)

but I do not really like the idea and having a rPdu.Outlets.Get(outletId.String()) would be much better in my opinion!

What do you think?

@stmcginnis
Copy link
Owner

That makes sense. But I'll need to think a little about this to see how it could fit.

There are a couple other options. Assuming you've already retrieved all of the outputs, identified the outlet that you care about, and are doing additional updates to that object and just want to get a fresh instance of it, all objects have an ODataID. This can be used to get the object directly with something like:

myOutlet, err := redfish.GetOutlet(client, outlets[3].ODataID)

If you don't have the full collection of all outlet, but you know it will always be the same thing, you can basically do the same but just hardcode the URI. Basically with how you are doing it in the example you provided, but without needing to do the lower level Get() call directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants