Repository: tenable/pyTenable

Issue:
Tenable.io Agent Groups List
**Is your feature request related to a problem? Please describe.**
The Agent Groups API Object does not have a function to list all the agent groups in a container. 

**Describe the solution you'd like**
A new function to be added which returns the Agent Groups as a list of dictionaries covering this endpoint: https://cloud.tenable.com/api#/resources/agent-groups/list

**Describe alternatives you've considered**
Easy to write your own but it's a function that should exist in the library


Discussion:

Patch:
diff --git a/tenable/io/agent_groups.py b/tenable/io/agent_groups.py
index 90ddb67..dadc019 100644
--- a/tenable/io/agent_groups.py
+++ b/tenable/io/agent_groups.py
@@ -201,6 +201,25 @@ class AgentGroupsAPI(TIOEndpoint):
                 self._check('group_id', group_id, int)
             )).json()
 
+    def list(self, scanner_id=1):
+        '''
+        Retrieves the list of agent groups configured
+
+        Args:
+            scanner_id (int, optional): The id of the scanner
+
+        Returns:
+             list: Listing of agent group resource records
+
+        Examples:
+            >>>> for agent_group in tio.agent_groups.list():
+            ...     pprint(agent_group)
+
+        '''
+
+        return self._api.get('scanners/{}/agent-groups'.format(self._check('scanner_id',
+                                                                           scanner_id, int))).json()['groups']
+
     def task_status(self, group_id, task_uuid, scanner_id=1):
         '''
         Retrieves the current status of a bulk task.
diff --git a/tenable/sc/base.py b/tenable/sc/base.py
index 7d07cfb..8fd44c0 100644
--- a/tenable/sc/base.py
+++ b/tenable/sc/base.py
@@ -137,7 +137,7 @@ class SCEndpoint(APIEndpoint):
         '''
         self._check('schedule:item', item, dict)
         resp = {'type': self._check('schedule:type', item['type'], str, 
-            choices=['ical', 'dependent', 'never', 'rollover', 'template', 'now'],
+            choices=['ical', 'dependent', 'never', 'rollover', 'template'],
             default='never')}
         
         if resp['type'] == 'ical' and 'start' in item and 'repeatRule' in item:


Test patch:
diff --git a/tests/io/cassettes/test_agentgroups_list.yaml b/tests/io/cassettes/test_agentgroups_list.yaml
new file mode 100644
index 0000000..c5643da
--- /dev/null
+++ b/tests/io/cassettes/test_agentgroups_list.yaml
@@ -0,0 +1,58 @@
+interactions:
+- request:
+    body: null
+    headers:
+      Accept:
+      - '*/*'
+      Accept-Encoding:
+      - gzip, deflate
+      Connection:
+      - keep-alive
+      User-Agent:
+      - pyTenable/0.3.15 (pyTenable/0.3.15; Python/3.6.7)
+      X-APIKeys:
+      - accessKey=TIO_ACCESS_KEY;secretKey=TIO_SECRET_KEY
+    method: GET
+    uri: https://cloud.tenable.com/scanners/1/agent-groups
+  response:
+    body:
+      string: !!binary |
+        H4sIAAAAAAAAA9WTyWrDMBRF/0VrP9A85FdKMRpTQ2wHS6aUkH+vXJu0aROybZa6um/Q4eqE9tM4
+        HzPavZxQF9COYIqxadA8LyeEmTI8YAFeJQ1cUgU2MQvUS86SEIQKhho02D5Wd4m5kHr0U7SlG4c2
+        2FJ1IhglRBld+x5sLm0/hi51/p6ndH1tZPvjtZzf7BSXFRs0vg9xqgPzRy6xR5vQdj9u222nX5bt
+        XYy7KLmgEDhxwHWKYAx14D1jKWLPtcK1Zs615Binvsu57loxEaobZPdxKLn14zwUtKPn5psdIRd2
+        GmsXRXRArLPAhZLgpDd1ZJCYGxmkodfs2D12GmP9iN3q+cNulZ+DHb6w44Fbp3QEioOpuYsBrFUG
+        kjOe08RJ0O6aHb2fO/OQ3eq5kTvzNOzohZ1UWju//FRpGHCVHLgkODAXSP2xjMmvGdue9nBo1773
+        w8fU4/AtnhvhW+T/CpCdX8+fAFMsNAEFAAA=
+    headers:
+      Cache-Control:
+      - no-cache
+      Connection:
+      - keep-alive
+      Content-Encoding:
+      - gzip
+      Content-Type:
+      - application/json; charset=utf-8
+      Date:
+      - Thu, 04 Apr 2019 15:27:54 GMT
+      Server:
+      - tenable.io
+      Set-Cookie:
+      - nginx-cloud-site-id=us-2b; path=/; HttpOnly
+      - nginx-cloud-site-id=us-2b; path=/; HttpOnly
+      Strict-Transport-Security:
+      - max-age=63072000; includeSubDomains
+      Transfer-Encoding:
+      - chunked
+      Vary:
+      - accept-encoding
+      X-Content-Type-Options:
+      - nosniff
+      X-Gateway-Site-ID:
+      - nginx-router-a-prod-us-east-2
+      X-Request-Uuid:
+      - 94d6ec2f165f7118d799b52ca25994c8
+    status:
+      code: 200
+      message: OK
+version: 1
diff --git a/tests/io/test_agent_groups.py b/tests/io/test_agent_groups.py
index 13e0ccf..43bdb8c 100644
--- a/tests/io/test_agent_groups.py
+++ b/tests/io/test_agent_groups.py
@@ -238,4 +238,27 @@ def test_agentgroups_task_status(api, agentgroup):
     check(task, 'last_update_time', int)
     check(task, 'start_time', int)
     check(task, 'status', str)
-    check(task, 'task_id', str)
\ No newline at end of file
+    check(task, 'task_id', str)
+
+@pytest.mark.vcr()
+def test_agentgroups_list(api):
+    assert isinstance(api.agent_groups.list(), list)
+
+@pytest.mark.vcr()
+def test_agentgroups_list_response(api):
+    agentgroups = api.agent_groups.list()
+    assert isinstance(agentgroups, list)
+    for ag in agentgroups:
+        # check(ag, 'agents', list)
+        check(ag, 'creation_date', int)
+        check(ag, 'id', int)
+        check(ag, 'last_modification_date', int)
+        check(ag, 'name', str)
+        check(ag, 'owner', str)
+        check(ag, 'owner_id', int)
+        check(ag, 'owner_name', str)
+        check(ag, 'owner_uuid', str)
+        # check(ag, 'pagination', dict)
+        check(ag, 'shared', int)
+        check(ag, 'user_permissions', int)
+        check(ag, 'uuid', str)