# Path: tenable_io/api/agent_config.py
# class AgentConfigRequest(BaseRequest):
# 
#     def __init__(
#             self,
#             software_update=None,
#             auto_unlink=None
#     ):
#         """Request for AgentConfigApi.edit.
# 
#         :param software_update: If True, software updates are enabled for agents pursuant to any agent exclusions that
#             are in effect. If False, software updates are disabled for all agents, even if no agent exclusions are in
#             effect.
#         :type software_update: bool
#         :param auto_unlink.enabled: If True, agent auto-unlink is enabled. Enabling auto-unlink causes it to take
#             effect against all agents retroactively. This configuration value is only available if Agent Enhancements
#             are enabled for your account.
#         :type auto_unlink.enabled: bool
#         :param auto_unlink.expiration: The expiration time for agents, in days. If an agent has not communicated in this
#             number of days, it will be considered 'expired' and auto-unlinked if auto_unlink.enabled is True. Valid
#             values are 1-365. This configuration value is only available if Agent Enhancements are enabled for your
#             account.
#         :type auto_unlink.expiration: int
#         """
#         self.software_update = software_update
#         self.auto_unlink = auto_unlink
# 
# 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


import pytest
from tenable_io.api.agent_config import AgentConfigRequest
from tenable_io.api.models import AgentConfig


@pytest.mark.vcr()
def test_agent_config_get_details(client):
    config = client.agent_config_api.details()
    assert isinstance(config, AgentConfig), u'The `details` method did not return type `AgentConfig`.'


@pytest.mark.vcr()
def test_agent_config_edit(client):
    config = client.agent_config_api.details()
    assert isinstance(config, AgentConfig), u'The `details` method did not return type `AgentConfig`.'

    # Edit agent config to new value.
    previous_expiration = config.auto_unlink['expiration']
    new_expiration = 10 if config.auto_unlink['expiration'] >= 365 else config.auto_unlink['expiration'] + 1

    edit_config = client.agent_config_api.edit(AgentConfigRequest(
        software_update=not config.software_update,
        auto_unlink={
            'enabled': not config.auto_unlink['enabled'],
            'expiration': new_expiration
        }
    ))

# Path: tenable_io/api/agent_config.py
# class AgentConfigRequest(BaseRequest):
# 
#     def __init__(
#             self,
#             software_update=None,
#             auto_unlink=None
#     ):
#         """Request for AgentConfigApi.edit.
# 
#         :param software_update: If True, software updates are enabled for agents pursuant to any agent exclusions that
#             are in effect. If False, software updates are disabled for all agents, even if no agent exclusions are in
#             effect.
#         :type software_update: bool
#         :param auto_unlink.enabled: If True, agent auto-unlink is enabled. Enabling auto-unlink causes it to take
#             effect against all agents retroactively. This configuration value is only available if Agent Enhancements
#             are enabled for your account.
#         :type auto_unlink.enabled: bool
#         :param auto_unlink.expiration: The expiration time for agents, in days. If an agent has not communicated in this
#             number of days, it will be considered 'expired' and auto-unlinked if auto_unlink.enabled is True. Valid
#             values are 1-365. This configuration value is only available if Agent Enhancements are enabled for your
#             account.
#         :type auto_unlink.expiration: int
#         """
#         self.software_update = software_update
#         self.auto_unlink = auto_unlink
# 
# 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: tests/integration/api/test_agent_config.py
import pytest
from tenable_io.api.agent_config import AgentConfigRequest
from tenable_io.api.models import AgentConfig



@pytest.mark.vcr()
def test_agent_config_get_details(client):
    config = client.agent_config_api.details()
    assert isinstance(config, AgentConfig), u'The `details` method did not return type `AgentConfig`.'


@pytest.mark.vcr()
def test_agent_config_edit(client):
    config = client.agent_config_api.details()
    assert isinstance(config, AgentConfig), u'The `details` method did not return type `AgentConfig`.'

    # Edit agent config to new value.
    previous_expiration = config.auto_unlink['expiration']
    new_expiration = 10 if config.auto_unlink['expiration'] >= 365 else config.auto_unlink['expiration'] + 1

    edit_config = client.agent_config_api.edit(AgentConfigRequest(
        software_update=not config.software_update,
        auto_unlink={
            'enabled': not config.auto_unlink['enabled'],
            'expiration': new_expiration
        }
    ))

    assert isinstance(edit_config, AgentConfig), u'The `edit` method did not return type `AgentConfig`.'