diff --git a/releasenotes/notes/add-instance-detailed-list-23dc77ed898cc6db.yaml b/releasenotes/notes/add-instance-detailed-list-23dc77ed898cc6db.yaml new file mode 100644 index 00000000..96b5ad56 --- /dev/null +++ b/releasenotes/notes/add-instance-detailed-list-23dc77ed898cc6db.yaml @@ -0,0 +1,7 @@ +--- +features: + - | + Added ``detailed`` option to instances client in ``instances.list`` + command. Now, detailed instance list can be obtained by setting + ``detailed`` parameter to ``True``. Trove will then include more details + in the API response. diff --git a/troveclient/tests/test_instances.py b/troveclient/tests/test_instances.py index b65583d6..2f21cace 100644 --- a/troveclient/tests/test_instances.py +++ b/troveclient/tests/test_instances.py @@ -124,6 +124,16 @@ class InstancesTest(testtools.TestCase): page_mock.assert_called_with("/instances", "instances", limit, marker, include_clustered) + def test_detailed_list(self): + page_mock = mock.Mock() + self.instances._paginated = page_mock + limit = "test-limit" + marker = "test-marker" + include_clustered = {'include_clustered': False} + self.instances.list(limit, marker, detailed=True) + page_mock.assert_called_with("/instances/detail", "instances", limit, + marker, include_clustered) + def test_get(self): def side_effect_func(path, inst): return path, inst diff --git a/troveclient/v1/instances.py b/troveclient/v1/instances.py index 04eb05a6..eb5aec85 100644 --- a/troveclient/v1/instances.py +++ b/troveclient/v1/instances.py @@ -179,12 +179,15 @@ class Instances(base.ManagerWithFind): resp, body = self.api.client.patch(url, body=body) common.check_for_exceptions(resp, body, url) - def list(self, limit=None, marker=None, include_clustered=False): + def list(self, limit=None, marker=None, include_clustered=False, + detailed=False): """Get a list of all instances. :rtype: list of :class:`Instance`. """ - return self._paginated("/instances", "instances", limit, marker, + detail = "/detail" if detailed else "" + url = "/instances%s" % detail + return self._paginated(url, "instances", limit, marker, {"include_clustered": include_clustered}) def get(self, instance):