Functions/New-IADataDefinition.ps1

Function New-IADataDefinition {
    <#
        .SYNOPSIS
            This is used to create a new DataDefinition.
        .DESCRIPTION
            This command will take an inputted IADataDefinitionObject and fit it in a webrequest after which it will be sent to Insight Analytics to be created.
            This is mostly an internal command, it is used when creating a new Widget Object. Usage can be closer seen in New-IAWidgetObject.
    #>

    Param(
        [Parameter(Mandatory = $true)]
        [PSObject] $IADataDefinitionObject,
        [Switch] $Passthru
    )

    $Uri = "DataDefinitions"
    $Body = $IADataDefinitionObject | ConvertTo-Json

    Write-Verbose "Body: $Body"

    $response = Invoke-IAQuery -QueryUrl $Uri -Method Post -Body $Body

    if($Passthru){

        if ($null -eq $response) {
            return $null
        }

        return $response
    }
}