Public/New-AddressGroup.ps1

<#
    .DESCRIPTION
    Wrapper for Nutanix API version 0.3.
 
    .NOTES
    Author: Timothy Rasiah
 
    .EXAMPLE
    New-NutanixV3AddressGroup -Name "AddressGroup1" -IpAddressBlockList @{"ip"="192.168.0.0";"prefix_length"=24},@{"ip"="192.168.1.0";"prefix_length"=24}
#>


function New-AddressGroup {
    [CmdletBinding()]
    param (
        [String]$AddressGroupString,
        [Parameter(Mandatory=$true)]
        [String]$Name,
        [Parameter(Mandatory=$true)]
        [Hashtable[]]$IpAddressBlockList,
        [String]$Description
    )

    $data = @{
        "name" = $Name
        "ip_address_block_list" = $IpAddressBlockList
    }

    if ($AddressGroupString) {
        $data["address_group_string"] = $AddressGroupString
    }

    if ($Description) {
        $data["description"] = $Description
    }
    
    $response = Send-Request -method "POST" -endpoint "/address_groups" -data $data
    return $response
}