blob: 3dbfe5e846b04611fb740b063b09f71993a139e3 [file] [log] [blame]
harika-vakadia92dd742013-02-19 20:41:22 +05301# Copyright 2013 OpenStack Foundation
2# All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
15
Yaroslav Lobankov61db2d92015-11-11 16:51:23 +030016"""
17http://developer.openstack.org/api-ref-identity-v3.html#service-catalog-v3
18"""
19
Matthew Treinish21905512015-07-13 10:33:35 -040020from oslo_serialization import jsonutils as json
harika-vakadia92dd742013-02-19 20:41:22 +053021
Ken'ichi Ohmichia6ac2422015-01-13 01:09:39 +000022from tempest.common import service_client
harika-vakadia92dd742013-02-19 20:41:22 +053023
24
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +000025class ServiceClient(service_client.ServiceClient):
ghanshyamd26b5cd2015-02-09 14:48:58 +090026 api_version = "v3"
harika-vakadia92dd742013-02-19 20:41:22 +053027
28 def update_service(self, service_id, **kwargs):
Yaroslav Lobankov61db2d92015-11-11 16:51:23 +030029 """Updates a service.
30
31 Available params: see http://developer.openstack.org/
32 api-ref-identity-v3.html#updateService
33 """
34 patch_body = json.dumps({'service': kwargs})
Valeriy Ponomaryov88686d82014-02-16 12:24:51 +020035 resp, body = self.patch('services/%s' % service_id, patch_body)
David Kranze9d2f422014-07-02 13:57:41 -040036 self.expected_success(200, resp.status)
harika-vakadia92dd742013-02-19 20:41:22 +053037 body = json.loads(body)
John Warrenf96750d2015-08-13 13:44:59 +000038 return service_client.ResponseBody(resp, body)
harika-vakadia92dd742013-02-19 20:41:22 +053039
Ken'ichi Ohmichi402b8752015-11-09 10:47:16 +000040 def show_service(self, service_id):
harika-vakadia92dd742013-02-19 20:41:22 +053041 """Get Service."""
42 url = 'services/%s' % service_id
43 resp, body = self.get(url)
David Kranze9d2f422014-07-02 13:57:41 -040044 self.expected_success(200, resp.status)
harika-vakadia92dd742013-02-19 20:41:22 +053045 body = json.loads(body)
John Warrenf96750d2015-08-13 13:44:59 +000046 return service_client.ResponseBody(resp, body)
Matthew Treinishdb2c5972014-01-31 22:18:59 +000047
Yaroslav Lobankov61db2d92015-11-11 16:51:23 +030048 def create_service(self, **kwargs):
49 """Creates a service.
50
51 Available params: see http://developer.openstack.org/
52 api-ref-identity-v3.html#createService
53 """
54 body = json.dumps({'service': kwargs})
vponomaryovf4c27f92014-02-18 10:56:42 +020055 resp, body = self.post("services", body)
David Kranze9d2f422014-07-02 13:57:41 -040056 self.expected_success(201, resp.status)
Matthew Treinishdb2c5972014-01-31 22:18:59 +000057 body = json.loads(body)
John Warrenf96750d2015-08-13 13:44:59 +000058 return service_client.ResponseBody(resp, body)
Matthew Treinishdb2c5972014-01-31 22:18:59 +000059
60 def delete_service(self, serv_id):
61 url = "services/" + serv_id
vponomaryovf4c27f92014-02-18 10:56:42 +020062 resp, body = self.delete(url)
David Kranze9d2f422014-07-02 13:57:41 -040063 self.expected_success(204, resp.status)
Ken'ichi Ohmichia6ac2422015-01-13 01:09:39 +000064 return service_client.ResponseBody(resp, body)
nayna-patel54b0fb52014-04-25 13:19:16 +000065
66 def list_services(self):
67 resp, body = self.get('services')
68 self.expected_success(200, resp.status)
69 body = json.loads(body)
John Warrenf96750d2015-08-13 13:44:59 +000070 return service_client.ResponseBody(resp, body)