buffet: Added minimal role into command definition
Possible values "viewer", "user", "owner", "manager".
Default minimal role is set to "user".
Role check is not yet implemented.
BUG=brillo:808
TEST=`FEATURES=test emerge-gizmo buffet`
Change-Id: I74d16c24618b50de1e7a2ffa37d7aef36978a38a
Reviewed-on: https://chromium-review.googlesource.com/274117
Reviewed-by: Vitaly Buka <vitalybuka@chromium.org>
Commit-Queue: Vitaly Buka <vitalybuka@chromium.org>
Tested-by: Vitaly Buka <vitalybuka@chromium.org>
diff --git a/buffet/commands/command_definition.h b/buffet/commands/command_definition.h
index a5e2916..ea8e5e6 100644
--- a/buffet/commands/command_definition.h
+++ b/buffet/commands/command_definition.h
@@ -11,6 +11,7 @@
#include <base/macros.h>
#include "buffet/commands/object_schema.h"
+#include "buffet/commands/user_role.h"
namespace buffet {
@@ -61,6 +62,10 @@
const Visibility& GetVisibility() const { return visibility_; }
// Changes the command visibility.
void SetVisibility(const Visibility& visibility);
+ // Returns the role required to execute command.
+ UserRole GetMinimalRole() const { return minimal_role_; }
+ // Changes the role required to execute command.
+ void SetMinimalRole(UserRole minimal_role) { minimal_role_ = minimal_role; }
private:
std::string category_; // Cmd category. Could be "powerd" for "base.reboot".
@@ -68,6 +73,8 @@
std::unique_ptr<const ObjectSchema> progress_; // Command progress def.
std::unique_ptr<const ObjectSchema> results_; // Command results def.
Visibility visibility_; // Available to all by default.
+ // Minimal role required to execute command.
+ UserRole minimal_role_{UserRole::kUser};
DISALLOW_COPY_AND_ASSIGN(CommandDefinition);
};