Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions tenable/io/agent_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,15 @@ def delete_agent(self, group_id, *agent_ids, **kw):
json={'items': [self._check('agent_ids', i, int) for i in agent_ids]},
).json()

def delete_agents(self, group_id, *agent_ids, **kw):
"""
Delete one or many agents from an agent group.

This plural alias matches the naming used by the other agent-group
operations while preserving the existing :meth:`delete_agent` API.
"""
return self.delete_agent(group_id, *agent_ids, **kw)

def details(self, group_id, *filters, **kw):
"""
Retrieve the details about the specified agent group.
Expand Down
13 changes: 13 additions & 0 deletions tests/io/test_agent_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
'''
import time
import uuid
from unittest.mock import patch

import pytest

Expand Down Expand Up @@ -259,6 +260,18 @@ def test_agentgroups_delete_agent_from_group_scanner_id_typeerror(api):
api.agent_groups.delete_agent(1, 1, scanner_id='nope')


def test_agentgroups_delete_agents_alias(api):
"""
The plural spelling should preserve the existing delete-agent behavior.
"""
agent_groups = api.agent_groups
with patch.object(agent_groups, 'delete_agent', return_value={'task_id': 'task'}) as delete_agent:
result = agent_groups.delete_agents(42, 10, 11, scanner_id=7)

assert result == {'task_id': 'task'}
delete_agent.assert_called_once_with(42, 10, 11, scanner_id=7)


@pytest.mark.vcr()
def test_agentgroups_delete_agent_from_group_notfounderror(api):
'''
Expand Down