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
31 changes: 22 additions & 9 deletions PowerFGT/Public/cmdb/firewall/address.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't really like the idea to have directly filter parameter.. but prefer we can build filter with filter_type, attribute...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oke i will remove it. Advanced searches can be done with invoke-FGTRestMothode if needed. is the parameter name-change (filter -> filter_build) oke? This will make it consistant with Invoke-FGTRestMethode. If not i will change it back.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok for change ParameterName

[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 @@ -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
Expand Down Expand Up @@ -463,4 +476,4 @@ function Remove-FGTFirewallAddress {

End {
}
}
}