-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added New-RscSlaDomain and New-RscSnapshotSchedule (#39)
- Loading branch information
1 parent
9f79386
commit 6dbe81e
Showing
3 changed files
with
174 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#Requires -Version 3 | ||
function New-RscSlaDomain | ||
{ | ||
<# | ||
.SYNOPSIS | ||
Creates a new Rubrik SLA Domain | ||
.DESCRIPTION | ||
The New-RscSlaDomain cmdlet will create a new SLA Domain. Rubrik SLA Domains are policies that define the frequency, retention, and rules for acrhival and replication. | ||
.LINK | ||
Schema reference: | ||
https://rubrikinc.github.io/rubrik-api-documentation/schema/reference | ||
.EXAMPLE | ||
Create a Snapshot schedule to take a snapshot every 1 hour and retain that snapshot for 7 days. Then create the SLA Domain with that schedule. | ||
$hourlySchedule = New-RscSnapshotSchedule -Type Hourly -Frequency 1 -Retention 7 -RetentionUnit DAYS | ||
New-RscSlaDomain -Name "Platinum" -HourlySchedule $hourlySchedule -ObjectType VSPHERE_OBJECT_TYPE | ||
#> | ||
|
||
[CmdletBinding()] | ||
Param( | ||
# SLA Domain Name | ||
[Parameter(Mandatory)] | ||
[ValidateNotNullOrEmpty()] | ||
[String]$Name, | ||
|
||
# Hourly Schedule object | ||
[Parameter()] | ||
[RubrikSecurityCloud.Types.HourlySnapshotScheduleInput]$HourlySchedule, | ||
|
||
# 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, | ||
|
||
# Yearly Schedule object | ||
[Parameter()] | ||
[RubrikSecurityCloud.Types.SlaObjectType]$ObjectType | ||
) | ||
Process { | ||
|
||
$query = New-RscMutation -GqlMutation createGlobalSla | ||
$query.Var.Input = New-Object -TypeName RubrikSecurityCloud.Types.CreateGlobalSlaInput | ||
$query.Var.Input.name = $Name | ||
$query.Var.Input.SnapshotSchedule = New-Object -TypeName RubrikSecurityCloud.Types.GlobalSnapshotScheduleInput | ||
$query.Var.Input.ObjectTypes = @($ObjectType) | ||
|
||
if ($HourlySchedule) { | ||
$query.var.input.SnapshotSchedule.Hourly = $HourlySchedule | ||
} | ||
if ($MonthlySchedule) { | ||
$query.var.input.SnapshotSchedule.Monthly = $MonthlySchedule | ||
} | ||
if ($QuarterlySchedule) { | ||
$query.var.input.SnapshotSchedule.Quarterly = $QuarterlySchedule | ||
} | ||
if ($YearlySchedule) { | ||
$query.var.input.SnapshotSchedule.Yearly = $YearlySchedule | ||
} | ||
$result = Invoke-Rsc -Query $query | ||
$result | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
#Requires -Version 3 | ||
function New-RscSnapshotSchedule { | ||
<# | ||
.SYNOPSIS | ||
Creates a Snapshot Schedule for use with New-RscSlaDomain | ||
.DESCRIPTION | ||
Creates a Snapshot Schedule for use with New-RscSlaDomain | ||
.PARAMETER Type | ||
The Type of Schedule | ||
(Minute, Hourly, Daily, Weekly, Monthly, Quarterly, Yearly) | ||
.PARAMETER Frequency | ||
The frequency to take a snapshot, based on the schedule type. | ||
.PARAMETER Retention | ||
Length of time to retain the snapshot | ||
.PARAMETER RetentionUnit | ||
Unit of time to retain the snapshot | ||
(Minute, Hourly, Daily, Weekly, Monthly, Quarterly, Yearly) | ||
.LINK | ||
Schema reference: | ||
https://rubrikinc.github.io/rubrik-api-documentation/schema/reference | ||
.EXAMPLE | ||
Create a Snapshot schedule to take a snapshot every 1 hour and retain that snapshot for 7 days. Then create the SLA Domain with that schedule. | ||
$hourlySchedule = New-RscSnapshotSchedule -Type Hourly -Frequency 1 -Retention 7 -RetentionUnit DAYS | ||
New-RscSlaDomain -Name "Platinum" -HourlySchedule $hourlySchedule -ObjectType VSPHERE_OBJECT_TYPE | ||
#> | ||
|
||
[CmdletBinding()] | ||
Param( | ||
[Parameter(Mandatory)] | ||
[ValidateSet("Minute","Hourly","Daily","Weekly","Monthly","Quarterly","Yearly")] | ||
$Type, | ||
|
||
[Parameter(Mandatory)] | ||
[Int]$Frequency, | ||
|
||
[Parameter(Mandatory)] | ||
[Int]$Retention, | ||
|
||
[Parameter(Mandatory)] | ||
[RubrikSecurityCloud.Types.RetentionUnit] | ||
$RetentionUnit, | ||
|
||
[Parameter()] | ||
[RubrikSecurityCloud.Types.DayOfWeek] | ||
$DayOfWeek = [RubrikSecurityCloud.Types.DayOfWeek]::FRIDAY, | ||
|
||
[Parameter()] | ||
[RubrikSecurityCloud.Types.DayOfMonth] | ||
$DayOfMonth = [RubrikSecurityCloud.Types.DayOfMonth]::LAST_DAY, | ||
|
||
[Parameter()] | ||
[RubrikSecurityCloud.Types.DayOfQuarter] | ||
$DayOfQuarter = [RubrikSecurityCloud.Types.DayOfQuarter]::LAST_DAY, | ||
|
||
[Parameter()] | ||
[RubrikSecurityCloud.Types.Month] | ||
$QuarterStartMonth = [RubrikSecurityCloud.Types.Month]::JANUARY, | ||
|
||
[Parameter()] | ||
[RubrikSecurityCloud.Types.DayOfYear] | ||
$DayOfYear = [RubrikSecurityCloud.Types.DayOfYear]::LAST_DAY, | ||
|
||
[Parameter()] | ||
[RubrikSecurityCloud.Types.Month] | ||
$YearStartMonth = [RubrikSecurityCloud.Types.Month]::JANUARY | ||
|
||
) | ||
|
||
Process { | ||
$schedule = New-Object -TypeName "RubrikSecurityCloud.Types.$($Type)SnapshotScheduleInput" | ||
$schedule.BasicSchedule = New-Object -TypeName RubrikSecurityCloud.Types.BasicSnapshotScheduleInput | ||
$schedule.BasicSchedule.Frequency = $Frequency | ||
$schedule.BasicSchedule.Retention = $Retention | ||
$schedule.BasicSchedule.RetentionUnit = $RetentionUnit | ||
|
||
if ($Type -eq "Weekly") { | ||
$schedule.DayOfWeek = $DayOfWeek | ||
} elseif ($Type -eq "Monthly") { | ||
$schedule.DayOfMonth = $DayOfMonth | ||
} elseif ($Type -eq "Quarterly") { | ||
$schedule.DayOfQuarter = $DayOfQuarter | ||
$schedule.QuarterStartMonth = $QuarterStartMonth | ||
} elseif ($Type -eq "Yearly") { | ||
$schedule.DayOfYear = $DayOfYear | ||
$schedule.YearStartMonth = $YearStartMonth | ||
} | ||
$schedule | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.