Interesting in the API there is a boolean parameter you can pass in when POSTing queries to an instance of redash that is “is_draft” (True or False)
However, in the post class method that receives this data, there is this line
:>json string query: Query text
:>json string query_hash: Hash of query text
:>json string schedule: Schedule interval, in seconds, for repeated execution of this query
:>json string api_key: Key for public access to this query's results.
:>json boolean is_archived: Whether this query is displayed in indexes and search results or not.
:>json boolean is_draft: Whether this query is a draft or not
:>json string updated_at: Time of last modification, in ISO format
:>json string created_at: Time of creation, in ISO format
:>json number data_source_id: ID of the data source this query will run on
:>json object options: Query options
:>json number version: Revision version (for update conflict avoidance)
:>json number user_id: ID of query creator
:>json number last_modified_by_id: ID of user who last modified this query
:>json string retrieved_at: Time when query results were last retrieved, in ISO format (may be null)
:>json number runtime: Runtime of last query execution, in seconds (may be null)
"""
query_def = request.get_json(force=True)
data_source = models.DataSource.get_by_id_and_org(query_def.pop('data_source_id'), self.current_org)
require_access(data_source.groups, self.current_user, not_view_only)
for field in ['id', 'created_at', 'api_key', 'visualizations', 'latest_query_data', 'last_modified_by']:
…which negates whatever you pass in. The other interesting thing is that for queries, there doesn’t appear to be a way to update an existing query via the AP
1 Like
Where I wrote:
“The other interesting thing is that for queries, there doesn’t appear to be a way to update an existing query via the API”
That is wrong. You can update against an individual record via the url /api/queries/ POSTing a parameter (like is_draft)
1 Like
arikfr
April 23, 2018, 7:43am
3
I’m happy to accept a pull request that changes this API call to accept an optional is_draft
value, so you can set it to False
on creation.