I’m trying to implement a use case where there’s a multi tenant app and users are performing actions against it that result in data being retrieved from the Looker API. We have a Look set up for this data retrieval use case. And we use a PDT with the Look to make the queries as fast and cheap as possible, since they execute against BigQuery. In the future, we plan to save the PDT in PostgreSQL instead of BigQuery because we know the aggregated form of the data in the PDT is small enough to fit in PostgreSQL.
I’m struggling to implement the part where I call the Looker API. The Look needs to support filtering. We added filters to it, and this works fine when clicking around the UI to query it given different filter values. But with the API, in the run_look method, there isn’t a way to set the filter values. I found this page which describes a workaround:
The workaround is to treat the Look as a mutable resource instead of immutable resource. Instead of querying it multiple times, specifying filters each time just for each query, you mutate the Look by editing its query, editing the filters of that query, then saving the new state of the Look after that edit. Then you run the Look using run_look.
I see how this solves that use case, but this wouldn’t work for our multitenant use case. Multiple users for each of our customers may be browsing the app at the same time, triggering these Looker API calls, and multiple customers may have their users browsing the app (we use customer as a filter to make the single Look support all of our customers). So we would have to implement some sort of locking mechanism to make this API call have a concurrency of 1, so that one user’s filter values don’t overwrite those of another user while a query is in progress.
I found the API method run_inline_query which appears to be what I’m looking for: https://docs.looker.com/reference/api-and-integration/api-reference/v3.1/query#run_inline_query
It would allow me to specify a query, including its filter values, every time. But I don’t see “look_id” in that method’s parameters. I want to run a fresh query against the Look we made each time, not against the model and view. It’s important that it’s the Look and not the model because we need to leverage the PDT feature so that we’re querying a small amount of data instead of the raw data of the model each time.
Is there a way to use run_inline_query for my use case? Or is there some other API method I should be using instead? Or, is it even possible to use the API for this use case?