-
Notifications
You must be signed in to change notification settings - Fork 900
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
API - VMs collection - replace decorators with SupportsFeatureMixin #14040
Conversation
if vm_decorators.include? 'supports_cockpit?' | ||
hash['supports_cockpit?'] = vm.supports_launch_cockpit? | ||
end | ||
hash |
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.
may end up with lotsa churn with this in API every-time there's a new decorator. Would prefer logic to be driven by "support_" prefix and calling the appropriate method on vm. Not sure about the differently named _cockpit? vs. launch_cockpit?, maybe define an alias in the model for compatibility so this code here is generic for all. Thanks.
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.
@abellotti My impression was that people want decorators gone from the API .. that's why I took this path, we still need to support the ones that were used, but the idea of this PR is that those would be the only ones. (And can be replaced/deprecated in a future API version.)
Does your objection still stand given that?
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.
Ahh ok, so keeping this for compatibility 🙇 new and future code would then leverage the attributes= instead. Does the following work today then ?
GET /api/vms?expand=resources&attributes=supports_launch_cockpit?,supports_console?
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.
Exactly :). The attributes
version does not work today, because SupportsFeatureMixin
does not create virtual attributes.
Not sure if the way forward is to make SupportFeatureMixin
create virtual attributes for every feature, or to add special support for these in attributes
, or to introduce a new query parameter..
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.
we can probably extend app/controllers/api/base_controller/renderer.rb's attr_virtual?/attr_accessible? to "support" those so they come for free with attributes= without having to change the query parameters.
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.
@abellotti Sounds good, do you want me to do it in this PR, or would you rather have your team do it..?
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.
I'm wondering if we should have capabilities
or something on the API objects...so not necessarily attributes, but implemented similarly
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.
while we certainly can add that on the server side, I just don't know how they'd be specified in the API client. I'm hoping we can still somehow use .select(...) for those and won't need something like search_options(...) as implemented in ManageIQ/manageiq-api-client#63 for collection_class.
This pull request is not mergeable. Please rebase and repush. |
console support for vms is not handled using the SupportsFeatureMixin - adding
this feature is relied upon by SUI, preserving compatibility
@abellotti is this blocked by anything? |
Checked commits https://github.com/himdel/manageiq/compare/4dcd311c92e69946f94548c8f2813f60d464baee~...21934bfeaf5127683ecc9386c7b0331cefef9537 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 app/models/mixins/supports_feature_mixin.rb
|
I don't think so, just me. we can introduce the capabilities/supports in a separate PR. Thanks @himdel for fixing this. 👍 |
only used by the API, for the Vms collection, removed in ManageIQ/manageiq#14040
only used by the API, for the Vms collection, removed in ManageIQ/manageiq#14040 (transferred from ManageIQ/manageiq-ui-classic@3e4f447)
only used by the API, for the Vms collection, removed in ManageIQ/manageiq#14040 (transferred from manageiq-ui-classic@3e4f447f248ad335e9479f4aa247ebf40ea8fe63)
This removes the only remaining use of decorators from manageiq (not ui).
Service UI is using
?decorators=vms.supports_console?,vms.supports_cockpit?
, so I suppose we need to preserve that. - Implementing only those two, by callingvm.supports_*?
.Since console support is not using the
SupportsFeatureMixin
, added it toVmOrTemplate
, using the same code that was previously inVmOrTemplateDecorator
.Cockpit support is using
SupportsFeatureMixin
, but uses a different name than the decorator (supports_cockpit?
vssupports_launch_cockpit?
).(Related to (but not dependent upon) ManageIQ/manageiq-ui-classic#237.)
Testing: (with a valid service ID, which has multiple vms..)
GET /api/services/10000000000245?expand=vms&decorators=vms.supports_console%3F%2Cvms.supports_cockpit%3F
Closes ManageIQ/manageiq-ui-classic#3
@abellotti, @jntullo WDYT? :)