From f6074af3ea66946a0596d094c4c6b24eea8cfaf3 Mon Sep 17 00:00:00 2001 From: John Mears Date: Thu, 18 Apr 2024 18:20:31 -0600 Subject: [PATCH] condition: Add biosControl condition Add the basic biosControl condition kind with task parameters struct and functions. --- condition/bios_control.go | 46 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 condition/bios_control.go diff --git a/condition/bios_control.go b/condition/bios_control.go new file mode 100644 index 0000000..4c490fb --- /dev/null +++ b/condition/bios_control.go @@ -0,0 +1,46 @@ +package condition + +import ( + "encoding/json" + + "github.com/google/uuid" +) + +type ( + BiosControlAction string +) + +const ( + // BiosControl identifies the Condition kind to configure the BIOS. + BiosControl Kind = "biosControl" + + // ResetSettings will reset the BIOS to default settings. + ResetSettings BiosControlAction = "reset_settings" +) + +// BiosControlTaskParameters are the parameters that are passed for the BiosControl condition. +type BiosControlTaskParameters struct { + // Identifier for the Asset in the Asset store. + // + // Required: true + AssetID uuid.UUID `json:"asset_id"` + + // The bios control action to be performed + // + // Required: true + Action BiosControlAction `json:"action"` +} + +func NewBiosControlTaskParameters(assetID uuid.UUID, action BiosControlAction) *BiosControlTaskParameters { + return &BiosControlTaskParameters{ + AssetID: assetID, + Action: action, + } +} + +func NewBiosControlParametersFromCondition(condition *Condition) (*BiosControlTaskParameters, error) { + b := &BiosControlTaskParameters{} + err := json.Unmarshal(condition.Parameters, b) + + return b, err +}