blob: db3050819051a89991826c079449db5ffb51c6d0 [file] [log] [blame]
rajalakshmi-ganesanab426722013-02-08 15:49:15 +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 Lobankov2b459ec2015-11-09 15:01:48 +030016"""
17http://developer.openstack.org/api-ref-identity-v3.html#endpoints-v3
18"""
19
Matthew Treinish21905512015-07-13 10:33:35 -040020from oslo_serialization import jsonutils as json
rajalakshmi-ganesanab426722013-02-08 15:49:15 +053021
Ken'ichi Ohmichid35a1332016-03-02 10:38:07 -080022from tempest.lib.common import rest_client
rajalakshmi-ganesanab426722013-02-08 15:49:15 +053023
24
Yaroslav Lobankovf6906e12016-02-26 19:44:53 -060025class EndPointsClient(rest_client.RestClient):
ghanshyamd26b5cd2015-02-09 14:48:58 +090026 api_version = "v3"
rajalakshmi-ganesanab426722013-02-08 15:49:15 +053027
28 def list_endpoints(self):
29 """GET endpoints."""
30 resp, body = self.get('endpoints')
David Kranz2aaf5312014-08-29 09:22:10 -040031 self.expected_success(200, resp.status)
rajalakshmi-ganesanab426722013-02-08 15:49:15 +053032 body = json.loads(body)
Ken'ichi Ohmichid35a1332016-03-02 10:38:07 -080033 return rest_client.ResponseBody(resp, body)
rajalakshmi-ganesanab426722013-02-08 15:49:15 +053034
Yaroslav Lobankov2b459ec2015-11-09 15:01:48 +030035 def create_endpoint(self, **kwargs):
Brant Knudson3a9bdf92014-02-27 17:09:50 -060036 """Create endpoint.
37
Yaroslav Lobankov2b459ec2015-11-09 15:01:48 +030038 Available params: see http://developer.openstack.org/
39 api-ref-identity-v3.html#createEndpoint
Brant Knudson3a9bdf92014-02-27 17:09:50 -060040 """
Yaroslav Lobankov2b459ec2015-11-09 15:01:48 +030041 post_body = json.dumps({'endpoint': kwargs})
Valeriy Ponomaryov88686d82014-02-16 12:24:51 +020042 resp, body = self.post('endpoints', post_body)
David Kranz2aaf5312014-08-29 09:22:10 -040043 self.expected_success(201, resp.status)
rajalakshmi-ganesanab426722013-02-08 15:49:15 +053044 body = json.loads(body)
Ken'ichi Ohmichid35a1332016-03-02 10:38:07 -080045 return rest_client.ResponseBody(resp, body)
rajalakshmi-ganesanab426722013-02-08 15:49:15 +053046
Yaroslav Lobankov2b459ec2015-11-09 15:01:48 +030047 def update_endpoint(self, endpoint_id, **kwargs):
Brant Knudson3a9bdf92014-02-27 17:09:50 -060048 """Updates an endpoint with given parameters.
49
Yaroslav Lobankov2b459ec2015-11-09 15:01:48 +030050 Available params: see http://developer.openstack.org/
51 api-ref-identity-v3.html#updateEndpoint
Brant Knudson3a9bdf92014-02-27 17:09:50 -060052 """
Yaroslav Lobankov2b459ec2015-11-09 15:01:48 +030053 post_body = json.dumps({'endpoint': kwargs})
Valeriy Ponomaryov88686d82014-02-16 12:24:51 +020054 resp, body = self.patch('endpoints/%s' % endpoint_id, post_body)
David Kranz2aaf5312014-08-29 09:22:10 -040055 self.expected_success(200, resp.status)
rajalakshmi-ganesanab426722013-02-08 15:49:15 +053056 body = json.loads(body)
Ken'ichi Ohmichid35a1332016-03-02 10:38:07 -080057 return rest_client.ResponseBody(resp, body)
rajalakshmi-ganesanab426722013-02-08 15:49:15 +053058
59 def delete_endpoint(self, endpoint_id):
60 """Delete endpoint."""
61 resp_header, resp_body = self.delete('endpoints/%s' % endpoint_id)
David Kranz2aaf5312014-08-29 09:22:10 -040062 self.expected_success(204, resp_header.status)
Ken'ichi Ohmichid35a1332016-03-02 10:38:07 -080063 return rest_client.ResponseBody(resp_header, resp_body)
apetrov5ae389f2016-01-21 16:16:13 +010064
65 def show_endpoint(self, endpoint_id):
66 """Get endpoint."""
67 resp_header, resp_body = self.get('endpoints/%s' % endpoint_id)
68 self.expected_success(200, resp_header.status)
69 resp_body = json.loads(resp_body)
Ken'ichi Ohmichid35a1332016-03-02 10:38:07 -080070 return rest_client.ResponseBody(resp_header, resp_body)