# 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 AgentConfig(BaseModel):
# 
#     def __init__(
#             self,
#             auto_unlink=None,
#             software_update=None
#     ):
#         self.auto_unlink = auto_unlink
#         self.software_update = software_update


from tenable_io.api.base import BaseApi, BaseRequest
from tenable_io.api.models import AgentConfig


class AgentConfigApi(BaseApi):

    def edit(self, agent_config, scanner_id=1):
        """Edit an agent config.

        :param agent_config: The agent config request.
        :param scanner_id: The scanner ID.
        :raise TenableIOApiException: When API error is encountered.
        :return: An instance of :class:`tenable_io.api.models.AgentConfig`.
        """
        assert isinstance(agent_config, AgentConfigRequest)
        response = self._client.put('scanners/%(scanner_id)s/agents/config', agent_config,
                                    path_params={
                                        'scanner_id': scanner_id
                                    })
        return AgentConfig.from_json(response.text)

    def details(self, scanner_id=1):
        """Get details of an agent config.

        :param scanner_id: The scanner ID.
        :raise TenableIOApiException: When API error is encountered.
        :return: An instance of :class:`tenable_io.api.models.AgentConfig`.
        """
        response = self._client.get('scanners/%(scanner_id)s/agents/config',
                                    path_params={
                                        'scanner_id': scanner_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 AgentConfig(BaseModel):
# 
#     def __init__(
#             self,
#             auto_unlink=None,
#             software_update=None
#     ):
#         self.auto_unlink = auto_unlink
#         self.software_update = software_update


# Path: tenable_io/api/agent_config.py
from tenable_io.api.base import BaseApi, BaseRequest
from tenable_io.api.models import AgentConfig



class AgentConfigApi(BaseApi):

    def edit(self, agent_config, scanner_id=1):
        """Edit an agent config.

        :param agent_config: The agent config request.
        :param scanner_id: The scanner ID.
        :raise TenableIOApiException: When API error is encountered.
        :return: An instance of :class:`tenable_io.api.models.AgentConfig`.
        """
        assert isinstance(agent_config, AgentConfigRequest)
        response = self._client.put('scanners/%(scanner_id)s/agents/config', agent_config,
                                    path_params={
                                        'scanner_id': scanner_id
                                    })
        return AgentConfig.from_json(response.text)

    def details(self, scanner_id=1):
        """Get details of an agent config.

        :param scanner_id: The scanner ID.
        :raise TenableIOApiException: When API error is encountered.
        :return: An instance of :class:`tenable_io.api.models.AgentConfig`.
        """
        response = self._client.get('scanners/%(scanner_id)s/agents/config',
                                    path_params={
                                        'scanner_id': scanner_id
                                    })

        return AgentConfig.from_json(response.text)