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

---@class FrudataIpmiCmds.GetComponentParametersPNReq
---@field ManufactureId integer
---@field ComponentType integer
---@field GroupId integer
---@field ComponentId integer
---@field ReadOffset integer
---@field Length integer
local TGetComponentParametersPNReq = {}
TGetComponentParametersPNReq.__index = TGetComponentParametersPNReq
TGetComponentParametersPNReq.group = {}

local function TGetComponentParametersPNReq_from_obj(obj)
    return setmetatable(obj, TGetComponentParametersPNReq)
end

function TGetComponentParametersPNReq.new(ManufactureId, ComponentType, GroupId, ComponentId, ReadOffset, Length)
    return TGetComponentParametersPNReq_from_obj({
        ManufactureId = ManufactureId,
        ComponentType = ComponentType,
        GroupId = GroupId,
        ComponentId = ComponentId,
        ReadOffset = ReadOffset,
        Length = Length
    })
end
---@param obj FrudataIpmiCmds.GetComponentParametersPNReq
function TGetComponentParametersPNReq:init_from_obj(obj)
    self.ManufactureId = obj.ManufactureId
    self.ComponentType = obj.ComponentType
    self.GroupId = obj.GroupId
    self.ComponentId = obj.ComponentId
    self.ReadOffset = obj.ReadOffset
    self.Length = obj.Length
end

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

TGetComponentParametersPNReq.from_obj = TGetComponentParametersPNReq_from_obj

TGetComponentParametersPNReq.proto_property = {
    'ManufactureId', 'ComponentType', 'GroupId', 'ComponentId', 'ReadOffset', 'Length'
}

TGetComponentParametersPNReq.default = {0, 0, 0, 0, 0, 0}

TGetComponentParametersPNReq.struct = {
    {name = 'ManufactureId', is_array = false, struct = nil}, {name = 'ComponentType', is_array = false, struct = nil},
    {name = 'GroupId', is_array = false, struct = nil}, {name = 'ComponentId', is_array = false, struct = nil},
    {name = 'ReadOffset', is_array = false, struct = nil}, {name = 'Length', is_array = false, struct = nil}
}

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

    validate.Optional(prefix .. 'ManufactureId', self.ManufactureId, 'uint32', false, errs, need_convert)
    validate.Optional(prefix .. 'ComponentType', self.ComponentType, 'uint32', false, errs, need_convert)
    validate.Optional(prefix .. 'GroupId', self.GroupId, 'uint8', false, errs, need_convert)
    validate.Optional(prefix .. 'ComponentId', self.ComponentId, 'uint16', false, errs, need_convert)
    validate.Optional(prefix .. 'ReadOffset', self.ReadOffset, 'uint16', false, errs, need_convert)
    validate.Optional(prefix .. 'Length', self.Length, 'uint8', false, errs, need_convert)

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

function TGetComponentParametersPNReq:unpack(_)
    return self.ManufactureId, self.ComponentType, self.GroupId, self.ComponentId, self.ReadOffset, self.Length
end

GetComponentParametersPN.GetComponentParametersPNReq = TGetComponentParametersPNReq

---@class FrudataIpmiCmds.GetComponentParametersPNRsp
---@field CompletionCode integer
---@field ManufactureId integer
---@field EndOfList integer
---@field Data string
local TGetComponentParametersPNRsp = {}
TGetComponentParametersPNRsp.__index = TGetComponentParametersPNRsp
TGetComponentParametersPNRsp.group = {}

local function TGetComponentParametersPNRsp_from_obj(obj)
    return setmetatable(obj, TGetComponentParametersPNRsp)
end

function TGetComponentParametersPNRsp.new(CompletionCode, ManufactureId, EndOfList, Data)
    return TGetComponentParametersPNRsp_from_obj({
        CompletionCode = CompletionCode,
        ManufactureId = ManufactureId,
        EndOfList = EndOfList,
        Data = Data
    })
end
---@param obj FrudataIpmiCmds.GetComponentParametersPNRsp
function TGetComponentParametersPNRsp:init_from_obj(obj)
    self.CompletionCode = obj.CompletionCode
    self.ManufactureId = obj.ManufactureId
    self.EndOfList = obj.EndOfList
    self.Data = obj.Data
end

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

TGetComponentParametersPNRsp.from_obj = TGetComponentParametersPNRsp_from_obj

TGetComponentParametersPNRsp.proto_property = {'CompletionCode', 'ManufactureId', 'EndOfList', 'Data'}

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

TGetComponentParametersPNRsp.struct = {
    {name = 'CompletionCode', is_array = false, struct = nil}, {name = 'ManufactureId', is_array = false, struct = nil},
    {name = 'EndOfList', is_array = false, struct = nil}, {name = 'Data', is_array = false, struct = nil}
}

function TGetComponentParametersPNRsp: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)
    validate.Optional(prefix .. 'EndOfList', self.EndOfList, 'uint8', false, errs, need_convert)
    validate.Optional(prefix .. 'Data', self.Data, 'string', false, errs, need_convert)

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

function TGetComponentParametersPNRsp:unpack(_)
    return self.CompletionCode, self.ManufactureId, self.EndOfList, self.Data
end

GetComponentParametersPN.GetComponentParametersPNRsp = TGetComponentParametersPNRsp

return GetComponentParametersPN
