Skip to content

Commit

Permalink
CSS cluster query parameters (#240)
Browse files Browse the repository at this point in the history
CSS cluster query parameters

add query mapping
add query for clusters method

Depends-On: opentelekomcloud-infra/otc-zuul-jobs#87

Reviewed-by: None <None>
Reviewed-by: Anton Sidelnikov <None>
Reviewed-by: Artem Goncharov <[email protected]>
  • Loading branch information
YustinaKvr authored Oct 21, 2021
1 parent 6070e61 commit 83db556
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
4 changes: 2 additions & 2 deletions otcextensions/sdk/css/v1/_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ def __init__(self, session, *args, **kwargs):
"Content-type": "application/json"}

# ======== Cluster ========
def clusters(self):
def clusters(self, **query):
"""List all Clusters.
:returns: a generator of
(:class:`~otcextensions.sdk.css.v1.cluster.Cluster`) instances
"""
return self._list(_cluster.Cluster)
return self._list(_cluster.Cluster, **query)

def get_cluster(self, cluster):
"""Get the cluster by UUID
Expand Down
3 changes: 3 additions & 0 deletions otcextensions/sdk/css/v1/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ class Cluster(resource.Resource):
allow_fetch = True
allow_patch = True

_query_mapping = resource.QueryParameters(
'id', 'start', 'limit')

# Properties
#: Current actions
actions = resource.Body('actions', type=list)
Expand Down
5 changes: 5 additions & 0 deletions otcextensions/tests/unit/sdk/css/v1/test_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ def test_basic(self):
self.assertTrue(sot.allow_create)
self.assertTrue(sot.allow_delete)
self.assertTrue(sot.allow_commit)
self.assertDictEqual({'id': 'id',
'start': 'start',
'limit': 'limit',
'marker': 'marker'},
sot._query_mapping._mapping)

def test_make_it(self):
sot = cluster.Cluster(**EXAMPLE)
Expand Down
15 changes: 14 additions & 1 deletion otcextensions/tests/unit/sdk/css/v1/test_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,20 @@ def setUp(self):
)

def test_clusters(self):
self.verify_list(self.proxy.clusters, _cluster.Cluster)
self.verify_list(
self.proxy.clusters,
_cluster.Cluster,
method_kwargs={
'id': 'foo',
'start': 999,
'limit': 666
},
expected_kwargs={
'id': 'foo',
'start': 999,
'limit': 666
}
)

def test_get_cluster(self):
self.verify_get(self.proxy.get_cluster, _cluster.Cluster)
Expand Down

0 comments on commit 83db556

Please sign in to comment.