# Path: tenable_io/api/base.py
# class BaseApi(object):
# 
#     def __init__(self, client):
#         self._client = client
# 
# Path: tenable_io/api/base.py
# class BaseRequest(object):
# 
#     def as_payload(self, filter_=None):
#         return payload_filter(self.__dict__, filter_)
# 
# Path: tenable_io/api/models.py
# class AccessGroup(BaseModel):
# 
#     def __init__(
#             self,
#             container_uuid=None,
#             created_at=None,
#             updated_at=None,
#             id=None,
#             name=None,
#             all_assets=None,
#             all_users=None,
#             status=None,
#             rules=None,
#             principals=None,
#             version=None,
#             created_by_uuid=None,
#             updated_by_uuid=None,
#             updated_by_name=None,
#             created_by_name=None,
#             processing_percent_complete=None
#     ):
#         self._rules = None
#         self._principals = None
#         self.container_uuid = container_uuid
#         self.created_at = created_at
#         self.updated_at = updated_at
#         self.id = id
#         self.name = name
#         self.all_assets = all_assets
#         self.all_users = all_users
#         self.status = status
#         self.rules = rules
#         self.principals = principals
#         self.version = version
#         self.created_by_uuid = created_by_uuid
#         self.updated_by_uuid = updated_by_uuid
#         self.updated_by_name = updated_by_name
#         self.created_by_name = created_by_name
#         self.processing_percent_complete = processing_percent_complete
# 
#     @property
#     def rules(self):
#         return self._rules
# 
#     @rules.setter
#     @BaseModel._model_list(AssetRule)
#     def rules(self, rules):
#         self._rules = rules
# 
#     @property
#     def principals(self):
#         return self._principals
# 
#     @principals.setter
#     @BaseModel._model_list(AssetRulePrincipal)
#     def principals(self, principals):
#         self._principals = principals
# 
# class AccessGroupList(BaseModel):
# 
#     def __init__(
#             self,
#             access_groups=None,
#             pagination=None
#     ):
#         self._access_groups = None
#         self._pagination = None
#         self.access_groups = access_groups
#         self.pagination = pagination
# 
#     @property
#     def access_groups(self):
#         return self._access_groups
# 
#     @access_groups.setter
#     @BaseModel._model_list(AccessGroup)
#     def access_groups(self, access_groups):
#         self._access_groups = access_groups
# 
#     @property
#     def pagination(self):
#         return self._pagination
# 
#     @pagination.setter
#     @BaseModel._model(FilterPagination)
#     def pagination(self, pagination):
#         self._pagination = pagination
# 
# class AssetRule(BaseModel):
# 
#     def __init__(
#             self,
#             type=None,
#             operator=None,
#             terms=None
#     ):
#         self.type = type
#         self.operator = operator
#         self.terms = terms
# 
# class AssetRuleFilter(Filter):
# 
#     def __init__(
#             self,
#             placeholder=None,
#     ):
#         self.placeholder = placeholder
# 
# class AssetRulePrincipal(BaseModel):
# 
#     def __init__(
#             self,
#             type=None,
#             principal_id=None,
#             principal_name=None
#     ):
#         self.type = type
#         self.principal_id = principal_id
#         self.principal_name = principal_name
# 
# class Filters(BaseModel):
# 
#     def __init__(
#             self,
#             filters=None,
#             sort=None,
#             wildcard_fields=None
#     ):
#         self._filters = None
#         self.filters = filters
#         self.sort = sort
#         self.wildcard_fields = wildcard_fields
# 
#     @property
#     def filters(self):
#         return self._filters
# 
#     @filters.setter
#     @BaseModel._model_list(Filter)
#     def filters(self, filters):
#         self._filters = filters


from json import loads
from tenable_io.api.base import BaseApi
from tenable_io.api.base import BaseRequest
from tenable_io.api.models import AccessGroup, AccessGroupList, AssetRule, AssetRuleFilter, AssetRulePrincipal, Filters
        :param sort: A list of fields on which the results are sorted.
        :raise TenableIOApiException:  When API error is encountered.
        :return: An instance of :class:`tenable_io.api.models.AccessGroupList`.
        """
        fgen = (i.field + ':' + i.operator + ':' + i.value for i in f) if f is not None else None
        response = self._client.get('access-groups',
                                    params={'f': '&'.join(fgen) if fgen is not None else None,
                                            'ft': ft, 'w': w, 'wf': ','.join(wf) if wf is not None else None,
                                            'limit': limit, 'offset': offset,
                                            'sort': ','.join(sort) if sort is not None else None})
        return AccessGroupList.from_json(response.text)

    def create(self, access_group_request):
        """Create a new access group.

        :param Access_group_request: An instance of :class:`AccessGroupRequest`.
        :raise TenableIOApiException:  When API error is encountered.
        :return: An instance of :class:`tenable_io.api.models.AccessGroup` without the rules information.
        """
        response = self._client.post('access-groups', access_group_request)
        return AccessGroup.from_json(response.text)

    def details(self, id):
        """Returns details for a specific access group

        :param id: The id of the access group
        :raise TenableIOApiException:  When API error is encountered.
        :return: An instance of :class:`tenable_io.api.models.AccessGroup`.
        """
        response = self._client.get('access-groups/%(id)s', path_params={'id': id})

# Path: tenable_io/api/base.py
# class BaseApi(object):
# 
#     def __init__(self, client):
#         self._client = client
# 
# Path: tenable_io/api/base.py
# class BaseRequest(object):
# 
#     def as_payload(self, filter_=None):
#         return payload_filter(self.__dict__, filter_)
# 
# Path: tenable_io/api/models.py
# class AccessGroup(BaseModel):
# 
#     def __init__(
#             self,
#             container_uuid=None,
#             created_at=None,
#             updated_at=None,
#             id=None,
#             name=None,
#             all_assets=None,
#             all_users=None,
#             status=None,
#             rules=None,
#             principals=None,
#             version=None,
#             created_by_uuid=None,
#             updated_by_uuid=None,
#             updated_by_name=None,
#             created_by_name=None,
#             processing_percent_complete=None
#     ):
#         self._rules = None
#         self._principals = None
#         self.container_uuid = container_uuid
#         self.created_at = created_at
#         self.updated_at = updated_at
#         self.id = id
#         self.name = name
#         self.all_assets = all_assets
#         self.all_users = all_users
#         self.status = status
#         self.rules = rules
#         self.principals = principals
#         self.version = version
#         self.created_by_uuid = created_by_uuid
#         self.updated_by_uuid = updated_by_uuid
#         self.updated_by_name = updated_by_name
#         self.created_by_name = created_by_name
#         self.processing_percent_complete = processing_percent_complete
# 
#     @property
#     def rules(self):
#         return self._rules
# 
#     @rules.setter
#     @BaseModel._model_list(AssetRule)
#     def rules(self, rules):
#         self._rules = rules
# 
#     @property
#     def principals(self):
#         return self._principals
# 
#     @principals.setter
#     @BaseModel._model_list(AssetRulePrincipal)
#     def principals(self, principals):
#         self._principals = principals
# 
# class AccessGroupList(BaseModel):
# 
#     def __init__(
#             self,
#             access_groups=None,
#             pagination=None
#     ):
#         self._access_groups = None
#         self._pagination = None
#         self.access_groups = access_groups
#         self.pagination = pagination
# 
#     @property
#     def access_groups(self):
#         return self._access_groups
# 
#     @access_groups.setter
#     @BaseModel._model_list(AccessGroup)
#     def access_groups(self, access_groups):
#         self._access_groups = access_groups
# 
#     @property
#     def pagination(self):
#         return self._pagination
# 
#     @pagination.setter
#     @BaseModel._model(FilterPagination)
#     def pagination(self, pagination):
#         self._pagination = pagination
# 
# class AssetRule(BaseModel):
# 
#     def __init__(
#             self,
#             type=None,
#             operator=None,
#             terms=None
#     ):
#         self.type = type
#         self.operator = operator
#         self.terms = terms
# 
# class AssetRuleFilter(Filter):
# 
#     def __init__(
#             self,
#             placeholder=None,
#     ):
#         self.placeholder = placeholder
# 
# class AssetRulePrincipal(BaseModel):
# 
#     def __init__(
#             self,
#             type=None,
#             principal_id=None,
#             principal_name=None
#     ):
#         self.type = type
#         self.principal_id = principal_id
#         self.principal_name = principal_name
# 
# class Filters(BaseModel):
# 
#     def __init__(
#             self,
#             filters=None,
#             sort=None,
#             wildcard_fields=None
#     ):
#         self._filters = None
#         self.filters = filters
#         self.sort = sort
#         self.wildcard_fields = wildcard_fields
# 
#     @property
#     def filters(self):
#         return self._filters
# 
#     @filters.setter
#     @BaseModel._model_list(Filter)
#     def filters(self, filters):
#         self._filters = filters


# Path: tenable_io/api/access_groups.py
from json import loads
from tenable_io.api.base import BaseApi
from tenable_io.api.base import BaseRequest
from tenable_io.api.models import AccessGroup, AccessGroupList, AssetRule, AssetRuleFilter, AssetRulePrincipal, Filters

        :param sort: A list of fields on which the results are sorted.
        :raise TenableIOApiException:  When API error is encountered.
        :return: An instance of :class:`tenable_io.api.models.AccessGroupList`.
        """
        fgen = (i.field + ':' + i.operator + ':' + i.value for i in f) if f is not None else None
        response = self._client.get('access-groups',
                                    params={'f': '&'.join(fgen) if fgen is not None else None,
                                            'ft': ft, 'w': w, 'wf': ','.join(wf) if wf is not None else None,
                                            'limit': limit, 'offset': offset,
                                            'sort': ','.join(sort) if sort is not None else None})
        return AccessGroupList.from_json(response.text)

    def create(self, access_group_request):
        """Create a new access group.

        :param Access_group_request: An instance of :class:`AccessGroupRequest`.
        :raise TenableIOApiException:  When API error is encountered.
        :return: An instance of :class:`tenable_io.api.models.AccessGroup` without the rules information.
        """
        response = self._client.post('access-groups', access_group_request)
        return AccessGroup.from_json(response.text)

    def details(self, id):
        """Returns details for a specific access group

        :param id: The id of the access group
        :raise TenableIOApiException:  When API error is encountered.
        :return: An instance of :class:`tenable_io.api.models.AccessGroup`.
        """
        response = self._client.get('access-groups/%(id)s', path_params={'id': id})

        return AccessGroup.from_json(response.text)