2026-01-27 09:06:40 -05:00
|
|
|
// SPDX-FileCopyrightText: 2012 Icinga GmbH <https://icinga.com>
|
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2015-07-30 11:50:17 -04:00
|
|
|
|
|
|
|
|
#include "remote/apiaction.hpp"
|
|
|
|
|
|
|
|
|
|
using namespace icinga;
|
|
|
|
|
|
2024-11-08 07:15:59 -05:00
|
|
|
INITIALIZE_ONCE_WITH_PRIORITY([]{
|
|
|
|
|
ApiActionRegistry::GetInstance()->Freeze();
|
|
|
|
|
}, InitializePriority::FreezeNamespaces);
|
|
|
|
|
|
2018-01-04 02:54:18 -05:00
|
|
|
ApiAction::ApiAction(std::vector<String> types, Callback action)
|
|
|
|
|
: m_Types(std::move(types)), m_Callback(std::move(action))
|
2015-07-30 11:50:17 -04:00
|
|
|
{ }
|
|
|
|
|
|
2025-09-15 05:17:45 -04:00
|
|
|
Value ApiAction::Invoke(const ConfigObject::Ptr& target, const ApiUser::Ptr& user, const Dictionary::Ptr& params)
|
2015-07-30 11:50:17 -04:00
|
|
|
{
|
2025-09-15 05:17:45 -04:00
|
|
|
return m_Callback(target, user, params);
|
2015-07-30 11:50:17 -04:00
|
|
|
}
|
|
|
|
|
|
2018-01-03 22:25:35 -05:00
|
|
|
const std::vector<String>& ApiAction::GetTypes() const
|
2015-07-30 11:50:17 -04:00
|
|
|
{
|
|
|
|
|
return m_Types;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ApiAction::Ptr ApiAction::GetByName(const String& name)
|
|
|
|
|
{
|
|
|
|
|
return ApiActionRegistry::GetInstance()->GetItem(name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ApiAction::Register(const String& name, const ApiAction::Ptr& action)
|
|
|
|
|
{
|
|
|
|
|
ApiActionRegistry::GetInstance()->Register(name, action);
|
|
|
|
|
}
|