Skip to content

Commit

Permalink
0.19
Browse files Browse the repository at this point in the history
  • Loading branch information
guirava committed Nov 22, 2023
1 parent 769de7b commit 314bb5b
Show file tree
Hide file tree
Showing 282 changed files with 10,042 additions and 3,590 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# Changelog

## Version 0.19

New Features:

- The SDK now imposes limits on page sizes when retrieving lists
from the API. The new default is 50 items per page.
Note that it should not result in any behavior change for users
as long as they collect pages with `Get-RscPages` (or
iterate manually through them). It will cause problems to scripts
that assumed that the API would return all items in a single
response and their deployment lists more than 50 items.

Breaking Changes:

- `Get-RscPages` now takes for parameter a `RscQuery` object
instead of a script block. See `Get-Help Get-RscPages` for details.

## Version 0.18.2

Fixes:
Expand Down
2 changes: 1 addition & 1 deletion Output/PublicFunctions.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Foreach ($import in @($Public))
Try
{
Write-Output("Importing module from file $($import.fullname)")
Import-Module $import.fullname -ErrorAction Stop
Import-Module $import.fullname -ErrorAction Stop -Force
}
Catch
{
Expand Down
4 changes: 2 additions & 2 deletions Output/RubrikSecurityCloud.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# RootModule = 'RubrikSecurityCloud.PowerShell.dll'

# Version number of this module.
ModuleVersion = '0.18.2'
ModuleVersion = '0.19'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand All @@ -27,7 +27,7 @@ Copyright = '(c) Rubrik. All rights reserved.'

# Description of the functionality provided by this module
# NOTE: This entry is generated.
Description = 'PowerShell Module for Rubrik Security Cloud. GraphQL schema version: v20231025-48 .'
Description = 'PowerShell Module for Rubrik Security Cloud. GraphQL schema version: v20231108-58 .'

# Minimum version of the PowerShell engine required by this module
PowerShellVersion = '5.0.0'
Expand Down
116 changes: 85 additions & 31 deletions Output/Toolkit/Public/Get-RscCluster.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Requires -Version 3
function Get-RscCluster {
<#
<#
.SYNOPSIS
Retrieve info about clusters
Expand All @@ -19,20 +19,22 @@ function Get-RscCluster {
https://rubrikinc.github.io/rubrik-api-documentation/schema/reference/cluster.doc.html
.PARAMETER List
Used to create a list of clusters that are connected to Rubrik Securiry Cloud
Retrieve the list of clusters that are connected to Rubrik Securiry Cloud.
This is the default parameter set.
.PARAMETER Name
Used to return a specific cluster based on the name
.PARAMETER Detail
Changes the data profile. This can affect the fields returned
Use the DETAIL field profile instead of the DEFAULT field profile.
The DETAIL field profile returns more fields than the DEFAULT field profile.
.PARAMETER IncludeNullProperties
By default, fields will a NULL are not returned. Supplying this parameter will return all fields, including fields
with a NULL in them.
.PARAMETER AsQuery
Instead of running the command, the query and variables used for the query will be returned.
Instead of running the command, the query object is returned.
.EXAMPLE
Return a list of all clusters managed by RSC
Expand All @@ -46,12 +48,12 @@ function Get-RscCluster {
.EXAMPLE
Return back all fields, including the fields that are null
Include the fields that are null in the response
Get-RscCluster -Name vault-r-london -IncludeNullProperties
.EXAMPLE
Return back just the query that will be run instead of running the query and returning the results
Return back just the query that would run instead of running the query and returning the results
Get-RscCluster -Name vault-r-london -AsQuery
#>
Expand All @@ -66,71 +68,123 @@ function Get-RscCluster {
ValueFromPipeline = $false
)][Switch]$List,

[Parameter(
ParameterSetName = "List",
Mandatory = $false,
ValueFromPipelineByPropertyName = $true,
HelpMessage = "Return only the first N clusters. Default is 0, which means use the default page size."
)]
[Int]$First = 0,

[Parameter(
ParameterSetName = "Count",
Mandatory = $false,
HelpMessage = "Return only the number of clusters"
)]
[Switch]$Count,

[Parameter(
ParameterSetName = "Id",
Mandatory = $false,
ValueFromPipelineByPropertyName = $true,
HelpMessage = "Return only the cluster with the specified id"
)]
[String]$Id,

[Parameter(
ParameterSetName = "Name",
Mandatory = $false,
ValueFromPipeline = $false
)][String]$Name,

# Common parameter to all parameter sets:

[Parameter(
Mandatory = $false,
ValueFromPipeline = $false
ValueFromPipeline = $false,
HelpMessage = "Return more fields than the default field profile"
)][Switch]$Detail,

[Parameter(
Mandatory = $false,
ValueFromPipeline = $false
ValueFromPipeline = $false,
HelpMessage = "Include fields that are null in the response"
)][Switch]$IncludeNullProperties,

[Parameter(
Mandatory = $false,
ValueFromPipeline = $false
ValueFromPipeline = $false,
HelpMessage = "Return the query object instead of running the query"
)][Switch]$AsQuery
)

Process {
# Re-use existing connection, or create a new one:
Connect-Rsc -ErrorAction Stop | Out-Null

# Count clusters:
if ( $PSCmdlet.ParameterSetName -eq "Count" ) {
$r = (New-RscQueryCluster -Op List -RemoveField Nodes).Invoke()
# Object's 'Count' property is hidden by the 'Count' method
# so we can't do `$r.Count`
$clusterCount = $r | Select-Object -ExpandProperty Count
return $clusterCount
}

# Determine field profile:
$fieldProfile = "DEFAULT"
if ( $Detail -eq $true ) {
$fieldProfile = "DETAIL"
}
Write-Host "Get-RscCluster field profile: $fieldProfile"
Write-Verbose "Get-RscCluster field profile: $fieldProfile"

#region Create Query
switch ( $PSCmdlet.ParameterSetName ){
# Create Query
switch ( $PSCmdlet.ParameterSetName ) {
"List" {
$query = New-RscQueryCluster -Operation List -RemoveField Nodes.isHealthy -FieldProfile $fieldProfile
}
"Name"{
"Id" {
$query = New-RscQueryCluster -Operation List -RemoveField Nodes.isHealthy -FieldProfile $fieldProfile
$query.Var.clusterUuid = $Id
}
"Name" {
$query = New-RscQueryCluster -Operation List -RemoveField Nodes.isHealthy -FieldProfile $fieldProfile
$query.Var.filter = New-Object -TypeName RubrikSecurityCloud.Types.ClusterFilterInput
$query.Var.filter.Name = $Name
}
}
#endregion

if ( $AsQuery -eq $true ) {
$result = $query.GqlRequest()
}else{
$result = $query.Invoke()
# Skip sending, return query object:
if ( $AsQuery ) {
return $query
}

if ($null -ne $result.Nodes){
if ( $IncludeNullProperties -eq $true ) {
$result.Nodes
}else{
$result.Nodes | Remove-NullProperties
}
}else{
if ( $IncludeNullProperties -eq $true ) {
$result
}else{
$result | Remove-NullProperties
}
}
# Invoke the query:
if ( $PSCmdlet.ParameterSetName -eq "List" ) {
$response = Get-RscPages -Query $query -First $First
}
else {
$response = Invoke-Rsc $query
}

# Filter results
# the response's `Nodes` field contains the list
if ($null -ne $response.Nodes) {
$result = $response.Nodes
}
else {
$result = $response
}

if ( $IncludeNullProperties -eq $true ) {
$result
}
else {
# Filter out null values:
# fields that were not selected for retrieval
# come back as nulls in the `$result` object,
# so we filter them out here:
$result | Remove-NullProperties
}
}
}
6 changes: 3 additions & 3 deletions Output/Toolkit/Public/Get-RscEventSeries.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ function Get-RscEventSeries {
.DESCRIPTION
By default, retrieve info about events.
`Get-RscEventSeriesSeries` defaults to `Get-RscEventSeries -List -First 1000`
which returns the first 1000 events.
`Get-RscEventSeriesSeries` defaults to `Get-RscEventSeries -List -First 50`
which returns the first 50 events.
To get info about a specific event, use the `-Id` parameter.
Expand Down Expand Up @@ -101,7 +101,7 @@ function Get-RscEventSeries {
Mandatory = $false,
ValueFromPipelineByPropertyName = $true
)]
[Int]$First = 1000,
[Int]$First = 50,

# Common parameter to all parameter sets:
[Parameter(
Expand Down
Loading

0 comments on commit 314bb5b

Please sign in to comment.