@@ -358,6 +358,7 @@ class Event(object):
358358 practice, this means you cannot rely on the order of message delivery.
359359 An advantage however is that events can still be used even in the
360360 absence of server nodes or during an outage."""
361+
361362 def __init__ (self , agent ):
362363 self .agent = agent
363364
@@ -1716,7 +1717,8 @@ def create(
17161717 lock_delay = 15 ,
17171718 behavior = 'release' ,
17181719 ttl = None ,
1719- dc = None ):
1720+ dc = None ,
1721+ token = None ):
17201722 """
17211723 Creates a new session. There is more documentation for sessions
17221724 `here <https://consul.io/docs/internals/sessions.html>`_.
@@ -1747,12 +1749,16 @@ def create(
17471749 By default the session will be created in the current datacenter
17481750 but an optional *dc* can be provided.
17491751
1752+ *token* is an optional `ACL token`_ to apply to this request.
1753+
17501754 Returns the string *session_id* for the session.
17511755 """
17521756 params = []
17531757 dc = dc or self .agent .dc
17541758 if dc :
17551759 params .append (('dc' , dc ))
1760+ if token :
1761+ params .append (('token' , token ))
17561762 data = {}
17571763 if name :
17581764 data ['name' ] = name
@@ -1780,22 +1786,26 @@ def create(
17801786 params = params ,
17811787 data = data )
17821788
1783- def destroy (self , session_id , dc = None ):
1789+ def destroy (self , session_id , dc = None , token = None ):
17841790 """
17851791 Destroys the session *session_id*
17861792
1793+ *token* is an optional `ACL token`_ to apply to this request.
1794+
17871795 Returns *True* on success.
17881796 """
17891797 params = []
17901798 dc = dc or self .agent .dc
17911799 if dc :
17921800 params .append (('dc' , dc ))
1801+ if token :
1802+ params .append (('token' , token ))
17931803 return self .agent .http .put (
17941804 CB .bool (),
17951805 '/v1/session/destroy/%s' % session_id ,
17961806 params = params )
17971807
1798- def list (self , index = None , wait = None , consistency = None , dc = None ):
1808+ def list (self , index = None , wait = None , consistency = None , dc = None , token = None ):
17991809 """
18001810 Returns a tuple of (*index*, *sessions*) of all active sessions in
18011811 the *dc* datacenter. *dc* defaults to the current datacenter of
@@ -1812,6 +1822,8 @@ def list(self, index=None, wait=None, consistency=None, dc=None):
18121822 not specified *consistency* will the consistency level this client
18131823 was configured with.
18141824
1825+ *token* is an optional `ACL token`_ to apply to this request.
1826+
18151827 The response looks like this::
18161828
18171829 (index, [
@@ -1831,6 +1843,8 @@ def list(self, index=None, wait=None, consistency=None, dc=None):
18311843 dc = dc or self .agent .dc
18321844 if dc :
18331845 params .append (('dc' , dc ))
1846+ if token :
1847+ params .append (('token' , token ))
18341848 if index :
18351849 params .append (('index' , index ))
18361850 if wait :
@@ -1841,7 +1855,7 @@ def list(self, index=None, wait=None, consistency=None, dc=None):
18411855 return self .agent .http .get (
18421856 CB .json (index = True ), '/v1/session/list' , params = params )
18431857
1844- def node (self , node , index = None , wait = None , consistency = None , dc = None ):
1858+ def node (self , node , index = None , wait = None , consistency = None , dc = None , token = None ):
18451859 """
18461860 Returns a tuple of (*index*, *sessions*) as per *session.list*, but
18471861 filters the sessions returned to only those active for *node*.
@@ -1856,11 +1870,15 @@ def node(self, node, index=None, wait=None, consistency=None, dc=None):
18561870 *consistency* can be either 'default', 'consistent' or 'stale'. if
18571871 not specified *consistency* will the consistency level this client
18581872 was configured with.
1873+
1874+ *token* is an optional `ACL token`_ to apply to this request.
18591875 """
18601876 params = []
18611877 dc = dc or self .agent .dc
18621878 if dc :
18631879 params .append (('dc' , dc ))
1880+ if token :
1881+ params .append (('token' , token ))
18641882 if index :
18651883 params .append (('index' , index ))
18661884 if wait :
@@ -1877,7 +1895,8 @@ def info(self,
18771895 index = None ,
18781896 wait = None ,
18791897 consistency = None ,
1880- dc = None ):
1898+ dc = None ,
1899+ token = None ):
18811900 """
18821901 Returns a tuple of (*index*, *session*) for the session
18831902 *session_id* in the *dc* datacenter. *dc* defaults to the current
@@ -1893,11 +1912,15 @@ def info(self,
18931912 *consistency* can be either 'default', 'consistent' or 'stale'. if
18941913 not specified *consistency* will the consistency level this client
18951914 was configured with.
1915+
1916+ *token* is an optional `ACL token`_ to apply to this request.
18961917 """
18971918 params = []
18981919 dc = dc or self .agent .dc
18991920 if dc :
19001921 params .append (('dc' , dc ))
1922+ if token :
1923+ params .append (('token' , token ))
19011924 if index :
19021925 params .append (('index' , index ))
19031926 if wait :
@@ -1910,20 +1933,24 @@ def info(self,
19101933 '/v1/session/info/%s' % session_id ,
19111934 params = params )
19121935
1913- def renew (self , session_id , dc = None ):
1936+ def renew (self , session_id , dc = None , token = None ):
19141937 """
19151938 This is used with sessions that have a TTL, and it extends the
19161939 expiration by the TTL.
19171940
19181941 *dc* is the optional datacenter that you wish to communicate with.
19191942 If None is provided, defaults to the agent's datacenter.
19201943
1944+ *token* is an optional `ACL token`_ to apply to this request.
1945+
19211946 Returns the session.
19221947 """
19231948 params = []
19241949 dc = dc or self .agent .dc
19251950 if dc :
19261951 params .append (('dc' , dc ))
1952+ if token :
1953+ params .append (('token' , token ))
19271954 return self .agent .http .put (
19281955 CB .json (one = True , allow_404 = False ),
19291956 '/v1/session/renew/%s' % session_id ,
0 commit comments