blob: f7b265d76fb0ee10ace7ff787fe10084aa7d7ea3 [file] [log] [blame]
Daniel Mellado3f951ef2016-01-13 09:48:00 +00001# 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
15from oslo_serialization import jsonutils as json
16
Ken'ichi Ohmichid35a1332016-03-02 10:38:07 -080017from tempest.lib.common import rest_client
Daniel Mellado3f951ef2016-01-13 09:48:00 +000018
19
Ken'ichi Ohmichid35a1332016-03-02 10:38:07 -080020class EndpointsClient(rest_client.RestClient):
Daniel Mellado3f951ef2016-01-13 09:48:00 +000021 api_version = "v2.0"
22
Ken'ichi Ohmichib5ebadb2016-06-13 14:19:22 -070023 def create_endpoint(self, **kwargs):
24 """Create an endpoint for service.
25
26 Available params: http://developer.openstack.org/
27 api-ref-identity-v2-ext.html#createEndpoint
28 """
29
30 post_body = json.dumps({'endpoint': kwargs})
Daniel Mellado3f951ef2016-01-13 09:48:00 +000031 resp, body = self.post('/endpoints', post_body)
32 self.expected_success(200, resp.status)
33 body = json.loads(body)
Ken'ichi Ohmichid35a1332016-03-02 10:38:07 -080034 return rest_client.ResponseBody(resp, body)
Daniel Mellado3f951ef2016-01-13 09:48:00 +000035
36 def list_endpoints(self):
37 """List Endpoints - Returns Endpoints."""
38 resp, body = self.get('/endpoints')
39 self.expected_success(200, resp.status)
40 body = json.loads(body)
Ken'ichi Ohmichid35a1332016-03-02 10:38:07 -080041 return rest_client.ResponseBody(resp, body)
Daniel Mellado3f951ef2016-01-13 09:48:00 +000042
43 def delete_endpoint(self, endpoint_id):
44 """Delete an endpoint."""
45 url = '/endpoints/%s' % endpoint_id
46 resp, body = self.delete(url)
47 self.expected_success(204, resp.status)
Ken'ichi Ohmichid35a1332016-03-02 10:38:07 -080048 return rest_client.ResponseBody(resp, body)