management: add Flags and Mask fields to faces/create and faces/update
refs #3731
Change-Id: I35fb84a875767649da0cb354be5e5c07de179198
diff --git a/src/management/nfd-control-command.cpp b/src/management/nfd-control-command.cpp
index 88db4f9..9853f9d 100644
--- a/src/management/nfd-control-command.cpp
+++ b/src/management/nfd-control-command.cpp
@@ -98,22 +98,37 @@
{
m_requestValidator
.required(CONTROL_PARAMETER_URI)
- .optional(CONTROL_PARAMETER_FACE_PERSISTENCY);
+ .optional(CONTROL_PARAMETER_FACE_PERSISTENCY)
+ .optional(CONTROL_PARAMETER_FLAGS)
+ .optional(CONTROL_PARAMETER_MASK);
m_responseValidator
- .required(CONTROL_PARAMETER_URI)
.required(CONTROL_PARAMETER_FACE_ID)
- .required(CONTROL_PARAMETER_FACE_PERSISTENCY);
+ .required(CONTROL_PARAMETER_FACE_PERSISTENCY)
+ .optional(CONTROL_PARAMETER_FLAGS)
+ .optional(CONTROL_PARAMETER_URI);
}
void
FaceCreateCommand::applyDefaultsToRequest(ControlParameters& parameters) const
{
+ parameters.setFaceId(0);
+
if (!parameters.hasFacePersistency()) {
parameters.setFacePersistency(FacePersistency::FACE_PERSISTENCY_PERSISTENT);
}
}
void
+FaceCreateCommand::validateRequest(const ControlParameters& parameters) const
+{
+ this->ControlCommand::validateRequest(parameters);
+
+ if (parameters.hasFlags() != parameters.hasMask()) {
+ BOOST_THROW_EXCEPTION(ArgumentError("Flags must be accompanied by Mask"));
+ }
+}
+
+void
FaceCreateCommand::validateResponse(const ControlParameters& parameters) const
{
this->ControlCommand::validateResponse(parameters);
@@ -127,12 +142,21 @@
: ControlCommand("faces", "update")
{
m_requestValidator
- .required(CONTROL_PARAMETER_FACE_ID)
- .optional(CONTROL_PARAMETER_FACE_PERSISTENCY);
+ .optional(CONTROL_PARAMETER_FACE_ID)
+ .optional(CONTROL_PARAMETER_FACE_PERSISTENCY)
+ .optional(CONTROL_PARAMETER_FLAGS)
+ .optional(CONTROL_PARAMETER_MASK);
m_responseValidator
- .required(CONTROL_PARAMETER_FACE_ID)
- .optional(CONTROL_PARAMETER_FACE_PERSISTENCY);
- m_responseValidator = m_requestValidator;
+ .optional(CONTROL_PARAMETER_FACE_ID)
+ .optional(CONTROL_PARAMETER_FACE_PERSISTENCY)
+ .optional(CONTROL_PARAMETER_FLAGS)
+ .optional(CONTROL_PARAMETER_MASK);
+}
+
+void
+FaceUpdateCommand::applyDefaultsToRequest(ControlParameters& parameters) const
+{
+ parameters.setFaceId(0);
}
void
@@ -140,8 +164,8 @@
{
this->ControlCommand::validateRequest(parameters);
- if (parameters.getFaceId() == 0) {
- BOOST_THROW_EXCEPTION(ArgumentError("FaceId must not be zero"));
+ if (parameters.hasFlags() != parameters.hasMask()) {
+ BOOST_THROW_EXCEPTION(ArgumentError("Flags must be accompanied by Mask"));
}
}