Repository: duosecurity/duo_client_python

Issue:
Retrieve Endpoint by ID
Would be great if there was a function in the admin client that covered this endpoint.

`/admin/v1/endpoints/[epkey]`

Discussion:

Patch:
diff --git a/.github/workflows/python-ci.yml b/.github/workflows/python-ci.yml
index 4b666cd..d61eb4f 100644
--- a/.github/workflows/python-ci.yml
+++ b/.github/workflows/python-ci.yml
@@ -7,7 +7,7 @@ jobs:
 
     strategy:
       matrix:
-        python-version: [2.7, 3.5, 3.6, 3.7, 3.8]
+        python-version: [2.7, 3.5, 3.6, 3.7, 3.8, 3.9]
 
     steps:
       - uses: actions/checkout@v2
diff --git a/duo_client/admin.py b/duo_client/admin.py
index b9d68e6..57a144d 100644
--- a/duo_client/admin.py
+++ b/duo_client/admin.py
@@ -1058,6 +1058,21 @@ class Admin(client.Client):
         params = {}
         return self.json_api_call('DELETE', path, params)
 
+    def get_endpoint(self, epkey):
+        """
+        Get a single endpoint from the AdminAPI by a supplied epkey.
+
+        Params:
+            epkey (str) - The supplied endpoint key to fetch.
+
+        Returns: The endpoint object represented as a dict.
+        Raises:
+            RuntimeError: if the request returns a non-200 status response.
+        """
+        escaped_epkey = six.moves.urllib.parse.quote_plus(str(epkey))
+        path = '/admin/v1/endpoints/' + escaped_epkey
+        return self.json_api_call('GET', path, {})
+
     def get_endpoints_iterator(self):
         """
         Returns iterator of endpoints objects.


Test patch:
diff --git a/tests/admin/test_endpoints.py b/tests/admin/test_endpoints.py
index 8f19861..8a04170 100644
--- a/tests/admin/test_endpoints.py
+++ b/tests/admin/test_endpoints.py
@@ -80,6 +80,19 @@ class TestEndpoints(TestAdmin):
                 'offset': ['20'],
             })
 
+    def test_get_endpoint(self):
+        """ Test getting a single endpoint.
+        """
+        epkey = 'EP18JX1A10AB102M2T2X'
+        response = self.client_list.get_endpoint(epkey)[0]
+        (uri, args) = response['uri'].split('?')
+        self.assertEqual(response['method'], 'GET')
+        self.assertEqual(uri, '/admin/v1/endpoints/' + epkey)
+        self.assertEqual(
+            util.params_to_dict(args),
+            {
+                'account_id': [self.client.account_id],
+            })
 
 if __name__ == '__main__':
     unittest.main()