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

---@class MDriveBackup.Manufacturer
---@field Manufacturer string
local TManufacturer = {}
TManufacturer.__index = TManufacturer
TManufacturer.group = {}

local function TManufacturer_from_obj(obj)
    return setmetatable(obj, TManufacturer)
end

function TManufacturer.new(Manufacturer)
    return TManufacturer_from_obj({Manufacturer = Manufacturer or [=[N/A]=]})
end
---@param obj MDriveBackup.Manufacturer
function TManufacturer:init_from_obj(obj)
    self.Manufacturer = obj.Manufacturer or [=[N/A]=]
end

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

TManufacturer.from_obj = TManufacturer_from_obj

TManufacturer.proto_property = {'Manufacturer'}

TManufacturer.default = {''}

TManufacturer.struct = {{name = 'Manufacturer', is_array = false, struct = nil}}

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

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

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

function TManufacturer:unpack(_)
    return self.Manufacturer
end

MDriveBackup.Manufacturer = TManufacturer

---@class MDriveBackup.CapableSpeedGbs
---@field CapableSpeedGbs integer
local TCapableSpeedGbs = {}
TCapableSpeedGbs.__index = TCapableSpeedGbs
TCapableSpeedGbs.group = {}

local function TCapableSpeedGbs_from_obj(obj)
    return setmetatable(obj, TCapableSpeedGbs)
end

function TCapableSpeedGbs.new(CapableSpeedGbs)
    return TCapableSpeedGbs_from_obj({CapableSpeedGbs = CapableSpeedGbs or 255})
end
---@param obj MDriveBackup.CapableSpeedGbs
function TCapableSpeedGbs:init_from_obj(obj)
    self.CapableSpeedGbs = obj.CapableSpeedGbs or 255
end

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

TCapableSpeedGbs.from_obj = TCapableSpeedGbs_from_obj

TCapableSpeedGbs.proto_property = {'CapableSpeedGbs'}

TCapableSpeedGbs.default = {0}

TCapableSpeedGbs.struct = {{name = 'CapableSpeedGbs', is_array = false, struct = nil}}

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

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

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

function TCapableSpeedGbs:unpack(_)
    return self.CapableSpeedGbs
end

MDriveBackup.CapableSpeedGbs = TCapableSpeedGbs

---@class MDriveBackup.NegotiatedSpeedGbs
---@field NegotiatedSpeedGbs integer
local TNegotiatedSpeedGbs = {}
TNegotiatedSpeedGbs.__index = TNegotiatedSpeedGbs
TNegotiatedSpeedGbs.group = {}

local function TNegotiatedSpeedGbs_from_obj(obj)
    return setmetatable(obj, TNegotiatedSpeedGbs)
end

function TNegotiatedSpeedGbs.new(NegotiatedSpeedGbs)
    return TNegotiatedSpeedGbs_from_obj({NegotiatedSpeedGbs = NegotiatedSpeedGbs or 255})
end
---@param obj MDriveBackup.NegotiatedSpeedGbs
function TNegotiatedSpeedGbs:init_from_obj(obj)
    self.NegotiatedSpeedGbs = obj.NegotiatedSpeedGbs or 255
end

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

TNegotiatedSpeedGbs.from_obj = TNegotiatedSpeedGbs_from_obj

TNegotiatedSpeedGbs.proto_property = {'NegotiatedSpeedGbs'}

TNegotiatedSpeedGbs.default = {0}

TNegotiatedSpeedGbs.struct = {{name = 'NegotiatedSpeedGbs', is_array = false, struct = nil}}

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

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

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

function TNegotiatedSpeedGbs:unpack(_)
    return self.NegotiatedSpeedGbs
end

MDriveBackup.NegotiatedSpeedGbs = TNegotiatedSpeedGbs

---@class MDriveBackup.MediaType
---@field MediaType integer
local TMediaType = {}
TMediaType.__index = TMediaType
TMediaType.group = {}

local function TMediaType_from_obj(obj)
    return setmetatable(obj, TMediaType)
end

function TMediaType.new(MediaType)
    return TMediaType_from_obj({MediaType = MediaType or 255})
end
---@param obj MDriveBackup.MediaType
function TMediaType:init_from_obj(obj)
    self.MediaType = obj.MediaType or 255
end

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

TMediaType.from_obj = TMediaType_from_obj

TMediaType.proto_property = {'MediaType'}

TMediaType.default = {0}

TMediaType.struct = {{name = 'MediaType', is_array = false, struct = nil}}

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

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

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

function TMediaType:unpack(_)
    return self.MediaType
end

MDriveBackup.MediaType = TMediaType

---@class MDriveBackup.SerialNumber
---@field SerialNumber string
local TSerialNumber = {}
TSerialNumber.__index = TSerialNumber
TSerialNumber.group = {}

local function TSerialNumber_from_obj(obj)
    return setmetatable(obj, TSerialNumber)
end

function TSerialNumber.new(SerialNumber)
    return TSerialNumber_from_obj({SerialNumber = SerialNumber or [=[N/A]=]})
end
---@param obj MDriveBackup.SerialNumber
function TSerialNumber:init_from_obj(obj)
    self.SerialNumber = obj.SerialNumber or [=[N/A]=]
end

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

TSerialNumber.from_obj = TSerialNumber_from_obj

TSerialNumber.proto_property = {'SerialNumber'}

TSerialNumber.default = {''}

TSerialNumber.struct = {{name = 'SerialNumber', is_array = false, struct = nil}}

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

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

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

function TSerialNumber:unpack(_)
    return self.SerialNumber
end

MDriveBackup.SerialNumber = TSerialNumber

---@class MDriveBackup.Model
---@field Model string
local TModel = {}
TModel.__index = TModel
TModel.group = {}

local function TModel_from_obj(obj)
    return setmetatable(obj, TModel)
end

function TModel.new(Model)
    return TModel_from_obj({Model = Model or [=[N/A]=]})
end
---@param obj MDriveBackup.Model
function TModel:init_from_obj(obj)
    self.Model = obj.Model or [=[N/A]=]
end

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

TModel.from_obj = TModel_from_obj

TModel.proto_property = {'Model'}

TModel.default = {''}

TModel.struct = {{name = 'Model', is_array = false, struct = nil}}

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

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

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

function TModel:unpack(_)
    return self.Model
end

MDriveBackup.Model = TModel

---@class MDriveBackup.CapacityMiB
---@field CapacityMiB integer
local TCapacityMiB = {}
TCapacityMiB.__index = TCapacityMiB
TCapacityMiB.group = {}

local function TCapacityMiB_from_obj(obj)
    return setmetatable(obj, TCapacityMiB)
end

function TCapacityMiB.new(CapacityMiB)
    return TCapacityMiB_from_obj({CapacityMiB = CapacityMiB or 4294967295})
end
---@param obj MDriveBackup.CapacityMiB
function TCapacityMiB:init_from_obj(obj)
    self.CapacityMiB = obj.CapacityMiB or 4294967295
end

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

TCapacityMiB.from_obj = TCapacityMiB_from_obj

TCapacityMiB.proto_property = {'CapacityMiB'}

TCapacityMiB.default = {0}

TCapacityMiB.struct = {{name = 'CapacityMiB', is_array = false, struct = nil}}

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

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

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

function TCapacityMiB:unpack(_)
    return self.CapacityMiB
end

MDriveBackup.CapacityMiB = TCapacityMiB

---@class MDriveBackup.Revision
---@field Revision string
local TRevision = {}
TRevision.__index = TRevision
TRevision.group = {}

local function TRevision_from_obj(obj)
    return setmetatable(obj, TRevision)
end

function TRevision.new(Revision)
    return TRevision_from_obj({Revision = Revision or [=[N/A]=]})
end
---@param obj MDriveBackup.Revision
function TRevision:init_from_obj(obj)
    self.Revision = obj.Revision or [=[N/A]=]
end

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

TRevision.from_obj = TRevision_from_obj

TRevision.proto_property = {'Revision'}

TRevision.default = {''}

TRevision.struct = {{name = 'Revision', is_array = false, struct = nil}}

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

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

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

function TRevision:unpack(_)
    return self.Revision
end

MDriveBackup.Revision = TRevision

---@class MDriveBackup.Protocol
---@field Protocol integer
local TProtocol = {}
TProtocol.__index = TProtocol
TProtocol.group = {}

local function TProtocol_from_obj(obj)
    return setmetatable(obj, TProtocol)
end

function TProtocol.new(Protocol)
    return TProtocol_from_obj({Protocol = Protocol or 255})
end
---@param obj MDriveBackup.Protocol
function TProtocol:init_from_obj(obj)
    self.Protocol = obj.Protocol or 255
end

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

TProtocol.from_obj = TProtocol_from_obj

TProtocol.proto_property = {'Protocol'}

TProtocol.default = {0}

TProtocol.struct = {{name = 'Protocol', is_array = false, struct = nil}}

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

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

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

function TProtocol:unpack(_)
    return self.Protocol
end

MDriveBackup.Protocol = TProtocol

---@class MDriveBackup.Id
---@field Id integer
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 MDriveBackup.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 = {0}

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, 'uint8', 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

MDriveBackup.Id = TId

return MDriveBackup
