Hello,
Is there api to enable notification for users on host build?
Thanks
Unfortunately, no. Assuming you want to automate creation of that, you can use foreman-rake console
. First find the ID of the built notification.
> MailNotification.pluck(:id, :name)
=> [[3, "audit_summary"],
[6, "config_error_state"],
[1, "config_summary"],
[7, "discovered_summary"],
[4, "host_built"],
[5, "tester"],
[2, "welcome"]]
Similar way find database IDs of users you want to assign this:
> User.pluck(:id, :login)
=> [[3, "foreman_api_admin"],
[4, "admin"],
[1, "foreman_admin"],
[2, "foreman_console_admin"],
[6, "myorg_manager"],
[5, "org_admin"],
[7, "secondorg_manager"]]
And do this, this is for one:
UserMailNotification.create!(user_id: 7, mail_notification_id: 4, interval: "Subscribe")
To do this for all users, you can use this Ruby syntax:
User.each |u| do
UserMailNotification.create!(user_id: u.id, mail_notification_id: 4, interval: "Subscribe")
end
Or something more similar. Work done!
Thanks, I will check on this!