Daniel Mellado | 3f951ef | 2016-01-13 09:48:00 +0000 | [diff] [blame] | 1 | # Copyright 2016 Red Hat, Inc. |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | |
| 15 | from oslo_serialization import jsonutils as json |
| 16 | |
Ken'ichi Ohmichi | d35a133 | 2016-03-02 10:38:07 -0800 | [diff] [blame] | 17 | from tempest.lib.common import rest_client |
Daniel Mellado | 3f951ef | 2016-01-13 09:48:00 +0000 | [diff] [blame] | 18 | |
| 19 | |
Ken'ichi Ohmichi | d35a133 | 2016-03-02 10:38:07 -0800 | [diff] [blame] | 20 | class EndpointsClient(rest_client.RestClient): |
Daniel Mellado | 3f951ef | 2016-01-13 09:48:00 +0000 | [diff] [blame] | 21 | api_version = "v2.0" |
| 22 | |
Ken'ichi Ohmichi | b5ebadb | 2016-06-13 14:19:22 -0700 | [diff] [blame] | 23 | def create_endpoint(self, **kwargs): |
| 24 | """Create an endpoint for service. |
| 25 | |
OTSUKA, Yuanying | faac571 | 2016-09-15 13:53:55 +0900 | [diff] [blame] | 26 | For a full list of available parameters, please refer to the official |
| 27 | API reference: |
zhufl | 6ea5f8b | 2017-04-05 17:34:08 +0800 | [diff] [blame] | 28 | https://developer.openstack.org/api-ref/identity/v2-admin/index.html#create-endpoint-template |
Ken'ichi Ohmichi | b5ebadb | 2016-06-13 14:19:22 -0700 | [diff] [blame] | 29 | """ |
| 30 | |
| 31 | post_body = json.dumps({'endpoint': kwargs}) |
Daniel Mellado | 3f951ef | 2016-01-13 09:48:00 +0000 | [diff] [blame] | 32 | resp, body = self.post('/endpoints', post_body) |
| 33 | self.expected_success(200, resp.status) |
| 34 | body = json.loads(body) |
Ken'ichi Ohmichi | d35a133 | 2016-03-02 10:38:07 -0800 | [diff] [blame] | 35 | return rest_client.ResponseBody(resp, body) |
Daniel Mellado | 3f951ef | 2016-01-13 09:48:00 +0000 | [diff] [blame] | 36 | |
| 37 | def list_endpoints(self): |
| 38 | """List Endpoints - Returns Endpoints.""" |
| 39 | resp, body = self.get('/endpoints') |
| 40 | self.expected_success(200, resp.status) |
| 41 | body = json.loads(body) |
Ken'ichi Ohmichi | d35a133 | 2016-03-02 10:38:07 -0800 | [diff] [blame] | 42 | return rest_client.ResponseBody(resp, body) |
Daniel Mellado | 3f951ef | 2016-01-13 09:48:00 +0000 | [diff] [blame] | 43 | |
| 44 | def delete_endpoint(self, endpoint_id): |
| 45 | """Delete an endpoint.""" |
| 46 | url = '/endpoints/%s' % endpoint_id |
| 47 | resp, body = self.delete(url) |
| 48 | self.expected_success(204, resp.status) |
Ken'ichi Ohmichi | d35a133 | 2016-03-02 10:38:07 -0800 | [diff] [blame] | 49 | return rest_client.ResponseBody(resp, body) |