42 exceptions::python::declareException<BadNameError, exceptions::RuntimeError>(mod,
"BadNameError",
44 exceptions::python::declareException<DictionaryError, exceptions::DomainError>(mod,
"DictionaryError",
46 exceptions::python::declareException<NameNotFound, exceptions::NotFoundError>(mod,
"NameNotFound",
48 exceptions::python::declareException<TypeError, exceptions::DomainError>(mod,
"TypeError",
"DomainError");
49 auto clsValidationError =
50 exceptions::python::declareException<ValidationError>(mod,
"ValidationError",
"LogicError");
52 py::enum_<ValidationError::ErrorType>(clsValidationError,
"ErrorType")
53 .value(
"OK", ValidationError::ErrorType::OK)
54 .value(
"WRONG_TYPE", ValidationError::ErrorType::WRONG_TYPE)
55 .value(
"MISSING_REQUIRED", ValidationError::ErrorType::MISSING_REQUIRED)
56 .value(
"NOT_AN_ARRAY", ValidationError::ErrorType::NOT_AN_ARRAY)
57 .value(
"ARRAY_TOO_SHORT", ValidationError::ErrorType::ARRAY_TOO_SHORT)
58 .value(
"TOO_FEW_VALUES", ValidationError::ErrorType::TOO_FEW_VALUES)
59 .value(
"TOO_MANY_VALUES", ValidationError::ErrorType::TOO_MANY_VALUES)
60 .value(
"WRONG_OCCURRENCE_COUNT", ValidationError::ErrorType::WRONG_OCCURRENCE_COUNT)
61 .value(
"VALUE_DISALLOWED", ValidationError::ErrorType::VALUE_DISALLOWED)
62 .value(
"VALUE_OUT_OF_RANGE", ValidationError::ErrorType::VALUE_OUT_OF_RANGE)
63 .value(
"BAD_VALUE", ValidationError::ErrorType::BAD_VALUE)
64 .value(
"UNKNOWN_NAME", ValidationError::ErrorType::UNKNOWN_NAME)
65 .value(
"BAD_DEFINITION", ValidationError::ErrorType::BAD_DEFINITION)
66 .value(
"NOT_LOADED", ValidationError::ErrorType::NOT_LOADED)
67 .value(
"UNKNOWN_ERROR", ValidationError::ErrorType::UNKNOWN_ERROR)
70 clsValidationError.def(py::init<const std::string&>());
71 clsValidationError.def(py::init<char const*, int, char const*>());
73 clsValidationError.def_readonly_static(
"EMPTY", &ValidationError::EMPTY);
74 clsValidationError.def(
"getErrorMessageFor", &ValidationError::getErrorMessageFor);
75 clsValidationError.def(
"getParamCount", &ValidationError::getParamCount);
76 clsValidationError.def(
"paramNames", &ValidationError::paramNames);
77 clsValidationError.def(
"getParamNames", &ValidationError::getParamNames);
78 clsValidationError.def(
"getErrors",
79 (
int (ValidationError::*)(
const std::string&)
const) & ValidationError::getErrors);
80 clsValidationError.def(
"getErrors", (
int (ValidationError::*)()
const) & ValidationError::getErrors);
81 clsValidationError.def(
"describe", &ValidationError::describe);
82 clsValidationError.def(
"what", &ValidationError::what);
84 py::class_<Policy, std::shared_ptr<Policy>> clsPolicy(mod,
"Policy");
86 py::enum_<Policy::ValueType>(clsPolicy,
"ValueType")
87 .value(
"UNDETERMINED", Policy::ValueType::UNDETERMINED)
88 .value(
"UNDEF", Policy::ValueType::UNDEF)
89 .value(
"BOOL", Policy::ValueType::BOOL)
90 .value(
"INT", Policy::ValueType::INT)
91 .value(
"DOUBLE", Policy::ValueType::DOUBLE)
92 .value(
"STRING", Policy::ValueType::STRING)
93 .value(
"POLICY", Policy::ValueType::POLICY)
94 .value(
"FILE", Policy::ValueType::FILE)
97 clsPolicy.def(py::init<>());
98 clsPolicy.def(py::init<bool, const Dictionary&>());
99 clsPolicy.def(py::init<const std::string&>());
100 clsPolicy.def(py::init<Policy&, bool>(),
"pol"_a,
"deep"_a =
false);
101 clsPolicy.def(py::init<const PolicySource&>());
103 clsPolicy.def_static(
"createPolicyFromUrn", &Policy::createPolicyFromUrn,
"urn"_a,
"validate"_a =
true);
104 clsPolicy.def_static(
"createPolicy", (Policy * (*)(PolicySource&,
bool,
bool)) & Policy::createPolicy,
105 "input"_a,
"doIncludes"_a =
true,
"validate"_a =
true);
106 clsPolicy.def_static(
"createPolicy",
107 (Policy * (*)(
const std::string&,
bool,
bool)) & Policy::createPolicy,
"input"_a,
108 "doIncludes"_a =
true,
"validate"_a =
true);
109 clsPolicy.def_static(
"createPolicy",
110 (Policy * (*)(PolicySource&,
const std::string&,
bool)) & Policy::createPolicy,
111 "input"_a,
"repos"_a,
"validate"_a =
true);
112 clsPolicy.def_static(
"createPolicy",
114 "input"_a,
"repos"_a,
"validate"_a =
true);
115 clsPolicy.def(
"getValueType",
116 (Policy::ValueType (Policy::*)(
const std::string&)
const) & Policy::getValueType);
117 clsPolicy.def(
"nameCount", &Policy::nameCount);
119 "names"_a,
"topLevelOnly"_a =
false,
"append"_a =
false);
120 clsPolicy.def(
"paramNames",
122 "names"_a,
"topLevelOnly"_a =
false,
"append"_a =
false);
123 clsPolicy.def(
"policyNames",
125 "names"_a,
"topLevelOnly"_a =
false,
"append"_a =
false);
126 clsPolicy.def(
"fileNames",
128 "topLevelOnly"_a =
false,
"append"_a =
false);
129 clsPolicy.def(
"names", (Policy::StringArray (Policy::*)(
bool)
const) & Policy::names,
130 "topLevelOnly"_a =
false);
131 clsPolicy.def(
"paramNames", (Policy::StringArray (Policy::*)(
bool)
const) & Policy::paramNames,
132 "topLevelOnly"_a =
false);
133 clsPolicy.def(
"policyNames", (Policy::StringArray (Policy::*)(
bool)
const) & Policy::policyNames,
134 "topLevelOnly"_a =
false);
135 clsPolicy.def(
"fileNames", (Policy::StringArray (Policy::*)(
bool)
const) & Policy::fileNames,
136 "topLevelOnly"_a =
false);
137 clsPolicy.def(
"isDictionary", &Policy::isDictionary);
138 clsPolicy.def(
"canValidate", &Policy::canValidate);
139 clsPolicy.def(
"getDictionary", &Policy::getDictionary);
140 clsPolicy.def(
"setDictionary", &Policy::setDictionary);
142 clsPolicy.def(
"validate", [](Policy
const&
self) {
return self.validate(); });
143 clsPolicy.def(
"validate", [](Policy
const&
self, ValidationError* errs) {
return self.validate(errs); });
144 clsPolicy.def(
"valueCount", &Policy::valueCount);
145 clsPolicy.def(
"isArray", &Policy::isArray);
146 clsPolicy.def(
"exists", &Policy::exists);
147 clsPolicy.def(
"isBool", &Policy::isBool);
148 clsPolicy.def(
"isInt", &Policy::isInt);
149 clsPolicy.def(
"isDouble", &Policy::isDouble);
150 clsPolicy.def(
"isString", &Policy::isString);
151 clsPolicy.def(
"isPolicy", &Policy::isPolicy);
152 clsPolicy.def(
"isFile", &Policy::isFile);
153 clsPolicy.def(
"getTypeInfo", &Policy::getTypeInfo);
154 clsPolicy.def(
"getPolicy", (Policy::Ptr (Policy::*)(
const std::string&)) & Policy::getPolicy);
155 clsPolicy.def(
"getFile", &Policy::getFile);
156 clsPolicy.def(
"getBool", &Policy::getBool);
157 clsPolicy.def(
"getInt", &Policy::getInt);
158 clsPolicy.def(
"getDouble", &Policy::getDouble);
159 clsPolicy.def(
"getString", &Policy::getString);
160 clsPolicy.def(
"getPolicyArray", &Policy::getPolicyArray);
161 clsPolicy.def(
"getFileArray", &Policy::getFileArray);
162 clsPolicy.def(
"getBoolArray", &Policy::getBoolArray);
163 clsPolicy.def(
"getIntArray", &Policy::getIntArray);
164 clsPolicy.def(
"getDoubleArray", &Policy::getDoubleArray);
165 clsPolicy.def(
"getStringArray", &Policy::getStringArray);
168 clsPolicy.def(
"_set", (
void (Policy::*)(
const std::string&,
bool)) & Policy::set);
169 clsPolicy.def(
"_set", (
void (Policy::*)(
const std::string&,
int)) & Policy::set);
170 clsPolicy.def(
"_set", (
void (Policy::*)(
const std::string&,
double)) & Policy::set);
172 clsPolicy.def(
"add", (
void (Policy::*)(
const std::string&,
const Policy::Ptr&)) & Policy::add);
173 clsPolicy.def(
"add", (
void (Policy::*)(
const std::string&,
bool)) & Policy::add);
174 clsPolicy.def(
"add", (
void (Policy::*)(
const std::string&,
int)) & Policy::add);
175 clsPolicy.def(
"add", (
void (Policy::*)(
const std::string&,
double)) & Policy::add);
177 clsPolicy.def(
"remove", &Policy::remove);
178 clsPolicy.def(
"loadPolicyFiles", (
int (Policy::*)(
bool)) & Policy::loadPolicyFiles,
"strict"_a =
true);
181 clsPolicy.def(
"loadPolicyFiles",
182 [](Policy&
self,
const std::string& path,
bool strict =
true) ->
int {
183 return self.loadPolicyFiles(boost::filesystem::path(path), strict);
185 "repository"_a,
"strict"_a =
true);
189 clsPolicy.def(
"str", &Policy::str,
"name"_a,
"indent"_a =
"");
190 clsPolicy.def(
"toString", &Policy::toString);
191 clsPolicy.def(
"__str__", &Policy::toString);
192 clsPolicy.def(
"asPropertySet", &Policy::asPropertySet);
daf::base::PropertySet * set
def mergeDefaults(kwds, defaults)