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

---@class MNodePortAddr.InterfaceDevicePortId
---@field InterfaceDevicePortId integer
local TInterfaceDevicePortId = {}
TInterfaceDevicePortId.__index = TInterfaceDevicePortId
TInterfaceDevicePortId.group = {}

local function TInterfaceDevicePortId_from_obj(obj)
    return setmetatable(obj, TInterfaceDevicePortId)
end

function TInterfaceDevicePortId.new(InterfaceDevicePortId)
    return TInterfaceDevicePortId_from_obj({InterfaceDevicePortId = InterfaceDevicePortId})
end
---@param obj MNodePortAddr.InterfaceDevicePortId
function TInterfaceDevicePortId:init_from_obj(obj)
    self.InterfaceDevicePortId = obj.InterfaceDevicePortId
end

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

TInterfaceDevicePortId.from_obj = TInterfaceDevicePortId_from_obj

TInterfaceDevicePortId.proto_property = {'InterfaceDevicePortId'}

TInterfaceDevicePortId.default = {0}

TInterfaceDevicePortId.struct = {{name = 'InterfaceDevicePortId', is_array = false, struct = nil}}

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

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

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

function TInterfaceDevicePortId:unpack(_)
    return self.InterfaceDevicePortId
end

MNodePortAddr.InterfaceDevicePortId = TInterfaceDevicePortId

---@class MNodePortAddr.InterfaceDeviceSlotId
---@field InterfaceDeviceSlotId integer
local TInterfaceDeviceSlotId = {}
TInterfaceDeviceSlotId.__index = TInterfaceDeviceSlotId
TInterfaceDeviceSlotId.group = {}

local function TInterfaceDeviceSlotId_from_obj(obj)
    return setmetatable(obj, TInterfaceDeviceSlotId)
end

function TInterfaceDeviceSlotId.new(InterfaceDeviceSlotId)
    return TInterfaceDeviceSlotId_from_obj({InterfaceDeviceSlotId = InterfaceDeviceSlotId})
end
---@param obj MNodePortAddr.InterfaceDeviceSlotId
function TInterfaceDeviceSlotId:init_from_obj(obj)
    self.InterfaceDeviceSlotId = obj.InterfaceDeviceSlotId
end

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

TInterfaceDeviceSlotId.from_obj = TInterfaceDeviceSlotId_from_obj

TInterfaceDeviceSlotId.proto_property = {'InterfaceDeviceSlotId'}

TInterfaceDeviceSlotId.default = {0}

TInterfaceDeviceSlotId.struct = {{name = 'InterfaceDeviceSlotId', is_array = false, struct = nil}}

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

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

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

function TInterfaceDeviceSlotId:unpack(_)
    return self.InterfaceDeviceSlotId
end

MNodePortAddr.InterfaceDeviceSlotId = TInterfaceDeviceSlotId

---@class MNodePortAddr.MacroId
---@field MacroId integer
local TMacroId = {}
TMacroId.__index = TMacroId
TMacroId.group = {}

local function TMacroId_from_obj(obj)
    return setmetatable(obj, TMacroId)
end

function TMacroId.new(MacroId)
    return TMacroId_from_obj({MacroId = MacroId})
end
---@param obj MNodePortAddr.MacroId
function TMacroId:init_from_obj(obj)
    self.MacroId = obj.MacroId
end

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

TMacroId.from_obj = TMacroId_from_obj

TMacroId.proto_property = {'MacroId'}

TMacroId.default = {0}

TMacroId.struct = {{name = 'MacroId', is_array = false, struct = nil}}

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

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

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

function TMacroId:unpack(_)
    return self.MacroId
end

MNodePortAddr.MacroId = TMacroId

---@class MNodePortAddr.DieId
---@field DieId integer
local TDieId = {}
TDieId.__index = TDieId
TDieId.group = {}

local function TDieId_from_obj(obj)
    return setmetatable(obj, TDieId)
end

function TDieId.new(DieId)
    return TDieId_from_obj({DieId = DieId})
end
---@param obj MNodePortAddr.DieId
function TDieId:init_from_obj(obj)
    self.DieId = obj.DieId
end

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

TDieId.from_obj = TDieId_from_obj

TDieId.proto_property = {'DieId'}

TDieId.default = {0}

TDieId.struct = {{name = 'DieId', is_array = false, struct = nil}}

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

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

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

function TDieId:unpack(_)
    return self.DieId
end

MNodePortAddr.DieId = TDieId

---@class MNodePortAddr.CPUId
---@field CPUId integer
local TCPUId = {}
TCPUId.__index = TCPUId
TCPUId.group = {}

local function TCPUId_from_obj(obj)
    return setmetatable(obj, TCPUId)
end

function TCPUId.new(CPUId)
    return TCPUId_from_obj({CPUId = CPUId})
end
---@param obj MNodePortAddr.CPUId
function TCPUId:init_from_obj(obj)
    self.CPUId = obj.CPUId
end

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

TCPUId.from_obj = TCPUId_from_obj

TCPUId.proto_property = {'CPUId'}

TCPUId.default = {0}

TCPUId.struct = {{name = 'CPUId', is_array = false, struct = nil}}

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

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

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

function TCPUId:unpack(_)
    return self.CPUId
end

MNodePortAddr.CPUId = TCPUId

---@class MNodePortAddr.NodeId
---@field NodeId integer
local TNodeId = {}
TNodeId.__index = TNodeId
TNodeId.group = {}

local function TNodeId_from_obj(obj)
    return setmetatable(obj, TNodeId)
end

function TNodeId.new(NodeId)
    return TNodeId_from_obj({NodeId = NodeId})
end
---@param obj MNodePortAddr.NodeId
function TNodeId:init_from_obj(obj)
    self.NodeId = obj.NodeId
end

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

TNodeId.from_obj = TNodeId_from_obj

TNodeId.proto_property = {'NodeId'}

TNodeId.default = {0}

TNodeId.struct = {{name = 'NodeId', is_array = false, struct = nil}}

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

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

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

function TNodeId:unpack(_)
    return self.NodeId
end

MNodePortAddr.NodeId = TNodeId

return MNodePortAddr
