-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathroles.py
More file actions
36 lines (28 loc) · 882 Bytes
/
roles.py
File metadata and controls
36 lines (28 loc) · 882 Bytes
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
import logging
from ...core.enum import RoleResolver
from ...core.types import RoleSettings
from .base_command import BaseCommand
logger = logging.getLogger('cterasdk.core')
class Roles(BaseCommand):
"""
Role Settings APIs
"""
@staticmethod
def find(role):
"""
Find Role
"""
options = {k: v for k, v in RoleResolver.__dict__.items() if not k.startswith('_')}
return options.get(role, None)
async def get(self, role):
"""
Get Role
:param str role: Role
:returns: Role settings
:rtype: cterasdk.core.types.RoleSettings
"""
name = Roles.find(role)
if name:
return RoleSettings.from_server_object(await self._core.v1.api.get(f'/rolesSettings/{name}'))
logger.warning('Could not find role. %s', {'role': role})
return None