Public/cmdb/firewall/policy.ps1

#
# Copyright 2019, Alexis La Goutte <alexis dot lagoutte at gmail dot com>
# Copyright 2019, Benjamin Perrier <ben dot perrier at outlook dot com>
#
# SPDX-License-Identifier: Apache-2.0
#

function Get-FGTFirewallPolicy {

    <#
        .SYNOPSIS
        Get list of all policies/rules
 
        .DESCRIPTION
        Get list of all policies (name, interface source/destination, address (network) source/destination, service, action...)
 
        .EXAMPLE
        Get-FGTFirewallPolicy
 
        Get list of all policies
 
        .EXAMPLE
        Get-FGTFirewallPolicy -skip
 
        Get list of all policies (but only relevant attributes)
 
        .EXAMPLE
        Get-FGTFirewallPolicy -vdom vdomX
 
        Get list of all policies on vdomX
    #>


    Param(
        [Parameter(Mandatory = $false)]
        [switch]$skip,
        [Parameter(Mandatory = $false)]
        [String[]]$vdom,
        [Parameter(Mandatory = $false)]
        [psobject]$connection=$DefaultFGTConnection
    )

    Begin {
    }

    Process {

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

        $reponse = Invoke-FGTRestMethod -uri 'api/v2/cmdb/firewall/policy' -method 'GET' -connection $connection @invokeParams
        $reponse.results
    }

    End {
    }
}