-- 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 MFru = {}

---@class MFru.SlotId
---@field SlotId integer
local TSlotId = {}
TSlotId.__index = TSlotId
TSlotId.group = {}

local function TSlotId_from_obj(obj)
    return setmetatable(obj, TSlotId)
end

function TSlotId.new(SlotId)
    return TSlotId_from_obj({SlotId = SlotId or 255})
end
---@param obj MFru.SlotId
function TSlotId:init_from_obj(obj)
    self.SlotId = obj.SlotId or 255
end

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

TSlotId.from_obj = TSlotId_from_obj

TSlotId.proto_property = {'SlotId'}

TSlotId.default = {0}

TSlotId.struct = {{name = 'SlotId', is_array = false, struct = nil}}

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

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

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

function TSlotId:unpack(_)
    return self.SlotId
end

MFru.SlotId = TSlotId

---@class MFru.BomId
---@field BomId integer
local TBomId = {}
TBomId.__index = TBomId
TBomId.group = {}

local function TBomId_from_obj(obj)
    return setmetatable(obj, TBomId)
end

function TBomId.new(BomId)
    return TBomId_from_obj({BomId = BomId or 255})
end
---@param obj MFru.BomId
function TBomId:init_from_obj(obj)
    self.BomId = obj.BomId or 255
end

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

TBomId.from_obj = TBomId_from_obj

TBomId.proto_property = {'BomId'}

TBomId.default = {0}

TBomId.struct = {{name = 'BomId', is_array = false, struct = nil}}

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

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

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

function TBomId:unpack(_)
    return self.BomId
end

MFru.BomId = TBomId

return MFru
