-
Notifications
You must be signed in to change notification settings - Fork 141
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
Generic Objects API #50
Generic Objects API #50
Conversation
def set_additional_attributes | ||
@additional_attributes = %w(property_attributes) | ||
return unless params[:property_associations] | ||
params[:property_associations].split(',').each do |prop| |
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 wanted to get your thoughts on this approach to returning associations since it's slightly different than we talked about. With GET /generic_objects/:id?property_associations=vms,services
, and by adding them to the additional attributes, they can then get returned as if they were a normal relationship, ie:
{
"id": "<generic_object_id>",
...
"vms" [ {"id": "vm_id" }, ... ]
"services": [ ... ]
}
thoughts?
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 like it, I wonder if the parameter shouldn't just be associations=vms,services,... to match the add_associations/remove_associations actions.
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 yeah, I like that. will update! 👍
delete specs
Thanks @jntullo for the PR. this LGTM 👍 /cc @imtayadeway can I borrow your 👀 for a quick look here. Thanks!! |
@@ -112,7 +112,8 @@ def normalize_select_attributes(obj, opts) | |||
end | |||
|
|||
def normalize_array(obj) | |||
obj.collect { |item| normalize_attr(@req.subcollection || @req.collection, item) } | |||
type = @req.subcollection || @req.collection |
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.
If you wish, you can use type = @req.subject
here
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.
👍 🎵
use subject instead of collection/subcollection
@imtayadeway waiting for your approval when you get a chance. Thanks !! |
Checked commits jntullo/manageiq-api@5d5fbf3~...103df94 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 |
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.
This LGTM. Thank you @jntullo ! 🥇
Echoing a previous question but how do you (1) get GO’s for a service and (2) how does one associate a GO with a service? /cc @chalettu |
@chriskacerguis @chalettu services don't have GO's so much as a GO can have a service. A service can be added to a Generic Object via association so long as that association is defined in the generic object definition of the GO (see #15 or #37). Then if that relationship exists, the services can be added as seen in the examples I have documented above (via both create and edit). @lfu and @bzwei would be best to describe it though, and to inform if there is a straightforward way in which to grab generic objects of a service. |
@jntullo thanks for the clarification. So, given a service, how can I get the associated GO's? |
@jntullo This is correct. A service can be connected to a generic object as an association. Generic objects can also be added to a service as resources. @chriskacerguis To get the associated GO's of a given service, just call:
(see ManageIQ/manageiq#15490) |
@lfu thank you! I did not see that relationship. @chriskacerguis I will create a PR for a subcollection on services. ie |
@chriskacerguis @chalettu just realized, it's not even necessary for the subcollection. you'll be able to specify |
nice. Thanks @jntullo |
@chalettu does all that address your concerns? |
I believe this does address my concerns . Thank you so much @jntullo for helping to clarify |
@jntullo agreeing with you above, simply accessing via attributes=generic_objects. Otherwise, we'd need to add the subcollection to all API CI's which map to an Miq reportable model type. |
LGTM !!! Thanks @jntullo for this API enhancement 👍 |
Generic Objects API CRUD
(will make separate PRs for subcollection actions and calling generic object methods)
GET
POST /api/generic_objects
Creating a new generic object
Editing a Generic Object
associations
andproperty_attributes
Deleting a Generic Object
POST /api/generic_objects/:id
Editing a generic object
Deleting a generic object
DELETE api/generic_objects/:id
@miq-bot add_label enhancement
@miq-bot assign @abellotti