--[[-- Copyright (c) 2024 Huawei Technologies Co., Ltd.
-- openUBMC is licensed under Mulan PSL v2.
-- You can use this software according to the terms and conditions of the Mulan PSL v2.
-- You may obtain a copy of Mulan PSL v2 at:
--          http://license.coscl.org.cn/MulanPSL2
-- THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
-- EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
-- MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
-- See the Mulan PSL v2 for more details.
]] --
local validate = require 'mc.validate'
local utils = require 'mc.utils'

local ClearElabelData = {}

---@class FrudataIpmiCmds.ClearElabelDataReq
---@field FruId integer
---@field Option integer
local TClearElabelDataReq = {}
TClearElabelDataReq.__index = TClearElabelDataReq
TClearElabelDataReq.group = {}

local function TClearElabelDataReq_from_obj(obj)
    return setmetatable(obj, TClearElabelDataReq)
end

function TClearElabelDataReq.new(FruId, Option)
    return TClearElabelDataReq_from_obj({FruId = FruId, Option = Option})
end
---@param obj FrudataIpmiCmds.ClearElabelDataReq
function TClearElabelDataReq:init_from_obj(obj)
    self.FruId = obj.FruId
    self.Option = obj.Option
end

function TClearElabelDataReq:remove_error_props(errs, obj)
    utils.remove_obj_error_property(obj, errs, TClearElabelDataReq.group)
end

TClearElabelDataReq.from_obj = TClearElabelDataReq_from_obj

TClearElabelDataReq.proto_property = {'FruId', 'Option'}

TClearElabelDataReq.default = {0, 0}

TClearElabelDataReq.struct = {
    {name = 'FruId', is_array = false, struct = nil}, {name = 'Option', is_array = false, struct = nil}
}

function TClearElabelDataReq:validate(prefix, errs, need_convert)
    prefix = prefix or ''

    validate.Optional(prefix .. 'FruId', self.FruId, 'uint8', false, errs, need_convert)
    validate.Optional(prefix .. 'Option', self.Option, 'uint8', false, errs, need_convert)

    TClearElabelDataReq:remove_error_props(errs, self)
    validate.CheckUnknowProperty(self, TClearElabelDataReq.proto_property, errs, need_convert)
    return self
end

function TClearElabelDataReq:unpack(_)
    return self.FruId, self.Option
end

ClearElabelData.ClearElabelDataReq = TClearElabelDataReq

---@class FrudataIpmiCmds.ClearElabelDataRsp
---@field CompletionCode integer
---@field EraseProgress integer
local TClearElabelDataRsp = {}
TClearElabelDataRsp.__index = TClearElabelDataRsp
TClearElabelDataRsp.group = {}

local function TClearElabelDataRsp_from_obj(obj)
    return setmetatable(obj, TClearElabelDataRsp)
end

function TClearElabelDataRsp.new(CompletionCode, EraseProgress)
    return TClearElabelDataRsp_from_obj({CompletionCode = CompletionCode, EraseProgress = EraseProgress})
end
---@param obj FrudataIpmiCmds.ClearElabelDataRsp
function TClearElabelDataRsp:init_from_obj(obj)
    self.CompletionCode = obj.CompletionCode
    self.EraseProgress = obj.EraseProgress
end

function TClearElabelDataRsp:remove_error_props(errs, obj)
    utils.remove_obj_error_property(obj, errs, TClearElabelDataRsp.group)
end

TClearElabelDataRsp.from_obj = TClearElabelDataRsp_from_obj

TClearElabelDataRsp.proto_property = {'CompletionCode', 'EraseProgress'}

TClearElabelDataRsp.default = {0, 0}

TClearElabelDataRsp.struct = {
    {name = 'CompletionCode', is_array = false, struct = nil}, {name = 'EraseProgress', is_array = false, struct = nil}
}

function TClearElabelDataRsp:validate(prefix, errs, need_convert)
    prefix = prefix or ''

    validate.Optional(prefix .. 'CompletionCode', self.CompletionCode, 'uint8', false, errs, need_convert)
    validate.Optional(prefix .. 'EraseProgress', self.EraseProgress, 'uint8', false, errs, need_convert)

    TClearElabelDataRsp:remove_error_props(errs, self)
    validate.CheckUnknowProperty(self, TClearElabelDataRsp.proto_property, errs, need_convert)
    return self
end

function TClearElabelDataRsp:unpack(_)
    return self.CompletionCode, self.EraseProgress
end

ClearElabelData.ClearElabelDataRsp = TClearElabelDataRsp

return ClearElabelData
