Skip to content
This repository was archived by the owner on Apr 15, 2024. It is now read-only.
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Added token for all consul.Session endpoints.
  • Loading branch information
Abhisek Padhi
Abhisek Padhi committed Mar 25, 2019
commit 500946b57ceb9fd0d231593bb6d3e038b7ab30ee
16 changes: 16 additions & 0 deletions consul/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1793,6 +1793,9 @@ def destroy(self, session_id, dc=None):
dc = dc or self.agent.dc
if dc:
params.append(('dc', dc))
token = self.agent.token
if token:
params.append(('token', token))
return self.agent.http.put(
CB.bool(),
'/v1/session/destroy/%s' % session_id,
Expand Down Expand Up @@ -1841,6 +1844,9 @@ def list(self, index=None, wait=None, consistency=None, dc=None):
consistency = consistency or self.agent.consistency
if consistency in ('consistent', 'stale'):
params.append((consistency, '1'))
token = self.agent.token
if token:
params.append(('token', token))
return self.agent.http.get(
CB.json(index=True), '/v1/session/list', params=params)

Expand Down Expand Up @@ -1871,6 +1877,9 @@ def node(self, node, index=None, wait=None, consistency=None, dc=None):
consistency = consistency or self.agent.consistency
if consistency in ('consistent', 'stale'):
params.append((consistency, '1'))
token = self.agent.token
if token:
params.append(('token', token))
return self.agent.http.get(
CB.json(index=True),
'/v1/session/node/%s' % node, params=params)
Expand Down Expand Up @@ -1908,6 +1917,9 @@ def info(self,
consistency = consistency or self.agent.consistency
if consistency in ('consistent', 'stale'):
params.append((consistency, '1'))
token = self.agent.token
if token:
params.append(('token', token))
return self.agent.http.get(
CB.json(index=True, one=True),
'/v1/session/info/%s' % session_id,
Expand All @@ -1927,6 +1939,9 @@ def renew(self, session_id, dc=None):
dc = dc or self.agent.dc
if dc:
params.append(('dc', dc))
token = self.agent.token
if token:
params.append(('token', token))
return self.agent.http.put(
CB.json(one=True, allow_404=False),
'/v1/session/renew/%s' % session_id,
Expand Down Expand Up @@ -2437,3 +2452,4 @@ def raft_config(self):
"""
return self.agent.http.get(
CB.json(), '/v1/operator/raft/configuration')