From 6261f1da2c975655237d576e22c6576d4b2b3756 Mon Sep 17 00:00:00 2001 From: scalhoon-apfc <56978199+scalhoon-apfc@users.noreply.github.com> Date: Wed, 30 Dec 2020 10:15:28 -0900 Subject: [PATCH] Rename and Tag extension Extend Tag colors. Extend Invoke-PaApiConfig for rename operation and created basic Tag rename command. --- PowerAlto/Classes/Main/PaTag.Class.ps1 | 26 ++++++++++++- .../Classes/Main/PaloAltoDevice.Class.ps1 | 4 ++ PowerAlto/Public/Invoke-PaApiConfig.ps1 | 8 ++++ PowerAlto/Public/Rename-PaTag.ps1 | 19 ++++++++++ PowerAlto/Public/Set-PaTag.ps1 | 2 +- PowerAlto/en-US/PowerAlto-help.xml | 38 +++++++++++++++++++ PowerAlto/en-US/PowerAlto4-help.xml | 38 +++++++++++++++++++ 7 files changed, 133 insertions(+), 2 deletions(-) create mode 100644 PowerAlto/Public/Rename-PaTag.ps1 diff --git a/PowerAlto/Classes/Main/PaTag.Class.ps1 b/PowerAlto/Classes/Main/PaTag.Class.ps1 index 133e26d..9d26f7d 100644 --- a/PowerAlto/Classes/Main/PaTag.Class.ps1 +++ b/PowerAlto/Classes/Main/PaTag.Class.ps1 @@ -56,7 +56,31 @@ class PaTag { $Mapping.color14 = 'Black' $Mapping.color15 = 'Gold' $Mapping.color16 = 'Brown' - $Mapping.color17 = 'Green' + $Mapping.color17 = 'Olive' + $Mapping.color19 = 'Maroon' + $Mapping.color20 = 'Red-Orange' + $Mapping.color21 = 'Yellow-Orange' + $Mapping.color22 = 'Forest Green' + $Mapping.color23 = 'Turquoise Blue' + $Mapping.color24 = 'Azure Blue' + $Mapping.color25 = 'Cerulean Blue' + $Mapping.color26 = 'Midnight Blue' + $Mapping.color27 = 'Medium Blue' + $Mapping.color28 = 'Cobalt Blue' + $Mapping.color29 = 'Violet Blue' + $Mapping.color30 = 'Blue Violet' + $Mapping.color31 = 'Medium Violet' + $Mapping.color32 = 'Medium Rose' + $Mapping.color33 = 'Lavender' + $Mapping.color34 = 'Orchid' + $Mapping.color35 = 'Thistle' + $Mapping.color36 = 'Peach' + $Mapping.color37 = 'Salmon' + $Mapping.color38 = 'Magenta' + $Mapping.color39 = 'Red Violet' + $Mapping.color40 = 'Mahogany' + $Mapping.color41 = 'Burnt Sienna' + $Mapping.color42 = 'Chestnut' $ReturnedName = $null $FriendlyName = $null diff --git a/PowerAlto/Classes/Main/PaloAltoDevice.Class.ps1 b/PowerAlto/Classes/Main/PaloAltoDevice.Class.ps1 index f1ca8cb..e77d77f 100644 --- a/PowerAlto/Classes/Main/PaloAltoDevice.Class.ps1 +++ b/PowerAlto/Classes/Main/PaloAltoDevice.Class.ps1 @@ -266,6 +266,10 @@ class PaloAltoDevice { $queryString.element = $Element continue } + 'rename' { + $queryString.newname = $Element + continue + } } $result = $this.invokeApiQuery($queryString) diff --git a/PowerAlto/Public/Invoke-PaApiConfig.ps1 b/PowerAlto/Public/Invoke-PaApiConfig.ps1 index 92f9db2..0405d9b 100644 --- a/PowerAlto/Public/Invoke-PaApiConfig.ps1 +++ b/PowerAlto/Public/Invoke-PaApiConfig.ps1 @@ -13,8 +13,12 @@ function Invoke-PaApiConfig { [Parameter(ParameterSetName = "set", Mandatory = $True, Position = 0)] [switch]$Set, + # rename parameters + [Parameter(ParameterSetName = "rename", Mandatory = $True, Position = 0)] + [switch]$Rename, [Parameter(ParameterSetName = "set", Mandatory = $True, Position = 1)] [Parameter(ParameterSetName = "edit", Mandatory = $True, Position = 1)] + [Parameter(ParameterSetName = "rename", Mandatory = $True, Position = 1)] [string]$Element, # move parameters @@ -51,6 +55,10 @@ function Invoke-PaApiConfig { $Global:PaDeviceObject.invokeConfigQuery('edit', $Xpath, $Element) continue } + 'rename' { + $Global:PaDeviceObject.invokeConfigQuery('rename', $Xpath, $Element) + continue + } 'move' { $Global:PaDeviceObject.invokeConfigQuery('move', $Xpath, $Location) continue diff --git a/PowerAlto/Public/Rename-PaTag.ps1 b/PowerAlto/Public/Rename-PaTag.ps1 new file mode 100644 index 0000000..f0fe225 --- /dev/null +++ b/PowerAlto/Public/Rename-PaTag.ps1 @@ -0,0 +1,19 @@ +function Rename-PaTag { + [CmdletBinding()] + Param ( + [Parameter(Mandatory = $True, Position = 0)] + [string]$Name, + [Parameter(Mandatory = $True, Position = 1)] + [string]$NewName + ) + + BEGIN { + $XPathNode = 'tag' + $Xpath = $Global:PaDeviceObject.createXPath($XPathNode, $Name) + } + + PROCESS { + $Rename = Invoke-PaApiConfig -Rename -Xpath $XPath -Element $NewName + $Rename + } +} \ No newline at end of file diff --git a/PowerAlto/Public/Set-PaTag.ps1 b/PowerAlto/Public/Set-PaTag.ps1 index 06b0ff2..03879a0 100644 --- a/PowerAlto/Public/Set-PaTag.ps1 +++ b/PowerAlto/Public/Set-PaTag.ps1 @@ -5,7 +5,7 @@ function Set-PaTag { [string]$Name, [Parameter(ParameterSetName = "name", Mandatory = $False, Position = 1)] - [ValidateSet('Red', 'Green', 'Blue', 'Yellow', 'Copper', 'Orange', 'Purple', 'Gray', 'Light Green', 'Cyan', 'Light Gray', 'Blue Gray', 'Lime', 'Black', 'Gold', 'Brown', 'Green')] + [ValidateSet('Red', 'Green', 'Blue', 'Yellow', 'Copper', 'Orange', 'Purple', 'Gray', 'Light Green', 'Cyan', 'Light Gray', 'Blue Gray', 'Lime', 'Black', 'Gold', 'Brown', 'Olive', 'Maroon', 'Red-Orange', 'Yellow-Orange', 'Forest Green', 'Turquoise Blue', 'Azure Blue', 'Cerulean Blue', 'Midnight Blue', 'Medium Blue', 'Cobalt Blue', 'Violet Blue', 'Blue Violet', 'Medium Violet', 'Medium Rose', 'Lavender', 'Orchid', 'Thistle', 'Peach', 'Salmon', 'Magenta', 'Red Violet', 'Mahogany', 'Burnt Sienna', 'Chestnut')] [string]$Color, [Parameter(ParameterSetName = "name", Mandatory = $False, Position = 2)] diff --git a/PowerAlto/en-US/PowerAlto-help.xml b/PowerAlto/en-US/PowerAlto-help.xml index e674d0d..a871c47 100644 --- a/PowerAlto/en-US/PowerAlto-help.xml +++ b/PowerAlto/en-US/PowerAlto-help.xml @@ -2225,6 +2225,44 @@ None + + Invoke-PaApiConfig + + Rename + + rename parameters + + + SwitchParameter + + + False + + + Element + + {{Fill Element Description}} + + String + + String + + + None + + + XPath + + XPath of desired configuration. + + String + + String + + + None + + Invoke-PaApiConfig diff --git a/PowerAlto/en-US/PowerAlto4-help.xml b/PowerAlto/en-US/PowerAlto4-help.xml index e4efb51..543f15a 100644 --- a/PowerAlto/en-US/PowerAlto4-help.xml +++ b/PowerAlto/en-US/PowerAlto4-help.xml @@ -1367,6 +1367,44 @@ None + + + Invoke-PaApiConfig + + Rename + + rename parameters + + + SwitchParameter + + + False + + + Element + + {{Fill Element Description}} + + String + + String + + + None + + + XPath + + XPath of desired configuration. + + String + + String + + + None + Invoke-PaApiConfig