Hi
In Order to achieve your request you can use the Update Data Source API
https://docs.microsoft.com/en-us/rest/api/power-bi/datasets/updatedatasourcesingroup
In order to automate either using Azure DevOps/ PowerShell I wrote an article which would helpful for you
https://community.powerbi.com/t5/Community-Blog/PowerBI-CICD-using-Azure-DevOps/ba-p/769244