-- Copyright (c) Huawei Technologies Co., Ltd. 2026. 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: 2026-2-12
-- Description: DO NOT EDIT; Code generated by "model.lua.mako"
local mdb = require 'mc.mdb'
local class = require 'mc.class_mgnt'
local privilege = require 'mc.privilege'

local pc_ie_mock_intf_types = require 'debug.json_types.PCIeMock'
local properties_intf_types = require 'mdb.bmc.kepler.Object.PropertiesInterface'

local PCIeMock = {
    ['mdb_prop_configs'] = {
        ['bmc.kepler.Debug.PCIeMock'] = {},
        ['bmc.kepler.Object.Properties'] = {
            ['ClassName'] = {
                ['baseType'] = 'String',
                ['readOnly'] = true,
                ['validator'] = properties_intf_types.ClassName
            },
            ['ObjectName'] = {
                ['baseType'] = 'String',
                ['readOnly'] = true,
                ['validator'] = properties_intf_types.ObjectName
            },
            ['ObjectIdentifier'] = {
                ['baseType'] = 'Struct',
                ['$ref'] = '#/defs/StructIdentifier',
                ['readOnly'] = true,
                ['validator'] = properties_intf_types.ObjectIdentifier
            }
        }
    },
    ['mdb_method_configs'] = {
        ['bmc.kepler.Debug.PCIeMock'] = {
            ['GetConnectors'] = {
                ['req'] = {
                    {
                        ['baseType'] = 'String',
                        ['enum'] = {'OCP', 'PCIe'},
                        ['displayDescription'] = 'Specify the device type: PCIe or OCP.',
                        ['param'] = 'DeviceType'
                    }
                },
                ['rsp'] = {
                    {['baseType'] = 'Array', ['items'] = {['$ref'] = '#/defs/ConnectorItem'}, ['param'] = 'Connectors'}
                },
                ['displayDescription'] = 'Display the slot number and presence status of the specified device.',
                ['cmdName'] = 'getconnectors'
            },
            ['LoadDevice'] = {
                ['req'] = {
                    {
                        ['baseType'] = 'String',
                        ['enum'] = {'OCP', 'PCIe'},
                        ['displayDescription'] = 'Specify the device type: PCIe or OCP.',
                        ['param'] = 'DeviceType'
                    }, {['baseType'] = 'U8', ['displayDescription'] = 'Slot of the device.', ['param'] = 'Slot'},
                    {['baseType'] = 'String', ['displayDescription'] = 'Id of the device.', ['param'] = 'Id'},
                    {['baseType'] = 'String', ['displayDescription'] = 'AuxId of the device.', ['param'] = 'AuxId'}
                },
                ['displayDescription'] = 'Simulate loading PCIe device.',
                ['cmdName'] = 'loaddevice'
            },
            ['UnloadDevice'] = {
                ['req'] = {
                    {['baseType'] = 'String', ['enum'] = {'OCP', 'PCIe'}, ['param'] = 'DeviceType'},
                    {['baseType'] = 'U8', ['param'] = 'Slot'}
                },
                ['cmdName'] = 'unloaddevice'
            }
        }
    },
    ['mdb_classes'] = mdb.get_class_obj('/bmc/kepler/Debug/PCIeMock'),
    ['new_mdb_objects'] = mdb.new_objects_builder({
        ['bmc.kepler.Debug.PCIeMock'] = {['property_defaults'] = {}, ['interface_types'] = pc_ie_mock_intf_types},
        ['bmc.kepler.Object.Properties'] = {
            ['property_defaults'] = {
                ['ClassName'] = properties_intf_types.ClassName.default[1],
                ['ObjectName'] = properties_intf_types.ObjectName.default[1],
                ['ObjectIdentifier'] = properties_intf_types.ObjectIdentifier.default[1]
            },
            ['interface_types'] = properties_intf_types
        }
    })
}

local M = {}

function M.init(bus)
    class('PCIeMock', PCIeMock):set_bus(bus)
end

-- The callback needs to be registered during app initialization
function M.ImplPCIeMockPCIeMockGetConnectors(cb)
    class('PCIeMock')['bmc.kepler.Debug.PCIeMock'].GetConnectors = function(obj, ctx, ...)
        local req = pc_ie_mock_intf_types.GetConnectorsReq.new(...):validate(nil, nil, true)
        local rsp = pc_ie_mock_intf_types.GetConnectorsRsp.new(cb(obj, ctx, req:unpack())):validate()
        return rsp:unpack(true)
    end
end

-- The callback needs to be registered during app initialization
function M.ImplPCIeMockPCIeMockLoadDevice(cb)
    class('PCIeMock')['bmc.kepler.Debug.PCIeMock'].LoadDevice = function(obj, ctx, ...)
        local req = pc_ie_mock_intf_types.LoadDeviceReq.new(...):validate(nil, nil, true)
        local rsp = pc_ie_mock_intf_types.LoadDeviceRsp.new(cb(obj, ctx, req:unpack())):validate()
        return rsp:unpack(true)
    end
end

-- The callback needs to be registered during app initialization
function M.ImplPCIeMockPCIeMockUnloadDevice(cb)
    class('PCIeMock')['bmc.kepler.Debug.PCIeMock'].UnloadDevice = function(obj, ctx, ...)
        local req = pc_ie_mock_intf_types.UnloadDeviceReq.new(...):validate(nil, nil, true)
        local rsp = pc_ie_mock_intf_types.UnloadDeviceRsp.new(cb(obj, ctx, req:unpack())):validate()
        return rsp:unpack(true)
    end
end

return M
