-
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
API support for adding/removing Policies to/from Policy Profiles #14575
API support for adding/removing Policies to/from Policy Profiles #14575
Conversation
@miq-bot add_label enhancement, api, control |
4274818
to
8d5ff56
Compare
@moolitayer @simon3z @zeari @abellotti please review |
spec/requests/api/policies_spec.rb
Outdated
|
||
expect(response).to have_http_status(:ok) | ||
expect(ps2.reload.miq_policies.count).to eq(0) | ||
end |
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.
these tests should go in policies_assignment_spec.rb, there are helper method you can simply call.
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.
Done, thanks!
Notice I added object.reload
in the unassign spec, without it the test fails.
@@ -8,11 +8,19 @@ def policies_query_resource(object) | |||
end | |||
|
|||
def policies_assign_resource(object, _type, id = nil, data = nil) | |||
policy_assign_action(object, :policies, id, data) | |||
if object.kind_of?(collection_class(:policy_profiles)) | |||
object.add_member(policy_specified(id, data, :policies, MiqPolicy)) |
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.
would prefer having add_policy and remove_policy provided in the MiqPolicySet model.
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 did the change, hope I understood you correctly
Currently, it is only possible to add/remove MiqPolicy from MiqPolicySet using the UI. This change adds to API support for these operations, using the assign/unassign actions. Example: POST /api/policy_profiles/:id/policies Body: { "action": "assign", "resources": [ { "href": "/api/policies/1" }, { "href": "/api/policies/2" } ] }
8d5ff56
to
7522f32
Compare
* miq_policy_set: add_policy, remove_policy, get_policies * api.yml: add identifier * move assignment specs
7522f32
to
20ac36a
Compare
Checked commits dkorn/manageiq@7aac779~...20ac36a with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 app/models/miq_policy_set.rb
|
Thanks @dkorn for the API Enhancement. LGTM!! |
Currently, it is only possible to add/remove MiqPolicy from MiqPolicySet using the UI.
This change adds to API support for these operations, using the
assign
/unassign
actions.Example:
POST /api/policy_profiles/:id/policies
Body: