--[[-- 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 SetFDMInfoPCIeAddrInfo = {}

---@class PcieDevice.SetFDMInfoPCIeAddrInfoReq
---@field ManufactureId integer
---@field Length integer
---@field Data string
local TSetFDMInfoPCIeAddrInfoReq = {}
TSetFDMInfoPCIeAddrInfoReq.__index = TSetFDMInfoPCIeAddrInfoReq
TSetFDMInfoPCIeAddrInfoReq.group = {}

local function TSetFDMInfoPCIeAddrInfoReq_from_obj(obj)
    return setmetatable(obj, TSetFDMInfoPCIeAddrInfoReq)
end

function TSetFDMInfoPCIeAddrInfoReq.new(ManufactureId, Length, Data)
    return TSetFDMInfoPCIeAddrInfoReq_from_obj({ManufactureId = ManufactureId, Length = Length, Data = Data})
end
---@param obj PcieDevice.SetFDMInfoPCIeAddrInfoReq
function TSetFDMInfoPCIeAddrInfoReq:init_from_obj(obj)
    self.ManufactureId = obj.ManufactureId
    self.Length = obj.Length
    self.Data = obj.Data
end

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

TSetFDMInfoPCIeAddrInfoReq.from_obj = TSetFDMInfoPCIeAddrInfoReq_from_obj

TSetFDMInfoPCIeAddrInfoReq.proto_property = {'ManufactureId', 'Length', 'Data'}

TSetFDMInfoPCIeAddrInfoReq.default = {0, 0, ''}

TSetFDMInfoPCIeAddrInfoReq.struct = {
    {name = 'ManufactureId', is_array = false, struct = nil}, {name = 'Length', is_array = false, struct = nil},
    {name = 'Data', is_array = false, struct = nil}
}

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

    validate.Optional(prefix .. 'ManufactureId', self.ManufactureId, 'uint32', false, errs, need_convert)
    validate.Optional(prefix .. 'Length', self.Length, 'uint8', false, errs, need_convert)
    validate.Optional(prefix .. 'Data', self.Data, 'string', false, errs, need_convert)

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

function TSetFDMInfoPCIeAddrInfoReq:unpack(_)
    return self.ManufactureId, self.Length, self.Data
end

SetFDMInfoPCIeAddrInfo.SetFDMInfoPCIeAddrInfoReq = TSetFDMInfoPCIeAddrInfoReq

---@class PcieDevice.SetFDMInfoPCIeAddrInfoRsp
---@field CompletionCode integer
---@field ManufactureId integer
local TSetFDMInfoPCIeAddrInfoRsp = {}
TSetFDMInfoPCIeAddrInfoRsp.__index = TSetFDMInfoPCIeAddrInfoRsp
TSetFDMInfoPCIeAddrInfoRsp.group = {}

local function TSetFDMInfoPCIeAddrInfoRsp_from_obj(obj)
    return setmetatable(obj, TSetFDMInfoPCIeAddrInfoRsp)
end

function TSetFDMInfoPCIeAddrInfoRsp.new(CompletionCode, ManufactureId)
    return TSetFDMInfoPCIeAddrInfoRsp_from_obj({CompletionCode = CompletionCode, ManufactureId = ManufactureId})
end
---@param obj PcieDevice.SetFDMInfoPCIeAddrInfoRsp
function TSetFDMInfoPCIeAddrInfoRsp:init_from_obj(obj)
    self.CompletionCode = obj.CompletionCode
    self.ManufactureId = obj.ManufactureId
end

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

TSetFDMInfoPCIeAddrInfoRsp.from_obj = TSetFDMInfoPCIeAddrInfoRsp_from_obj

TSetFDMInfoPCIeAddrInfoRsp.proto_property = {'CompletionCode', 'ManufactureId'}

TSetFDMInfoPCIeAddrInfoRsp.default = {0, 0}

TSetFDMInfoPCIeAddrInfoRsp.struct = {
    {name = 'CompletionCode', is_array = false, struct = nil}, {name = 'ManufactureId', is_array = false, struct = nil}
}

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

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

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

function TSetFDMInfoPCIeAddrInfoRsp:unpack(_)
    return self.CompletionCode, self.ManufactureId
end

SetFDMInfoPCIeAddrInfo.SetFDMInfoPCIeAddrInfoRsp = TSetFDMInfoPCIeAddrInfoRsp

return SetFDMInfoPCIeAddrInfo
