Python SDK - modify a datasource
I am looking for a way to programmatically change a number of datasources.
I searched through the API v3. documentation but couldn’t find any way. There are some calls to get information from datasources, but none to change them.
I was expecting to find something like “patch_datasource_by_id”.
Any ideas?
Javier Llorente
Posted 3 years ago·Last reply 3 years ago
5 comments
Javier Llorente
OP3 years agoI found the way to do that request. I found your example code on https://github.com/sweenig/lm/tree/main/LMAutomation/lmwrapper
That was the piece of code I needed.
Thanks for your help!
Javier Llorente
OP3 years ago@Stuart Weenig Do you have any example code to do such a request using Python?
Thanks a lot for your help.
Michael Raymond
·3 years ago@Stuart Weenig -- The ‘forceUniqueIdentifier’ param is to force the change/update of ‘useWildValueAsUUID’. So like how the checkbox is disabled in the UI once you commit and save that setting:
You can bypass that via the API with the param ‘forceUniqueIdentifier’:
You also need that key param as well. This is considered destructive and should be used with caution. 😬
@Javier -- But yeah you can leverage the API to update DataSources, but it’s not documented and considered unsupported at this time.
LM User
·3 years agoI totally missed the title of your post. It’s not in the SDK because it’s not a published endpoint in the API. So, you’ll have to manually make the call using the requests library. If you need example code of how to do that, let me know.
LM User
·3 years agoThe UI uses a PUT on /setting/datasources/{dsId} with a “reason” query parameter containing the encoded text of the update reason (the same thing you’re prompted for when you hit save on a datasource). Looks like it also uses forceUniqueIdentifier as a boolean. Not sure what this does. That endpoint is undocumented. If you haven’t already, I’d suggest you go onto the product and submit a feature request that PUT /setting/datasources be documented (along with the other hidden API endpoints).
You should be able to use that endpoint after doing a GET on the same endpoint to get the definition. Update the definition and pass it back in using a PUT.