diff --git a/consul/base.py b/consul/base.py index 9d27dbd..ce16d2f 100755 --- a/consul/base.py +++ b/consul/base.py @@ -4003,7 +4003,7 @@ class Txn(object): def __init__(self, agent): self.agent = agent - def put(self, payload, token=None): + def put(self, payload, token=None, dc=None): """ Create a transaction by submitting a list of operations to apply to the KV store inside of a transaction. If any operation fails, the @@ -4024,11 +4024,22 @@ def put(self, payload, token=None): "Session": "" } } + + *dc* (string: "") - Specifies the datacenter to query. This will + default to the datacenter of the agent being queried. This is + specified as part of the URL as a query parameter """ headers = {} + params = [] token = token or self.agent.token if token: headers['X-Consul-Token'] = token + + dc = dc or self.agent.dc + if dc: + params.append(('dc', dc)) + return self.agent.http.put(CB.json(), path="/v1/txn", headers=headers, + params=params, data=json.dumps(payload))