Pat_IronBridges
New Contributor II

So, here is an alternative to either the UI (doesn't work actually; not possible) or the CLI. Use the Databricks API.

endpoint_change = f"{databricksURL}/api/2.1/clusters/edit" # change single owner

payload_change = {
    "cluster_id": cluster_id
  ,"cluster_name": cluster_name
  ,"single_user_name": new_owner # serv principal user id
  ,"num_workers": 1
  ,"spark_version": "14.3.x-cpu-ml-scala2.12" # required; set to what you want
  ,"node_type_id": "r6id.xlarge" #required; set to what you want
  ,"data_security_mode": "SINGLE_USER"

}

response = requests.post(
            endpoint_change,
            headers=headers,
            json=payload_change
        )
#if you have init scripts running, they should be included in the the json payload as well.  (doesn't work setting them in the UI).
# also be sure the service principal has access to the init script location