appsec/List-AppSecMatchTargets.ps1
function List-AppSecMatchTargets { Param( [Parameter(ParameterSetName="name", Mandatory=$true)] [string] $ConfigName, [Parameter(ParameterSetName="id", Mandatory=$true)] [string] $ConfigID, [Parameter(Mandatory=$true)] [string] $VersionNumber, [Parameter(Mandatory=$false)] [string] $PolicyID, [Parameter(Mandatory=$false)] [switch] $IncludeChildObjectName, [Parameter(Mandatory=$false)] [string] $EdgeRCFile = '~\.edgerc', [Parameter(Mandatory=$false)] [string] $Section = 'default', [Parameter(Mandatory=$false)] [string] $AccountSwitchKey ) # nullify false switches $IncludeChildObjectNameString = $IncludeChildObjectName.IsPresent.ToString().ToLower() if(!$IncludeChildObjectName){ $IncludeChildObjectNameString = '' } if($ConfigName){ $Config = List-AppSecConfigurations -EdgeRCFile $EdgeRCFile -Section $Section -AccountSwitchKey $AccountSwitchKey | where {$_.name -eq $ConfigName} if($Config){ $ConfigID = $Config.id } else{ throw("Security config '$ConfigName' not found") } } if($VersionNumber.ToLower() -eq 'latest'){ $VersionNumber = (List-AppSecConfigurationVersions -ConfigID $ConfigID -PageSize 1 -EdgeRCFile $EdgeRCFile -Section $Section -AccountSwitchKey $AccountSwitchKey).version } $Path = "/appsec/v1/configs/$ConfigID/versions/$VersionNumber/match-targets?policyId=$PolicyID&includeChildObjectName=$IncludeChildObjectNameString&accountSwitchKey=$AccountSwitchKey" try { $Result = Invoke-AkamaiRestMethod -Method GET -Path $Path -EdgeRCFile $EdgeRCFile -Section $Section return $Result.matchTargets } catch { throw $_.Exception } } |