# frozen_string_literal: true# Copyright (c) 2020-2024 Comet Licensing Ltd.# Please see the LICENSE file for usage information.## SPDX-License-Identifier: MITrequire'json'moduleComet# BackupRuleConfig is a typed class wrapper around the underlying Comet Server API data structure.# A backup rule connects one source Protected Item and one destination Storage Vault, with multiple# time schedules or event triggersclassBackupRuleConfig# @type [String] descriptionattr_accessor:description# Unix timestamp in seconds# @type [Number] create_timeattr_accessor:create_time# Unix timestamp in seconds. The caller is responsible for updating this themselves.# @type [Number] modify_timeattr_accessor:modify_time# Custom commands to run before the job# @type [Array<String>] pre_execattr_accessor:pre_exec# Custom commands to run after taking a disk snapshot# @type [Array<String>] thaw_execattr_accessor:thaw_exec# Custom commands to run after the job# @type [Array<String>] post_execattr_accessor:post_exec# The source Protected Item ID to back up from, during this schedule# @type [String] sourceattr_accessor:source# The destination Storage Vault ID to back up to, during this schedule# @type [String] destinationattr_accessor:destination# @type [Boolean] skip_already_runningattr_accessor:skip_already_running# If Zero: disabled# @type [Number] stop_afterattr_accessor:stop_after# If Zero: disabled# @type [Number] limit_vault_speed_bpsattr_accessor:limit_vault_speed_bps# Default disabled# @type [Boolean] reduce_disk_concurrencyattr_accessor:reduce_disk_concurrency# Default disabled# @type [Boolean] use_on_disk_indexesattr_accessor:use_on_disk_indexes# Default disabled# @type [Boolean] allow_zero_files_successattr_accessor:allow_zero_files_success# If Zero: default Automatic (BACKUPJOBAUTORETENTION_AUTOMATIC)# @type [Number] auto_retention_levelattr_accessor:auto_retention_level# Desired concurrency count. If Zero, uses mode defaults# @type [Number] concurrency_countattr_accessor:concurrency_count# Log verbosity level. LOG_DEBUG has the greatest verbosity# @type [String] log_levelattr_accessor:log_level# Scheduled start times# @type [Array<Comet::ScheduleConfig>] schedulesattr_accessor:schedules# Other events that will cause this scheduled job to start# @type [Comet::BackupRuleEventTriggers] event_triggersattr_accessor:event_triggers# @type [Hash] Hidden storage to preserve future properties for non-destructive roundtrip operationsattr_accessor:unknown_json_fieldsdefinitializeclearenddefclear@description=''@create_time=0@modify_time=0@pre_exec=[]@thaw_exec=[]@post_exec=[]@source=''@destination=''@stop_after=0@limit_vault_speed_bps=0@auto_retention_level=0@concurrency_count=0@log_level=''@schedules=[]@event_triggers=Comet::BackupRuleEventTriggers.new@unknown_json_fields={}end# @param [String] json_string The complete object in JSON formatdeffrom_json(json_string)raiseTypeError,"'json_string' expected String, got #{json_string.class}"unlessjson_string.is_a?Stringfrom_hash(JSON.parse(json_string))end# @param [Hash] obj The complete object as a Ruby hashdeffrom_hash(obj)raiseTypeError,"'obj' expected Hash, got #{obj.class}"unlessobj.is_a?Hashobj.eachdo|k,v|casekwhen'Description'raiseTypeError,"'v' expected String, got #{v.class}"unlessv.is_a?String@description=vwhen'CreateTime'raiseTypeError,"'v' expected Numeric, got #{v.class}"unlessv.is_a?Numeric@create_time=vwhen'ModifyTime'raiseTypeError,"'v' expected Numeric, got #{v.class}"unlessv.is_a?Numeric@modify_time=vwhen'PreExec'ifv.nil?@pre_exec=[]else@pre_exec=Array.new(v.length)v.each_with_indexdo|v1,i1|raiseTypeError,"'v1' expected String, got #{v1.class}"unlessv1.is_a?String@pre_exec[i1]=v1endendwhen'ThawExec'ifv.nil?@thaw_exec=[]else@thaw_exec=Array.new(v.length)v.each_with_indexdo|v1,i1|raiseTypeError,"'v1' expected String, got #{v1.class}"unlessv1.is_a?String@thaw_exec[i1]=v1endendwhen'PostExec'ifv.nil?@post_exec=[]else@post_exec=Array.new(v.length)v.each_with_indexdo|v1,i1|raiseTypeError,"'v1' expected String, got #{v1.class}"unlessv1.is_a?String@post_exec[i1]=v1endendwhen'Source'raiseTypeError,"'v' expected String, got #{v.class}"unlessv.is_a?String@source=vwhen'Destination'raiseTypeError,"'v' expected String, got #{v.class}"unlessv.is_a?String@destination=vwhen'SkipAlreadyRunning'@skip_already_running=vwhen'StopAfter'raiseTypeError,"'v' expected Numeric, got #{v.class}"unlessv.is_a?Numeric@stop_after=vwhen'LimitVaultSpeedBps'raiseTypeError,"'v' expected Numeric, got #{v.class}"unlessv.is_a?Numeric@limit_vault_speed_bps=vwhen'ReduceDiskConcurrency'@reduce_disk_concurrency=vwhen'UseOnDiskIndexes'@use_on_disk_indexes=vwhen'AllowZeroFilesSuccess'@allow_zero_files_success=vwhen'AutoRetentionLevel'raiseTypeError,"'v' expected Numeric, got #{v.class}"unlessv.is_a?Numeric@auto_retention_level=vwhen'ConcurrencyCount'raiseTypeError,"'v' expected Numeric, got #{v.class}"unlessv.is_a?Numeric@concurrency_count=vwhen'LogLevel'raiseTypeError,"'v' expected String, got #{v.class}"unlessv.is_a?String@log_level=vwhen'Schedules'ifv.nil?@schedules=[]else@schedules=Array.new(v.length)v.each_with_indexdo|v1,i1|@schedules[i1]=Comet::ScheduleConfig.new@schedules[i1].from_hash(v1)endendwhen'EventTriggers'@event_triggers=Comet::BackupRuleEventTriggers.new@event_triggers.from_hash(v)else@unknown_json_fields[k]=vendendend# @return [Hash] The complete object as a Ruby hashdefto_hashret={}ret['Description']=@descriptionret['CreateTime']=@create_timeret['ModifyTime']=@modify_timeret['PreExec']=@pre_execret['ThawExec']=@thaw_execret['PostExec']=@post_execret['Source']=@sourceret['Destination']=@destinationret['SkipAlreadyRunning']=@skip_already_runningret['StopAfter']=@stop_afterret['LimitVaultSpeedBps']=@limit_vault_speed_bpsret['ReduceDiskConcurrency']=@reduce_disk_concurrencyret['UseOnDiskIndexes']=@use_on_disk_indexesret['AllowZeroFilesSuccess']=@allow_zero_files_successret['AutoRetentionLevel']=@auto_retention_levelret['ConcurrencyCount']=@concurrency_countret['LogLevel']=@log_levelret['Schedules']=@schedulesret['EventTriggers']=@event_triggers@unknown_json_fields.eachdo|k,v|ret[k]=vendretend# @return [Hash] The complete object as a Ruby hashdefto_hto_hashend# @return [String] The complete object as a JSON stringdefto_json(options={})to_hash.to_json(options)endendend