Debian Codegraph @

magnum_tempest_plugin/tests/api/v1/clients/magnum_service_client.py

raw
1 # Licensed under the Apache License, Version 2.0 (the "License"); you may
2 # not use this file except in compliance with the License. You may obtain
3 # a copy of the License at
4 #
5 # http://www.apache.org/licenses/LICENSE-2.0
6 #
7 # Unless required by applicable law or agreed to in writing, software
8 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10 # License for the specific language governing permissions and limitations
11 # under the License.
12
13 from magnum_tempest_plugin.common import client
14 from magnum_tempest_plugin.tests.api.v1.models import magnum_service_model
15
16
17 class MagnumServiceClient(client.MagnumClient):
18 """Encapsulates REST calls and maps JSON to/from models"""
19
20 @classmethod
21 def magnum_service_uri(cls, filters=None):
22 """Construct magnum services uri with optional filters
23
24 :param filters: Optional k:v dict that's converted to url query
25 :returns: url string
26 """
27
28 url = "/mservices"
29 if filters:
30 url = cls.add_filters(url, filters)
31 return url
32
33 def magnum_service_list(self, filters=None, **kwargs):
34 """Makes GET /mservices request and returns MagnumServiceCollection
35
36 Abstracts REST call to return all magnum services.
37
38 :param filters: Optional k:v dict that's converted to url query
39 :returns: response object and MagnumServiceCollection object
40 """
41
42 resp, body = self.get(self.magnum_service_uri(filters), **kwargs)
43 return self.deserialize(resp, body,
44 magnum_service_model.MagnumServiceCollection)