From f001c615385ef27ec7601fa4508e8288a0598774 Mon Sep 17 00:00:00 2001 From: Sergey Kvetko Date: Wed, 29 Nov 2017 12:05:09 +0300 Subject: [PATCH] Add param to set type of template variable --- grafanalib/core.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/grafanalib/core.py b/grafanalib/core.py index f09a4daf..634abe2e 100644 --- a/grafanalib/core.py +++ b/grafanalib/core.py @@ -7,6 +7,7 @@ import attr from attr.validators import instance_of +from grafanalib.validators import is_in import itertools import math from numbers import Number @@ -143,6 +144,9 @@ def to_json_data(self): PLUGIN_ID_ELASTICSEARCH = "elasticsearch" PLUGIN_ID_CLOUDWATCH = "cloudwatch" +# Template types +TEMPLATE_TYPES = ('custom', 'query', 'interval') + @attr.s class Mapping(object): @@ -511,6 +515,7 @@ class Template(object): return by your data source query. :param multi: If enabled, the variable will support the selection of multiple options at the same time. + :param variableType: set type of template variable """ default = attr.ib() @@ -528,6 +533,10 @@ class Template(object): validator=instance_of(bool), ) regex = attr.ib(default=None) + variableType = attr.ib( + default='query', + validator=is_in(TEMPLATE_TYPES), + ) def to_json_data(self): return { @@ -550,7 +559,7 @@ def to_json_data(self): 'sort': 1, 'tagValuesQuery': None, 'tagsQuery': None, - 'type': 'query', + 'type': self.variableType, }