};
[config, internal, get_protected] String type (TypeNameV);
[config] name(Zone) zone (ZoneName);
- [config] String module;
+ [config] String package;
[config, internal, get_protected] Array::Ptr templates;
[get_protected] bool active;
[get_protected] bool paused {
return true;
}
-static void IncludeZoneDirRecursive(const String& path, const String& module, bool& success)
+static void IncludeZoneDirRecursive(const String& path, const String& package, bool& success)
{
String zoneName = Utility::BaseName(path);
ConfigCompiler::RegisterZoneDir("_etc", path, zoneName);
std::vector<Expression *> expressions;
- Utility::GlobRecursive(path, "*.conf", boost::bind(&ConfigCompiler::CollectIncludes, boost::ref(expressions), _1, zoneName, module), GlobFile);
+ Utility::GlobRecursive(path, "*.conf", boost::bind(&ConfigCompiler::CollectIncludes, boost::ref(expressions), _1, zoneName, package), GlobFile);
DictExpression expr(expressions);
if (!ExecuteExpression(&expr))
success = false;
}
-static void IncludeNonLocalZone(const String& zonePath, const String& module, bool& success)
+static void IncludeNonLocalZone(const String& zonePath, const String& package, bool& success)
{
String etcPath = Application::GetZonesDir() + "/" + Utility::BaseName(zonePath);
if (Utility::PathExists(etcPath) || Utility::PathExists(zonePath + "/.authoritative"))
return;
- IncludeZoneDirRecursive(zonePath, module, success);
+ IncludeZoneDirRecursive(zonePath, package, success);
}
-static void IncludeModule(const String& modulePath, bool& success)
+static void IncludePackage(const String& packagePath, bool& success)
{
- String moduleName = Utility::BaseName(modulePath);
+ String packageName = Utility::BaseName(packagePath);
- if (Utility::PathExists(modulePath + "/include.conf")) {
- Expression *expr = ConfigCompiler::CompileFile(modulePath + "/include.conf",
- String(), moduleName);
+ if (Utility::PathExists(packagePath + "/include.conf")) {
+ Expression *expr = ConfigCompiler::CompileFile(packagePath + "/include.conf",
+ String(), packageName);
if (!ExecuteExpression(expr))
success = false;
if (!success)
return false;
- String modulesVarDir = Application::GetLocalStateDir() + "/lib/icinga2/api/modules";
- if (Utility::PathExists(modulesVarDir))
- Utility::Glob(modulesVarDir + "/*", boost::bind(&IncludeModule, _1, boost::ref(success)), GlobDirectory);
+ String packagesVarDir = Application::GetLocalStateDir() + "/lib/icinga2/api/packages";
+ if (Utility::PathExists(packagesVarDir))
+ Utility::Glob(packagesVarDir + "/*", boost::bind(&IncludePackage, _1, boost::ref(success)), GlobDirectory);
if (!success)
return false;
ApplyRule::TypeMap ApplyRule::m_Types;
ApplyRule::ApplyRule(const String& targetType, const String& name, const boost::shared_ptr<Expression>& expression,
- const boost::shared_ptr<Expression>& filter, const String& module, const String& fkvar, const String& fvvar, const boost::shared_ptr<Expression>& fterm,
+ const boost::shared_ptr<Expression>& filter, const String& package, const String& fkvar, const String& fvvar, const boost::shared_ptr<Expression>& fterm,
const DebugInfo& di, const Dictionary::Ptr& scope)
- : m_TargetType(targetType), m_Name(name), m_Expression(expression), m_Filter(filter), m_Module(module), m_FKVar(fkvar),
+ : m_TargetType(targetType), m_Name(name), m_Expression(expression), m_Filter(filter), m_Package(package), m_FKVar(fkvar),
m_FVVar(fvvar), m_FTerm(fterm), m_DebugInfo(di), m_Scope(scope), m_HasMatches(false)
{ }
return m_Filter;
}
-String ApplyRule::GetModule(void) const
+String ApplyRule::GetPackage(void) const
{
- return m_Module;
+ return m_Package;
}
String ApplyRule::GetFKVar(void) const
}
void ApplyRule::AddRule(const String& sourceType, const String& targetType, const String& name,
- const boost::shared_ptr<Expression>& expression, const boost::shared_ptr<Expression>& filter, const String& module, const String& fkvar,
+ const boost::shared_ptr<Expression>& expression, const boost::shared_ptr<Expression>& filter, const String& package, const String& fkvar,
const String& fvvar, const boost::shared_ptr<Expression>& fterm, const DebugInfo& di, const Dictionary::Ptr& scope)
{
- m_Rules[sourceType].push_back(ApplyRule(targetType, name, expression, filter, module, fkvar, fvvar, fterm, di, scope));
+ m_Rules[sourceType].push_back(ApplyRule(targetType, name, expression, filter, package, fkvar, fvvar, fterm, di, scope));
}
bool ApplyRule::EvaluateFilter(ScriptFrame& frame) const
String GetName(void) const;
boost::shared_ptr<Expression> GetExpression(void) const;
boost::shared_ptr<Expression> GetFilter(void) const;
- String GetModule(void) const;
+ String GetPackage(void) const;
String GetFKVar(void) const;
String GetFVVar(void) const;
boost::shared_ptr<Expression> GetFTerm(void) const;
bool EvaluateFilter(ScriptFrame& frame) const;
static void AddRule(const String& sourceType, const String& targetType, const String& name, const boost::shared_ptr<Expression>& expression,
- const boost::shared_ptr<Expression>& filter, const String& module, const String& fkvar, const String& fvvar, const boost::shared_ptr<Expression>& fterm, const DebugInfo& di, const Dictionary::Ptr& scope);
+ const boost::shared_ptr<Expression>& filter, const String& package, const String& fkvar, const String& fvvar, const boost::shared_ptr<Expression>& fterm, const DebugInfo& di, const Dictionary::Ptr& scope);
static std::vector<ApplyRule>& GetRules(const String& type);
static void RegisterType(const String& sourceType, const std::vector<String>& targetTypes);
String m_Name;
boost::shared_ptr<Expression> m_Expression;
boost::shared_ptr<Expression> m_Filter;
- String m_Module;
+ String m_Package;
String m_FKVar;
String m_FVVar;
boost::shared_ptr<Expression> m_FTerm;
static RuleMap m_Rules;
ApplyRule(const String& targetType, const String& name, const boost::shared_ptr<Expression>& expression,
- const boost::shared_ptr<Expression>& filter, const String& module, const String& fkvar, const String& fvvar, const boost::shared_ptr<Expression>& fterm,
+ const boost::shared_ptr<Expression>& filter, const String& package, const String& fkvar, const String& fvvar, const boost::shared_ptr<Expression>& fterm,
const DebugInfo& di, const Dictionary::Ptr& scope);
};
BOOST_THROW_EXCEPTION(ScriptError("object rule 'ignore' is missing 'assign' for type '" + type + "'", DebugInfoRange(@2, @4)));
}
- $$ = new ObjectExpression(abstract, type, $4, filter, context->GetZone(), context->GetModule(), $5, $6, DebugInfoRange(@2, @5));
+ $$ = new ObjectExpression(abstract, type, $4, filter, context->GetZone(), context->GetPackage(), $5, $6, DebugInfoRange(@2, @5));
}
;
Expression *fterm = context->m_FTerm.top();
context->m_FTerm.pop();
- $$ = new ApplyExpression(type, target, $4, filter, context->GetModule(), fkvar, fvvar, fterm, $7, $8, DebugInfoRange(@2, @7));
+ $$ = new ApplyExpression(type, target, $4, filter, context->GetPackage(), fkvar, fvvar, fterm, $7, $8, DebugInfoRange(@2, @7));
}
;
* @param zone The zone.
*/
ConfigCompiler::ConfigCompiler(const String& path, std::istream *input,
- const String& zone, const String& module)
- : m_Path(path), m_Input(input), m_Zone(zone), m_Module(module),
+ const String& zone, const String& package)
+ : m_Path(path), m_Input(input), m_Zone(zone), m_Package(package),
m_Eof(false), m_OpenBraces(0), m_IgnoreNewlines(0)
{
InitializeScanner();
return m_Zone;
}
-void ConfigCompiler::SetModule(const String& module)
+void ConfigCompiler::SetPackage(const String& package)
{
- m_Module = module;
+ m_Package = package;
}
-String ConfigCompiler::GetModule(void) const
+String ConfigCompiler::GetPackage(void) const
{
- return m_Module;
+ return m_Package;
}
void ConfigCompiler::CollectIncludes(std::vector<Expression *>& expressions,
- const String& file, const String& zone, const String& module)
+ const String& file, const String& zone, const String& package)
{
- expressions.push_back(CompileFile(file, zone, module));
+ expressions.push_back(CompileFile(file, zone, package));
}
/**
std::vector<Expression *> expressions;
- if (!Utility::Glob(includePath, boost::bind(&ConfigCompiler::CollectIncludes, boost::ref(expressions), _1, m_Zone, m_Module), GlobFile) && includePath.FindFirstOf("*?") == String::NPos) {
+ if (!Utility::Glob(includePath, boost::bind(&ConfigCompiler::CollectIncludes, boost::ref(expressions), _1, m_Zone, m_Package), GlobFile) && includePath.FindFirstOf("*?") == String::NPos) {
std::ostringstream msgbuf;
msgbuf << "Include file '" + include + "' does not exist";
BOOST_THROW_EXCEPTION(ScriptError(msgbuf.str(), debuginfo));
ppath = Utility::DirName(GetPath()) + "/" + path;
std::vector<Expression *> expressions;
- Utility::GlobRecursive(ppath, pattern, boost::bind(&ConfigCompiler::CollectIncludes, boost::ref(expressions), _1, m_Zone, m_Module), GlobFile);
+ Utility::GlobRecursive(ppath, pattern, boost::bind(&ConfigCompiler::CollectIncludes, boost::ref(expressions), _1, m_Zone, m_Package), GlobFile);
return new DictExpression(expressions);
}
RegisterZoneDir(tag, ppath, zoneName);
- Utility::GlobRecursive(ppath, pattern, boost::bind(&ConfigCompiler::CollectIncludes, boost::ref(expressions), _1, zoneName, m_Module), GlobFile);
+ Utility::GlobRecursive(ppath, pattern, boost::bind(&ConfigCompiler::CollectIncludes, boost::ref(expressions), _1, zoneName, m_Package), GlobFile);
}
/**
* @returns Configuration items.
*/
Expression *ConfigCompiler::CompileStream(const String& path,
- std::istream *stream, const String& zone, const String& module)
+ std::istream *stream, const String& zone, const String& package)
{
CONTEXT("Compiling configuration stream with name '" + path + "'");
stream->exceptions(std::istream::badbit);
- ConfigCompiler ctx(path, stream, zone, module);
+ ConfigCompiler ctx(path, stream, zone, package);
try {
return ctx.Compile();
* @returns Configuration items.
*/
Expression *ConfigCompiler::CompileFile(const String& path, const String& zone,
- const String& module)
+ const String& package)
{
CONTEXT("Compiling configuration file '" + path + "'");
Log(LogInformation, "ConfigCompiler")
<< "Compiling config file: " << path;
- return CompileStream(path, &stream, zone, module);
+ return CompileStream(path, &stream, zone, package);
}
/**
* @returns Configuration items.
*/
Expression *ConfigCompiler::CompileText(const String& path, const String& text,
- const String& zone, const String& module)
+ const String& zone, const String& package)
{
std::stringstream stream(text);
- return CompileStream(path, &stream, zone, module);
+ return CompileStream(path, &stream, zone, package);
}
/**
{
public:
explicit ConfigCompiler(const String& path, std::istream *input,
- const String& zone = String(), const String& module = String());
+ const String& zone = String(), const String& package = String());
virtual ~ConfigCompiler(void);
Expression *Compile(void);
static Expression *CompileStream(const String& path, std::istream *stream,
- const String& zone = String(), const String& module = String());
+ const String& zone = String(), const String& package = String());
static Expression *CompileFile(const String& path, const String& zone = String(),
- const String& module = String());
+ const String& package = String());
static Expression *CompileText(const String& path, const String& text,
- const String& zone = String(), const String& module = String());
+ const String& zone = String(), const String& package = String());
static void AddIncludeSearchDir(const String& dir);
void SetZone(const String& zone);
String GetZone(void) const;
- void SetModule(const String& module);
- String GetModule(void) const;
+ void SetPackage(const String& package);
+ String GetPackage(void) const;
static void CollectIncludes(std::vector<Expression *>& expressions,
- const String& file, const String& zone, const String& module);
+ const String& file, const String& zone, const String& package);
/* internally used methods */
Expression *HandleInclude(const String& include, bool search, const DebugInfo& debuginfo = DebugInfo());
String m_Path;
std::istream *m_Input;
String m_Zone;
- String m_Module;
+ String m_Package;
void *m_Scanner;
bool abstract, const boost::shared_ptr<Expression>& exprl,
const boost::shared_ptr<Expression>& filter,
const DebugInfo& debuginfo, const Dictionary::Ptr& scope,
- const String& zone, const String& module)
+ const String& zone, const String& package)
: m_Type(type), m_Name(name), m_Abstract(abstract),
m_Expression(exprl), m_Filter(filter),
m_DebugInfo(debuginfo), m_Scope(scope), m_Zone(zone),
- m_Module(module)
+ m_Package(package)
{
}
dobj->SetDebugInfo(m_DebugInfo);
dobj->SetTypeNameV(m_Type);
dobj->SetZoneName(m_Zone);
- dobj->SetModule(m_Module);
+ dobj->SetPackage(m_Package);
dobj->SetName(m_Name);
DebugHint debugHints;
const boost::shared_ptr<Expression>& filter,
const DebugInfo& debuginfo,
const Dictionary::Ptr& scope, const String& zone,
- const String& module);
+ const String& package);
String GetType(void) const;
String GetName(void) const;
DebugInfo m_DebugInfo; /**< Debug information. */
Dictionary::Ptr m_Scope; /**< variable scope. */
String m_Zone; /**< The zone. */
- String m_Module;
+ String m_Package;
ConfigObject::Ptr m_Object;
m_Zone = zone;
}
-void ConfigItemBuilder::SetModule(const String& module)
+void ConfigItemBuilder::SetPackage(const String& package)
{
- m_Module = module;
+ m_Package = package;
}
void ConfigItemBuilder::AddExpression(Expression *expr)
exprl->MakeInline();
return new ConfigItem(m_Type, m_Name, m_Abstract, exprl, m_Filter,
- m_DebugInfo, m_Scope, m_Zone, m_Module);
+ m_DebugInfo, m_Scope, m_Zone, m_Package);
}
void SetAbstract(bool abstract);
void SetScope(const Dictionary::Ptr& scope);
void SetZone(const String& zone);
- void SetModule(const String& module);
+ void SetPackage(const String& package);
void AddExpression(Expression *expr);
void SetFilter(const boost::shared_ptr<Expression>& filter);
DebugInfo m_DebugInfo; /**< Debug information. */
Dictionary::Ptr m_Scope; /**< variable scope. */
String m_Zone; /**< The zone. */
- String m_Module; /**< The module name. */
+ String m_Package; /**< The package name. */
};
}
CHECK_RESULT(nameres);
return VMOps::NewApply(frame, m_Type, m_Target, nameres.GetValue(), m_Filter,
- m_Module, m_FKVar, m_FVVar, m_FTerm, m_ClosedVars, m_Expression, m_DebugInfo);
+ m_Package, m_FKVar, m_FVVar, m_FTerm, m_ClosedVars, m_Expression, m_DebugInfo);
}
ExpressionResult ObjectExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const
}
return VMOps::NewObject(frame, m_Abstract, m_Type, name, m_Filter, m_Zone,
- m_Module, m_ClosedVars, m_Expression, m_DebugInfo);
+ m_Package, m_ClosedVars, m_Expression, m_DebugInfo);
}
ExpressionResult ForExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const
{
public:
ApplyExpression(const String& type, const String& target, Expression *name,
- Expression *filter, const String& module, const String& fkvar, const String& fvvar,
+ Expression *filter, const String& package, const String& fkvar, const String& fvvar,
Expression *fterm, std::map<String, Expression *> *closedVars,
Expression *expression, const DebugInfo& debugInfo = DebugInfo())
: DebuggableExpression(debugInfo), m_Type(type), m_Target(target),
- m_Name(name), m_Filter(filter), m_Module(module), m_FKVar(fkvar), m_FVVar(fvvar),
+ m_Name(name), m_Filter(filter), m_Package(package), m_FKVar(fkvar), m_FVVar(fvvar),
m_FTerm(fterm), m_ClosedVars(closedVars), m_Expression(expression)
{ }
String m_Target;
Expression *m_Name;
boost::shared_ptr<Expression> m_Filter;
- String m_Module;
+ String m_Package;
String m_FKVar;
String m_FVVar;
boost::shared_ptr<Expression> m_FTerm;
{
public:
ObjectExpression(bool abstract, const String& type, Expression *name, Expression *filter,
- const String& zone, const String& module, std::map<String, Expression *> *closedVars,
+ const String& zone, const String& package, std::map<String, Expression *> *closedVars,
Expression *expression, const DebugInfo& debugInfo = DebugInfo())
: DebuggableExpression(debugInfo), m_Abstract(abstract), m_Type(type),
- m_Name(name), m_Filter(filter), m_Zone(zone), m_Module(module), m_ClosedVars(closedVars), m_Expression(expression)
+ m_Name(name), m_Filter(filter), m_Zone(zone), m_Package(package), m_ClosedVars(closedVars), m_Expression(expression)
{ }
~ObjectExpression(void)
Expression *m_Name;
boost::shared_ptr<Expression> m_Filter;
String m_Zone;
- String m_Module;
+ String m_Package;
std::map<String, Expression *> *m_ClosedVars;
boost::shared_ptr<Expression> m_Expression;
};
}
static inline Value NewApply(ScriptFrame& frame, const String& type, const String& target, const String& name, const boost::shared_ptr<Expression>& filter,
- const String& module, const String& fkvar, const String& fvvar, const boost::shared_ptr<Expression>& fterm, std::map<String, Expression *> *closedVars,
+ const String& package, const String& fkvar, const String& fvvar, const boost::shared_ptr<Expression>& fterm, std::map<String, Expression *> *closedVars,
const boost::shared_ptr<Expression>& expression, const DebugInfo& debugInfo = DebugInfo())
{
- ApplyRule::AddRule(type, target, name, expression, filter, module, fkvar,
+ ApplyRule::AddRule(type, target, name, expression, filter, package, fkvar,
fvvar, fterm, debugInfo, EvaluateClosedVars(frame, closedVars));
return Empty;
}
static inline Value NewObject(ScriptFrame& frame, bool abstract, const String& type, const String& name, const boost::shared_ptr<Expression>& filter,
- const String& zone, const String& module, std::map<String, Expression *> *closedVars, const boost::shared_ptr<Expression>& expression, const DebugInfo& debugInfo = DebugInfo())
+ const String& zone, const String& package, std::map<String, Expression *> *closedVars, const boost::shared_ptr<Expression>& expression, const DebugInfo& debugInfo = DebugInfo())
{
ConfigItemBuilder::Ptr item = new ConfigItemBuilder(debugInfo);
item->SetAbstract(abstract);
item->SetScope(EvaluateClosedVars(frame, closedVars));
item->SetZone(zone);
- item->SetModule(module);
+ item->SetPackage(package);
item->SetFilter(filter);
item->Compile()->Register();
if (!zone.IsEmpty())
builder->AddExpression(new SetExpression(MakeIndexer(ScopeThis, "zone"), OpSetLiteral, MakeLiteral(zone), di));
- builder->AddExpression(new SetExpression(MakeIndexer(ScopeThis, "module"), OpSetLiteral, MakeLiteral(rule.GetModule()), di));
+ builder->AddExpression(new SetExpression(MakeIndexer(ScopeThis, "package"), OpSetLiteral, MakeLiteral(rule.GetPackage()), di));
builder->AddExpression(new OwnedExpression(rule.GetExpression()));
if (!zone.IsEmpty())
builder->AddExpression(new SetExpression(MakeIndexer(ScopeThis, "zone"), OpSetLiteral, MakeLiteral(zone), di));
- builder->AddExpression(new SetExpression(MakeIndexer(ScopeThis, "module"), OpSetLiteral, MakeLiteral(rule.GetModule()), di));
+ builder->AddExpression(new SetExpression(MakeIndexer(ScopeThis, "package"), OpSetLiteral, MakeLiteral(rule.GetPackage()), di));
builder->AddExpression(new OwnedExpression(rule.GetExpression()));
if (!zone.IsEmpty())
builder->AddExpression(new SetExpression(MakeIndexer(ScopeThis, "zone"), OpSetLiteral, MakeLiteral(zone), di));
- builder->AddExpression(new SetExpression(MakeIndexer(ScopeThis, "module"), OpSetLiteral, MakeLiteral(rule.GetModule()), di));
+ builder->AddExpression(new SetExpression(MakeIndexer(ScopeThis, "package"), OpSetLiteral, MakeLiteral(rule.GetPackage()), di));
builder->AddExpression(new OwnedExpression(rule.GetExpression()));
if (!zone.IsEmpty())
builder->AddExpression(new SetExpression(MakeIndexer(ScopeThis, "zone"), OpSetLiteral, MakeLiteral(zone), di));
- builder->AddExpression(new SetExpression(MakeIndexer(ScopeThis, "module"), OpSetLiteral, MakeLiteral(rule.GetModule()), di));
+ builder->AddExpression(new SetExpression(MakeIndexer(ScopeThis, "package"), OpSetLiteral, MakeLiteral(rule.GetPackage()), di));
builder->AddExpression(new OwnedExpression(rule.GetExpression()));
actionshandler.cpp apiaction.cpp
apifunction.cpp apilistener.cpp apilistener.thpp apilistener-sync.cpp
apiuser.cpp apiuser.thpp authority.cpp base64.cpp
- configfileshandler.cpp configmoduleshandler.cpp configmoduleutility.cpp configobjectutility.cpp
+ configfileshandler.cpp configpackageshandler.cpp configpackageutility.cpp configobjectutility.cpp
configstageshandler.cpp createobjecthandler.cpp deleteobjecthandler.cpp
endpoint.cpp endpoint.thpp filterutility.cpp
httpchunkedencoding.cpp httpclientconnection.cpp httpserverconnection.cpp httphandler.cpp httprequest.cpp httpresponse.cpp
******************************************************************************/
#include "remote/configfileshandler.hpp"
-#include "remote/configmoduleutility.hpp"
+#include "remote/configpackageutility.hpp"
#include "remote/httputility.hpp"
#include "base/exception.hpp"
#include <boost/algorithm/string/join.hpp>
const std::vector<String>& urlPath = request.RequestUrl->GetPath();
if (urlPath.size() >= 4)
- params->Set("module", urlPath[3]);
+ params->Set("package", urlPath[3]);
if (urlPath.size() >= 5)
params->Set("stage", urlPath[4]);
params->Set("path", boost::algorithm::join(tmpPath, "/"));
}
- String moduleName = HttpUtility::GetLastParameter(params, "module");
+ String packageName = HttpUtility::GetLastParameter(params, "package");
String stageName = HttpUtility::GetLastParameter(params, "stage");
- if (!ConfigModuleUtility::ValidateName(moduleName) || !ConfigModuleUtility::ValidateName(stageName)) {
+ if (!ConfigPackageUtility::ValidateName(packageName) || !ConfigPackageUtility::ValidateName(stageName)) {
response.SetStatus(403, "Forbidden");
return;
}
String relativePath = HttpUtility::GetLastParameter(params, "path");
- if (ConfigModuleUtility::ContainsDotDot(relativePath)) {
+ if (ConfigPackageUtility::ContainsDotDot(relativePath)) {
response.SetStatus(403, "Forbidden");
return;
}
- String path = ConfigModuleUtility::GetModuleDir() + "/" + moduleName + "/" + stageName + "/" + relativePath;
+ String path = ConfigPackageUtility::GetPackageDir() + "/" + packageName + "/" + stageName + "/" + relativePath;
if (!Utility::PathExists(path)) {
response.SetStatus(404, "File not found");
******************************************************************************/
#include "remote/configobjectutility.hpp"
-#include "remote/configmoduleutility.hpp"
+#include "remote/configpackageutility.hpp"
#include "config/configitembuilder.hpp"
#include "config/configitem.hpp"
#include "config/configwriter.hpp"
String ConfigObjectUtility::GetConfigDir(void)
{
- return ConfigModuleUtility::GetModuleDir() + "/_api/" +
- ConfigModuleUtility::GetActiveStage("_api");
+ return ConfigPackageUtility::GetPackageDir() + "/_api/" +
+ ConfigPackageUtility::GetActiveStage("_api");
}
String ConfigObjectUtility::EscapeName(const String& name)
builder->SetType(type->GetName());
builder->SetName(name);
builder->SetScope(ScriptGlobal::GetGlobals());
- builder->SetModule("_api");
+ builder->SetPackage("_api");
if (templates) {
ObjectLock olock(templates);
return false;
}
- if (!ConfigModuleUtility::ModuleExists("_api")) {
- ConfigModuleUtility::CreateModule("_api");
+ if (!ConfigPackageUtility::PackageExists("_api")) {
+ ConfigPackageUtility::CreatePackage("_api");
- String stage = ConfigModuleUtility::CreateStage("_api");
- ConfigModuleUtility::ActivateStage("_api", stage);
+ String stage = ConfigPackageUtility::CreateStage("_api");
+ ConfigPackageUtility::ActivateStage("_api", stage);
}
String typeDir = type->GetPluralName();
bool ConfigObjectUtility::DeleteObject(const ConfigObject::Ptr& object, bool cascade, const Array::Ptr& errors)
{
- if (object->GetModule() != "_api") {
+ if (object->GetPackage() != "_api") {
if (errors)
errors->Add("Object cannot be deleted because it was not created using the API.");
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
******************************************************************************/
-#include "remote/configmoduleshandler.hpp"
-#include "remote/configmoduleutility.hpp"
+#include "remote/configpackageshandler.hpp"
+#include "remote/configpackageutility.hpp"
#include "remote/httputility.hpp"
#include "base/exception.hpp"
using namespace icinga;
-REGISTER_URLHANDLER("/v1/config/modules", ConfigModulesHandler);
+REGISTER_URLHANDLER("/v1/config/packages", ConfigPackagesHandler);
-bool ConfigModulesHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& request, HttpResponse& response)
+bool ConfigPackagesHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& request, HttpResponse& response)
{
if (request.RequestUrl->GetPath().size() > 4)
return false;
return true;
}
-void ConfigModulesHandler::HandleGet(const ApiUser::Ptr& user, HttpRequest& request, HttpResponse& response)
+void ConfigPackagesHandler::HandleGet(const ApiUser::Ptr& user, HttpRequest& request, HttpResponse& response)
{
- std::vector<String> modules = ConfigModuleUtility::GetModules();
+ std::vector<String> packages = ConfigPackageUtility::GetPackages();
Array::Ptr results = new Array();
- BOOST_FOREACH(const String& module, modules) {
- Dictionary::Ptr moduleInfo = new Dictionary();
- moduleInfo->Set("name", module);
- moduleInfo->Set("stages", Array::FromVector(ConfigModuleUtility::GetStages(module)));
- moduleInfo->Set("active-stage", ConfigModuleUtility::GetActiveStage(module));
- results->Add(moduleInfo);
+ BOOST_FOREACH(const String& package, packages) {
+ Dictionary::Ptr packageInfo = new Dictionary();
+ packageInfo->Set("name", package);
+ packageInfo->Set("stages", Array::FromVector(ConfigPackageUtility::GetStages(package)));
+ packageInfo->Set("active-stage", ConfigPackageUtility::GetActiveStage(package));
+ results->Add(packageInfo);
}
Dictionary::Ptr result = new Dictionary();
HttpUtility::SendJsonBody(response, result);
}
-void ConfigModulesHandler::HandlePost(const ApiUser::Ptr& user, HttpRequest& request, HttpResponse& response)
+void ConfigPackagesHandler::HandlePost(const ApiUser::Ptr& user, HttpRequest& request, HttpResponse& response)
{
Dictionary::Ptr params = HttpUtility::FetchRequestParameters(request);
if (request.RequestUrl->GetPath().size() >= 4)
- params->Set("module", request.RequestUrl->GetPath()[3]);
+ params->Set("package", request.RequestUrl->GetPath()[3]);
- String moduleName = HttpUtility::GetLastParameter(params, "module");
+ String packageName = HttpUtility::GetLastParameter(params, "package");
- if (!ConfigModuleUtility::ValidateName(moduleName)) {
+ if (!ConfigPackageUtility::ValidateName(packageName)) {
response.SetStatus(403, "Forbidden");
return;
}
int code = 200;
- String status = "Created module.";
+ String status = "Created package.";
try {
- ConfigModuleUtility::CreateModule(moduleName);
+ ConfigPackageUtility::CreatePackage(packageName);
} catch (const std::exception& ex) {
code = 501;
status = "Error: " + DiagnosticInformation(ex);
Dictionary::Ptr result1 = new Dictionary();
- result1->Set("module", moduleName);
+ result1->Set("package", packageName);
result1->Set("code", code);
result1->Set("status", status);
HttpUtility::SendJsonBody(response, result);
}
-void ConfigModulesHandler::HandleDelete(const ApiUser::Ptr& user, HttpRequest& request, HttpResponse& response)
+void ConfigPackagesHandler::HandleDelete(const ApiUser::Ptr& user, HttpRequest& request, HttpResponse& response)
{
Dictionary::Ptr params = HttpUtility::FetchRequestParameters(request);
if (request.RequestUrl->GetPath().size() >= 4)
- params->Set("module", request.RequestUrl->GetPath()[3]);
+ params->Set("package", request.RequestUrl->GetPath()[3]);
- String moduleName = HttpUtility::GetLastParameter(params, "module");
+ String packageName = HttpUtility::GetLastParameter(params, "package");
- if (!ConfigModuleUtility::ValidateName(moduleName)) {
+ if (!ConfigPackageUtility::ValidateName(packageName)) {
response.SetStatus(403, "Forbidden");
return;
}
int code = 200;
- String status = "Deleted module.";
+ String status = "Deleted package.";
try {
- ConfigModuleUtility::DeleteModule(moduleName);
+ ConfigPackageUtility::DeletePackage(packageName);
} catch (const std::exception& ex) {
code = 501;
status = "Error: " + DiagnosticInformation(ex);
Dictionary::Ptr result1 = new Dictionary();
- result1->Set("module", moduleName);
+ result1->Set("package", packageName);
result1->Set("code", code);
result1->Set("status", status);
namespace icinga
{
-class I2_REMOTE_API ConfigModulesHandler : public HttpHandler
+class I2_REMOTE_API ConfigPackagesHandler : public HttpHandler
{
public:
- DECLARE_PTR_TYPEDEFS(ConfigModulesHandler);
+ DECLARE_PTR_TYPEDEFS(ConfigPackagesHandler);
virtual bool HandleRequest(const ApiUser::Ptr& user, HttpRequest& request, HttpResponse& response) override;
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
******************************************************************************/
-#include "remote/configmoduleutility.hpp"
+#include "remote/configpackageutility.hpp"
#include "base/application.hpp"
#include "base/exception.hpp"
#include "base/scriptglobal.hpp"
using namespace icinga;
-String ConfigModuleUtility::GetModuleDir(void)
+String ConfigPackageUtility::GetPackageDir(void)
{
- return Application::GetLocalStateDir() + "/lib/icinga2/api/modules";
+ return Application::GetLocalStateDir() + "/lib/icinga2/api/packages";
}
-void ConfigModuleUtility::CreateModule(const String& name)
+void ConfigPackageUtility::CreatePackage(const String& name)
{
- String path = GetModuleDir() + "/" + name;
+ String path = GetPackageDir() + "/" + name;
if (Utility::PathExists(path))
- BOOST_THROW_EXCEPTION(std::invalid_argument("Module already exists."));
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Package already exists."));
Utility::MkDirP(path, 0700);
- WriteModuleConfig(name);
+ WritePackageConfig(name);
}
-void ConfigModuleUtility::DeleteModule(const String& name)
+void ConfigPackageUtility::DeletePackage(const String& name)
{
- String path = GetModuleDir() + "/" + name;
+ String path = GetPackageDir() + "/" + name;
if (!Utility::PathExists(path))
- BOOST_THROW_EXCEPTION(std::invalid_argument("Module does not exist."));
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Package does not exist."));
Utility::RemoveDirRecursive(path);
Application::RequestRestart();
}
-std::vector<String> ConfigModuleUtility::GetModules(void)
+std::vector<String> ConfigPackageUtility::GetPackages(void)
{
- std::vector<String> modules;
- Utility::Glob(GetModuleDir() + "/*", boost::bind(&ConfigModuleUtility::CollectDirNames, _1, boost::ref(modules)), GlobDirectory);
- return modules;
+ std::vector<String> packages;
+ Utility::Glob(GetPackageDir() + "/*", boost::bind(&ConfigPackageUtility::CollectDirNames, _1, boost::ref(packages)), GlobDirectory);
+ return packages;
}
-void ConfigModuleUtility::CollectDirNames(const String& path, std::vector<String>& dirs)
+void ConfigPackageUtility::CollectDirNames(const String& path, std::vector<String>& dirs)
{
String name = Utility::BaseName(path);
dirs.push_back(name);
}
-bool ConfigModuleUtility::ModuleExists(const String& name)
+bool ConfigPackageUtility::PackageExists(const String& name)
{
- return Utility::PathExists(GetModuleDir() + "/" + name);
+ return Utility::PathExists(GetPackageDir() + "/" + name);
}
-String ConfigModuleUtility::CreateStage(const String& moduleName, const Dictionary::Ptr& files)
+String ConfigPackageUtility::CreateStage(const String& packageName, const Dictionary::Ptr& files)
{
String stageName = Utility::NewUniqueID();
- String path = GetModuleDir() + "/" + moduleName;
+ String path = GetPackageDir() + "/" + packageName;
if (!Utility::PathExists(path))
- BOOST_THROW_EXCEPTION(std::invalid_argument("Module does not exist."));
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Package does not exist."));
path += "/" + stageName;
Utility::MkDirP(path, 0700);
Utility::MkDirP(path + "/conf.d", 0700);
Utility::MkDirP(path + "/zones.d", 0700);
- WriteStageConfig(moduleName, stageName);
+ WriteStageConfig(packageName, stageName);
bool foundDotDot = false;
String filePath = path + "/" + kv.first;
- Log(LogInformation, "ConfigModuleUtility")
+ Log(LogInformation, "ConfigPackageUtility")
<< "Updating configuration file: " << filePath;
//pass the directory and generate a dir tree, if not existing already
return stageName;
}
-void ConfigModuleUtility::WriteModuleConfig(const String& moduleName)
+void ConfigPackageUtility::WritePackageConfig(const String& packageName)
{
- String stageName = GetActiveStage(moduleName);
+ String stageName = GetActiveStage(packageName);
- String includePath = GetModuleDir() + "/" + moduleName + "/include.conf";
+ String includePath = GetPackageDir() + "/" + packageName + "/include.conf";
std::ofstream fpInclude(includePath.CStr(), std::ofstream::out | std::ostream::binary | std::ostream::trunc);
fpInclude << "include \"*/include.conf\"\n";
fpInclude.close();
- String activePath = GetModuleDir() + "/" + moduleName + "/active.conf";
+ String activePath = GetPackageDir() + "/" + packageName + "/active.conf";
std::ofstream fpActive(activePath.CStr(), std::ofstream::out | std::ostream::binary | std::ostream::trunc);
fpActive << "if (!globals.contains(\"ActiveStages\")) {\n"
<< " globals.ActiveStages = {}\n"
<< "\n"
<< "if (globals.contains(\"ActiveStageOverride\")) {\n"
<< " var arr = ActiveStageOverride.split(\":\")\n"
- << " if (arr[0] == \"" << moduleName << "\") {\n"
+ << " if (arr[0] == \"" << packageName << "\") {\n"
<< " if (arr.len() < 2) {\n"
<< " log(LogCritical, \"Config\", \"Invalid value for ActiveStageOverride\")\n"
<< " } else {\n"
- << " ActiveStages[\"" << moduleName << "\"] = arr[1]\n"
+ << " ActiveStages[\"" << packageName << "\"] = arr[1]\n"
<< " }\n"
<< " }\n"
<< "}\n"
<< "\n"
- << "if (!ActiveStages.contains(\"" << moduleName << "\")) {\n"
- << " ActiveStages[\"" << moduleName << "\"] = \"" << stageName << "\"\n"
+ << "if (!ActiveStages.contains(\"" << packageName << "\")) {\n"
+ << " ActiveStages[\"" << packageName << "\"] = \"" << stageName << "\"\n"
<< "}\n";
fpActive.close();
}
-void ConfigModuleUtility::WriteStageConfig(const String& moduleName, const String& stageName)
+void ConfigPackageUtility::WriteStageConfig(const String& packageName, const String& stageName)
{
- String path = GetModuleDir() + "/" + moduleName + "/" + stageName + "/include.conf";
+ String path = GetPackageDir() + "/" + packageName + "/" + stageName + "/include.conf";
std::ofstream fp(path.CStr(), std::ofstream::out | std::ostream::binary | std::ostream::trunc);
fp << "include \"../active.conf\"\n"
- << "if (ActiveStages[\"" << moduleName << "\"] == \"" << stageName << "\") {\n"
+ << "if (ActiveStages[\"" << packageName << "\"] == \"" << stageName << "\") {\n"
<< " include_recursive \"conf.d\"\n"
- << " include_zones \"" << moduleName << "\", \"zones.d\"\n"
+ << " include_zones \"" << packageName << "\", \"zones.d\"\n"
<< "}\n";
fp.close();
}
-void ConfigModuleUtility::ActivateStage(const String& moduleName, const String& stageName)
+void ConfigPackageUtility::ActivateStage(const String& packageName, const String& stageName)
{
- String activeStagePath = GetModuleDir() + "/" + moduleName + "/active-stage";
+ String activeStagePath = GetPackageDir() + "/" + packageName + "/active-stage";
std::ofstream fpActiveStage(activeStagePath.CStr(), std::ofstream::out | std::ostream::binary | std::ostream::trunc);
fpActiveStage << stageName;
fpActiveStage.close();
- WriteModuleConfig(moduleName);
+ WritePackageConfig(packageName);
}
-void ConfigModuleUtility::TryActivateStageCallback(const ProcessResult& pr, const String& moduleName, const String& stageName)
+void ConfigPackageUtility::TryActivateStageCallback(const ProcessResult& pr, const String& packageName, const String& stageName)
{
- String logFile = GetModuleDir() + "/" + moduleName + "/" + stageName + "/startup.log";
+ String logFile = GetPackageDir() + "/" + packageName + "/" + stageName + "/startup.log";
std::ofstream fpLog(logFile.CStr(), std::ofstream::out | std::ostream::binary | std::ostream::trunc);
fpLog << pr.Output;
fpLog.close();
- String statusFile = GetModuleDir() + "/" + moduleName + "/" + stageName + "/status";
+ String statusFile = GetPackageDir() + "/" + packageName + "/" + stageName + "/status";
std::ofstream fpStatus(statusFile.CStr(), std::ofstream::out | std::ostream::binary | std::ostream::trunc);
fpStatus << pr.ExitStatus;
fpStatus.close();
/* validation went fine, activate stage and reload */
if (pr.ExitStatus == 0) {
- ActivateStage(moduleName, stageName);
+ ActivateStage(packageName, stageName);
Application::RequestRestart();
} else {
- Log(LogCritical, "ConfigModuleUtility")
- << "Config validation failed for module '"
- << moduleName << "' and stage '" << stageName << "'.";
+ Log(LogCritical, "ConfigPackageUtility")
+ << "Config validation failed for package '"
+ << packageName << "' and stage '" << stageName << "'.";
}
}
-void ConfigModuleUtility::AsyncTryActivateStage(const String& moduleName, const String& stageName)
+void ConfigPackageUtility::AsyncTryActivateStage(const String& packageName, const String& stageName)
{
// prepare arguments
Array::Ptr args = new Array();
args->Add("daemon");
args->Add("--validate");
args->Add("--define");
- args->Add("ActiveStageOverride=" + moduleName + ":" + stageName);
+ args->Add("ActiveStageOverride=" + packageName + ":" + stageName);
Process::Ptr process = new Process(Process::PrepareCommand(args));
process->SetTimeout(300);
- process->Run(boost::bind(&TryActivateStageCallback, _1, moduleName, stageName));
+ process->Run(boost::bind(&TryActivateStageCallback, _1, packageName, stageName));
}
-void ConfigModuleUtility::DeleteStage(const String& moduleName, const String& stageName)
+void ConfigPackageUtility::DeleteStage(const String& packageName, const String& stageName)
{
- String path = GetModuleDir() + "/" + moduleName + "/" + stageName;
+ String path = GetPackageDir() + "/" + packageName + "/" + stageName;
if (!Utility::PathExists(path))
BOOST_THROW_EXCEPTION(std::invalid_argument("Stage does not exist."));
- if (GetActiveStage(moduleName) == stageName)
+ if (GetActiveStage(packageName) == stageName)
BOOST_THROW_EXCEPTION(std::invalid_argument("Active stage cannot be deleted."));
Utility::RemoveDirRecursive(path);
}
-std::vector<String> ConfigModuleUtility::GetStages(const String& moduleName)
+std::vector<String> ConfigPackageUtility::GetStages(const String& packageName)
{
std::vector<String> stages;
- Utility::Glob(GetModuleDir() + "/" + moduleName + "/*", boost::bind(&ConfigModuleUtility::CollectDirNames, _1, boost::ref(stages)), GlobDirectory);
+ Utility::Glob(GetPackageDir() + "/" + packageName + "/*", boost::bind(&ConfigPackageUtility::CollectDirNames, _1, boost::ref(stages)), GlobDirectory);
return stages;
}
-String ConfigModuleUtility::GetActiveStage(const String& moduleName)
+String ConfigPackageUtility::GetActiveStage(const String& packageName)
{
- String path = GetModuleDir() + "/" + moduleName + "/active-stage";
+ String path = GetPackageDir() + "/" + packageName + "/active-stage";
std::ifstream fp;
fp.open(path.CStr());
}
-std::vector<std::pair<String, bool> > ConfigModuleUtility::GetFiles(const String& moduleName, const String& stageName)
+std::vector<std::pair<String, bool> > ConfigPackageUtility::GetFiles(const String& packageName, const String& stageName)
{
std::vector<std::pair<String, bool> > paths;
- Utility::GlobRecursive(GetModuleDir() + "/" + moduleName + "/" + stageName, "*", boost::bind(&ConfigModuleUtility::CollectPaths, _1, boost::ref(paths)), GlobDirectory | GlobFile);
+ Utility::GlobRecursive(GetPackageDir() + "/" + packageName + "/" + stageName, "*", boost::bind(&ConfigPackageUtility::CollectPaths, _1, boost::ref(paths)), GlobDirectory | GlobFile);
return paths;
}
-void ConfigModuleUtility::CollectPaths(const String& path, std::vector<std::pair<String, bool> >& paths)
+void ConfigPackageUtility::CollectPaths(const String& path, std::vector<std::pair<String, bool> >& paths)
{
#ifndef _WIN32
struct stat statbuf;
#endif /* _WIN32 */
}
-bool ConfigModuleUtility::ContainsDotDot(const String& path)
+bool ConfigPackageUtility::ContainsDotDot(const String& path)
{
std::vector<String> tokens;
boost::algorithm::split(tokens, path, boost::is_any_of("/\\"));
return false;
}
-bool ConfigModuleUtility::ValidateName(const String& name)
+bool ConfigPackageUtility::ValidateName(const String& name)
{
if (name.IsEmpty())
return false;
*
* @ingroup remote
*/
-class I2_REMOTE_API ConfigModuleUtility
+class I2_REMOTE_API ConfigPackageUtility
{
public:
- static String GetModuleDir(void);
+ static String GetPackageDir(void);
- static void CreateModule(const String& name);
- static void DeleteModule(const String& name);
- static std::vector<String> GetModules(void);
- static bool ModuleExists(const String& name);
+ static void CreatePackage(const String& name);
+ static void DeletePackage(const String& name);
+ static std::vector<String> GetPackages(void);
+ static bool PackageExists(const String& name);
- static String CreateStage(const String& moduleName, const Dictionary::Ptr& files = Dictionary::Ptr());
- static void DeleteStage(const String& moduleName, const String& stageName);
- static std::vector<String> GetStages(const String& moduleName);
- static String GetActiveStage(const String& moduleName);
- static void ActivateStage(const String& moduleName, const String& stageName);
- static void AsyncTryActivateStage(const String& moduleName, const String& stageName);
+ static String CreateStage(const String& packageName, const Dictionary::Ptr& files = Dictionary::Ptr());
+ static void DeleteStage(const String& packageName, const String& stageName);
+ static std::vector<String> GetStages(const String& packageName);
+ static String GetActiveStage(const String& packageName);
+ static void ActivateStage(const String& packageName, const String& stageName);
+ static void AsyncTryActivateStage(const String& packageName, const String& stageName);
- static std::vector<std::pair<String, bool> > GetFiles(const String& moduleName, const String& stageName);
+ static std::vector<std::pair<String, bool> > GetFiles(const String& packageName, const String& stageName);
static bool ContainsDotDot(const String& path);
static bool ValidateName(const String& name);
static void CollectDirNames(const String& path, std::vector<String>& dirs);
static void CollectPaths(const String& path, std::vector<std::pair<String, bool> >& paths);
- static void WriteModuleConfig(const String& moduleName);
- static void WriteStageConfig(const String& moduleName, const String& stageName);
+ static void WritePackageConfig(const String& packageName);
+ static void WriteStageConfig(const String& packageName, const String& stageName);
- static void TryActivateStageCallback(const ProcessResult& pr, const String& moduleName, const String& stageName);
+ static void TryActivateStageCallback(const ProcessResult& pr, const String& packageName, const String& stageName);
};
}
******************************************************************************/
#include "remote/configstageshandler.hpp"
-#include "remote/configmoduleutility.hpp"
+#include "remote/configpackageutility.hpp"
#include "remote/httputility.hpp"
#include "base/application.hpp"
#include "base/exception.hpp"
Dictionary::Ptr params = HttpUtility::FetchRequestParameters(request);
if (request.RequestUrl->GetPath().size() >= 4)
- params->Set("module", request.RequestUrl->GetPath()[3]);
+ params->Set("package", request.RequestUrl->GetPath()[3]);
if (request.RequestUrl->GetPath().size() >= 5)
params->Set("stage", request.RequestUrl->GetPath()[4]);
- String moduleName = HttpUtility::GetLastParameter(params, "module");
+ String packageName = HttpUtility::GetLastParameter(params, "package");
String stageName = HttpUtility::GetLastParameter(params, "stage");
- if (!ConfigModuleUtility::ValidateName(moduleName) || !ConfigModuleUtility::ValidateName(stageName)) {
+ if (!ConfigPackageUtility::ValidateName(packageName) || !ConfigPackageUtility::ValidateName(stageName)) {
response.SetStatus(403, "Forbidden");
return;
}
Array::Ptr results = new Array();
- std::vector<std::pair<String, bool> > paths = ConfigModuleUtility::GetFiles(moduleName, stageName);
+ std::vector<std::pair<String, bool> > paths = ConfigPackageUtility::GetFiles(packageName, stageName);
- String prefixPath = ConfigModuleUtility::GetModuleDir() + "/" + moduleName + "/" + stageName + "/";
+ String prefixPath = ConfigPackageUtility::GetPackageDir() + "/" + packageName + "/" + stageName + "/";
typedef std::pair<String, bool> kv_pair;
BOOST_FOREACH(const kv_pair& kv, paths) {
Dictionary::Ptr params = HttpUtility::FetchRequestParameters(request);
if (request.RequestUrl->GetPath().size() >= 4)
- params->Set("module", request.RequestUrl->GetPath()[3]);
+ params->Set("package", request.RequestUrl->GetPath()[3]);
- String moduleName = HttpUtility::GetLastParameter(params, "module");
+ String packageName = HttpUtility::GetLastParameter(params, "package");
- if (!ConfigModuleUtility::ValidateName(moduleName)) {
+ if (!ConfigPackageUtility::ValidateName(packageName)) {
response.SetStatus(403, "Forbidden");
return;
}
if (!files)
BOOST_THROW_EXCEPTION(std::invalid_argument("Parameter 'files' must be specified."));
- stageName = ConfigModuleUtility::CreateStage(moduleName, files);
+ stageName = ConfigPackageUtility::CreateStage(packageName, files);
/* validate the config. on success, activate stage and reload */
- ConfigModuleUtility::AsyncTryActivateStage(moduleName, stageName);
+ ConfigPackageUtility::AsyncTryActivateStage(packageName, stageName);
} catch (const std::exception& ex) {
code = 501;
status = "Error: " + DiagnosticInformation(ex);
Dictionary::Ptr result1 = new Dictionary();
- result1->Set("module", moduleName);
+ result1->Set("package", packageName);
result1->Set("stage", stageName);
result1->Set("code", code);
result1->Set("status", status);
Dictionary::Ptr params = HttpUtility::FetchRequestParameters(request);
if (request.RequestUrl->GetPath().size() >= 4)
- params->Set("module", request.RequestUrl->GetPath()[3]);
+ params->Set("package", request.RequestUrl->GetPath()[3]);
if (request.RequestUrl->GetPath().size() >= 5)
params->Set("stage", request.RequestUrl->GetPath()[4]);
- String moduleName = HttpUtility::GetLastParameter(params, "module");
+ String packageName = HttpUtility::GetLastParameter(params, "package");
String stageName = HttpUtility::GetLastParameter(params, "stage");
- if (!ConfigModuleUtility::ValidateName(moduleName) || !ConfigModuleUtility::ValidateName(stageName)) {
+ if (!ConfigPackageUtility::ValidateName(packageName) || !ConfigPackageUtility::ValidateName(stageName)) {
response.SetStatus(403, "Forbidden");
return;
}
String status = "Deleted stage.";
try {
- ConfigModuleUtility::DeleteStage(moduleName, stageName);
+ ConfigPackageUtility::DeleteStage(packageName, stageName);
} catch (const std::exception& ex) {
code = 501;
status = "Error: " + DiagnosticInformation(ex);
Dictionary::Ptr result1 = new Dictionary();
- result1->Set("module", moduleName);
+ result1->Set("package", packageName);
result1->Set("stage", stageName);
result1->Set("code", code);
result1->Set("status", status);