Skip to content

Commit

Permalink
added token to agent.force_leave
Browse files Browse the repository at this point in the history
  • Loading branch information
zanloy committed Jul 2, 2024
1 parent 32570c2 commit c1b120b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions consul/api/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def join(self, address, wan=False, token=None):

return self.agent.http.put(CB.bool(), f"/v1/agent/join/{address}", params=params)

def force_leave(self, node):
def force_leave(self, node, token=None):
"""
This endpoint instructs the agent to force a node into the left
state. If a node fails unexpectedly, then it will be in a failed
Expand All @@ -129,7 +129,13 @@ def force_leave(self, node):
*node* is the node to change state for.
"""

return self.agent.http.put(CB.bool(), f"/v1/agent/force-leave/{node}")
params = []

token = token or self.agent.token
if token:
params.append(("token", token))

return self.agent.http.put(CB.bool(), f"/v1/agent/force-leave/{node}", params=params)

class Service:
def __init__(self, agent):
Expand Down

0 comments on commit c1b120b

Please sign in to comment.