-- Copyright (c) 2024 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 def_types = require 'class.types.types'

local MSessionService = {}

---@class MSessionService.SessionModeDB
---@field SessionModeDB def_types.OccupationMode
local TSessionModeDB = {}
TSessionModeDB.__index = TSessionModeDB
TSessionModeDB.group = {}

local function TSessionModeDB_from_obj(obj)
    obj.SessionModeDB = obj.SessionModeDB and def_types.OccupationMode.new(obj.SessionModeDB)
    return setmetatable(obj, TSessionModeDB)
end

function TSessionModeDB.new(SessionModeDB)
    return TSessionModeDB_from_obj({SessionModeDB = SessionModeDB})
end
---@param obj MSessionService.SessionModeDB
function TSessionModeDB:init_from_obj(obj)
    self.SessionModeDB = obj.SessionModeDB
end

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

TSessionModeDB.from_obj = TSessionModeDB_from_obj

TSessionModeDB.proto_property = {'SessionModeDB'}

TSessionModeDB.default = {def_types.OccupationMode.default}

TSessionModeDB.struct = {{name = 'SessionModeDB', is_array = false, struct = def_types.OccupationMode.struct}}

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

    validate.Optional(prefix .. 'SessionModeDB', self.SessionModeDB, 'def_types.OccupationMode', false, errs,
        need_convert)

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

function TSessionModeDB:unpack(raw)
    local SessionModeDB = utils.unpack_enum(raw, self.SessionModeDB)
    return SessionModeDB
end

MSessionService.SessionModeDB = TSessionModeDB

---@class MSessionService.SessionType
---@field SessionType def_types.SessionType
local TSessionType = {}
TSessionType.__index = TSessionType
TSessionType.group = {}

local function TSessionType_from_obj(obj)
    obj.SessionType = obj.SessionType and def_types.SessionType.new(obj.SessionType)
    return setmetatable(obj, TSessionType)
end

function TSessionType.new(SessionType)
    return TSessionType_from_obj({SessionType = SessionType})
end
---@param obj MSessionService.SessionType
function TSessionType:init_from_obj(obj)
    self.SessionType = obj.SessionType
end

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

TSessionType.from_obj = TSessionType_from_obj

TSessionType.proto_property = {'SessionType'}

TSessionType.default = {def_types.SessionType.default}

TSessionType.struct = {{name = 'SessionType', is_array = false, struct = def_types.SessionType.struct}}

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

    validate.Required(prefix .. 'SessionType', self.SessionType, 'def_types.SessionType', false, errs, need_convert)

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

function TSessionType:unpack(raw)
    local SessionType = utils.unpack_enum(raw, self.SessionType)
    return SessionType
end

MSessionService.SessionType = TSessionType

return MSessionService
