Functions/Remove-DatabricksJobsFromConfig.ps1

<#
.SYNOPSIS
Remove DataBricks job(s) that is present in the config file from a workspace.
 
.DESCRIPTION
Remove DataBricks job(s) that is present in the config file from a workspace.
 
.PARAMETER config
Configuration json file from the environment used to workout whether to remove a job from a workspace.
 
.EXAMPLE
Remove-DatabricksJobsFromConfig -config $config
 
.NOTES
Author: Sabin IO
 
#>
 
Function Remove-DatabricksJobsFromConfig {
    [cmdletbinding()]
    Param(
        [parameter(Mandatory = $true)]$config
    )
    
    try {

        if (($config.removeJobsByName) -and ($config.removeJobsByName.Length -ge 1)) {
            Write-Output "[Removing] job(s) listed in config"  

            foreach ($jobName in $config.removeJobsByName) {

                Remove-DatabricksJobFromWorkspaceByName -config $config `
                    -jobName $jobName
            }
        }

    }    
    catch {
        #uh oh
        throw $_.Exception
    }
}