Skip to content

Commit 0853553

Browse files
committed
Get-RubrikFileset support
1 parent 72c21de commit 0853553

File tree

2 files changed

+51
-20
lines changed

2 files changed

+51
-20
lines changed

Rubrik/Private/Get-RubrikRSCFileset.ps1

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,57 @@ function Get-RubrikRSCFileset {
7575
[String]$api = $global:RubrikConnection.api
7676
)
7777

78-
$RscParams = @{}
79-
8078
if ($Id) {
81-
$RscParams.Add('id',$Id)
79+
$query = New-RSCQuery -GqlQuery filesetTemplate
80+
$query.Var.fid = "$Id"
81+
$query.Field.includes = "FETCH"
82+
$response = Invoke-RSC $query
8283
}
83-
84-
$response = Get-RscFileset @RscParams
85-
return $response.nodes
84+
else {
85+
$query = New-RscQuery -GqlQuery filesetTemplates -AddField Nodes.Includes
86+
Write-Verbose -Message "Filtering list by cluster"
87+
$filter = New-Object System.Collections.ArrayList
88+
89+
$filter.Add(
90+
@{
91+
"field" = "CLUSTER_ID"
92+
"texts" = "$($global:rubrikConnection.clusterId)"
93+
}
94+
) | Out-Null
95+
96+
if ($Name) {
97+
$filter.Add(
98+
@{
99+
"field" = "NAME_EXACT_MATCH"
100+
"texts" = "$Name"
101+
}
102+
) | Out-Null
103+
}
104+
105+
if ($OperatingSystemType) {
106+
if ($OperatingSystemType -eq "Windows") {
107+
$hostRoots = @("WINDOWS_HOST_ROOT")
108+
} elseif ($OperatingSystemType -eq "Linux") {
109+
$hostRoots = @("LINUX_HOST_ROOT")
110+
} else {
111+
$hostRoots = @("WINDOWS_HOST_ROOT", "LINUX_HOST_ROOT")
112+
}
113+
} else {
114+
$hostRoots = @("WINDOWS_HOST_ROOT", "LINUX_HOST_ROOT")
115+
}
116+
117+
Write-Verbose -Message "Adding filter to query"
118+
$query.var.filter = $filter
119+
120+
$response = foreach ($hostRoot in $hostRoots) {
121+
$query.Var.hostRoot = "$hostRoot"
122+
$response = Invoke-RSC $query
123+
$response.nodes
124+
}
125+
}
126+
127+
128+
return $response
86129

87130

88131

Rubrik/Private/Get-RubrikRSCFilesetTemplate.ps1

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,11 @@ function Get-RubrikRSCFilesetTemplate
3333
if ($Id) {
3434
$query = New-RSCQuery -GqlQuery filesetTemplate
3535
$query.Var.fid = "$Id"
36-
<#
37-
# Populate Additional fields to fetch
38-
# For Example
39-
$query.field.nodes[1].ProtectedObjectCount = 0
40-
#>
41-
36+
$query.Field.includes = "FETCH"
4237
$response = Invoke-RSC $query
4338
}
4439
else {
45-
$query = New-RscQuery -GqlQuery filesetTemplates
40+
$query = New-RscQuery -GqlQuery filesetTemplates -AddField Nodes.Includes
4641
Write-Verbose -Message "Filtering list by cluster"
4742
$filter = New-Object System.Collections.ArrayList
4843

@@ -74,13 +69,6 @@ function Get-RubrikRSCFilesetTemplate
7469
$hostRoots = @("WINDOWS_HOST_ROOT", "LINUX_HOST_ROOT")
7570
}
7671

77-
# Add support for share type maybe?
78-
79-
<#
80-
# Populate Additional fields to fetch
81-
# For Example
82-
$query.field.nodes[1].ProtectedObjectCount = 0
83-
#>
8472
Write-Verbose -Message "Adding filter to query"
8573
$query.var.filter = $filter
8674

0 commit comments

Comments
 (0)