# Path: tenable_io/api/models.py
# class Permissions(BaseModel):
# 
#     class Scan:
#         # Scan Permissions
#         PERMISSION_NO_ACCESS = 0
#         PERMISSION_CAN_VIEW = 16
#         PERMISSION_CAN_CONTROL = 32
#         PERMISSION_CAN_CONFIGURE = 64
# 
#     class Policy:
#         # Policy Permissions
#         PERMISSION_NO_ACCESS = 0
#         PERMISSION_CAN_USE = 16
#         PERMISSION_CAN_EDIT = 32
# 
#     class Scanner:
#         # Scanner Permissions
#         PERMISSION_NO_ACCESS = 0
#         PERMISSION_CAN_USE = 16
#         PERMISSION_CAN_MANAGE = 32
# 
#     class Agent:
#         # Agent Permissions
#         PERMISSION_NO_ACCESS = 0
#         PERMISSION_CAN_USE = 16
# 
#     class TargetGroup:
#         # Target Group Permissions
#         PERMISSION_NO_ACCESS = 0
#         PERMISSION_CAN_VIEW = 32
#         PERMISSION_CAN_SCAN = 64
# 
#     class User:
#         # User Roles
#         PERMISSION_BASIC = 16
#         PERMISSION_SCAN_OPERATOR = 24
#         PERMISSION_STANDARD = 32
#         PERMISSION_SCAN_MANAGER = 40
#         PERMISSION_ADMINISTRATOR = 64
# 
#     class Type:
#         # Types of Permissible entity
#         DEFAULT = u'default'
#         USER = u'user'
#         GROUP = u'group'
# 
#     def __init__(
#             self,
#             owner=None,
#             type=None,
#             permissions=None,
#             id=None,
#             name=None,
#     ):
#         self.owner = owner
#         self.type = type
#         self.permissions = permissions
#         self.id = id
#         self.name = name


from tenable_io.api.models import Permissions


class PermissionsHelper(object):

    def __init__(self, client):
        self._client = client

    def default_scan(self, access_level):
        """Generates a Permission object for the default role.

        :param access_level: The access level the default user group should be granted for a scan
               (0, 16, 32, 64). See `Permissions.Scan`.
        :return: A Permissions instance
        """
        return Permissions(type=Permissions.Type.DEFAULT,
                           permissions=access_level)

    def user_scan(self, user_id, access_level):
        """Generates a Permission object for the given user id with the given permissions

        :param user_id: Numeric User Id
        :param access_level: The access level the default user group should be granted for a scan
               (0, 16, 32, 64). See `Permissions.Scan`.
        :return: A Permissions instance
        """
        user = self._client.users_api.get(user_id)
        return Permissions(owner=user.id,

# Path: tenable_io/api/models.py
# class Permissions(BaseModel):
# 
#     class Scan:
#         # Scan Permissions
#         PERMISSION_NO_ACCESS = 0
#         PERMISSION_CAN_VIEW = 16
#         PERMISSION_CAN_CONTROL = 32
#         PERMISSION_CAN_CONFIGURE = 64
# 
#     class Policy:
#         # Policy Permissions
#         PERMISSION_NO_ACCESS = 0
#         PERMISSION_CAN_USE = 16
#         PERMISSION_CAN_EDIT = 32
# 
#     class Scanner:
#         # Scanner Permissions
#         PERMISSION_NO_ACCESS = 0
#         PERMISSION_CAN_USE = 16
#         PERMISSION_CAN_MANAGE = 32
# 
#     class Agent:
#         # Agent Permissions
#         PERMISSION_NO_ACCESS = 0
#         PERMISSION_CAN_USE = 16
# 
#     class TargetGroup:
#         # Target Group Permissions
#         PERMISSION_NO_ACCESS = 0
#         PERMISSION_CAN_VIEW = 32
#         PERMISSION_CAN_SCAN = 64
# 
#     class User:
#         # User Roles
#         PERMISSION_BASIC = 16
#         PERMISSION_SCAN_OPERATOR = 24
#         PERMISSION_STANDARD = 32
#         PERMISSION_SCAN_MANAGER = 40
#         PERMISSION_ADMINISTRATOR = 64
# 
#     class Type:
#         # Types of Permissible entity
#         DEFAULT = u'default'
#         USER = u'user'
#         GROUP = u'group'
# 
#     def __init__(
#             self,
#             owner=None,
#             type=None,
#             permissions=None,
#             id=None,
#             name=None,
#     ):
#         self.owner = owner
#         self.type = type
#         self.permissions = permissions
#         self.id = id
#         self.name = name


# Path: tenable_io/helpers/permissions.py
from tenable_io.api.models import Permissions



class PermissionsHelper(object):

    def __init__(self, client):
        self._client = client

    def default_scan(self, access_level):
        """Generates a Permission object for the default role.

        :param access_level: The access level the default user group should be granted for a scan
               (0, 16, 32, 64). See `Permissions.Scan`.
        :return: A Permissions instance
        """
        return Permissions(type=Permissions.Type.DEFAULT,
                           permissions=access_level)

    def user_scan(self, user_id, access_level):
        """Generates a Permission object for the given user id with the given permissions

        :param user_id: Numeric User Id
        :param access_level: The access level the default user group should be granted for a scan
               (0, 16, 32, 64). See `Permissions.Scan`.
        :return: A Permissions instance
        """
        user = self._client.users_api.get(user_id)
        return Permissions(owner=user.id,

                           type=Permissions.Type.USER,