query can not be executed by ID
I created a query, and recorded it's ID.
queryId = c.query.creat('TestService-service', name='testQuery')['ID']
but when I attempt to execute this query by ID,it raised a ConsulException.
raise ConsulException("%d %s" % (response.code, response.body)) consul.base.ConsulException: 500 prepared query templates can only be resolved up by name, not by ID
then I checked the python-consul doc, and it says that it could be executed by ID.
so does the Consul API website.
is this a bug, or a new feature?
well, I found out,the query I created is a template.
the left is a query created by HTTP API, which could be executed by ID.
and the right is the query created by python-consul API, and could not be executed by ID.
the difference is the value of type.
then I noticed that both the python-consul doc and Consul API website said the name_prefix_match is the only option for type.
then I read the code and confirmed it's actually not configurable.
data = dict([
(k, v) for k, v in {
'name': name,
'session': session,
'token': token or self.agent.token,
'dns': {
'ttl': ttl
} if ttl is not None else None,
'template': dict([
(k, v) for k, v in {
'type': 'name_prefix_match',
'regexp': regexp
}.items() if v is not None
]),
'service': service_body
}.items() if v is not None
]
then I modified the code and set the value of type to empty string, and it could be executed by ID now.
so, is this a bug? should the default value of type be empty string?