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

---@class SensorIpmiCmds.DeleteSDRReq
---@field ReserveIdL integer
---@field ReserveIdH integer
---@field RecordIdL integer
---@field RecordIdH integer
local TDeleteSDRReq = {}
TDeleteSDRReq.__index = TDeleteSDRReq
TDeleteSDRReq.group = {}

local function TDeleteSDRReq_from_obj(obj)
    return setmetatable(obj, TDeleteSDRReq)
end

function TDeleteSDRReq.new(ReserveIdL, ReserveIdH, RecordIdL, RecordIdH)
    return TDeleteSDRReq_from_obj({
        ReserveIdL = ReserveIdL,
        ReserveIdH = ReserveIdH,
        RecordIdL = RecordIdL,
        RecordIdH = RecordIdH
    })
end
---@param obj SensorIpmiCmds.DeleteSDRReq
function TDeleteSDRReq:init_from_obj(obj)
    self.ReserveIdL = obj.ReserveIdL
    self.ReserveIdH = obj.ReserveIdH
    self.RecordIdL = obj.RecordIdL
    self.RecordIdH = obj.RecordIdH
end

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

TDeleteSDRReq.from_obj = TDeleteSDRReq_from_obj

TDeleteSDRReq.proto_property = {'ReserveIdL', 'ReserveIdH', 'RecordIdL', 'RecordIdH'}

TDeleteSDRReq.default = {0, 0, 0, 0}

TDeleteSDRReq.struct = {
    {name = 'ReserveIdL', is_array = false, struct = nil}, {name = 'ReserveIdH', is_array = false, struct = nil},
    {name = 'RecordIdL', is_array = false, struct = nil}, {name = 'RecordIdH', is_array = false, struct = nil}
}

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

    validate.Optional(prefix .. 'ReserveIdL', self.ReserveIdL, 'uint8', false, errs, need_convert)
    validate.Optional(prefix .. 'ReserveIdH', self.ReserveIdH, 'uint8', false, errs, need_convert)
    validate.Optional(prefix .. 'RecordIdL', self.RecordIdL, 'uint8', false, errs, need_convert)
    validate.Optional(prefix .. 'RecordIdH', self.RecordIdH, 'uint8', false, errs, need_convert)

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

function TDeleteSDRReq:unpack(_)
    return self.ReserveIdL, self.ReserveIdH, self.RecordIdL, self.RecordIdH
end

DeleteSDR.DeleteSDRReq = TDeleteSDRReq

---@class SensorIpmiCmds.DeleteSDRRsp
---@field CompletionCode integer
---@field RecordIdL integer
---@field RecordIdH integer
local TDeleteSDRRsp = {}
TDeleteSDRRsp.__index = TDeleteSDRRsp
TDeleteSDRRsp.group = {}

local function TDeleteSDRRsp_from_obj(obj)
    return setmetatable(obj, TDeleteSDRRsp)
end

function TDeleteSDRRsp.new(CompletionCode, RecordIdL, RecordIdH)
    return TDeleteSDRRsp_from_obj({CompletionCode = CompletionCode, RecordIdL = RecordIdL, RecordIdH = RecordIdH})
end
---@param obj SensorIpmiCmds.DeleteSDRRsp
function TDeleteSDRRsp:init_from_obj(obj)
    self.CompletionCode = obj.CompletionCode
    self.RecordIdL = obj.RecordIdL
    self.RecordIdH = obj.RecordIdH
end

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

TDeleteSDRRsp.from_obj = TDeleteSDRRsp_from_obj

TDeleteSDRRsp.proto_property = {'CompletionCode', 'RecordIdL', 'RecordIdH'}

TDeleteSDRRsp.default = {0, 0, 0}

TDeleteSDRRsp.struct = {
    {name = 'CompletionCode', is_array = false, struct = nil}, {name = 'RecordIdL', is_array = false, struct = nil},
    {name = 'RecordIdH', is_array = false, struct = nil}
}

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

    validate.Optional(prefix .. 'CompletionCode', self.CompletionCode, 'uint8', false, errs, need_convert)
    validate.Optional(prefix .. 'RecordIdL', self.RecordIdL, 'uint8', false, errs, need_convert)
    validate.Optional(prefix .. 'RecordIdH', self.RecordIdH, 'uint8', false, errs, need_convert)

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

function TDeleteSDRRsp:unpack(_)
    return self.CompletionCode, self.RecordIdL, self.RecordIdH
end

DeleteSDR.DeleteSDRRsp = TDeleteSDRRsp

return DeleteSDR
