Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using kwargs in create_XX functions to allow passing any parameters in the payload #14

Open
benoitscherrer opened this issue Oct 29, 2020 · 0 comments

Comments

@benoitscherrer
Copy link

For example, for create_query:

It is probably good that the payload always contains a few parameters (e.g., data_source_id, name, etc...), but what about all other potential (and useful) parameters? For example tags, etc, Using kwargs would be a great way to make your API much more general.

For example for create_query:

def create_query(self, ds_id: int, name: str, qry: str, desc: str="", with_results: bool=True, **kwargs):
        payload = {
            "data_source_id": ds_id,
            "name": name,
            "query": qry,
            "description": desc,
            **kwargs
        }

        res = self.post('queries', payload)

        if with_results:
            self.generate_query_results(ds_id, qry)

        return res

Then you can use it with

redash.create_query(1, "my query", "select 1 from table", "description", with_results=False, tags=["mytag"], options={} )

If you remove options (i would) that would be a breaking change, so that's probably your decision.
But all that would be very easy to add that to all create_XXX functions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant