8000 remove __check functions for validator model · python-microservices/consulate@a85c8cc · GitHub
[go: up one dir, main page]

Skip to content

Commit a85c8cc

Browse files
committed
remove __check functions for validator model
1 parent 7f3805e commit a85c8cc

File tree

1 file changed

+0
-50
lines changed

1 file changed

+0
-50
lines changed

consulate/api/acl.py

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
44
"""
55
import logging
6-
import json
76

87
from consulate.models import acl as model
98
from consulate.api import base
@@ -20,48 +19,6 @@
2019
# RoleLinks = List[RoleLink]
2120

2221

23-
def __check_policylinks(policies):
24-
""" Checks if policies is formatted correctly.
25-
:param list policies: A list of PolicyLink.
26-
:param rtype: bool
27-
:raises: consulate.exceptions.ACLFormatError
28-
29-
"""
30-
for policy in policies:
31-
if not ('ID' in policy or 'Name' in policy):
32-
raise exceptions.ACLPolicyFormatError(str(policy))
33-
34-
return True
35-
36-
37-
def __check_service_identities(service_identities):
38-
""" Checks if service_identities is formatted correctly.
39-
:param list service_identities: A ServiceIdentity list
40-
:param rtype: bool
41-
:raises: consulate.exceptions.ACLFormatError
42-
43-
"""
44-
for service_identity in service_identities:
45-
if 'ServiceName' not in service_identity:
46-
raise exceptions.ACLPolicyFormatError(str(service_identity))
47-
48-
return True
49-
50-
51-
def __create_json_format(structures, check):
52-
"""Creates a json string from a structures provided check passes.
53-
:param list structure: a PolicyLinks or ServiceIdentities.
54-
:param function check: a function to check structure
55-
:param rtype: str
56-
57-
"""
58-
formatted = None
59-
if structures is not None and check(structures):
60-
formatted = json.dumps(structures)
61-
62-
return formatted
63-
64-
6522
class ACL(base.Endpoint):
6623
"""The ACL endpoints are used to create, update, destroy, and query ACL
6724
tokens.
@@ -176,10 +133,6 @@ def create_role(self,
176133
:param rtype: dict
177134
178135
"""
179-
policies = __create_json_format(policies, __check_policylinks)
180-
service_identities = __create_json_format(service_identities,
181-
__check_service_identities)
182-
183136
return self._put_response_body(
184137
["role"], {},
185138
dict(
@@ -203,9 +156,6 @@ def update_role(self,
203156
:param rtype: dict
204157
205158
"""
206-
policies = __create_json_format(policies, __check_policylinks)
207-
service_identities = __create_json_format(service_identities,
208-
__check_service_identities)
209159
return self._put_response_body(
210160
["role", id], {},
211161
dict(

0 commit comments

Comments
 (0)
0