--[[-- Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved.
-- 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 SetLdapEnabled = {}

---@class iamIpmiCmds.SetLdapEnabledReq
---@field ManufactureId integer
---@field Flag integer
---@field Reserved integer
---@field Offset integer
---@field Length integer
---@field Data string
local TSetLdapEnabledReq = {}
TSetLdapEnabledReq.__index = TSetLdapEnabledReq
TSetLdapEnabledReq.group = {}

local function TSetLdapEnabledReq_from_obj(obj)
    return setmetatable(obj, TSetLdapEnabledReq)
end

function TSetLdapEnabledReq.new(ManufactureId, Flag, Reserved, Offset, Length, Data)
    return TSetLdapEnabledReq_from_obj({
        ManufactureId = ManufactureId,
        Flag = Flag,
        Reserved = Reserved,
        Offset = Offset,
        Length = Length,
        Data = Data
    })
end
---@param obj iamIpmiCmds.SetLdapEnabledReq
function TSetLdapEnabledReq:init_from_obj(obj)
    self.ManufactureId = obj.ManufactureId
    self.Flag = obj.Flag
    self.Reserved = obj.Reserved
    self.Offset = obj.Offset
    self.Length = obj.Length
    self.Data = obj.Data
end

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

TSetLdapEnabledReq.from_obj = TSetLdapEnabledReq_from_obj

TSetLdapEnabledReq.proto_property = {'ManufactureId', 'Flag', 'Reserved', 'Offset', 'Length', 'Data'}

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

TSetLdapEnabledReq.struct = {
    {name = 'ManufactureId', is_array = false, struct = nil}, {name = 'Flag', is_array = false, struct = nil},
    {name = 'Reserved', is_array = false, struct = nil}, {name = 'Offset', is_array = false, struct = nil},
    {name = 'Length', is_array = false, struct = nil}, {name = 'Data', is_array = false, struct = nil}
}

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

    validate.Optional(prefix .. 'ManufactureId', self.ManufactureId, 'uint32', false, errs, need_convert)
    validate.Optional(prefix .. 'Flag', self.Flag, 'uint8', false, errs, need_convert)
    validate.Optional(prefix .. 'Reserved', self.Reserved, 'uint8', false, errs, need_convert)
    validate.Optional(prefix .. 'Offset', self.Offset, 'uint8', 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)

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

function TSetLdapEnabledReq:unpack(_)
    return self.ManufactureId, self.Flag, self.Reserved, self.Offset, self.Length, self.Data
end

SetLdapEnabled.SetLdapEnabledReq = TSetLdapEnabledReq

---@class iamIpmiCmds.SetLdapEnabledRsp
---@field CompletionCode integer
---@field ManufactureId integer
local TSetLdapEnabledRsp = {}
TSetLdapEnabledRsp.__index = TSetLdapEnabledRsp
TSetLdapEnabledRsp.group = {}

local function TSetLdapEnabledRsp_from_obj(obj)
    return setmetatable(obj, TSetLdapEnabledRsp)
end

function TSetLdapEnabledRsp.new(CompletionCode, ManufactureId)
    return TSetLdapEnabledRsp_from_obj({CompletionCode = CompletionCode, ManufactureId = ManufactureId})
end
---@param obj iamIpmiCmds.SetLdapEnabledRsp
function TSetLdapEnabledRsp:init_from_obj(obj)
    self.CompletionCode = obj.CompletionCode
    self.ManufactureId = obj.ManufactureId
end

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

TSetLdapEnabledRsp.from_obj = TSetLdapEnabledRsp_from_obj

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

TSetLdapEnabledRsp.default = {0, 0}

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

function TSetLdapEnabledRsp: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)

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

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

SetLdapEnabled.SetLdapEnabledRsp = TSetLdapEnabledRsp

return SetLdapEnabled
