Skip to content

Commit

Permalink
Add more functions
Browse files Browse the repository at this point in the history
Added:
Get-vRAExternalNetworkIPRange
Get-vRALoadBalancer
Get-vRANetwork
Get-vRANetworkDomain
Get-vRANetworkIPRange
Get-vRARegion
Get-vRASecurityGroup
Get-vRAStorageProfile
Get-vRATag

Fixed issue with:
Get-vRAImageProfile - was referencing the wrong URI

Side note: It appears that the organizationId parameter is going to be deprecated, though is still widely in use by the module. I've moved to using orgId, but maintained the OrganizationId PSCustomObject property. I'll go back and fix the response content reference for the other functions later.
  • Loading branch information
mpuckett159 committed Sep 5, 2020
1 parent 1413dad commit dd93639
Show file tree
Hide file tree
Showing 11 changed files with 1,059 additions and 2 deletions.
131 changes: 131 additions & 0 deletions src/Functions/Public/iaas/Get-vRAExternalNetworkIPRange.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
function Get-vRAExternalNetworkIPRange {
<#
.SYNOPSIS
Get a vRA External Network IP Range
.DESCRIPTION
Get a vRA External Network IP Range
.PARAMETER Id
The ID of the vRA External Network IP Range
.PARAMETER Name
The Name of the vRA External Network IP Range
.INPUTS
System.String
.OUTPUTS
System.Management.Automation.PSObject
.EXAMPLE
Get-vRAExternalNetworkIPRange
.EXAMPLE
Get-vRAExternalNetworkIPRange -Id '3492a6e8-r5d4-1293-b6c4-39037ba693f9'
.EXAMPLE
Get-vRAExternalNetworkIPRange -Name 'TestExternalNetworkIPRange'
#>
[CmdletBinding(DefaultParameterSetName="Standard")][OutputType('System.Management.Automation.PSObject')]

Param (

[Parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,ParameterSetName="ById")]
[ValidateNotNullOrEmpty()]
[String[]]$Id,

[Parameter(Mandatory=$true,ParameterSetName="ByName")]
[ValidateNotNullOrEmpty()]
[String[]]$Name
)

begin {
$APIUrl = '/iaas/api/external-network-ip-ranges'

function CalculateOutput([PSCustomObject]$ExternalNetworkIPRange) {

[PSCustomObject] @{
Owner = $ExternalNetworkIPRange.owner
Description = $ExternalNetworkIPRange.description
Tags = $ExternalNetworkIPRange.tags
ExternalId = $ExternalNetworkIPRange.externalId
SubnetPrefixLength = $ExternalNetworkIPRange.subnetPrefixLength
Name = $ExternalNetworkIPRange.name
Id = $ExternalNetworkIPRange.id
CreatedAt = $ExternalNetworkIPRange.createdAt
UpdatedAt = $ExternalNetworkIPRange.updatedAt
OrganizationId = $ExternalNetworkIPRange.orgId
StartIPAddress = $ExternalNetworkIPRange.startIPAddress
EndIPAddress = $ExternalNetworkIPRange.endIPAddress
IPVersion = $ExternalNetworkIPRange.ipVersion
AddressSpaceId = $ExternalNetworkIPRange.addressSpaceId
DNSServerAddresses = $ExternalNetworkIPRange.dnsServerAddresses
DNSSearchDomains = $ExternalNetworkIPRange.dnsSearchDomains
Domain = $ExternalNetworkIPRange.domain
GatewayAddress = $ExternalNetworkIPRange.gatewayAddress
Links = $ExternalNetworkIPRange._links
}
}
}

process {

try {

switch ($PsCmdlet.ParameterSetName) {

# --- Get External Network IP Range by Id
'ById' {

foreach ($ExternalNetworkIPRangeId in $Id){

$URI = "$($APIUrl)?`$filter=id eq '$($ExternalNetworkIPRangeId)'"
$Response = Invoke-vRARestMethod -Method GET -URI $URI -Verbose:$VerbosePreference

foreach ($ExternalNetworkIPRange in $Response.content) {
CalculateOutput $ExternalNetworkIPRange
}
}

break
}
# --- Get External Network IP Range by Name
'ByName' {

foreach ($ExternalNetworkIPRangeName in $Name){

$URI = "$($APIUrl)?`$filter=name eq '$($ExternalNetworkIPRangeName)'"
$Response = Invoke-vRARestMethod -Method GET -URI $URI -Verbose:$VerbosePreference

foreach ($ExternalNetworkIPRange in $Response.content) {
CalculateOutput $ExternalNetworkIPRange
}
}

break
}
# --- No parameters passed so return all External Network IP Ranges
'Standard' {

$URI = $APIUrl
$Response = Invoke-vRARestMethod -Method GET -URI $URI -Verbose:$VerbosePreference

foreach ($ExternalNetworkIPRange in $Response.content) {
CalculateOutput $ExternalNetworkIPRange
}
}
}
}
catch [Exception]{

throw
}
}

end {

}
}

2 changes: 1 addition & 1 deletion src/Functions/Public/iaas/Get-vRAImageProfile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function Get-vRAImageProfile {
Name = $ImageProfile.name
Id = $ImageProfile.id
UpdatedAt = $ImageProfile.updatedAt
OrganizationId = $ImageProfile.organizationId
OrgId = $ImageProfile.orgId
Links = $ImageProfile._links
}
}
Expand Down
124 changes: 124 additions & 0 deletions src/Functions/Public/iaas/Get-vRALoadBalancer.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
function Get-vRALoadBalancer {
<#
.SYNOPSIS
Get a vRA Load Balancer
.DESCRIPTION
Get a vRA Load Balancer
.PARAMETER Id
The ID of the vRA Load Balancer
.PARAMETER Name
The Name of the vRA Load Balancer
.INPUTS
System.String
.OUTPUTS
System.Management.Automation.PSObject
.EXAMPLE
Get-vRALoadBalancer
.EXAMPLE
Get-vRALoadBalancer -Id '3492a6e8-r5d4-1293-b6c4-39037ba693f9'
.EXAMPLE
Get-vRALoadBalancer -Name 'TestLoadBalancer'
#>
[CmdletBinding(DefaultParameterSetName="Standard")][OutputType('System.Management.Automation.PSObject')]

Param (

[Parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,ParameterSetName="ById")]
[ValidateNotNullOrEmpty()]
[String[]]$Id,

[Parameter(Mandatory=$true,ParameterSetName="ByName")]
[ValidateNotNullOrEmpty()]
[String[]]$Name
)

begin {
$APIUrl = '/iaas/api/load-balancers'

function CalculateOutput([PSCustomObject]$LoadBalancer) {

[PSCustomObject] @{
Address = $LoadBalancer.address
Routes = $LoadBalancer.routes
ExternalRegionId = $LoadBalancer.externalRegionId
CloudAccountIds = $LoadBalancer.cloudAccountIds
Tags = $LoadBalancer.tags
CustomProperties = $LoadBalancer.customProperties
ExternalId = $LoadBalancer.externalId
Name = $LoadBalancer.name
Id = $LoadBalancer.id
UpdatedAt = $LoadBalancer.updatedAt
OrgId = $LoadBalancer.orgId
Links = $LoadBalancer._links
}
}
}

process {

try {

switch ($PsCmdlet.ParameterSetName) {

# --- Get Load Balancer by Id
'ById' {

foreach ($LoadBalancerId in $Id){

$URI = "$($APIUrl)?`$filter=id eq '$($LoadBalancerId)'"
$Response = Invoke-vRARestMethod -Method GET -URI $URI -Verbose:$VerbosePreference

foreach ($LoadBalancer in $Response.content) {
CalculateOutput $LoadBalancer
}
}

break
}
# --- Get Load Balancer by Name
'ByName' {

foreach ($LoadBalancerName in $Name){

$URI = "$($APIUrl)?`$filter=name eq '$($LoadBalancerName)'"
$Response = Invoke-vRARestMethod -Method GET -URI $URI -Verbose:$VerbosePreference

foreach ($LoadBalancer in $Response.content) {
CalculateOutput $LoadBalancer
}
}

break
}
# --- No parameters passed so return all Load Balancers
'Standard' {

$URI = $APIUrl
$Response = Invoke-vRARestMethod -Method GET -URI $URI -Verbose:$VerbosePreference

foreach ($LoadBalancer in $Response.content) {
CalculateOutput $LoadBalancer
}
}
}
}
catch [Exception]{

throw
}
}

end {

}
}

124 changes: 124 additions & 0 deletions src/Functions/Public/iaas/Get-vRANetwork.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
function Get-vRANetwork {
<#
.SYNOPSIS
Get a vRA Network
.DESCRIPTION
Get a vRA Network
.PARAMETER Id
The ID of the vRA Network
.PARAMETER Name
The Name of the vRA Network
.INPUTS
System.String
.OUTPUTS
System.Management.Automation.PSObject
.EXAMPLE
Get-vRANetwork
.EXAMPLE
Get-vRANetwork -Id '3492a6e8-r5d4-1293-b6c4-39037ba693f9'
.EXAMPLE
Get-vRANetwork -Name 'TestNetwork'
#>
[CmdletBinding(DefaultParameterSetName="Standard")][OutputType('System.Management.Automation.PSObject')]

Param (

[Parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,ParameterSetName="ById")]
[ValidateNotNullOrEmpty()]
[String[]]$Id,

[Parameter(Mandatory=$true,ParameterSetName="ByName")]
[ValidateNotNullOrEmpty()]
[String[]]$Name
)

begin {
$APIUrl = '/iaas/api/networks'

function CalculateOutput([PSCustomObject]$Network) {

[PSCustomObject] @{
Cidr = $Network.cidr
ExternalZoneId = $Network.externalZoneId
ExternalRegionId = $Network.externalRegionId
CloudAccountIds = $Network.cloudAccountIds
Tags = $Network.tags
CustomProperties = $Network.customProperties
ExternalId = $Network.externalId
Name = $Network.name
Id = $Network.id
UpdatedAt = $Network.updatedAt
OrganizationId = $Network.orgId
Links = $Network._links
}
}
}

process {

try {

switch ($PsCmdlet.ParameterSetName) {

# --- Get Network by Id
'ById' {

foreach ($NetworkId in $Id){

$URI = "$($APIUrl)?`$filter=id eq '$($NetworkId)'"
$Response = Invoke-vRARestMethod -Method GET -URI $URI -Verbose:$VerbosePreference

foreach ($Network in $Response.content) {
CalculateOutput $Network
}
}

break
}
# --- Get Network by Name
'ByName' {

foreach ($NetworkName in $Name){

$URI = "$($APIUrl)?`$filter=name eq '$($NetworkName)'"
$Response = Invoke-vRARestMethod -Method GET -URI $URI -Verbose:$VerbosePreference

foreach ($Network in $Response.content) {
CalculateOutput $Network
}
}

break
}
# --- No parameters passed so return all Networks
'Standard' {

$URI = $APIUrl
$Response = Invoke-vRARestMethod -Method GET -URI $URI -Verbose:$VerbosePreference

foreach ($Network in $Response.content) {
CalculateOutput $Network
}
}
}
}
catch [Exception]{

throw
}
}

end {

}
}

Loading

0 comments on commit dd93639

Please sign in to comment.