Skip to content
This repository was archived by the owner on May 30, 2024. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion consul/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -4024,11 +4024,22 @@ def put(self, payload, token=None):
"Session": "<session id>"
}
}

*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))