From 24e1179451647687bc0cd3eb0644354a70e13558 Mon Sep 17 00:00:00 2001 From: Arthur Heijnen Date: Fri, 10 Apr 2020 09:20:30 +0200 Subject: [PATCH 1/9] removed line from filter section --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 9f07b874..c259d39d 100644 --- a/README.md +++ b/README.md @@ -259,7 +259,6 @@ For `Invoke-FGTRestMethod` and `Get-XXX` cmdlet like `Get-FGTFirewallAddress`, ... ``` -Actually, support only `equal` and `contains` filter type ### Address Group From db657bfbbb7cb909f8d5293162425b8bed3b5149 Mon Sep 17 00:00:00 2001 From: Arthur Heijnen Date: Fri, 10 Apr 2020 10:20:44 +0200 Subject: [PATCH 2/9] Fixed non working parameter groups and added remaining filter types notequal, notcontains, less, lessorequal, greater, greaterorequal added. Non-working parameterset fixed. Old Syntax output: SYNTAX Invoke-FGTRestMethod [-uri] [-method ] [-body ] [-skip] [-vdom ] [-filter ] [-filter_attribute ] [-filter_type ] [-filter_value ] [-connection ] [] Invoke-FGTRestMethod [-uri] [-method ] [-body ] [-skip] [-vdom ] [-filter ] [-filter_attribute ] [-filter_type ] [-filter_value ] [-connection ] [] Invoke-FGTRestMethod [-uri] [-method ] [-body ] [-skip] [-vdom ] [-filter ] [-filter_attribute ] [-filter_type ] [-filter_value ] [-connection ] [] New Syntax output: SYNTAX Invoke-FGTRestMethod [-uri] [-method ] [-body ] [-skip] [-vdom ] [-connection ] [] Invoke-FGTRestMethod [-uri] [-method ] [-body ] [-skip] [-vdom ] [-filter ] [-connection ] [] Invoke-FGTRestMethod [-uri] [-method ] [-body ] [-skip] [-vdom ] [-filter_attribute ] [-filter_type ] [-filter_value ] [-connection ] [] --- PowerFGT/Private/RestMethod.ps1 | 34 +++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/PowerFGT/Private/RestMethod.ps1 b/PowerFGT/Private/RestMethod.ps1 index d6b4e493..581c4580 100644 --- a/PowerFGT/Private/RestMethod.ps1 +++ b/PowerFGT/Private/RestMethod.ps1 @@ -67,18 +67,14 @@ function Invoke-FGTRestMethod { [switch]$skip, [Parameter(Mandatory = $false)] [String[]]$vdom, - [Parameter(Mandatory = $false)] - [Parameter (ParameterSetName = "filter")] + [Parameter(Mandatory = $false, ParameterSetName = "filter")] [String]$filter, - [Parameter(Mandatory = $false)] - [Parameter (ParameterSetName = "filter_build")] + [Parameter(Mandatory = $false, ParameterSetName = "filter_build")] [string]$filter_attribute, - [Parameter(Mandatory = $false)] - [ValidateSet('equal', 'contains')] - [Parameter (ParameterSetName = "filter_build")] + [Parameter(Mandatory = $false, ParameterSetName = "filter_build")] + [ValidateSet('equal', 'notequal', 'contains', 'notcontains', 'less', 'lessorequal', 'greater', 'greaterorequal')] [string]$filter_type, - [Parameter (Mandatory = $false)] - [Parameter (ParameterSetName = "filter_build")] + [Parameter (Mandatory = $false, ParameterSetName = "filter_build")] [psobject]$filter_value, [Parameter(Mandatory = $false)] [psobject]$connection @@ -132,9 +128,27 @@ function Invoke-FGTRestMethod { "equal" { $filter_value = "==" + $filter_value } + "notequal" { + $filter_value = "!=" + $filter_value + } "contains" { $filter_value = "=@" + $filter_value } + "notcontains" { + $filter_value = "!@" + $filter_value + } + "less" { + $filter_value = "<" + $filter_value + } + "lessorequal" { + $filter_value = "<=" + $filter_value + } + "greater" { + $filter_value = ">" + $filter_value + } + "greaterorequal" { + $filter_value = ">=" + $filter_value + } #by default set to equal.. default { $filter_value = "==" + $filter_value @@ -169,4 +183,4 @@ function Invoke-FGTRestMethod { } -} \ No newline at end of file +} From 2f11b59a534ca9d594db95fcd1df3437e6a8f35a Mon Sep 17 00:00:00 2001 From: Arthur Heijnen Date: Fri, 10 Apr 2020 13:45:34 +0200 Subject: [PATCH 3/9] Corrected parametersets and added remaining filter types --- PowerFGT/Public/cmdb/firewall/address.ps1 | 31 ++++++++++++++++------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/PowerFGT/Public/cmdb/firewall/address.ps1 b/PowerFGT/Public/cmdb/firewall/address.ps1 index 63c9dafa..da3faab8 100644 --- a/PowerFGT/Public/cmdb/firewall/address.ps1 +++ b/PowerFGT/Public/cmdb/firewall/address.ps1 @@ -186,6 +186,16 @@ function Get-FGTFirewallAddress { Get address contains with *FGT* + .EXAMPLE + Get-FGTFirewallAddress -filter "name=@FGT,fqdn=@FGT" + + Get address contains with *FGT* OR fqdn contains *FGT* + + .EXAMPLE + Get-FGTFirewallAddress -filter "name=@FGT&fqdn!@FGT" + + Get address contains with *FGT* AND NOT fqdn contains *FGT* + .EXAMPLE Get-FGTFirewallAddress -uuid 9e73a10e-1772-51ea-a8d7-297686fd7702 @@ -209,17 +219,16 @@ function Get-FGTFirewallAddress { [string]$name, [Parameter (Mandatory = $false, ParameterSetName = "uuid")] [string]$uuid, - [Parameter (Mandatory = $false)] - [Parameter (ParameterSetName = "filter")] + [Parameter(Mandatory = $false, ParameterSetName = "filter")] + [String]$filter, + [Parameter (Mandatory = $false, ParameterSetName = "filter_build")] [string]$filter_attribute, - [Parameter (Mandatory = $false)] - [Parameter (ParameterSetName = "name")] + [Parameter (Mandatory = $false, ParameterSetName = "name")] [Parameter (ParameterSetName = "uuid")] - [Parameter (ParameterSetName = "filter")] - [ValidateSet('equal', 'contains')] + [Parameter (ParameterSetName = "filter_build")] + [ValidateSet('equal', 'notequal', 'contains', 'notcontains', 'less', 'lessorequal', 'greater', 'greaterorequal')] [string]$filter_type = "equal", - [Parameter (Mandatory = $false)] - [Parameter (ParameterSetName = "filter")] + [Parameter (Mandatory = $false, ParameterSetName = "filter_build")] [psobject]$filter_value, [Parameter(Mandatory = $false)] [switch]$skip, @@ -261,6 +270,10 @@ function Get-FGTFirewallAddress { $invokeParams.add( 'filter_type', $filter_type ) } + if ( $filter) { + $invokeParams.add( 'filter', $filter ) + } + $response = Invoke-FGTRestMethod -uri 'api/v2/cmdb/firewall/address' -method 'GET' -connection $connection @invokeParams $response.results @@ -463,4 +476,4 @@ function Remove-FGTFirewallAddress { End { } -} \ No newline at end of file +} From e43973d41a8948b868c834111cf519ade0587df7 Mon Sep 17 00:00:00 2001 From: Arthur Heijnen Date: Tue, 14 Apr 2020 09:37:27 +0200 Subject: [PATCH 4/9] Removed the direct filter option --- PowerFGT/Public/cmdb/firewall/address.ps1 | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/PowerFGT/Public/cmdb/firewall/address.ps1 b/PowerFGT/Public/cmdb/firewall/address.ps1 index da3faab8..a3a56839 100644 --- a/PowerFGT/Public/cmdb/firewall/address.ps1 +++ b/PowerFGT/Public/cmdb/firewall/address.ps1 @@ -186,16 +186,6 @@ function Get-FGTFirewallAddress { Get address contains with *FGT* - .EXAMPLE - Get-FGTFirewallAddress -filter "name=@FGT,fqdn=@FGT" - - Get address contains with *FGT* OR fqdn contains *FGT* - - .EXAMPLE - Get-FGTFirewallAddress -filter "name=@FGT&fqdn!@FGT" - - Get address contains with *FGT* AND NOT fqdn contains *FGT* - .EXAMPLE Get-FGTFirewallAddress -uuid 9e73a10e-1772-51ea-a8d7-297686fd7702 @@ -219,8 +209,6 @@ function Get-FGTFirewallAddress { [string]$name, [Parameter (Mandatory = $false, ParameterSetName = "uuid")] [string]$uuid, - [Parameter(Mandatory = $false, ParameterSetName = "filter")] - [String]$filter, [Parameter (Mandatory = $false, ParameterSetName = "filter_build")] [string]$filter_attribute, [Parameter (Mandatory = $false, ParameterSetName = "name")] @@ -270,10 +258,6 @@ function Get-FGTFirewallAddress { $invokeParams.add( 'filter_type', $filter_type ) } - if ( $filter) { - $invokeParams.add( 'filter', $filter ) - } - $response = Invoke-FGTRestMethod -uri 'api/v2/cmdb/firewall/address' -method 'GET' -connection $connection @invokeParams $response.results From b88782fdc47d5418c4f3675a0c29533e01ff6d15 Mon Sep 17 00:00:00 2001 From: Arthur Heijnen Date: Tue, 14 Apr 2020 09:42:29 +0200 Subject: [PATCH 5/9] Fixed Parametersets and added extra types --- PowerFGT/Public/cmdb/firewall/addressgroup.ps1 | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/PowerFGT/Public/cmdb/firewall/addressgroup.ps1 b/PowerFGT/Public/cmdb/firewall/addressgroup.ps1 index 6e8a79f5..a097ad75 100644 --- a/PowerFGT/Public/cmdb/firewall/addressgroup.ps1 +++ b/PowerFGT/Public/cmdb/firewall/addressgroup.ps1 @@ -264,17 +264,14 @@ function Get-FGTFirewallAddressGroup { [string]$name, [Parameter (Mandatory = $false, ParameterSetName = "uuid")] [string]$uuid, - [Parameter (Mandatory = $false)] - [Parameter (ParameterSetName = "filter")] + [Parameter (Mandatory = $false, ParameterSetName = "filter_build")] [string]$filter_attribute, - [Parameter (Mandatory = $false)] - [Parameter (ParameterSetName = "name")] + [Parameter (Mandatory = $false, ParameterSetName = "name")] [Parameter (ParameterSetName = "uuid")] - [Parameter (ParameterSetName = "filter")] - [ValidateSet('equal', 'contains')] + [Parameter (ParameterSetName = "filter_build")] + [ValidateSet('equal', 'notequal', 'contains', 'notcontains', 'less', 'lessorequal', 'greater', 'greaterorequal')] [string]$filter_type = "equal", - [Parameter (Mandatory = $false)] - [Parameter (ParameterSetName = "filter")] + [Parameter (Mandatory = $false, ParameterSetName = "filter_build")] [psobject]$filter_value, [Parameter(Mandatory = $false)] [switch]$skip, From 727d2a2c62f72382a11614c429f8d6cd21a9ed6c Mon Sep 17 00:00:00 2001 From: Arthur Heijnen Date: Tue, 14 Apr 2020 09:46:11 +0200 Subject: [PATCH 6/9] Fixed parametersets and added filter types --- PowerFGT/Public/cmdb/firewall/ippool.ps1 | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/PowerFGT/Public/cmdb/firewall/ippool.ps1 b/PowerFGT/Public/cmdb/firewall/ippool.ps1 index 02b82d0e..75b0e087 100644 --- a/PowerFGT/Public/cmdb/firewall/ippool.ps1 +++ b/PowerFGT/Public/cmdb/firewall/ippool.ps1 @@ -43,16 +43,14 @@ function Get-FGTFirewallIPPool { Param( [Parameter (Mandatory = $false, Position = 1, ParameterSetName = "name")] [string]$name, - [Parameter (Mandatory = $false)] - [Parameter (ParameterSetName = "filter")] + [Parameter (Mandatory = $false, ParameterSetName = "filter_build")] [string]$filter_attribute, - [Parameter (Mandatory = $false)] - [Parameter (ParameterSetName = "name")] - [Parameter (ParameterSetName = "filter")] - [ValidateSet('equal', 'contains')] + [Parameter (Mandatory = $false, ParameterSetName = "name")] + [Parameter (ParameterSetName = "filter_build")] + [ValidateSet('equal', 'notequal', 'contains', 'notcontains', 'less', 'lessorequal', 'greater', 'greaterorequal')] [string]$filter_type = "equal", [Parameter (Mandatory = $false)] - [Parameter (ParameterSetName = "filter")] + [Parameter (ParameterSetName = "filter_build")] [psobject]$filter_value, [Parameter(Mandatory = $false)] [switch]$skip, @@ -97,4 +95,4 @@ function Get-FGTFirewallIPPool { End { } -} \ No newline at end of file +} From 95836a713d9dd310f6050ff50a9c09e789ea8d24 Mon Sep 17 00:00:00 2001 From: Arthur Heijnen Date: Tue, 14 Apr 2020 09:48:34 +0200 Subject: [PATCH 7/9] Update ippool.ps1 --- PowerFGT/Public/cmdb/firewall/ippool.ps1 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/PowerFGT/Public/cmdb/firewall/ippool.ps1 b/PowerFGT/Public/cmdb/firewall/ippool.ps1 index 75b0e087..feddade2 100644 --- a/PowerFGT/Public/cmdb/firewall/ippool.ps1 +++ b/PowerFGT/Public/cmdb/firewall/ippool.ps1 @@ -49,8 +49,7 @@ function Get-FGTFirewallIPPool { [Parameter (ParameterSetName = "filter_build")] [ValidateSet('equal', 'notequal', 'contains', 'notcontains', 'less', 'lessorequal', 'greater', 'greaterorequal')] [string]$filter_type = "equal", - [Parameter (Mandatory = $false)] - [Parameter (ParameterSetName = "filter_build")] + [Parameter (Mandatory = $false, ParameterSetName = "filter_build")] [psobject]$filter_value, [Parameter(Mandatory = $false)] [switch]$skip, From 9c4afff6e5f0f801f0a981550206b0ad8d2968c7 Mon Sep 17 00:00:00 2001 From: Arthur Heijnen Date: Tue, 14 Apr 2020 09:50:56 +0200 Subject: [PATCH 8/9] Fixed parametersets and added filter types --- PowerFGT/Public/cmdb/firewall/policy.ps1 | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/PowerFGT/Public/cmdb/firewall/policy.ps1 b/PowerFGT/Public/cmdb/firewall/policy.ps1 index 0e1a486a..a877d5c9 100644 --- a/PowerFGT/Public/cmdb/firewall/policy.ps1 +++ b/PowerFGT/Public/cmdb/firewall/policy.ps1 @@ -352,18 +352,15 @@ function Get-FGTFirewallPolicy { [string]$uuid, [Parameter (Mandatory = $false, ParameterSetName = "policyid")] [string]$policyid, - [Parameter (Mandatory = $false)] - [Parameter (ParameterSetName = "filter")] + [Parameter (Mandatory = $false, ParameterSetName = "filter_build")] [string]$filter_attribute, - [Parameter (Mandatory = $false)] - [Parameter (ParameterSetName = "name")] + [Parameter (Mandatory = $false, ParameterSetName = "name")] [Parameter (ParameterSetName = "uuid")] [Parameter (ParameterSetName = "policyid")] - [Parameter (ParameterSetName = "filter")] - [ValidateSet('equal', 'contains')] + [Parameter (ParameterSetName = "filter_build")] + [ValidateSet('equal', 'notequal', 'contains', 'notcontains', 'less', 'lessorequal', 'greater', 'greaterorequal')] [string]$filter_type = "equal", - [Parameter (Mandatory = $false)] - [Parameter (ParameterSetName = "filter")] + [Parameter (Mandatory = $false, ParameterSetName = "filter_build")] [psobject]$filter_value, [Parameter(Mandatory = $false)] [switch]$skip, @@ -580,4 +577,4 @@ function Remove-FGTFirewallPolicyMember { End { } -} \ No newline at end of file +} From 5562f7d46c042c1c31b5c19c9b5f91b3b9c683ee Mon Sep 17 00:00:00 2001 From: Arthur Heijnen Date: Tue, 14 Apr 2020 09:53:48 +0200 Subject: [PATCH 9/9] Fixed parametersets and added filter types --- PowerFGT/Public/cmdb/firewall/vip.ps1 | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/PowerFGT/Public/cmdb/firewall/vip.ps1 b/PowerFGT/Public/cmdb/firewall/vip.ps1 index d49b1470..8926368d 100644 --- a/PowerFGT/Public/cmdb/firewall/vip.ps1 +++ b/PowerFGT/Public/cmdb/firewall/vip.ps1 @@ -177,17 +177,14 @@ function Get-FGTFirewallVip { [string]$name, [Parameter (Mandatory = $false, ParameterSetName = "uuid")] [string]$uuid, - [Parameter (Mandatory = $false)] - [Parameter (ParameterSetName = "filter")] + [Parameter (Mandatory = $false, ParameterSetName = "filter_build")] [string]$filter_attribute, - [Parameter (Mandatory = $false)] - [Parameter (ParameterSetName = "name")] + [Parameter (Mandatory = $false, ParameterSetName = "name")] [Parameter (ParameterSetName = "uuid")] - [Parameter (ParameterSetName = "filter")] - [ValidateSet('equal', 'contains')] + [Parameter (ParameterSetName = "filter_build")] + [ValidateSet('equal', 'notequal', 'contains', 'notcontains', 'less', 'lessorequal', 'greater', 'greaterorequal')] [string]$filter_type = "equal", - [Parameter (Mandatory = $false)] - [Parameter (ParameterSetName = "filter")] + [Parameter (Mandatory = $false, ParameterSetName = "filter_build")] [psobject]$filter_value, [Parameter(Mandatory = $false)] [switch]$skip, @@ -305,4 +302,4 @@ function Remove-FGTFirewallVip { End { } -} \ No newline at end of file +}