-
Notifications
You must be signed in to change notification settings - Fork 897
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
Return only requested attributes #14734
Conversation
@jntullo yes, the fqname is returned intentionally. the id cannot be used for fetching automate resources, they pertain to different classes in the automate model. automate resources are fetched by path name (arbitratry_resource_path in our api.yml, like settings), thus the fqname needs to be returned. Thanks. |
# Expand if: resource is being returned and subcollection is configured | ||
# IE an update to /service_catalogs expects service_templates as part of its resource | ||
def expand_action_resource?(sc) | ||
@req.method != :get && collection_config.show?(sc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jntullo why was the @req.method != :get check needed ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without this it returns the subcollection - ie https://github.com/ManageIQ/manageiq/pull/14734/files#diff-d54e0c907bbc882d070223cd425c086bR90 fails because it returns features
and https://github.com/ManageIQ/manageiq/pull/14734/files#diff-4dcc5ad5710cf94c07b7143879fef0a5R35 fails because it returns service_templates
.
@abellotti @jntullo bump |
it seems we're losing id, i.e. fetching /api/vms?expand=resources&attributes=name,vendor returns href,name,vendor but no longer returns id. Let's add id back, could be breaking current client scripts. This PR will still be fixing |
Checked commits jntullo/manageiq@1515262~...0e9623d with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 |
Thanks @jntullo for fixing this. 😍 |
This PR ensures that only the requested attributes are being returned when:
expand='resources'&attributes='<attributes>'
is specified.First fix:
attribute_selection
: This was merging attribute selection with any additional attributes. As a result, any@additional_attributes
specified within the controller were being returned, no matter what the user specified attributes were.After I fixed ^, everything else broke 😄 ...
Second fix:
expand_subcollection?
: With the first fix, this was no longer rendering everything as expected. From the tests that were broken, I saw that there were essentially 3 cases:expand=resources
was specified, no other attributes were specified, and it was in thecollection_config
expand='service_templates'
)From the above cases I updated
expand_subcollection?
to use 3 methods that test those cases.Also of note: Although the BZ states that
fqname
should not be returned for theautomate
collection, it seems that it may be done intentionally - otherwise that will need to be refactored as wellDefinitely need some eyes, especially for number 2!
@miq-bot add_label api, bug
@miq-bot assign @abellotti
cc: @imtayadeway