Skip to content

Commit

Permalink
Removing unused params, spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
joel74 committed Aug 27, 2023
1 parent fb92be8 commit 61684c3
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 88 deletions.
123 changes: 45 additions & 78 deletions F5-LTM/Private/ArgumentCompletion.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
$Script:F5LTMPublicCommands = Get-ChildItem -Path ($PSScriptRoot -replace 'Private','Public') -Filter '*.ps1' -Recurse | Select-Object -ExpandProperty BaseName
function Get-F5Command {
<#
.SYNOPSIS
(Get-Command -Module F5-LTM) adversely affects module import performance.
.SYNOPSIS
(Get-Command -Module F5-LTM) adversely affects module import performance.
This is a much faster alternative without resorting to static command names
for Register-ArgumentCompleter -Command parameters.
#>
Expand All @@ -22,168 +22,135 @@ function Get-CompleteSession {
Invoke-NullCoalescing {$boundSession} {$Script:F5Session}
}
function CompleteMonitorName {
param($commandName,
$parameterName,
$wordToComplete,
$commandAst,
param($wordToComplete,
$fakeBoundParameters)
$Session = Get-CompleteSession $fakeBoundParameters.F5Session
$Session = Get-CompleteSession $fakeBoundParameters.F5Session
if ($Session) {
Get-HealthMonitor -F5Session $Session -Partition $fakeBoundParameters.Partition -Type $fakeBoundParameters.Type | Where-Object { $_.name -like "$wordToComplete*" } | ForEach-Object {
if ($fakeBoundParameters.Partition) {
$_.name
} else {
$_.fullPath
$_.fullPath
}
}
}
}
}
function CompleteMonitorType {
param($commandName,
$parameterName,
$wordToComplete,
$commandAst,
param($wordToComplete,
$fakeBoundParameters)
$Session = Get-CompleteSession $fakeBoundParameters.F5Session
$Session = Get-CompleteSession $fakeBoundParameters.F5Session
if ($Session) {
Get-HealthMonitorType -F5Session $Session | Where-Object { $_ -like "$wordToComplete*" }
}
}
function CompleteNodeAddress {
param($commandName,
$parameterName,
$wordToComplete,
$commandAst,
param($wordToComplete,
$fakeBoundParameters)
$Session = Get-CompleteSession $fakeBoundParameters.F5Session
$Session = Get-CompleteSession $fakeBoundParameters.F5Session
if ($Session) {
Get-Node -F5Session $Session -Partition $fakeBoundParameters.Partition |
Where-Object { $_.address -like "$wordToComplete*" } |
Get-Node -F5Session $Session -Partition $fakeBoundParameters.Partition |
Where-Object { $_.address -like "$wordToComplete*" } |
Select-Object -ExpandProperty address
}
}
function CompleteNodeName {
param($commandName,
$parameterName,
$wordToComplete,
$commandAst,
param($wordToComplete,
$fakeBoundParameters)
$Session = Get-CompleteSession $fakeBoundParameters.F5Session
$Session = Get-CompleteSession $fakeBoundParameters.F5Session
if ($Session) {
Get-Node -F5Session $Session -Partition $fakeBoundParameters.Partition | Where-Object { $_.name -like "$wordToComplete*" } | ForEach-Object {
if ($fakeBoundParameters.Partition) {
$_.name
} else {
$_.fullPath
$_.fullPath
}
}
}
}
}
function CompleteBIGIPPartition {
param($commandName,
$parameterName,
$wordToComplete,
$commandAst,
param($wordToComplete,
$fakeBoundParameters)
$Session = Get-CompleteSession $fakeBoundParameters.F5Session
$Session = Get-CompleteSession $fakeBoundParameters.F5Session
if ($Session) {
Get-BIGIPPartition -F5Session $Session | Where-Object { $_ -like "$wordToComplete*" }
}
}
function CompletePoolMemberAddress {
param($commandName,
$parameterName,
$wordToComplete,
$commandAst,
param($wordToComplete,
$fakeBoundParameters)
if ($fakeBoundParameters.PoolName) {
$Session = Get-CompleteSession $fakeBoundParameters.F5Session
$Session = Get-CompleteSession $fakeBoundParameters.F5Session
if ($Session) {
Get-PoolMember -F5Session $Session -PoolName $fakeBoundParameters.PoolName -Partition $fakeBoundParameters.Partition -Name (Invoke-NullCoalescing {$fakeBoundParameters.Name} {'*'}) |
Where-Object { $_.address -like "$wordToComplete*" } |
Get-PoolMember -F5Session $Session -PoolName $fakeBoundParameters.PoolName -Partition $fakeBoundParameters.Partition -Name (Invoke-NullCoalescing {$fakeBoundParameters.Name} {'*'}) |
Where-Object { $_.address -like "$wordToComplete*" } |
Select-Object -ExpandProperty address
}
}
}
function CompletePoolMemberName {
param($commandName,
$parameterName,
$wordToComplete,
$commandAst,
param($wordToComplete,
$fakeBoundParameters)
if ($fakeBoundParameters.PoolName) {
$Session = Get-CompleteSession $fakeBoundParameters.F5Session
$Session = Get-CompleteSession $fakeBoundParameters.F5Session
if ($Session) {
Get-PoolMember -F5Session $Session -PoolName $fakeBoundParameters.PoolName -Partition $fakeBoundParameters.Partition -Address (Invoke-NullCoalescing {$fakeBoundParameters.Address} {'*'}) |
Where-Object { $_.name -like "$wordToComplete*" } |
Get-PoolMember -F5Session $Session -PoolName $fakeBoundParameters.PoolName -Partition $fakeBoundParameters.Partition -Address (Invoke-NullCoalescing {$fakeBoundParameters.Address} {'*'}) |
Where-Object { $_.name -like "$wordToComplete*" } |
Select-Object -ExpandProperty name
}
}
}
function CompletePoolMonitorName {
param($commandName,
$parameterName,
$wordToComplete,
$commandAst,
param($wordToComplete,
$fakeBoundParameters)
if ($fakeBoundParameters.PoolName) {
$Session = Get-CompleteSession $fakeBoundParameters.F5Session
$Session = Get-CompleteSession $fakeBoundParameters.F5Session
if ($Session) {
Get-PoolMonitor -F5Session $Session -PoolName $fakeBoundParameters.PoolName -Partition $fakeBoundParameters.Partition |
Where-Object { $_.name -match "\b$wordToComplete*" } |
Get-PoolMonitor -F5Session $Session -PoolName $fakeBoundParameters.PoolName -Partition $fakeBoundParameters.Partition |
Where-Object { $_.name -match "\b$wordToComplete*" } |
Select-Object -ExpandProperty name
}
}
}
function CompletePoolName {
param($commandName,
$parameterName,
$wordToComplete,
$commandAst,
param($wordToComplete,
$fakeBoundParameters)
$Session = Get-CompleteSession $fakeBoundParameters.F5Session
$Session = Get-CompleteSession $fakeBoundParameters.F5Session
if ($Session) {
Get-Pool -F5Session $Session -Partition $fakeBoundParameters.Partition | Where-Object { $_.name -like "$wordToComplete*" -or $_.fullPath -like "$wordToComplete*" } | ForEach-Object {
if ($fakeBoundParameters.Partition) {
$_.name
} else {
$_.fullPath
$_.fullPath
}
}
}
}
}
function CompleteRuleName {
param($commandName,
$parameterName,
$wordToComplete,
$commandAst,
param($wordToComplete,
$fakeBoundParameters)
$Session = Get-CompleteSession $fakeBoundParameters.F5Session
$Session = Get-CompleteSession $fakeBoundParameters.F5Session
if ($Session) {
Get-iRule -F5Session $Session -Partition $fakeBoundParameters.Partition | Where-Object { $_.name -like "$wordToComplete*" -or $_.fullPath -like "$wordToComplete" } | ForEach-Object {
if ($fakeBoundParameters.Partition) {
$_.name
} else {
$_.fullPath
$_.fullPath
}
}
}
}
}
function CompleteVirtualServerName {
param($commandName,
$parameterName,
$wordToComplete,
$commandAst,
param($wordToComplete,
$fakeBoundParameters)
$Session = Get-CompleteSession $fakeBoundParameters.F5Session
$Session = Get-CompleteSession $fakeBoundParameters.F5Session
if ($Session) {
Get-VirtualServer -F5Session $Session -Partition $fakeBoundParameters.Partition | Where-Object { $_.name -like "$wordToComplete*" -or $_.fullPath -like "$wordToComplete" } | ForEach-Object {
if ($fakeBoundParameters.Partition) {
$_.name
} else {
$_.fullPath
$_.fullPath
}
}
}
}
}
if (Get-Command Register-ArgumentCompleter -ErrorAction Ignore)
Expand Down Expand Up @@ -232,17 +199,17 @@ if (Get-Command Register-ArgumentCompleter -ErrorAction Ignore)
-CommandName @(Get-F5Command '*') `
-ParameterName Partition `
-ScriptBlock $function:CompletePartition

Register-ArgumentCompleter `
-CommandName 'Get-BIGIPPartition' `
-ParameterName Name `
-ScriptBlock $function:CompleteBIGIPPartition

Register-ArgumentCompleter `
-CommandName @(Get-F5Command '*-Pool*') `
-ParameterName PoolName `
-ScriptBlock $function:CompletePoolName

Register-ArgumentCompleter `
-CommandName 'Get-iRule' `
-ParameterName Name `
Expand Down
4 changes: 2 additions & 2 deletions F5-LTM/Public/Deprecated/Set-PoolLoadBalancingMode.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
[Parameter(Mandatory=$true,ParameterSetName='InputObject',ValueFromPipeline=$true)]
[Alias('Pool')]
[PSObject[]]$InputObject,

[Parameter(Mandatory=$true,ParameterSetName='PoolName',ValueFromPipeline=$true)]
[string[]]$PoolName,

[Parameter(Mandatory=$false,ParameterSetName='PoolName')]
[string]$Partition,

[Alias('LoadBalancingMode')]
[Parameter(Mandatory=$true)]
[ValidateSet("dynamic-ratio-member","dynamic-ratio-node","fastest-app-response","fastest-node","least-connections-members","least-connections-node","least-sessions","observed-member","observed-node","predictive-member","predictive-node","ratio-least-connections-member","ratio-least-connections-node","ratio-member","ratio-node","ratio-session","round-robin","weighted-least-connections-member","weighted-least-connections-node")]
Expand Down
16 changes: 8 additions & 8 deletions F5-LTM/Public/New-ProfileHttp.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ Function New-ProfileHttp {
Create a new profile.
.DESCRIPTION
Read more about http profiles
Read more about http profiles
https://devcentral.f5.com/Wiki/iControlREST.APIRef_tm_ltm_profile_http.ashx
.EXAMPLE
New-Profile -F5Session $F5Session -Name $ProfileName -Partition $Partition -insertXforwardedFor "Enabled"
.EXAMPLE
New-Profile -F5Session $F5Session -Name "Service1" -Partition "ADO" -insertXforwardedFor "Enabled"
New-Profile -F5Session $F5Session -Name "Service1" -Partition "ADO" -insertXforwardedFor "Enabled"
.EXAMPLE
Result of RestAPI
Result of RestAPI
kind : tm:ltm:profile:http:httpstate
name : http_ServiceGB123
partition : ADO
Expand Down Expand Up @@ -50,14 +50,14 @@ Function New-ProfileHttp {
viaRequest : Preserve
viaResponse : Preserve
xffAlternativeNames : {}
#>
#>
[cmdletBinding()]
param (
$F5Session=$Script:F5Session,
[Alias('ProfileName')]
[Parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)]
[string[]]$Name,

[Parameter(Mandatory=$false,ValueFromPipelineByPropertyName=$true)]
[string]$Partition,
[ValidateSet('enabled','disabled')]
Expand Down Expand Up @@ -98,12 +98,12 @@ Function New-ProfileHttp {
#Test that the F5 session is in a valid format
Test-F5Session($F5Session)


}
process {
$URI = ($F5Session.BaseURL + "profile/http")
foreach ($profilename in $Name) {
$newitem = New-F5Item -Name $profilename -Partition $Partition
$newitem = New-F5Item -Name $profilename -Partition $Partition
#Check whether the specified profile already exists
If (Test-Profilehttp -F5session $F5Session -Name $newitem.Name -Partition $newitem.Partition){
Write-Error "The $($newitem.FullPath) profile already exists."
Expand Down

0 comments on commit 61684c3

Please sign in to comment.