blob: db8d7cc607b463fe679b61caad36d4b6a345e63b [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
OTSUKA, Yuanyingfaac5712016-09-15 13:53:55 +090026 For a full list of available parameters, please refer to the official
27 API reference:
zhufl6ea5f8b2017-04-05 17:34:08 +080028 https://developer.openstack.org/api-ref/identity/v2-admin/index.html#create-endpoint-template
Ken'ichi Ohmichib5ebadb2016-06-13 14:19:22 -070029 """
30
31 post_body = json.dumps({'endpoint': kwargs})
Daniel Mellado3f951ef2016-01-13 09:48:00 +000032 resp, body = self.post('/endpoints', post_body)
33 self.expected_success(200, resp.status)
34 body = json.loads(body)
Ken'ichi Ohmichid35a1332016-03-02 10:38:07 -080035 return rest_client.ResponseBody(resp, body)
Daniel Mellado3f951ef2016-01-13 09:48:00 +000036
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 Ohmichid35a1332016-03-02 10:38:07 -080042 return rest_client.ResponseBody(resp, body)
Daniel Mellado3f951ef2016-01-13 09:48:00 +000043
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 Ohmichid35a1332016-03-02 10:38:07 -080049 return rest_client.ResponseBody(resp, body)