mirror of
https://github.com/Icinga/icinga2.git
synced 2026-06-11 01:30:22 -04:00
Merge pull request #6204 from Icinga/fix/api-create-object-exists-errors
API: Check if objects exists and return proper error message
This commit is contained in:
commit
24752f3733
1 changed files with 7 additions and 0 deletions
|
|
@ -110,6 +110,13 @@ bool ConfigObjectUtility::CreateObject(const Type::Ptr& type, const String& full
|
|||
}
|
||||
}
|
||||
|
||||
ConfigItem::Ptr item = ConfigItem::GetByTypeAndName(type, fullName);
|
||||
|
||||
if (item) {
|
||||
errors->Add("Object '" + fullName + "' already exists.");
|
||||
return false;
|
||||
}
|
||||
|
||||
String path = GetObjectConfigPath(type, fullName);
|
||||
Utility::MkDirP(Utility::DirName(path), 0700);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue