# Path: tenable_io/api/base.py
# class BaseApi(object):
# 
#     def __init__(self, client):
#         self._client = client
# 
# class BaseRequest(object):
# 
#     def as_payload(self, filter_=None):
#         return payload_filter(self.__dict__, filter_)
# 
# Path: tenable_io/api/models.py
# class TargetGroup:
#     # Target Group Permissions
#     PERMISSION_NO_ACCESS = 0
#     PERMISSION_CAN_VIEW = 32
#     PERMISSION_CAN_SCAN = 64
# 
# class TargetGroupList(BaseModel):
# 
#     def __init__(
#             self,
#             target_groups=None,
#     ):
#         self._target_groups = None
#         self.target_groups = target_groups
# 
#     @property
#     def target_groups(self):
#         return self._target_groups
# 
#     @target_groups.setter
#     @BaseModel._model_list(TargetGroup)
#     def target_groups(self, target_groups):
#         self._target_groups = target_groups


from tenable_io.api.base import BaseApi, BaseRequest
from tenable_io.api.models import TargetGroup, TargetGroupList
class TargetGroupsApi(BaseApi):

    def create(self, target_group_create):
        """Create a new target group.

        :param target_group_create: An instance of :class:`TargetGroupCreateRequest`.
        :raise TenableIOApiException:  When API error is encountered.
        :return: An instance of :class:`tenable_io.api.models.TargetGroup`.
        """
        response = self._client.post('target-groups', target_group_create)
        return TargetGroup.from_json(response.text)

    def delete(self, group_id):
        """Delete a target group.

        :param group_id: The group ID.
        :raise TenableIOApiException:  When API error is encountered.
        :return: True if successful
        """
        self._client.delete('target-groups/%(group_id)s', {'group_id': group_id})
        return True

    def details(self, group_id):
        """Return details of the target group.

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

# Path: tenable_io/api/base.py
# class BaseApi(object):
# 
#     def __init__(self, client):
#         self._client = client
# 
# class BaseRequest(object):
# 
#     def as_payload(self, filter_=None):
#         return payload_filter(self.__dict__, filter_)
# 
# Path: tenable_io/api/models.py
# class TargetGroup:
#     # Target Group Permissions
#     PERMISSION_NO_ACCESS = 0
#     PERMISSION_CAN_VIEW = 32
#     PERMISSION_CAN_SCAN = 64
# 
# class TargetGroupList(BaseModel):
# 
#     def __init__(
#             self,
#             target_groups=None,
#     ):
#         self._target_groups = None
#         self.target_groups = target_groups
# 
#     @property
#     def target_groups(self):
#         return self._target_groups
# 
#     @target_groups.setter
#     @BaseModel._model_list(TargetGroup)
#     def target_groups(self, target_groups):
#         self._target_groups = target_groups


# Path: tenable_io/api/target_groups.py
from tenable_io.api.base import BaseApi, BaseRequest
from tenable_io.api.models import TargetGroup, TargetGroupList

class TargetGroupsApi(BaseApi):

    def create(self, target_group_create):
        """Create a new target group.

        :param target_group_create: An instance of :class:`TargetGroupCreateRequest`.
        :raise TenableIOApiException:  When API error is encountered.
        :return: An instance of :class:`tenable_io.api.models.TargetGroup`.
        """
        response = self._client.post('target-groups', target_group_create)
        return TargetGroup.from_json(response.text)

    def delete(self, group_id):
        """Delete a target group.

        :param group_id: The group ID.
        :raise TenableIOApiException:  When API error is encountered.
        :return: True if successful
        """
        self._client.delete('target-groups/%(group_id)s', {'group_id': group_id})
        return True

    def details(self, group_id):
        """Return details of the target group.

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

        return TargetGroup.from_json(response.text)