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

Get-FGTMonitorSystemConfigBackup: Add scope vdom #272

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
31 changes: 23 additions & 8 deletions PowerFGT/Public/monitor/system/config/backup.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#
#
alagoutte marked this conversation as resolved.
Show resolved Hide resolved
# Copyright 2022, Alexis La Goutte <alexis dot lagoutte at gmail dot com>
#
# SPDX-License-Identifier: Apache-2.0
Expand Down Expand Up @@ -26,6 +26,11 @@ function Get-FGTMonitorSystemConfigBackup {
Get-FGTMonitorSystemConfigBackup -vdom vdomX

Get System Config Backup on vdomX

.EXAMPLE
Get-FGTMonitorSystemConfigBackup -scope global -vdom vdomX
alagoutte marked this conversation as resolved.
Show resolved Hide resolved

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

Param(
Expand All @@ -34,33 +39,43 @@ function Get-FGTMonitorSystemConfigBackup {
[Parameter(Mandatory = $false)]
[String[]]$vdom,
[Parameter(Mandatory = $false)]
[ValidateSet("global", "vdom")]
[string]$scope = "global", # Scope parameter with default "global"
[Parameter(Mandatory = $false)]
[psobject]$connection = $DefaultFGTConnection
)

Begin {
}

Process {

$invokeParams = @{ }

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

# 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") {
alagoutte marked this conversation as resolved.
Show resolved Hide resolved
$scope = "vdom"
}
}

#before 7.6.x, config/backup is available with get method and using paramater
alagoutte marked this conversation as resolved.
Show resolved Hide resolved
# Prepare URI and request method based on connection version
if ($connection.version -lt "7.6.0") {
$method = "get"
$uri = 'api/v2/monitor/system/config/backup?scope=global'
$uri = "api/v2/monitor/system/config/backup?scope=$scope"
$body = ""
}
else {
$method = "post"
$uri = 'api/v2/monitor/system/config/backup'
$body = @{
"scope" = "global"
"scope" = "$scope"
}
}

Expand Down