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

Enhance Filters (Invoke-FGTRestMethod) #95

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
34 changes: 24 additions & 10 deletions PowerFGT/Private/RestMethod.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -169,4 +183,4 @@ function Invoke-FGTRestMethod {

}

}
}
15 changes: 6 additions & 9 deletions PowerFGT/Public/cmdb/firewall/address.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -209,17 +209,14 @@ function Get-FGTFirewallAddress {
[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,
Expand Down Expand Up @@ -463,4 +460,4 @@ function Remove-FGTFirewallAddress {

End {
}
}
}
13 changes: 5 additions & 8 deletions PowerFGT/Public/cmdb/firewall/addressgroup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
15 changes: 6 additions & 9 deletions PowerFGT/Public/cmdb/firewall/ippool.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,13 @@ 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 (Mandatory = $false, ParameterSetName = "filter_build")]
[psobject]$filter_value,
[Parameter(Mandatory = $false)]
[switch]$skip,
Expand Down Expand Up @@ -97,4 +94,4 @@ function Get-FGTFirewallIPPool {

End {
}
}
}
15 changes: 6 additions & 9 deletions PowerFGT/Public/cmdb/firewall/policy.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -580,4 +577,4 @@ function Remove-FGTFirewallPolicyMember {

End {
}
}
}
15 changes: 6 additions & 9 deletions PowerFGT/Public/cmdb/firewall/vip.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -305,4 +302,4 @@ function Remove-FGTFirewallVip {

End {
}
}
}
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,6 @@ For `Invoke-FGTRestMethod` and `Get-XXX` cmdlet like `Get-FGTFirewallAddress`,
...

```
Actually, support only `equal` and `contains` filter type

### Address Group

Expand Down