blob: f045bb7398a209adfa57b5be0a76824c63cb1e20 [file] [log] [blame]
Sean Dague556add52013-07-19 14:28:44 -04001# 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
Matthew Treinish21905512015-07-13 10:33:35 -040013from oslo_serialization import jsonutils as json
chris fattarsi8ed39ac2012-04-30 14:11:27 -070014
Ken'ichi Ohmichi0e836652015-01-08 04:38:56 +000015from tempest.common import service_client
Matthew Treinish684d8992014-01-30 16:27:40 +000016
chris fattarsi8ed39ac2012-04-30 14:11:27 -070017
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +000018class IdentityClient(service_client.ServiceClient):
Ralf Haferkampd5525e32015-06-19 17:17:47 +020019 api_version = "v2.0"
chris fattarsi8ed39ac2012-04-30 14:11:27 -070020
Ken'ichi Ohmichi402b8752015-11-09 10:47:16 +000021 def show_api_description(self):
Filip Hubík81354052015-03-09 19:04:23 +010022 """Retrieves info about the v2.0 Identity API"""
23 url = ''
24 resp, body = self.get(url)
25 self.expected_success([200, 203], resp.status)
Anusha Ramineni0cfb4612015-08-24 08:49:10 +053026 body = json.loads(body)
27 return service_client.ResponseBody(resp, body)
Filip Hubík81354052015-03-09 19:04:23 +010028
Ken'ichi Ohmichi402b8752015-11-09 10:47:16 +000029 def show_token(self, token_id):
Zhi Kun Liu30caeae2014-02-26 15:30:24 +080030 """Get token details."""
31 resp, body = self.get("tokens/%s" % token_id)
David Kranze9d2f422014-07-02 13:57:41 -040032 self.expected_success(200, resp.status)
Anusha Ramineni0cfb4612015-08-24 08:49:10 +053033 body = json.loads(body)
34 return service_client.ResponseBody(resp, body)
Zhi Kun Liu30caeae2014-02-26 15:30:24 +080035
Rohit Karajgi6b1e1542012-05-14 05:55:54 -070036 def delete_token(self, token_id):
Sean Daguef237ccb2013-01-04 15:19:14 -050037 """Delete a token."""
David Kranze9d2f422014-07-02 13:57:41 -040038 resp, body = self.delete("tokens/%s" % token_id)
39 self.expected_success(204, resp.status)
Ken'ichi Ohmichia6ac2422015-01-13 01:09:39 +000040 return service_client.ResponseBody(resp, body)
Rohit Karajgi6b1e1542012-05-14 05:55:54 -070041
Abhijeet.Jain3f49b842014-05-20 12:06:20 +053042 def list_extensions(self):
43 """List all the extensions."""
44 resp, body = self.get('/extensions')
David Kranze9d2f422014-07-02 13:57:41 -040045 self.expected_success(200, resp.status)
Abhijeet.Jain3f49b842014-05-20 12:06:20 +053046 body = json.loads(body)
Anusha Ramineni0cfb4612015-08-24 08:49:10 +053047 return service_client.ResponseBody(resp, body)