-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathauth_group.py
49 lines (36 loc) · 1.4 KB
/
auth_group.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
from apimatic_core_interfaces.types.authentication import Authentication
from apimatic_core.authentication.multiple.single_auth import Single
class AuthGroup(Authentication):
@property
def auth_participants(self):
return self._auth_participants
@property
def mapped_group(self):
return self._mapped_group
@property
def error_messages(self):
return self._error_messages
@property
def is_valid_group(self):
return self._is_valid_group
def __init__(self, auth_group):
self._auth_participants = []
for auth_participant in auth_group:
if auth_participant is not None and isinstance(auth_participant, str):
self._auth_participants.append(Single(auth_participant))
elif auth_participant is not None:
self._auth_participants.append(auth_participant)
self._mapped_group = []
self._error_messages = []
self._is_valid_group = None
def with_auth_managers(self, auth_managers):
for participant in self.auth_participants:
self.mapped_group.append(participant.with_auth_managers(auth_managers))
return self
def is_valid(self): # pragma: no cover
...
def apply(self, http_request):
if not self.is_valid_group:
return
for participant in self.mapped_group:
participant.apply(http_request)