Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backup(monitor): Enhance Example #281

Merged
merged 1 commit into from
Jan 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 5 additions & 17 deletions PowerFGT/Public/monitor/system/config/backup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,17 @@ function Get-FGTMonitorSystemConfigBackup {
.EXAMPLE
Get-FGTMonitorSystemConfigBackup

Get System Config Backup
Get System Config Backup on global scope

.EXAMPLE
Get-FGTMonitorSystemConfigBackup -skip

Get System Config Backup (but only relevant attributes)

.EXAMPLE
Get-FGTMonitorSystemConfigBackup -vdom vdomX
Get-FGTMonitorSystemConfigBackup -scope vdom -vdom vdomX

Get System Config Backup on vdomX

.EXAMPLE
Get-FGTMonitorSystemConfigBackup -scope global -vdom vdomX

Get System Config Backup in global scope even if vdom is specified
#>

Param(
Expand All @@ -40,7 +35,7 @@ function Get-FGTMonitorSystemConfigBackup {
[String[]]$vdom,
[Parameter(Mandatory = $false)]
[ValidateSet("global", "vdom")]
[string]$scope = "global", # Scope parameter with default "global"
[string]$scope = "global",
[Parameter(Mandatory = $false)]
[psobject]$connection = $DefaultFGTConnection
)
Expand All @@ -49,23 +44,16 @@ function Get-FGTMonitorSystemConfigBackup {
}

Process {
$invokeParams = @{ }

$invokeParams = @{ }
if ( $PsBoundParameters.ContainsKey('skip') ) {
$invokeParams.add('skip', $skip)
}

# Add vdom to invokeParams if provided
if ($PsBoundParameters.ContainsKey('vdom')) {
$invokeParams.add('vdom', $vdom)

# Only change scope to "vdom" if vdom is provided and scope was not explicitly set to "global"
if (-not $PsBoundParameters.ContainsKey('scope') -or $scope -eq "vdom") {
$scope = "vdom"
}
}

# Prepare URI and request method based on connection version
#before 7.6.x, config/backup is available with get method and using paramater
if ($connection.version -lt "7.6.0") {
$method = "get"
$uri = "api/v2/monitor/system/config/backup?scope=$scope"
Expand Down
Loading