--[[-- Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved.
--
-- this file licensed under the 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.
--
-- Author: auto generate
-- Create: 2025-8-21
-- Description: DO NOT EDIT; Code generated by "ipmi_message.lua.mako"
]] --
local validate = require 'mc.validate'
local utils = require 'mc.utils'

local SetKvmKey = {}

---@class IamIpmiCmds.SetKvmKeyReq
---@field ManufactureId integer
---@field Reserved1 integer
---@field Offset integer
---@field Length integer
---@field Reserved2 integer
---@field KeyId integer
---@field SecretKey string
---@field UserName string
---@field SessionMode integer
local TSetKvmKeyReq = {}
TSetKvmKeyReq.__index = TSetKvmKeyReq
TSetKvmKeyReq.group = {}

local function TSetKvmKeyReq_from_obj(obj)
    return setmetatable(obj, TSetKvmKeyReq)
end

function TSetKvmKeyReq.new(ManufactureId, Reserved1, Offset, Length, Reserved2, KeyId, SecretKey, UserName, SessionMode)
    return TSetKvmKeyReq_from_obj({
        ManufactureId = ManufactureId,
        Reserved1 = Reserved1,
        Offset = Offset,
        Length = Length,
        Reserved2 = Reserved2,
        KeyId = KeyId,
        SecretKey = SecretKey,
        UserName = UserName,
        SessionMode = SessionMode
    })
end
---@param obj IamIpmiCmds.SetKvmKeyReq
function TSetKvmKeyReq:init_from_obj(obj)
    self.ManufactureId = obj.ManufactureId
    self.Reserved1 = obj.Reserved1
    self.Offset = obj.Offset
    self.Length = obj.Length
    self.Reserved2 = obj.Reserved2
    self.KeyId = obj.KeyId
    self.SecretKey = obj.SecretKey
    self.UserName = obj.UserName
    self.SessionMode = obj.SessionMode
end

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

TSetKvmKeyReq.from_obj = TSetKvmKeyReq_from_obj

TSetKvmKeyReq.proto_property = {
    'ManufactureId', 'Reserved1', 'Offset', 'Length', 'Reserved2', 'KeyId', 'SecretKey', 'UserName', 'SessionMode'
}

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

TSetKvmKeyReq.struct = {
    {name = 'ManufactureId', is_array = false, struct = nil}, {name = 'Reserved1', is_array = false, struct = nil},
    {name = 'Offset', is_array = false, struct = nil}, {name = 'Length', is_array = false, struct = nil},
    {name = 'Reserved2', is_array = false, struct = nil}, {name = 'KeyId', is_array = false, struct = nil},
    {name = 'SecretKey', is_array = false, struct = nil}, {name = 'UserName', is_array = false, struct = nil},
    {name = 'SessionMode', is_array = false, struct = nil}
}

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

    validate.Optional(prefix .. 'ManufactureId', self.ManufactureId, 'uint32', false, errs, need_convert)
    validate.Optional(prefix .. 'Reserved1', self.Reserved1, '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 .. 'Reserved2', self.Reserved2, 'uint16', false, errs, need_convert)
    validate.Optional(prefix .. 'KeyId', self.KeyId, 'uint32', false, errs, need_convert)
    validate.Optional(prefix .. 'SecretKey', self.SecretKey, 'string', false, errs, need_convert)
    validate.Optional(prefix .. 'UserName', self.UserName, 'string', false, errs, need_convert)
    validate.Optional(prefix .. 'SessionMode', self.SessionMode, 'uint8', false, errs, need_convert)

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

function TSetKvmKeyReq:unpack(_)
    return self.ManufactureId, self.Reserved1, self.Offset, self.Length, self.Reserved2, self.KeyId, self.SecretKey,
        self.UserName, self.SessionMode
end

SetKvmKey.SetKvmKeyReq = TSetKvmKeyReq

---@class IamIpmiCmds.SetKvmKeyRsp
---@field CompletionCode integer
---@field ManufactureId integer
local TSetKvmKeyRsp = {}
TSetKvmKeyRsp.__index = TSetKvmKeyRsp
TSetKvmKeyRsp.group = {}

local function TSetKvmKeyRsp_from_obj(obj)
    return setmetatable(obj, TSetKvmKeyRsp)
end

function TSetKvmKeyRsp.new(CompletionCode, ManufactureId)
    return TSetKvmKeyRsp_from_obj({CompletionCode = CompletionCode, ManufactureId = ManufactureId})
end
---@param obj IamIpmiCmds.SetKvmKeyRsp
function TSetKvmKeyRsp:init_from_obj(obj)
    self.CompletionCode = obj.CompletionCode
    self.ManufactureId = obj.ManufactureId
end

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

TSetKvmKeyRsp.from_obj = TSetKvmKeyRsp_from_obj

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

TSetKvmKeyRsp.default = {0, 0}

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

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

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

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

SetKvmKey.SetKvmKeyRsp = TSetKvmKeyRsp

return SetKvmKey
