Forum Discussion

Javier's avatar
Javier
Icon for Neophyte rankNeophyte
2 years ago

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?

  • @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.

  • @Stuart Weenig Do you have any example code to do such a request using Python?

    Thanks a lot for your help.

  • mray's avatar
    mray
    Icon for LM Conqueror rankLM Conqueror

    @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.

  • Anonymous's avatar
    Anonymous

    I 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.

  • Anonymous's avatar
    Anonymous

    The 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.