-- Copyright (c) 2026 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 MDPUCardMapping = {}

---@class MDPUCardMapping.SubDeviceID
---@field SubDeviceID integer
local TSubDeviceID = {}
TSubDeviceID.__index = TSubDeviceID
TSubDeviceID.group = {}

local function TSubDeviceID_from_obj(obj)
    return setmetatable(obj, TSubDeviceID)
end

function TSubDeviceID.new(SubDeviceID)
    return TSubDeviceID_from_obj({SubDeviceID = SubDeviceID})
end
---@param obj MDPUCardMapping.SubDeviceID
function TSubDeviceID:init_from_obj(obj)
    self.SubDeviceID = obj.SubDeviceID
end

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

TSubDeviceID.from_obj = TSubDeviceID_from_obj

TSubDeviceID.proto_property = {'SubDeviceID'}

TSubDeviceID.default = {0}

TSubDeviceID.struct = {{name = 'SubDeviceID', is_array = false, struct = nil}}

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

    validate.Optional(prefix .. 'SubDeviceID', self.SubDeviceID, 'uint16', false, errs, need_convert)

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

function TSubDeviceID:unpack(_)
    return self.SubDeviceID
end

MDPUCardMapping.SubDeviceID = TSubDeviceID

---@class MDPUCardMapping.SubVendorID
---@field SubVendorID integer
local TSubVendorID = {}
TSubVendorID.__index = TSubVendorID
TSubVendorID.group = {}

local function TSubVendorID_from_obj(obj)
    return setmetatable(obj, TSubVendorID)
end

function TSubVendorID.new(SubVendorID)
    return TSubVendorID_from_obj({SubVendorID = SubVendorID})
end
---@param obj MDPUCardMapping.SubVendorID
function TSubVendorID:init_from_obj(obj)
    self.SubVendorID = obj.SubVendorID
end

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

TSubVendorID.from_obj = TSubVendorID_from_obj

TSubVendorID.proto_property = {'SubVendorID'}

TSubVendorID.default = {0}

TSubVendorID.struct = {{name = 'SubVendorID', is_array = false, struct = nil}}

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

    validate.Optional(prefix .. 'SubVendorID', self.SubVendorID, 'uint16', false, errs, need_convert)

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

function TSubVendorID:unpack(_)
    return self.SubVendorID
end

MDPUCardMapping.SubVendorID = TSubVendorID

---@class MDPUCardMapping.DeviceID
---@field DeviceID integer
local TDeviceID = {}
TDeviceID.__index = TDeviceID
TDeviceID.group = {}

local function TDeviceID_from_obj(obj)
    return setmetatable(obj, TDeviceID)
end

function TDeviceID.new(DeviceID)
    return TDeviceID_from_obj({DeviceID = DeviceID})
end
---@param obj MDPUCardMapping.DeviceID
function TDeviceID:init_from_obj(obj)
    self.DeviceID = obj.DeviceID
end

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

TDeviceID.from_obj = TDeviceID_from_obj

TDeviceID.proto_property = {'DeviceID'}

TDeviceID.default = {0}

TDeviceID.struct = {{name = 'DeviceID', is_array = false, struct = nil}}

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

    validate.Optional(prefix .. 'DeviceID', self.DeviceID, 'uint16', false, errs, need_convert)

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

function TDeviceID:unpack(_)
    return self.DeviceID
end

MDPUCardMapping.DeviceID = TDeviceID

---@class MDPUCardMapping.VendorID
---@field VendorID integer
local TVendorID = {}
TVendorID.__index = TVendorID
TVendorID.group = {}

local function TVendorID_from_obj(obj)
    return setmetatable(obj, TVendorID)
end

function TVendorID.new(VendorID)
    return TVendorID_from_obj({VendorID = VendorID})
end
---@param obj MDPUCardMapping.VendorID
function TVendorID:init_from_obj(obj)
    self.VendorID = obj.VendorID
end

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

TVendorID.from_obj = TVendorID_from_obj

TVendorID.proto_property = {'VendorID'}

TVendorID.default = {0}

TVendorID.struct = {{name = 'VendorID', is_array = false, struct = nil}}

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

    validate.Optional(prefix .. 'VendorID', self.VendorID, 'uint16', false, errs, need_convert)

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

function TVendorID:unpack(_)
    return self.VendorID
end

MDPUCardMapping.VendorID = TVendorID

---@class MDPUCardMapping.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})
end
---@param obj MDPUCardMapping.SlotID
function TSlotID:init_from_obj(obj)
    self.SlotID = obj.SlotID
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.Required(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

MDPUCardMapping.SlotID = TSlotID

return MDPUCardMapping
