| 354 | } |
| 355 | |
| 356 | Dictionary::Ptr ApiActions::RemoveComment( |
| 357 | const ConfigObject::Ptr& object, |
| 358 | const ApiUser::Ptr&, |
| 359 | const Dictionary::Ptr& params |
| 360 | ) |
| 361 | { |
| 362 | ConfigObjectsSharedLock lock (std::try_to_lock); |
| 363 | |
| 364 | if (!lock) { |
| 365 | return ApiActions::CreateResult(503, "Icinga is reloading."); |
| 366 | } |
| 367 | |
| 368 | auto author (HttpUtility::GetLastParameter(params, "author")); |
| 369 | Checkable::Ptr checkable = dynamic_pointer_cast<Checkable>(object); |
| 370 | |
| 371 | if (checkable) { |
| 372 | std::set<Comment::Ptr> comments = checkable->GetComments(); |
| 373 | |
| 374 | for (const Comment::Ptr& comment : comments) { |
| 375 | Comment::RemoveComment(comment->GetName(), true, author); |
| 376 | } |
| 377 | |
| 378 | return ApiActions::CreateResult(200, "Successfully removed all comments for object '" + checkable->GetName() + "'."); |
| 379 | } |
| 380 | |
| 381 | Comment::Ptr comment = static_pointer_cast<Comment>(object); |
| 382 | |
| 383 | if (!comment) |
| 384 | return ApiActions::CreateResult(404, "Cannot remove non-existent comment object."); |
| 385 | |
| 386 | String commentName = comment->GetName(); |
| 387 | |
| 388 | Comment::RemoveComment(commentName, true, author); |
| 389 | |
| 390 | return ApiActions::CreateResult(200, "Successfully removed comment '" + commentName + "'."); |
| 391 | } |
| 392 | |
| 393 | Dictionary::Ptr ApiActions::ScheduleDowntime( |
| 394 | const ConfigObject::Ptr& object, |
nothing calls this directly
no test coverage detected