Toolkit/Public/Set-RscSla.ps1
|
#Requires -Version 3 function Set-RscSla { <# .SYNOPSIS Updates an existing SLA Domain in Rubrik Security Cloud. .DESCRIPTION Modifies an SLA Domain policy. Unlike a full replacement, this cmdlet uses a patch-style approach: you only need to provide the fields you want to change, and all other settings are preserved. You can update schedules, archival and replication rules, backup windows, retention lock settings, and workload-specific configurations for VMware, Oracle, MSSQL, and other platforms. .LINK Schema reference: https://rubrikinc.github.io/rubrik-api-documentation/schema/reference .PARAMETER Name The new name for the SLA Domain. .PARAMETER Sla An existing SLA Domain object to update. Pipe from Get-RscSla. .PARAMETER Description The new description for the SLA Domain. .PARAMETER MinuteSchedule Updated minute-level snapshot schedule. .PARAMETER HourlySchedule Updated hourly snapshot schedule. .PARAMETER DailySchedule Updated daily snapshot schedule. .PARAMETER WeeklySchedule Updated weekly snapshot schedule. .PARAMETER MonthlySchedule Updated monthly snapshot schedule. .PARAMETER QuarterlySchedule Updated quarterly snapshot schedule. .PARAMETER YearlySchedule Updated yearly snapshot schedule. .PARAMETER UserNote An optional note to attach to the SLA Domain update. .PARAMETER ObjectTypes The list of object types this SLA Domain applies to. .PARAMETER LocalRetentionLimit Retention limit for local snapshots on the Rubrik cluster. .PARAMETER BackupWindows One or more backup window objects restricting when snapshots may run. .PARAMETER FirstFullBackupWindows One or more backup window objects restricting when first full backups may run. .PARAMETER ShouldApplyToExistingSnapshots Apply the updated SLA policy to existing snapshots. .PARAMETER ShouldApplyToNonPolicySnapshots Apply the updated SLA policy to non-policy snapshots. .PARAMETER RetentionLockSla Enable retention lock on this SLA Domain. .PARAMETER RetentionLockMode The retention lock mode for the SLA Domain. .PARAMETER ArchivalSpecs Updated archival specifications for this SLA Domain. .PARAMETER ReplicationSpecs Updated replication specifications for this SLA Domain. .PARAMETER VmwareVmConfig VMware VM-specific settings for this SLA Domain. .PARAMETER OracleConfig Oracle-specific settings for this SLA Domain. .PARAMETER SapHana SAP HANA-specific settings for this SLA Domain. .PARAMETER AwsRds AWS RDS-specific settings for this SLA Domain. .PARAMETER AzureSqlDatabaseConfig Azure SQL Database-specific settings for this SLA Domain. .PARAMETER AzureSqlManagedInstanceConfig Azure SQL Managed Instance-specific settings for this SLA Domain. .PARAMETER Db2Config Db2-specific settings for this SLA Domain. .PARAMETER MsSqlConfig MSSQL-specific settings for this SLA Domain. .PARAMETER MongoConfig MongoDB-specific settings for this SLA Domain. .PARAMETER AzureBlobConfig Azure Blob-specific settings for this SLA Domain. .PARAMETER AwsNativeS3Config AWS S3-specific settings for this SLA Domain. .PARAMETER ManagedVolumeConfig Managed Volume-specific settings for this SLA Domain. .PARAMETER PostgresDbClusterConfig PostgreSQL DB Cluster-specific settings for this SLA Domain. .PARAMETER AsQuery Return the query object instead of running the query. Preliminary read-only queries may still run to gather IDs or other data needed to build the main query. Return the query object instead of executing it. .EXAMPLE Update an SLA Domain's name and daily schedule. $dailySchedule = New-RscSlaSnapshotSchedule -Type Daily -Frequency 2 -Retention 1 -RetentionUnit MONTHS Set-RscSla -Sla (Get-RscSla -Name "OldName") -Name "NewName" -DailySchedule $dailySchedule .EXAMPLE Update Oracle-specific config, backup windows, and archival specs. $daily = New-RscSlaSnapshotSchedule -Type Daily -Frequency 2 -Retention 6 -RetentionUnit DAYS $backupWindow = New-RscSlaBackupWindow -Duration 2 -DayOfWeek TUESDAY -Hour 1 -Minute 30 $slaDuration = New-RscSlaDuration -Duration 10 -Unit DAYS $oracle = New-RscSlaObjectSpecificConfig -Oracle -Frequency $slaDuration -LogRetention $slaDuration $archival = New-RscSlaArchivalSpecs -ArchivalThreshold 230 -Frequencies @('MONTHS') -ArchivalThresholdUnit DAYS -ClusterUuids @('cluster-uuid') -LocationIds @('location-id') Set-RscSla -Sla (Get-RscSla -Name "MySLA") -DailySchedule $daily -BackupWindows @($backupWindow) -OracleConfig $oracle -ArchivalSpecs @($archival) #> [CmdletBinding()] Param( # SLA Domain Name [Parameter()] [String]$Name, # SLA Domain Object [Parameter(ValueFromPipeline=$true)] [ValidateNotNullOrEmpty()] [RubrikSecurityCloud.Types.GlobalSlaReply]$Sla, # SLA Domain Description [Parameter()] [String]$Description, # Minute Schedule object [Parameter()] [RubrikSecurityCloud.Types.MinuteSnapshotScheduleInput]$MinuteSchedule, # Hourly Schedule object [Parameter()] [RubrikSecurityCloud.Types.HourlySnapshotScheduleInput]$HourlySchedule, # Daily Schedule object [Parameter()] [RubrikSecurityCloud.Types.DailySnapshotScheduleInput]$DailySchedule, # Weekly Schedule object [Parameter()] [RubrikSecurityCloud.Types.WeeklySnapshotScheduleInput]$WeeklySchedule, # Monthly Schedule object [Parameter()] [RubrikSecurityCloud.Types.MonthlySnapshotScheduleInput]$MonthlySchedule, # Quarterly Schedule object [Parameter()] [RubrikSecurityCloud.Types.QuarterlySnapshotScheduleInput]$QuarterlySchedule, # Yearly Schedule object [Parameter()] [RubrikSecurityCloud.Types.YearlySnapshotScheduleInput]$YearlySchedule, # SLA Domain object type [Parameter()] [RubrikSecurityCloud.Types.SlaObjectType[]]$ObjectTypes, # Local Retention Limit [Parameter()] [RubrikSecurityCloud.Types.SlaDurationInput]$LocalRetentionLimit, # Backup Windows [Parameter()] [RubrikSecurityCloud.Types.BackupWindowInput[]]$BackupWindows, # First full Backup Windows [Parameter()] [RubrikSecurityCloud.Types.BackupWindowInput[]]$FirstFullBackupWindows, # Should the SLA be applied to existing snapshots [Parameter()] [Switch]$ShouldApplyToExistingSnapshots, # Should the SLA be applied to non-policy snapshots [Parameter()] [Switch]$ShouldApplyToNonPolicySnapshots, # Retention Lock SLA [Parameter()] [Switch]$RetentionLockSla, # The retention lock mode for the intended SLA Domain update. [Parameter()] [RubrikSecurityCloud.Types.RetentionLockMode] $RetentionLockMode, # Archival specs for this SLA. [Parameter()] [RubrikSecurityCloud.Types.ArchivalSpecInput[]]$ArchivalSpecs, # Replication specs for this SLA. [Parameter()] [RubrikSecurityCloud.Types.ReplicationSpecV2Input[]]$ReplicationSpecs, # VmwareVm specific settings of this SLA. [Parameter()] [RubrikSecurityCloud.Types.VmwareVmConfigInput]$VmwareVmConfig, # Oracle specific settings of this SLA. [Parameter()] [RubrikSecurityCloud.Types.OracleConfigInput]$OracleConfig, # SAP HANA specific settings of this SLA. [Parameter()] [RubrikSecurityCloud.Types.SapHanaConfigInput]$SapHanaConfig, # AWS RDS specific settings of this SLA. [Parameter()] [RubrikSecurityCloud.Types.AwsRdsConfigInput]$AwsRdsConfig, # Azure Sql DatabaseDb specific settings of this SLA. [Parameter()] [RubrikSecurityCloud.Types.AzureSqlDatabaseDbConfigInput]$AzureSqlDatabaseConfig, # Azure Sql Managed InstanceDb specific settings of this SLA. [Parameter()] [RubrikSecurityCloud.Types.AzureSqlManagedInstanceDbConfigInput]$AzureSqlManagedInstanceConfig, # Db2 specific settings of this SLA. [Parameter()] [RubrikSecurityCloud.Types.Db2ConfigInput]$Db2Config, # MS Sql specific settings of this SLA. [Parameter()] [RubrikSecurityCloud.Types.MsSqlConfigInput]$MsSqlConfig, # MySqlDb specific settings of this SLA. [Parameter()] [RubrikSecurityCloud.Types.MysqldbSlaConfigInput]$MysqldbConfig, # Mongo specific settings of this SLA. [Parameter()] [RubrikSecurityCloud.Types.MongoConfigInput]$MongoConfig, # AzureBlob specific settings of this SLA. [Parameter()] [RubrikSecurityCloud.Types.AzureBlobConfigInput]$AzureBlobConfig, # Aws Native S3 specific settings of this SLA. [Parameter()] [RubrikSecurityCloud.Types.AwsNativeS3SlaConfigInput]$AwsNativeS3Config, # Managed Volume specific settings of this SLA. [Parameter()] [RubrikSecurityCloud.Types.ManagedVolumeSlaConfigInput]$ManagedVolumeConfig, # Postgres Db Cluster specific settings of this SLA. [Parameter()] [RubrikSecurityCloud.Types.PostgresDbClusterSlaConfigInput]$PostgresDbClusterConfig, # User Note [Parameter()] [String]$UserNote, # Should Cmdlet return the query object instead of running it [Parameter()] [Switch]$AsQuery ) Process { # ------------------------------- Function Block Start ---------------------------------- # Cast Duration To SlaDurationInput Type function CastToSlaDurationInput { param ( [RubrikSecurityCloud.Types.Duration]$Duration ) if ($null -eq $Duration) { return $null } $obj = New-Object -TypeName RubrikSecurityCloud.Types.SlaDurationInput $obj.Duration = $Duration.DurationField $obj.Unit = $Duration.Unit return $obj } # Cast BackupWindow To BackupWindowInput Type function CastToBackupWindowInput { param ( [RubrikSecurityCloud.Types.BackupWindow]$BackupWindow ) if ($null -eq $BackupWindow) { return $null } $BackupWindowInput = New-Object RubrikSecurityCloud.Types.BackupWindowInput $BackupWindowInput.DurationInHours = $BackupWindow.DurationInHours if ($null -ne $BackupWindow.StartTimeAttributes) { $StartTimeAttributesInput = New-Object RubrikSecurityCloud.Types.StartTimeAttributesInput if ($null -ne $BackupWindow.StartTimeAttributes.DayOfWeek) { $DayOfWeekOptInput = New-Object RubrikSecurityCloud.Types.DayOfWeekOptInput $DayOfWeekOptInput.day = $BackupWindow.StartTimeAttributes.DayOfWeek.day $StartTimeAttributesInput.DayOfWeek = $DayOfWeekOptInput } else { $StartTimeAttributesInput.DayOfWeek = $null } $StartTimeAttributesInput.Hour = $BackupWindow.StartTimeAttributes.Hour $StartTimeAttributesInput.Minute = $BackupWindow.StartTimeAttributes.Minute $BackupWindowInput.StartTimeAttributes = $StartTimeAttributesInput } else { $BackupWindowInput.StartTimeAttributes = $null } return $BackupWindowInput } # Cast ArchivalSpec To ArchivalSpecInput Type function CastToArchivalSpecInput { param ( [RubrikSecurityCloud.Types.ArchivalSpec]$ArchivalSpec ) if ($null -eq $ArchivalSpec) { return $null } $ArchivalSpecInput = New-Object RubrikSecurityCloud.Types.ArchivalSpecInput # For new global SLA archival design, the archival group id is not supported in the archival # spec input for data center archival. if ($ArchivalSpec.StorageSetting -and $ArchivalSpec.ArchivalLocationToClusterMapping.Count -eq 0 ) { $ArchivalSpecInput.ArchivalGroupId = [string]$ArchivalSpec.StorageSetting.Id } else { $ArchivalSpecInput.ArchivalGroupId = $null } $ArchivalSpecInput.Threshold = $ArchivalSpec.Threshold $ArchivalSpecInput.ThresholdUnit = $ArchivalSpec.ThresholdUnit if ($ArchivalSpec.ArchivalTieringSpec) { $ArchivalTieringSpecInput = New-Object RubrikSecurityCloud.Types.ArchivalTieringSpecInput $ArchivalTieringSpecInput.IsInstantTieringEnabled = $ArchivalSpec.ArchivalTieringSpec.IsInstantTieringEnabled $ArchivalTieringSpecInput.MinAccessibleDurationInSeconds = $ArchivalSpec.ArchivalTieringSpec.MinAccessibleDurationInSeconds $ArchivalTieringSpecInput.ColdStorageClass = $ArchivalSpec.ArchivalTieringSpec.ColdStorageClass $ArchivalTieringSpecInput.ShouldTierExistingSnapshots = $ArchivalSpec.ArchivalTieringSpec.ShouldTierExistingSnapshots $ArchivalSpecInput.ArchivalTieringSpecInput = $ArchivalTieringSpecInput } else { $ArchivalSpecInput.ArchivalTieringSpecInput = $null } $ArchivalSpecInput.Frequencies = $ArchivalSpec.Frequencies $ArchivalLocationToClusterMappingInputs = @() foreach ($Mapping in $ArchivalSpec.ArchivalLocationToClusterMapping) { $MappingInput = New-Object RubrikSecurityCloud.Types.ArchivalLocationToClusterMappingInput if ($Mapping.Cluster) { $MappingInput.ClusterUuid = [string]$Mapping.Cluster.Id } else { $MappingInput.ClusterUuid = $null } if ($Mapping.Location) { $MappingInput.LocationId = [string]$Mapping.Location.Id } else { $MappingInput.LocationId = $null } $ArchivalLocationToClusterMappingInputs += $MappingInput } $ArchivalSpecInput.ArchivalLocationToClusterMapping = $ArchivalLocationToClusterMappingInputs return $ArchivalSpecInput } # Cast ReplicationSpec To ReplicationSpecInput Type function CastToReplicationSpecToInput { param ( [RubrikSecurityCloud.Types.ReplicationSpecV2]$ReplicationSpec ) if ($null -eq $ReplicationSpec) { return $null } $ReplicationSpecInput = New-Object RubrikSecurityCloud.Types.ReplicationSpecV2Input if ($null -ne $ReplicationSpec.Cluster) { $ReplicationSpecInput.ClusterUuid = [string]$ReplicationSpec.Cluster.Id } else { $ReplicationSpecInput.ClusterUuid = $null } if ($null -ne $ReplicationSpec.TargetMapping) { $ReplicationSpecInput.StorageSettingId = [string]$ReplicationSpec.TargetMapping.Id } else { $ReplicationSpecInput.StorageSettingId = $null } $ReplicationSpecInput.RetentionDuration = CastToSlaDurationInput -Duration $ReplicationSpec.RetentionDuration if ($null -ne $ReplicationSpec.AwsTarget) { $ReplicationSpecInput.AwsAccount = $ReplicationSpec.AwsTarget.AccountName } else { $ReplicationSpecInput.AwsAccount = $null } if ($null -ne $ReplicationSpec.AzureTarget) { $ReplicationSpecInput.AzureSubscription = $ReplicationSpec.AzureTarget.SubscriptionName } else { $ReplicationSpecInput.AzureSubscription = $null } $ReplicationSpecInput.ReplicationLocalRetentionDuration = CastToSlaDurationInput -Duration $ReplicationSpec.ReplicationLocalRetentionDuration $CascadingArchivalSpecInputs = @() foreach ($CascadingArchivalSpec in $ReplicationSpec.CascadingArchivalSpecs) { $CascadingArchivalSpecInput = New-Object RubrikSecurityCloud.Types.CascadingArchivalSpecInput $CascadingArchivalSpecInput.ArchivalThreshold = CastToSlaDurationInput -Duration $CascadingArchivalSpec.ArchivalThreshold if ($CascadingArchivalSpec.ArchivalTieringSpec) { $ArchivalTieringSpecInput = New-Object RubrikSecurityCloud.Types.ArchivalTieringSpecInput $ArchivalTieringSpecInput.IsInstantTieringEnabled = $CascadingArchivalSpec.ArchivalTieringSpec.IsInstantTieringEnabled $ArchivalTieringSpecInput.MinAccessibleDurationInSeconds = $CascadingArchivalSpec.ArchivalTieringSpec.MinAccessibleDurationInSeconds $ArchivalTieringSpecInput.ColdStorageClass = $CascadingArchivalSpec.ArchivalTieringSpec.ColdStorageClass $ArchivalTieringSpecInput.ShouldTierExistingSnapshots = $CascadingArchivalSpec.ArchivalTieringSpec.ShouldTierExistingSnapshots $CascadingArchivalSpecInput.ArchivalTieringSpecInput = $ArchivalTieringSpecInput } else { $CascadingArchivalSpecInput.ArchivalTieringSpecInput = $null } $CascadingArchivalSpecInput.Frequency = $CascadingArchivalSpec.Frequency $CascadingArchivalSpecInput.ArchivalLocationId = [string]$CascadingArchivalSpec.ArchivalLocation.Id $ArchivalLocationToClusterMappingInputs = @() foreach ($Mapping in $CascadingArchivalSpec.ArchivalLocationToClusterMapping) { $MappingInput = New-Object RubrikSecurityCloud.Types.ArchivalLocationToClusterMappingInput if ($Mapping.Cluster) { $MappingInput.ClusterUuid = [string]$Mapping.Cluster.Id } else { $MappingInput.ClusterUuid = $null } if ($Mapping.Location) { $MappingInput.LocationId = [string]$Mapping.Location.Id } else { $MappingInput.LocationId = $null } $ArchivalLocationToClusterMappingInputs += $MappingInput } $CascadingArchivalSpecInput.ArchivalLocationToClusterMapping = $ArchivalLocationToClusterMappingInputs $CascadingArchivalSpecInputs += $CascadingArchivalSpecInput } $ReplicationSpecInput.CascadingArchivalSpecs = $CascadingArchivalSpecInputs $ReplicationPairInputs = @() foreach ($Pair in $ReplicationSpec.ReplicationPairs) { $PairInput = New-Object RubrikSecurityCloud.Types.ReplicationPairInput if ($Pair.SourceCluster) { $PairInput.SourceClusterUuid = [string]$Pair.SourceCluster.Id } else { $PairInput.SourceClusterUuid = $null } if ($Pair.TargetCluster) { $PairInput.TargetClusterUuid = [string]$Pair.TargetCluster.Id } else { $PairInput.TargetClusterUuid = $null } $ReplicationPairInputs += $PairInput } $ReplicationSpecInput.ReplicationPairs = $ReplicationPairInputs $ReplicationSpecInput.AwsRegion = [RubrikSecurityCloud.Types.AwsNativeRegionForReplication] $ReplicationSpec.AwsRegion $ReplicationSpecInput.AzureRegion = [RubrikSecurityCloud.Types.AzureNativeRegionForReplication] $ReplicationSpec.AzureRegion return $ReplicationSpecInput } # ------------------------------- Function Block End ---------------------------------- $Mutation = New-RscMutation -Gql updateGlobalSla $Mutation.Var.Input = New-Object -TypeName RubrikSecurityCloud.Types.UpdateGlobalSlaInput $Mutation.Var.Input.Id = $Sla.Id # Prevent race conditions during SLA updates. # Only set stateVersion programmatically, not by user input. $Mutation.Var.Input.stateVersion = $Sla.stateVersion if ($Name) { $Mutation.Var.Input.Name = $Name } else { $Mutation.Var.Input.Name = $Sla.Name } if ($Description) { $Mutation.Var.Input.Description = $Description } else { $Mutation.Var.Input.Description = $Sla.Description } # If UserNote is not provided, set it to null if ($UserNote) { $Mutation.Var.Input.UserNote = $UserNote } else { $Mutation.Var.Input.UserNote = $null } if ($ObjectTypes) { $Mutation.Var.Input.ObjectTypes = $ObjectTypes } else { $Mutation.Var.Input.ObjectTypes = $Sla.ObjectTypes } # ------------------------------- Snapshot Schedule Block Start ---------------------------------- # Setting each SnapshotSchedule from the existing SLA if not provided $Mutation.Var.Input.SnapshotSchedule = New-Object -TypeName RubrikSecurityCloud.Types.GlobalSnapshotScheduleInput if ($MinuteSchedule) { $Mutation.Var.Input.SnapshotSchedule.Minute = $MinuteSchedule } else { if ($Sla.SnapshotSchedule.Minute) { $ConfigObj = $Sla.SnapshotSchedule.Minute $InputObj = New-Object -TypeName RubrikSecurityCloud.Types.MinuteSnapshotScheduleInput if($ConfigObj.BasicSchedule) { $InputObj.BasicSchedule = New-Object -TypeName RubrikSecurityCloud.Types.BasicSnapshotScheduleInput $InputObj.BasicSchedule.Frequency = $ConfigObj.BasicSchedule.Frequency $InputObj.BasicSchedule.RetentionUnit = $ConfigObj.BasicSchedule.RetentionUnit $InputObj.BasicSchedule.Retention = $ConfigObj.BasicSchedule.Retention } else { $InputObj.BasicSchedule = $null } $Mutation.Var.Input.SnapshotSchedule.Minute = $InputObj } else { $Mutation.Var.Input.SnapshotSchedule.Minute = $null; } } if ($HourlySchedule) { $Mutation.Var.Input.SnapshotSchedule.Hourly = $HourlySchedule } else { if ($Sla.SnapshotSchedule.Hourly) { $ConfigObj = $Sla.SnapshotSchedule.Hourly $InputObj = New-Object -TypeName RubrikSecurityCloud.Types.HourlySnapshotScheduleInput if($ConfigObj.BasicSchedule) { $InputObj.BasicSchedule = New-Object -TypeName RubrikSecurityCloud.Types.BasicSnapshotScheduleInput $InputObj.BasicSchedule.Frequency = $ConfigObj.BasicSchedule.Frequency $InputObj.BasicSchedule.RetentionUnit = $ConfigObj.BasicSchedule.RetentionUnit $InputObj.BasicSchedule.Retention = $ConfigObj.BasicSchedule.Retention } else { $InputObj.BasicSchedule = $null } $Mutation.Var.Input.SnapshotSchedule.Hourly = $InputObj } else { $Mutation.Var.Input.SnapshotSchedule.Hourly = $null; } } if ($DailySchedule) { $Mutation.Var.Input.SnapshotSchedule.Daily = $DailySchedule } else { if ($Sla.SnapshotSchedule.Daily) { $ConfigObj = $Sla.SnapshotSchedule.Daily $InputObj = New-Object -TypeName RubrikSecurityCloud.Types.DailySnapshotScheduleInput if($ConfigObj.BasicSchedule) { $InputObj.BasicSchedule = New-Object -TypeName RubrikSecurityCloud.Types.BasicSnapshotScheduleInput $InputObj.BasicSchedule.Frequency = $ConfigObj.BasicSchedule.Frequency $InputObj.BasicSchedule.RetentionUnit = $ConfigObj.BasicSchedule.RetentionUnit $InputObj.BasicSchedule.Retention = $ConfigObj.BasicSchedule.Retention } else { $InputObj.BasicSchedule = $null } $Mutation.Var.Input.SnapshotSchedule.Daily = $InputObj } else { $Mutation.Var.Input.SnapshotSchedule.Daily = $null; } } if ($WeeklySchedule) { $Mutation.Var.Input.SnapshotSchedule.Weekly = $WeeklySchedule } else { if ($Sla.SnapshotSchedule.Weekly) { $ConfigObj = $Sla.SnapshotSchedule.Weekly $InputObj = New-Object -TypeName RubrikSecurityCloud.Types.WeeklySnapshotScheduleInput if($ConfigObj.BasicSchedule) { $InputObj.BasicSchedule = New-Object -TypeName RubrikSecurityCloud.Types.BasicSnapshotScheduleInput $InputObj.BasicSchedule.Frequency = $ConfigObj.BasicSchedule.Frequency $InputObj.BasicSchedule.RetentionUnit = $ConfigObj.BasicSchedule.RetentionUnit $InputObj.BasicSchedule.Retention = $ConfigObj.BasicSchedule.Retention } else { $InputObj.BasicSchedule = $null } $InputObj.DayOfWeek = $ConfigObj.DayOfWeek $Mutation.Var.Input.SnapshotSchedule.Weekly = $InputObj } else { $Mutation.Var.Input.SnapshotSchedule.Weekly = $null; } } if ($MonthlySchedule) { $Mutation.Var.Input.SnapshotSchedule.Monthly = $MonthlySchedule } else { if ($Sla.SnapshotSchedule.Monthly) { $ConfigObj = $Sla.SnapshotSchedule.Monthly $InputObj = New-Object -TypeName RubrikSecurityCloud.Types.MonthlySnapshotScheduleInput if($ConfigObj.BasicSchedule) { $InputObj.BasicSchedule = New-Object -TypeName RubrikSecurityCloud.Types.BasicSnapshotScheduleInput $InputObj.BasicSchedule.Frequency = $ConfigObj.BasicSchedule.Frequency $InputObj.BasicSchedule.RetentionUnit = $ConfigObj.BasicSchedule.RetentionUnit $InputObj.BasicSchedule.Retention = $ConfigObj.BasicSchedule.Retention } else { $InputObj.BasicSchedule = $null } $InputObj.DayOfMonth = $ConfigObj.DayOfMonth $Mutation.Var.Input.SnapshotSchedule.Monthly = $InputObj } else { $Mutation.Var.Input.SnapshotSchedule.Monthly = $null; } } if ($QuarterlySchedule) { $Mutation.Var.Input.SnapshotSchedule.Quarterly = $QuarterlySchedule } else { if ($Sla.SnapshotSchedule.Quarterly) { $ConfigObj = $Sla.SnapshotSchedule.Quarterly $InputObj = New-Object -TypeName RubrikSecurityCloud.Types.QuarterlySnapshotScheduleInput if($ConfigObj.BasicSchedule) { $InputObj.BasicSchedule = New-Object -TypeName RubrikSecurityCloud.Types.BasicSnapshotScheduleInput $InputObj.BasicSchedule.Frequency = $ConfigObj.BasicSchedule.Frequency $InputObj.BasicSchedule.RetentionUnit = $ConfigObj.BasicSchedule.RetentionUnit $InputObj.BasicSchedule.Retention = $ConfigObj.BasicSchedule.Retention } else { $InputObj.BasicSchedule = $null } $InputObj.DayOfQuarter = $ConfigObj.DayOfQuarter $InputObj.QuarterStartMonth = $ConfigObj.QuarterStartMonth $Mutation.Var.Input.SnapshotSchedule.Quarterly = $InputObj } else { $Mutation.Var.Input.SnapshotSchedule.Quarterly = $null; } } if ($YearlySchedule) { $Mutation.Var.Input.SnapshotSchedule.Yearly = $YearlySchedule } else { if ($Sla.SnapshotSchedule.Yearly) { $ConfigObj = $Sla.SnapshotSchedule.Yearly $InputObj = New-Object -TypeName RubrikSecurityCloud.Types.YearlySnapshotScheduleInput if($ConfigObj.BasicSchedule) { $InputObj.BasicSchedule = New-Object -TypeName RubrikSecurityCloud.Types.BasicSnapshotScheduleInput $InputObj.BasicSchedule.Frequency = $ConfigObj.BasicSchedule.Frequency $InputObj.BasicSchedule.RetentionUnit = $ConfigObj.BasicSchedule.RetentionUnit $InputObj.BasicSchedule.Retention = $ConfigObj.BasicSchedule.Retention } else { $InputObj.BasicSchedule = $null } $InputObj.DayOfYear = $ConfigObj.DayOfYear $InputObj.YearStartMonth = $ConfigObj.YearStartMonth $Mutation.Var.Input.SnapshotSchedule.Yearly = $InputObj } else { $Mutation.Var.Input.SnapshotSchedule.Yearly = $null; } } # ------------------------------- Snapshot Schedule Block End ---------------------------------- if ($LocalRetentionLimit) { $Mutation.Var.Input.LocalRetentionLimit = $LocalRetentionLimit } else { $Mutation.Var.Input.LocalRetentionLimit = CastToSlaDurationInput -Duration $Sla.LocalRetentionLimit } if ($BackupWindows) { $Mutation.Var.Input.BackupWindows = $BackupWindows } else { $BackupWindowInputs = @() if ($null -ne $Sla.BackupWindows) { foreach ($BackupWindow in $Sla.BackupWindows) { $BackupWindowInputs += CastToBackupWindowInput -BackupWindow $BackupWindow } } $Mutation.Var.Input.BackupWindows = $BackupWindowInputs } if ($FirstFullBackupWindows) { $Mutation.Var.Input.FirstFullBackupWindows = $FirstFullBackupWindows } else { $FirstFullBackupWindowInputs = @() if ($null -ne $Sla.FirstFullBackupWindows) { foreach ($FirstFullBackupWindow in $Sla.FirstFullBackupWindows) { $FirstFullBackupWindowInputs += CastToBackupWindowInput -BackupWindow $FirstFullBackupWindow } } $Mutation.Var.Input.FirstFullBackupWindows = $FirstFullBackupWindowInputs } $ShouldApplyToExistingSnapshotsInput = New-Object -TypeName RubrikSecurityCloud.Types.ShouldApplyToExistingSnapshots if ($ShouldApplyToExistingSnapshots) { $ShouldApplyToExistingSnapshotsInput.Value = $true } else { $ShouldApplyToExistingSnapshotsInput.Value = $false } $Mutation.Var.Input.ShouldApplyToExistingSnapshots = $ShouldApplyToExistingSnapshotsInput $ShouldApplyToNonPolicySnapshotsInput = New-Object -TypeName RubrikSecurityCloud.Types.ShouldApplyToNonPolicySnapshots if($ShouldApplyToNonPolicySnapshots) { $ShouldApplyToNonPolicySnapshotsInput.Value = $true } else { $ShouldApplyToNonPolicySnapshotsInput.Value = $false } $Mutation.Var.Input.ShouldApplyToNonPolicySnapshots = $ShouldApplyToNonPolicySnapshotsInput if ($RetentionLockSla) { $Mutation.Var.Input.IsRetentionLockedSla = $true } else { $Mutation.Var.Input.IsRetentionLockedSla = $Sla.IsRetentionLockedSla } if ($RetentionLockMode) { $Mutation.Var.Input.RetentionLockMode = $RetentionLockMode } else { $Mutation.Var.Input.RetentionLockMode = $Sla.RetentionLockMode } if ($ArchivalSpecs) { $Mutation.Var.Input.ArchivalSpecs = $ArchivalSpecs } else { if ($Sla.ArchivalSpecs) { $ArchivalSpecInputs = @() foreach ($ArchivalSpec in $Sla.ArchivalSpecs) { $ArchivalSpecInputs += CastToArchivalSpecInput -ArchivalSpec $ArchivalSpec } $Mutation.Var.Input.ArchivalSpecs = $ArchivalSpecInputs } else { $Mutation.Var.Input.ArchivalSpecs = $null } } if ($ReplicationSpecs) { $Mutation.Var.Input.ReplicationSpecsV2 = $ReplicationSpecs } else { if ($Sla.ReplicationSpecsV2) { $ReplicationSpecInputs = @() foreach ($ReplicationSpec in $Sla.ReplicationSpecsV2) { $ReplicationSpecInput = CastToReplicationSpecToInput -ReplicationSpec $ReplicationSpec $ReplicationSpecInputs += $ReplicationSpecInput } $Mutation.Var.Input.ReplicationSpecsV2 = $ReplicationSpecInputs } else { $Mutation.Var.Input.ReplicationSpecsV2 = $null } } # ------------------------------- Object Specific Config Block Start ---------------------------------- $ObjectSpecificConfig = New-Object -TypeName RubrikSecurityCloud.Types.ObjectSpecificConfigsInput if ($VmwareVmConfig) { $ObjectSpecificConfig.VmwareVmConfigInput = $VmwareVmConfig } else { if ($Sla.ObjectSpecificConfigs.VmwareVmConfig) { $ConfigObj = $Sla.ObjectSpecificConfigs.VmwareVmConfig $InputObj = New-Object -TypeName RubrikSecurityCloud.Types.VmwareVmConfigInput $InputObj.LogRetentionSeconds = $ConfigObj.LogRetentionSeconds $ObjectSpecificConfig.VmwareVmConfigInput = $InputObj } else { $ObjectSpecificConfig.VmwareVmConfigInput = $null } } if ($OracleConfig) { $ObjectSpecificConfig.OracleConfigInput = $OracleConfig } else { if ($Sla.ObjectSpecificConfigs.OracleConfig) { $ConfigObj = $Sla.ObjectSpecificConfigs.OracleConfig $InputObj = New-Object -TypeName RubrikSecurityCloud.Types.OracleConfigInput $InputObj.Frequency = CastToSlaDurationInput -Duration $ConfigObj.Frequency $InputObj.LogRetention = CastToSlaDurationInput -Duration $ConfigObj.LogRetention $InputObj.HostLogRetention = CastToSlaDurationInput -Duration $ConfigObj.HostLogRetention $ObjectSpecificConfig.OracleConfigInput = $InputObj } else { $ObjectSpecificConfig.OracleConfigInput = $null } } if ($SapHanaConfig) { $ObjectSpecificConfig.SapHanaConfigInput = $SapHanaConfig } else { if ($Sla.ObjectSpecificConfigs.SapHanaConfig) { $ConfigObj = $Sla.ObjectSpecificConfigs.SapHanaConfig $InputObj = New-Object -TypeName RubrikSecurityCloud.Types.SapHanaConfigInput $InputObj.IncrementalFrequency = CastToSlaDurationInput -Duration $ConfigObj.IncrementalFrequency $InputObj.LogRetention = CastToSlaDurationInput -Duration $ConfigObj.LogRetention $InputObj.DifferentialFrequency = CastToSlaDurationInput -Duration $ConfigObj.DifferentialFrequency if ($null -ne $ConfigObj.StorageSnapshotConfig) { $StorageSnapshotConfigInput = New-Object -TypeName RubrikSecurityCloud.Types.SapHanaStorageSnapshotConfigInput $StorageSnapshotConfigInput.Retention = CastToSlaDurationInput -Duration $ConfigObj.StorageSnapshotConfig.Retention $StorageSnapshotConfigInput.Frequency = CastToSlaDurationInput -Duration $ConfigObj.StorageSnapshotConfig.Frequency $InputObj.StorageSnapshotConfig = $StorageSnapshotConfigInput } $ObjectSpecificConfig.SapHanaConfigInput = $InputObj } else { $ObjectSpecificConfig.SapHanaConfigInput = $null } } if ($AwsRdsConfig) { $ObjectSpecificConfig.AwsRdsConfigInput = $AwsRdsConfig } else { if ($Sla.ObjectSpecificConfigs.AwsRdsConfig) { $ConfigObj = $Sla.ObjectSpecificConfigs.AwsRdsConfig $InputObj = New-Object -TypeName RubrikSecurityCloud.Types.AwsRdsConfigInput $InputObj.LogRetention = CastToSlaDurationInput -Duration $ConfigObj.LogRetention $ObjectSpecificConfig.AwsRdsConfigInput = $InputObj } else { $ObjectSpecificConfig.AwsRdsConfigInput = $null } } if ($AzureSqlDatabaseConfig) { $ObjectSpecificConfig.AzureSqlDatabaseDbConfigInput = $AzureSqlDatabaseConfig } else { if ($Sla.ObjectSpecificConfigs.AzureSqlDatabaseDbConfig) { $ConfigObj = $Sla.ObjectSpecificConfigs.AzureSqlDatabaseDbConfig $InputObj = New-Object -TypeName RubrikSecurityCloud.Types.AzureSqlDatabaseDbConfigInput $InputObj.LogRetentionInDays = $ConfigObj.LogRetentionInDays $ObjectSpecificConfig.AzureSqlDatabaseDbConfigInput = $InputObj } else { $ObjectSpecificConfig.AzureSqlDatabaseDbConfigInput = $null } } if ($AzureSqlManagedInstanceConfig) { $ObjectSpecificConfig.AzureSqlManagedInstanceDbConfigInput = $AzureSqlManagedInstanceConfig } else { if ($Sla.ObjectSpecificConfigs.AzureSqlManagedInstanceDbConfig) { $ConfigObj = $Sla.ObjectSpecificConfigs.AzureSqlManagedInstanceDbConfig $InputObj = New-Object -TypeName RubrikSecurityCloud.Types.AzureSqlManagedInstanceDbConfigInput $InputObj.LogRetentionInDays = $ConfigObj.LogRetentionInDays $ObjectSpecificConfig.AzureSqlManagedInstanceDbConfigInput = $InputObj } else { $ObjectSpecificConfig.AzureSqlManagedInstanceDbConfigInput = $null } } if ($Db2Config) { $ObjectSpecificConfig.Db2ConfigInput = $Db2Config } else { if ($Sla.ObjectSpecificConfigs.Db2Config) { $ConfigObj = $Sla.ObjectSpecificConfigs.Db2Config $InputObj = New-Object -TypeName RubrikSecurityCloud.Types.Db2ConfigInput $InputObj.IncrementalFrequency = CastToSlaDurationInput -Duration $ConfigObj.IncrementalFrequency $InputObj.LogRetention = CastToSlaDurationInput -Duration $ConfigObj.LogRetention $InputObj.DifferentialFrequency = CastToSlaDurationInput -Duration $ConfigObj.DifferentialFrequency $InputObj.LogArchivalMethod = $ConfigObj.LogArchivalMethod $ObjectSpecificConfig.Db2ConfigInput = $InputObj } else { $ObjectSpecificConfig.Db2ConfigInput = $null } } if ($MsSqlConfig) { $ObjectSpecificConfig.MsSqlConfigInput = $MsSqlConfig } else { if ($Sla.ObjectSpecificConfigs.MssqlConfig) { $ConfigObj = $Sla.ObjectSpecificConfigs.MssqlConfig $InputObj = New-Object -TypeName RubrikSecurityCloud.Types.MssqlConfigInput $InputObj.Frequency = CastToSlaDurationInput -Duration $ConfigObj.Frequency $InputObj.LogRetention = CastToSlaDurationInput -Duration $ConfigObj.LogRetention $ObjectSpecificConfig.MsSqlConfigInput = $InputObj } else { $ObjectSpecificConfig.MsSqlConfigInput = $null } } if ($MysqldbConfig) { $ObjectSpecificConfig.MysqldbConfigInput = $MysqldbConfig } else { if ($Sla.ObjectSpecificConfigs.MysqldbSlaConfig) { $ConfigObj = $Sla.ObjectSpecificConfigs.MysqldbSlaConfig $InputObj = New-Object -TypeName RubrikSecurityCloud.Types.MysqldbSlaConfigInput $InputObj.LogFrequency = CastToSlaDurationInput -Duration $ConfigObj.LogFrequency $InputObj.LogRetention = CastToSlaDurationInput -Duration $ConfigObj.LogRetention $ObjectSpecificConfig.MysqldbConfigInput = $InputObj } else { $ObjectSpecificConfig.MysqldbConfigInput = $null } } if ($MongoConfig) { $ObjectSpecificConfig.MongoConfigInput = $MongoConfig } else { if ($Sla.ObjectSpecificConfigs.MongoConfig) { $ConfigObj = $Sla.ObjectSpecificConfigs.MongoConfig $InputObj = New-Object -TypeName RubrikSecurityCloud.Types.MongoConfigInput $InputObj.LogFrequency = CastToSlaDurationInput -Duration $ConfigObj.LogFrequency $InputObj.LogRetention = CastToSlaDurationInput -Duration $ConfigObj.LogRetention $ObjectSpecificConfig.MongoConfigInput = $InputObj } else { $ObjectSpecificConfig.MongoConfigInput = $null } } if ($AzureBlobConfig) { $ObjectSpecificConfig.AzureBlobConfigInput = $AzureBlobConfig } else { if ($Sla.ObjectSpecificConfigs.AzureBlobConfig) { $ConfigObj = $Sla.ObjectSpecificConfigs.AzureBlobConfig $InputObj = New-Object -TypeName RubrikSecurityCloud.Types.AzureBlobConfigInput $InputObj.ContinuousBackupRetentionInDays = $ConfigObj.ContinuousBackupRetentionInDays $InputObj.BackupLocationId = $ConfigObj.BackupLocationId $ObjectSpecificConfig.AzureBlobConfigInput = $InputObj } else { $ObjectSpecificConfig.AzureBlobConfigInput = $null } } if ($AwsNativeS3Config) { $ObjectSpecificConfig.AwsNativeS3SlaConfigInput = $AwsNativeS3Config } else { if ($Sla.ObjectSpecificConfigs.AwsNativeS3SlaConfig) { $ConfigObj = $Sla.ObjectSpecificConfigs.AwsNativeS3SlaConfig $InputObj = New-Object -TypeName RubrikSecurityCloud.Types.AwsNativeS3SlaConfigInput $InputObj.ContinuousBackupRetentionInDays = $ConfigObj.ContinuousBackupRetentionInDays $InputObj.ArchivalLocationId = $ConfigObj.ArchivalLocationId $ObjectSpecificConfig.AwsNativeS3SlaConfigInput = $InputObj } else { $ObjectSpecificConfig.AwsNativeS3SlaConfigInput = $null } } if ($ManagedVolumeConfig) { $ObjectSpecificConfig.ManagedVolumeSlaConfigInput = $ManagedVolumeConfig } else { if ($Sla.ObjectSpecificConfigs.ManagedVolumeSlaConfig) { $ConfigObj = $Sla.ObjectSpecificConfigs.ManagedVolumeSlaConfig $InputObj = New-Object -TypeName RubrikSecurityCloud.Types.ManagedVolumeSlaConfigInput $InputObj.LogRetention = CastToSlaDurationInput -Duration $ConfigObj.LogRetention $ObjectSpecificConfig.ManagedVolumeSlaConfigInput = $InputObj } else { $ObjectSpecificConfig.ManagedVolumeSlaConfigInput = $null } } if ($PostgresDbClusterConfig) { $ObjectSpecificConfig.PostgresDbClusterSlaConfigInput = $PostgresDbClusterConfig } else { if ($Sla.ObjectSpecificConfigs.PostgresDbClusterSlaConfig) { $ConfigObj = $Sla.ObjectSpecificConfigs.PostgresDbClusterSlaConfig $InputObj = New-Object -TypeName RubrikSecurityCloud.Types.PostgresDbClusterSlaConfigInput $InputObj.LogRetention = CastToSlaDurationInput -Duration $ConfigObj.LogRetention $ObjectSpecificConfig.PostgresDbClusterSlaConfigInput = $InputObj } else { $ObjectSpecificConfig.PostgresDbClusterSlaConfigInput = $null } } $Mutation.Var.Input.ObjectSpecificConfigsInput = $ObjectSpecificConfig # ------------------------------- Object Specific Config Block End ---------------------------------- if ($AsQuery) { return $Mutation } return Invoke-Rsc -Query $Mutation } } |