-- 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 MCertInfoTable = {}

---@class MCertInfoTable.CertHash
---@field CertHash integer
local TCertHash = {}
TCertHash.__index = TCertHash
TCertHash.group = {}

local function TCertHash_from_obj(obj)
    return setmetatable(obj, TCertHash)
end

function TCertHash.new(CertHash)
    return TCertHash_from_obj({CertHash = CertHash})
end
---@param obj MCertInfoTable.CertHash
function TCertHash:init_from_obj(obj)
    self.CertHash = obj.CertHash
end

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

TCertHash.from_obj = TCertHash_from_obj

TCertHash.proto_property = {'CertHash'}

TCertHash.default = {0}

TCertHash.struct = {{name = 'CertHash', is_array = false, struct = nil}}

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

    validate.Optional(prefix .. 'CertHash', self.CertHash, 'uint32', false, errs, need_convert)

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

function TCertHash:unpack(_)
    return self.CertHash
end

MCertInfoTable.CertHash = TCertHash

---@class MCertInfoTable.CertInfo
---@field CertInfo string
local TCertInfo = {}
TCertInfo.__index = TCertInfo
TCertInfo.group = {}

local function TCertInfo_from_obj(obj)
    return setmetatable(obj, TCertInfo)
end

function TCertInfo.new(CertInfo)
    return TCertInfo_from_obj({CertInfo = CertInfo})
end
---@param obj MCertInfoTable.CertInfo
function TCertInfo:init_from_obj(obj)
    self.CertInfo = obj.CertInfo
end

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

TCertInfo.from_obj = TCertInfo_from_obj

TCertInfo.proto_property = {'CertInfo'}

TCertInfo.default = {''}

TCertInfo.struct = {{name = 'CertInfo', is_array = false, struct = nil}}

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

    validate.Optional(prefix .. 'CertInfo', self.CertInfo, 'string', false, errs, need_convert)

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

function TCertInfo:unpack(_)
    return self.CertInfo
end

MCertInfoTable.CertInfo = TCertInfo

---@class MCertInfoTable.CertificateExpired
---@field CertificateExpired integer
local TCertificateExpired = {}
TCertificateExpired.__index = TCertificateExpired
TCertificateExpired.group = {}

local function TCertificateExpired_from_obj(obj)
    return setmetatable(obj, TCertificateExpired)
end

function TCertificateExpired.new(CertificateExpired)
    return TCertificateExpired_from_obj({CertificateExpired = CertificateExpired or 0})
end
---@param obj MCertInfoTable.CertificateExpired
function TCertificateExpired:init_from_obj(obj)
    self.CertificateExpired = obj.CertificateExpired or 0
end

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

TCertificateExpired.from_obj = TCertificateExpired_from_obj

TCertificateExpired.proto_property = {'CertificateExpired'}

TCertificateExpired.default = {0}

TCertificateExpired.struct = {{name = 'CertificateExpired', is_array = false, struct = nil}}

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

    validate.Optional(prefix .. 'CertificateExpired', self.CertificateExpired, 'uint8', false, errs, need_convert)

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

function TCertificateExpired:unpack(_)
    return self.CertificateExpired
end

MCertInfoTable.CertificateExpired = TCertificateExpired

---@class MCertInfoTable.Id
---@field Id string
local TId = {}
TId.__index = TId
TId.group = {}

local function TId_from_obj(obj)
    return setmetatable(obj, TId)
end

function TId.new(Id)
    return TId_from_obj({Id = Id})
end
---@param obj MCertInfoTable.Id
function TId:init_from_obj(obj)
    self.Id = obj.Id
end

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

TId.from_obj = TId_from_obj

TId.proto_property = {'Id'}

TId.default = {''}

TId.struct = {{name = 'Id', is_array = false, struct = nil}}

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

    validate.Required(prefix .. 'Id', self.Id, 'string', false, errs, need_convert)

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

function TId:unpack(_)
    return self.Id
end

MCertInfoTable.Id = TId

return MCertInfoTable
