-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add acl.list and list.read
- Loading branch information
Showing
3 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
from consul.api.acl.policies import Policies | ||
from consul.api.acl.token import Token | ||
|
||
|
||
class ACL: | ||
def __init__(self, agent): | ||
self.agent = agent | ||
self.token = Token(agent) | ||
self.policies = Policies(agent) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from consul.callback import CB | ||
|
||
|
||
class Policies: | ||
def __init__(self, agent): | ||
self.agent = agent | ||
|
||
def list(self, token=None): | ||
""" | ||
Lists all the active ACL policies. This is a privileged endpoint, and | ||
requires a management token. *token* will override this client's | ||
default token. | ||
Requires a token with acl:read capability. ACLPermissionDenied raised otherwise | ||
""" | ||
params = [] | ||
token = token or self.agent.token | ||
if token: | ||
params.append(("token", token)) | ||
return self.agent.http.get(CB.json(), "/v1/acl/policies", params=params) | ||
|
||
def read(self, uuid, token=None): | ||
""" | ||
Returns the policy information for *id*. Requires a token with acl:read capability. | ||
:param accessor_id: Specifies the UUID of the policy you lookup. | ||
:param token: token with acl:read capability | ||
:return: selected Polic information | ||
""" | ||
params = [] | ||
token = token or self.agent.token | ||
if token: | ||
params.append(("token", token)) | ||
return self.agent.http.get(CB.json(), f"/v1/acl/policy/{uuid}", params=params) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters