Functions/Remove-DatabricksClustersLibrariesFromConfig.ps1

<#
.SYNOPSIS
Deploys DataBricks Cluster(s) from configuration json file(s) to a workspace
 
.DESCRIPTION
Deploys DataBricks Cluster(s) from configuration json file(s) to a workspace
 
.PARAMETER config
Configuration json file from the environment used to workout whether to deploy a clusters from a folder or file(s)
 
.PARAMETER bearerToken
Your Databricks Bearer token to authenticate to your workspace (see User Settings in Datatbricks WebUI)
 
.EXAMPLE
Remove-DatabricksClustersLibrariesFromConfig -config $config -bearerToken 'dapi1234567890'
 
.NOTES
Author: Sabin IO
 
#>
 
Function Remove-DatabricksClustersLibrariesFromConfig {
    [cmdletbinding()]
    Param(
        [parameter(Mandatory = $true)]$config,
        [parameter(Mandatory = $true)][string]$bearerToken
    )
    
    try {

        if (($config.librariesUninstall) -and ($config.librariesUninstall.Length -ge 1)) {
            Write-Verbose "[Removing] clusters libraries by config"  

            foreach ($libraryConfig in $config.librariesUninstall) {

                Remove-DatabricksClusterLibrariesFromWorkspaceByName -config $config `
                    -bearerToken $bearerToken `
                    -librariesConfig $libraryConfig
            }
        }

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