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

---@class MNetworkAdapterFirmware.FirmwareVersion
---@field FirmwareVersion string
local TFirmwareVersion = {}
TFirmwareVersion.__index = TFirmwareVersion
TFirmwareVersion.group = {}

local function TFirmwareVersion_from_obj(obj)
    return setmetatable(obj, TFirmwareVersion)
end

function TFirmwareVersion.new(FirmwareVersion)
    return TFirmwareVersion_from_obj({FirmwareVersion = FirmwareVersion})
end
---@param obj MNetworkAdapterFirmware.FirmwareVersion
function TFirmwareVersion:init_from_obj(obj)
    self.FirmwareVersion = obj.FirmwareVersion
end

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

TFirmwareVersion.from_obj = TFirmwareVersion_from_obj

TFirmwareVersion.proto_property = {'FirmwareVersion'}

TFirmwareVersion.default = {''}

TFirmwareVersion.struct = {{name = 'FirmwareVersion', is_array = false, struct = nil}}

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

    validate.Optional(prefix .. 'FirmwareVersion', self.FirmwareVersion, 'string', false, errs, need_convert)

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

function TFirmwareVersion:unpack(_)
    return self.FirmwareVersion
end

MNetworkAdapterFirmware.FirmwareVersion = TFirmwareVersion

---@class MNetworkAdapterFirmware.Protocol
---@field Protocol string
local TProtocol = {}
TProtocol.__index = TProtocol
TProtocol.group = {}

local function TProtocol_from_obj(obj)
    return setmetatable(obj, TProtocol)
end

function TProtocol.new(Protocol)
    return TProtocol_from_obj({Protocol = Protocol or [=[SFC]=]})
end
---@param obj MNetworkAdapterFirmware.Protocol
function TProtocol:init_from_obj(obj)
    self.Protocol = obj.Protocol or [=[SFC]=]
end

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

TProtocol.from_obj = TProtocol_from_obj

TProtocol.proto_property = {'Protocol'}

TProtocol.default = {''}

TProtocol.struct = {{name = 'Protocol', is_array = false, struct = nil}}

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

    validate.Optional(prefix .. 'Protocol', self.Protocol, 'string', false, errs, need_convert)

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

function TProtocol:unpack(_)
    return self.Protocol
end

MNetworkAdapterFirmware.Protocol = TProtocol

---@class MNetworkAdapterFirmware.FlashSizeKiB
---@field FlashSizeKiB integer
local TFlashSizeKiB = {}
TFlashSizeKiB.__index = TFlashSizeKiB
TFlashSizeKiB.group = {}

local function TFlashSizeKiB_from_obj(obj)
    return setmetatable(obj, TFlashSizeKiB)
end

function TFlashSizeKiB.new(FlashSizeKiB)
    return TFlashSizeKiB_from_obj({FlashSizeKiB = FlashSizeKiB or 0})
end
---@param obj MNetworkAdapterFirmware.FlashSizeKiB
function TFlashSizeKiB:init_from_obj(obj)
    self.FlashSizeKiB = obj.FlashSizeKiB or 0
end

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

TFlashSizeKiB.from_obj = TFlashSizeKiB_from_obj

TFlashSizeKiB.proto_property = {'FlashSizeKiB'}

TFlashSizeKiB.default = {0}

TFlashSizeKiB.struct = {{name = 'FlashSizeKiB', is_array = false, struct = nil}}

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

    validate.Optional(prefix .. 'FlashSizeKiB', self.FlashSizeKiB, 'uint32', false, errs, need_convert)

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

function TFlashSizeKiB:unpack(_)
    return self.FlashSizeKiB
end

MNetworkAdapterFirmware.FlashSizeKiB = TFlashSizeKiB

---@class MNetworkAdapterFirmware.FirmwareRoute
---@field FirmwareRoute integer
local TFirmwareRoute = {}
TFirmwareRoute.__index = TFirmwareRoute
TFirmwareRoute.group = {}

local function TFirmwareRoute_from_obj(obj)
    return setmetatable(obj, TFirmwareRoute)
end

function TFirmwareRoute.new(FirmwareRoute)
    return TFirmwareRoute_from_obj({FirmwareRoute = FirmwareRoute})
end
---@param obj MNetworkAdapterFirmware.FirmwareRoute
function TFirmwareRoute:init_from_obj(obj)
    self.FirmwareRoute = obj.FirmwareRoute
end

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

TFirmwareRoute.from_obj = TFirmwareRoute_from_obj

TFirmwareRoute.proto_property = {'FirmwareRoute'}

TFirmwareRoute.default = {0}

TFirmwareRoute.struct = {{name = 'FirmwareRoute', is_array = false, struct = nil}}

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

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

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

function TFirmwareRoute:unpack(_)
    return self.FirmwareRoute
end

MNetworkAdapterFirmware.FirmwareRoute = TFirmwareRoute

---@class MNetworkAdapterFirmware.DefaultRoute
---@field DefaultRoute integer
local TDefaultRoute = {}
TDefaultRoute.__index = TDefaultRoute
TDefaultRoute.group = {}

local function TDefaultRoute_from_obj(obj)
    return setmetatable(obj, TDefaultRoute)
end

function TDefaultRoute.new(DefaultRoute)
    return TDefaultRoute_from_obj({DefaultRoute = DefaultRoute})
end
---@param obj MNetworkAdapterFirmware.DefaultRoute
function TDefaultRoute:init_from_obj(obj)
    self.DefaultRoute = obj.DefaultRoute
end

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

TDefaultRoute.from_obj = TDefaultRoute_from_obj

TDefaultRoute.proto_property = {'DefaultRoute'}

TDefaultRoute.default = {0}

TDefaultRoute.struct = {{name = 'DefaultRoute', is_array = false, struct = nil}}

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

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

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

function TDefaultRoute:unpack(_)
    return self.DefaultRoute
end

MNetworkAdapterFirmware.DefaultRoute = TDefaultRoute

---@class MNetworkAdapterFirmware.Route
---@field Route integer
local TRoute = {}
TRoute.__index = TRoute
TRoute.group = {}

local function TRoute_from_obj(obj)
    return setmetatable(obj, TRoute)
end

function TRoute.new(Route)
    return TRoute_from_obj({Route = Route})
end
---@param obj MNetworkAdapterFirmware.Route
function TRoute:init_from_obj(obj)
    self.Route = obj.Route
end

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

TRoute.from_obj = TRoute_from_obj

TRoute.proto_property = {'Route'}

TRoute.default = {0}

TRoute.struct = {{name = 'Route', is_array = false, struct = nil}}

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

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

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

function TRoute:unpack(_)
    return self.Route
end

MNetworkAdapterFirmware.Route = TRoute

---@class MNetworkAdapterFirmware.ComponentIDEx
---@field ComponentIDEx integer
local TComponentIDEx = {}
TComponentIDEx.__index = TComponentIDEx
TComponentIDEx.group = {}

local function TComponentIDEx_from_obj(obj)
    return setmetatable(obj, TComponentIDEx)
end

function TComponentIDEx.new(ComponentIDEx)
    return TComponentIDEx_from_obj({ComponentIDEx = ComponentIDEx or 4294967295})
end
---@param obj MNetworkAdapterFirmware.ComponentIDEx
function TComponentIDEx:init_from_obj(obj)
    self.ComponentIDEx = obj.ComponentIDEx or 4294967295
end

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

TComponentIDEx.from_obj = TComponentIDEx_from_obj

TComponentIDEx.proto_property = {'ComponentIDEx'}

TComponentIDEx.default = {0}

TComponentIDEx.struct = {{name = 'ComponentIDEx', is_array = false, struct = nil}}

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

    validate.Optional(prefix .. 'ComponentIDEx', self.ComponentIDEx, 'uint32', false, errs, need_convert)

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

function TComponentIDEx:unpack(_)
    return self.ComponentIDEx
end

MNetworkAdapterFirmware.ComponentIDEx = TComponentIDEx

---@class MNetworkAdapterFirmware.ComponentID
---@field ComponentID integer
local TComponentID = {}
TComponentID.__index = TComponentID
TComponentID.group = {}

local function TComponentID_from_obj(obj)
    return setmetatable(obj, TComponentID)
end

function TComponentID.new(ComponentID)
    return TComponentID_from_obj({ComponentID = ComponentID or 255})
end
---@param obj MNetworkAdapterFirmware.ComponentID
function TComponentID:init_from_obj(obj)
    self.ComponentID = obj.ComponentID or 255
end

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

TComponentID.from_obj = TComponentID_from_obj

TComponentID.proto_property = {'ComponentID'}

TComponentID.default = {0}

TComponentID.struct = {{name = 'ComponentID', is_array = false, struct = nil}}

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

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

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

function TComponentID:unpack(_)
    return self.ComponentID
end

MNetworkAdapterFirmware.ComponentID = TComponentID

return MNetworkAdapterFirmware
