I'm not too familiar with Tableau Server and don't know that this would work for your use case, but with raw tableau workbooks you can change connection information by parsing the underlying XML, replacing with a new value, and then saving that back as a .TWB file. For example, here is the start of the XML code for one workbook:
<?xml version='1.0' encoding='utf-8' ?>
<!-- build 9300.16.0315.0125 -->
<workbook source-build='9.3.0 (9300.16.0315.0125)' source-platform='win' version='9.3' xmlns:user='http://www.tableausoftware.com/xml/user'>
<preference name='ui.encoding.shelf.height' value='24' />
<preference name='ui.shelf.height' value='26' />
<datasource caption='Mock TDE Extract' inline='true' name='dataengine.1wha8gx0mft71t10ykj4l1y94maw' version='9.3'>
<connection class='dataengine' dbname='C:\Users\Desktop\Tableau\Mock TDE.tde' schema='Extract' tablename='Extract'>
<relation name='Extract (Extract.Extract)' table='[Extract].[Extract]' type='table' />
Changing the file path to a new TDE and resaving worked for me. I'm not sure how this would need to be tweaked for non-extract workbooks, but I'm sure the connection information is in the XML as well.
You would need to automate downloading the workbooks from server, update connection information, resave as .TWBs, and then republish them back to server after processing. Like I said, I'm not familiar with server but this works on local tableau workbook files.
Did you manage to get this working? I'm trying through python, and having difficulties.
Please see this link for more detail: How to edit connection published datasource - python rest API
Thank you in advance.