Functions/Import-WorkspaceJobs.ps1


Function Import-WorkspaceJobs {
    [cmdletbinding()]
    param(
        $config, 
        $jobSettings, 
        $BearerToken,
        [switch] $returnJob
    )

    try {
        Write-Verbose "Running Add-DatabricksNotebookJob..."
        $notebookJobId = $null
        $notebookJobId = Add-DatabricksNotebookJob -JobName $jobSettings.name -BearerToken $BearerToken -Region $config.Region -InputObject $jobSettings -Verbose 
    }
    catch {
        #uh oh
        throw $_.Exception
    }
    if ($returnJob) {
        $job = Get-DatabricksJobs -BearerToken $BearerToken -Region $config.Region | Where-Object { $_.job_id -eq $notebookJobId }
        return $job
    }

}