Functions/Public/iaas-proxy-provider/Get-vRANetworkProfileIPRangeSummary.psm1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
function Get-vRANetworkProfileIPRangeSummary {
<#
    .SYNOPSIS
    Returns a list of range summaries within the network profile.

    .DESCRIPTION
    Returns a list of range summaries within the network profile.

    .PARAMETER NetworkProfileId
    The id of the network profile

    .PARAMETER Limit
    The number of entries returned per page from the API. This has a default value of 100.

    .PARAMETER Page
    The page of response to return. By default this is 1.

    .INPUTS
    System.String
    System.Int

    .OUTPUTS
    System.Management.Automation.PSObject

    .EXAMPLE
    Get-vRAExternalNetworkProfile -Name EXT-01 | Get-vRANetworkProfileIPRangeSummary

    .EXAMPLE
     Get-vRAExternalNetworkProfile -Name EXT-01 | Get-vRANetworkProfileIPRangeSummary -Limit 10 -Page 1

#>

[CmdletBinding()][OutputType('System.Management.Automation.PSObject')]

    Param (

        [Alias("Id")]
        [Parameter(Mandatory=$true, ValueFromPipelineByPropertyName=$true)]
        [ValidateNotNullOrEmpty()]
        [String]$NetworkProfileId,

        [Parameter(Mandatory=$false)]
        [ValidateNotNullOrEmpty()]
        [Int]$Limit = 100,
    
        [Parameter(Mandatory=$false)]
        [ValidateNotNullOrEmpty()]
        [Int]$Page = 1
       
    )    

    xRequires -Version 7.1

    try {

        $URI = "/iaas-proxy-provider/api/network/profiles/range-summaries/$($NetworkProfileId)?limit=$($limit)&page=$($page)"

        $Response = Invoke-vRARestMethod -Method GET -URI $URI -Verbose:$verbosePreference

        foreach ($NetworkProfileRange in $Response.content) {

            [PSCustomObject] @{

                Id = $NetworkProfileRange.id
                Name = $NetworkProfileRange.name
                Description = $NetworkProfileRange.description
                BeginIPv4Address = $NetworkProfileRange.beginIPv4Address
                EndIPv4Address = $NetworkProfileRange.endIPv4Address
                State = $NetworkProfileRange.state
                CreatedDate = $NetworkProfileRange.createdDate
                LastModifiedDate = $NetworkProfileRange.lastModifiedDate
                TotalAddresses = $NetworkProfileRange.totalAddresses
                AllocatedAddresses = $NetworkProfileRange.allocatedAddresses
                UnallocatedAddresses = $NetworkProfileRange.unallocatedAddresses
                DestroyedAddresses = $NetworkProfileRange.destroyedAddresses
                ExpiredAddresses = $NetworkProfileRange.expiredAddresses

            }

        }

        Write-Verbose -Message "Total: $($Response.metadata.totalElements) | Page: $($Response.metadata.number) of $($Response.metadata.totalPages) | Size: $($Response.metadata.size)"
    
    }
    catch [Exception]{
        
        throw

    }   
     
}