mirror of https://github.com/Icinga/icinga2.git
/v1/actions/remove-downtime: let users specify themselves
This commit is contained in:
parent
7849da0b78
commit
a361bf716e
|
@ -457,12 +457,18 @@ Dictionary::Ptr ApiActions::ScheduleDowntime(const ConfigObject::Ptr& object,
|
|||
Dictionary::Ptr ApiActions::RemoveDowntime(const ConfigObject::Ptr& object,
|
||||
const Dictionary::Ptr& params)
|
||||
{
|
||||
auto author (HttpUtility::GetLastParameter(params, "author"));
|
||||
Checkable::Ptr checkable = dynamic_pointer_cast<Checkable>(object);
|
||||
|
||||
if (checkable) {
|
||||
std::set<Downtime::Ptr> downtimes = checkable->GetDowntimes();
|
||||
|
||||
for (const Downtime::Ptr& downtime : downtimes) {
|
||||
{
|
||||
ObjectLock oLock (downtime);
|
||||
downtime->SetRemovedBy(author);
|
||||
}
|
||||
|
||||
Downtime::RemoveDowntime(downtime->GetName(), true);
|
||||
}
|
||||
|
||||
|
@ -474,6 +480,11 @@ Dictionary::Ptr ApiActions::RemoveDowntime(const ConfigObject::Ptr& object,
|
|||
if (!downtime)
|
||||
return ApiActions::CreateResult(404, "Cannot remove non-existent downtime object.");
|
||||
|
||||
{
|
||||
ObjectLock oLock (downtime);
|
||||
downtime->SetRemovedBy(author);
|
||||
}
|
||||
|
||||
String downtimeName = downtime->GetName();
|
||||
|
||||
Downtime::RemoveDowntime(downtimeName, true);
|
||||
|
|
|
@ -70,6 +70,8 @@ class Downtime : ConfigObject < DowntimeNameComposer
|
|||
[state] bool was_cancelled;
|
||||
[config] String config_owner;
|
||||
[config] String authoritative_zone;
|
||||
|
||||
[no_user_view, no_user_modify] String removed_by;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -1375,7 +1375,7 @@ void IcingaDB::SendRemovedDowntime(const Downtime::Ptr& downtime)
|
|||
"downtime_id", GetObjectIdentifier(downtime),
|
||||
"environment_id", SHA1(GetEnvironment()),
|
||||
"entry_time", Convert::ToString(TimestampToMilliseconds(downtime->GetEntryTime())),
|
||||
"author", Utility::ValidateUTF8(downtime->GetAuthor()),
|
||||
"author", Utility::ValidateUTF8(downtime->GetRemovedBy()),
|
||||
"comment", Utility::ValidateUTF8(downtime->GetComment()),
|
||||
"is_flexible", Convert::ToString((unsigned short)!downtime->GetFixed()),
|
||||
"flexible_duration", Convert::ToString(downtime->GetDuration()),
|
||||
|
|
Loading…
Reference in New Issue