Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add token authorization to Agent.force_leave #79

Merged
merged 1 commit into from
Jul 3, 2024
Merged
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
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