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

API support for adding/removing Policies to/from Policy Profiles #14575

Merged
merged 2 commits into from
Apr 27, 2017

Conversation

dkorn
Copy link
Contributor

@dkorn dkorn commented Mar 30, 2017

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" }
    ]
}

@dkorn
Copy link
Contributor Author

dkorn commented Mar 30, 2017

@miq-bot add_label enhancement, api, control

@dkorn dkorn changed the title API support for adding/removing Policies to/from Polciy Profiles API support for adding/removing Policies to/from Policy Profiles Mar 30, 2017
@dkorn dkorn force-pushed the add_policy_to_policy_profile branch from 4274818 to 8d5ff56 Compare March 30, 2017 11:27
@dkorn
Copy link
Contributor Author

dkorn commented Mar 30, 2017

@moolitayer @simon3z @zeari @abellotti please review


expect(response).to have_http_status(:ok)
expect(ps2.reload.miq_policies.count).to eq(0)
end
Copy link
Member

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.

Copy link
Contributor Author

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))
Copy link
Member

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.

Copy link
Contributor Author

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" }
    ]
}
@dkorn dkorn force-pushed the add_policy_to_policy_profile branch from 8d5ff56 to 7522f32 Compare April 24, 2017 09:15
* miq_policy_set: add_policy, remove_policy, get_policies
* api.yml: add identifier
* move assignment specs
@dkorn dkorn force-pushed the add_policy_to_policy_profile branch from 7522f32 to 20ac36a Compare April 24, 2017 09:22
@miq-bot
Copy link
Member

miq-bot commented Apr 24, 2017

Checked commits dkorn/manageiq@7aac779~...20ac36a with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
2 files checked, 1 offense detected

app/models/miq_policy_set.rb

@dkorn dkorn closed this Apr 25, 2017
@dkorn dkorn reopened this Apr 25, 2017
@abellotti
Copy link
Member

Thanks @dkorn for the API Enhancement. LGTM!!

@abellotti abellotti merged commit 2a2153a into ManageIQ:master Apr 27, 2017
@abellotti abellotti added this to the Sprint 60 Ending May 8, 2017 milestone Apr 27, 2017
@dkorn dkorn deleted the add_policy_to_policy_profile branch April 27, 2017 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants