functions/New-BBDataSource.ps1


#Does not create a new one if one exists. This is how the API Works.
function New-BBDataSource
{
    [CmdletBinding(SupportsShouldProcess)]
    [Alias()]
    Param
    (
        [parameter(mandatory,ValueFromPipelineByPropertyName)][string]$externalId,
        [parameter(ValueFromPipelineByPropertyName)][string]$description = "",
        [string]$Environment = 'Production'
    )

    Begin
    {

    }
    Process
    {
        $Body = @{}
        $Body.Add('externalId', $externalId)
        if($description){$Body.Add('description', $description)}

        Invoke-BBRestMethod -API "/learn/api/public/v1/dataSources"`
            -Method Post `
            -ContentType application/json `
            -Body $Body `
            -Environment $Environment
    }
    End
    {
    }
}