rajalakshmi-ganesan | ab42672 | 2013-02-08 15:49:15 +0530 | [diff] [blame] | 1 | # 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 Lobankov | 2b459ec | 2015-11-09 15:01:48 +0300 | [diff] [blame] | 16 | """ |
| 17 | http://developer.openstack.org/api-ref-identity-v3.html#endpoints-v3 |
| 18 | """ |
| 19 | |
Matthew Treinish | 2190551 | 2015-07-13 10:33:35 -0400 | [diff] [blame] | 20 | from oslo_serialization import jsonutils as json |
rajalakshmi-ganesan | ab42672 | 2013-02-08 15:49:15 +0530 | [diff] [blame] | 21 | |
Ken'ichi Ohmichi | d35a133 | 2016-03-02 10:38:07 -0800 | [diff] [blame] | 22 | from tempest.lib.common import rest_client |
rajalakshmi-ganesan | ab42672 | 2013-02-08 15:49:15 +0530 | [diff] [blame] | 23 | |
| 24 | |
Yaroslav Lobankov | f6906e1 | 2016-02-26 19:44:53 -0600 | [diff] [blame] | 25 | class EndPointsClient(rest_client.RestClient): |
ghanshyam | d26b5cd | 2015-02-09 14:48:58 +0900 | [diff] [blame] | 26 | api_version = "v3" |
rajalakshmi-ganesan | ab42672 | 2013-02-08 15:49:15 +0530 | [diff] [blame] | 27 | |
| 28 | def list_endpoints(self): |
| 29 | """GET endpoints.""" |
| 30 | resp, body = self.get('endpoints') |
David Kranz | 2aaf531 | 2014-08-29 09:22:10 -0400 | [diff] [blame] | 31 | self.expected_success(200, resp.status) |
rajalakshmi-ganesan | ab42672 | 2013-02-08 15:49:15 +0530 | [diff] [blame] | 32 | body = json.loads(body) |
Ken'ichi Ohmichi | d35a133 | 2016-03-02 10:38:07 -0800 | [diff] [blame] | 33 | return rest_client.ResponseBody(resp, body) |
rajalakshmi-ganesan | ab42672 | 2013-02-08 15:49:15 +0530 | [diff] [blame] | 34 | |
Yaroslav Lobankov | 2b459ec | 2015-11-09 15:01:48 +0300 | [diff] [blame] | 35 | def create_endpoint(self, **kwargs): |
Brant Knudson | 3a9bdf9 | 2014-02-27 17:09:50 -0600 | [diff] [blame] | 36 | """Create endpoint. |
| 37 | |
Yaroslav Lobankov | 2b459ec | 2015-11-09 15:01:48 +0300 | [diff] [blame] | 38 | Available params: see http://developer.openstack.org/ |
| 39 | api-ref-identity-v3.html#createEndpoint |
Brant Knudson | 3a9bdf9 | 2014-02-27 17:09:50 -0600 | [diff] [blame] | 40 | """ |
Yaroslav Lobankov | 2b459ec | 2015-11-09 15:01:48 +0300 | [diff] [blame] | 41 | post_body = json.dumps({'endpoint': kwargs}) |
Valeriy Ponomaryov | 88686d8 | 2014-02-16 12:24:51 +0200 | [diff] [blame] | 42 | resp, body = self.post('endpoints', post_body) |
David Kranz | 2aaf531 | 2014-08-29 09:22:10 -0400 | [diff] [blame] | 43 | self.expected_success(201, resp.status) |
rajalakshmi-ganesan | ab42672 | 2013-02-08 15:49:15 +0530 | [diff] [blame] | 44 | body = json.loads(body) |
Ken'ichi Ohmichi | d35a133 | 2016-03-02 10:38:07 -0800 | [diff] [blame] | 45 | return rest_client.ResponseBody(resp, body) |
rajalakshmi-ganesan | ab42672 | 2013-02-08 15:49:15 +0530 | [diff] [blame] | 46 | |
Yaroslav Lobankov | 2b459ec | 2015-11-09 15:01:48 +0300 | [diff] [blame] | 47 | def update_endpoint(self, endpoint_id, **kwargs): |
Brant Knudson | 3a9bdf9 | 2014-02-27 17:09:50 -0600 | [diff] [blame] | 48 | """Updates an endpoint with given parameters. |
| 49 | |
Yaroslav Lobankov | 2b459ec | 2015-11-09 15:01:48 +0300 | [diff] [blame] | 50 | Available params: see http://developer.openstack.org/ |
| 51 | api-ref-identity-v3.html#updateEndpoint |
Brant Knudson | 3a9bdf9 | 2014-02-27 17:09:50 -0600 | [diff] [blame] | 52 | """ |
Yaroslav Lobankov | 2b459ec | 2015-11-09 15:01:48 +0300 | [diff] [blame] | 53 | post_body = json.dumps({'endpoint': kwargs}) |
Valeriy Ponomaryov | 88686d8 | 2014-02-16 12:24:51 +0200 | [diff] [blame] | 54 | resp, body = self.patch('endpoints/%s' % endpoint_id, post_body) |
David Kranz | 2aaf531 | 2014-08-29 09:22:10 -0400 | [diff] [blame] | 55 | self.expected_success(200, resp.status) |
rajalakshmi-ganesan | ab42672 | 2013-02-08 15:49:15 +0530 | [diff] [blame] | 56 | body = json.loads(body) |
Ken'ichi Ohmichi | d35a133 | 2016-03-02 10:38:07 -0800 | [diff] [blame] | 57 | return rest_client.ResponseBody(resp, body) |
rajalakshmi-ganesan | ab42672 | 2013-02-08 15:49:15 +0530 | [diff] [blame] | 58 | |
| 59 | def delete_endpoint(self, endpoint_id): |
| 60 | """Delete endpoint.""" |
| 61 | resp_header, resp_body = self.delete('endpoints/%s' % endpoint_id) |
David Kranz | 2aaf531 | 2014-08-29 09:22:10 -0400 | [diff] [blame] | 62 | self.expected_success(204, resp_header.status) |
Ken'ichi Ohmichi | d35a133 | 2016-03-02 10:38:07 -0800 | [diff] [blame] | 63 | return rest_client.ResponseBody(resp_header, resp_body) |
apetrov | 5ae389f | 2016-01-21 16:16:13 +0100 | [diff] [blame] | 64 | |
| 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 Ohmichi | d35a133 | 2016-03-02 10:38:07 -0800 | [diff] [blame] | 70 | return rest_client.ResponseBody(resp_header, resp_body) |