blob: 752a48e77c3363f0f7d78929955494517fcb08e2 [file] [log] [blame]
ivan-zhud57f3cf2013-11-06 16:59:52 +08001# Copyright 2013 IBM Corp
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
16import json
17
ghanshyam405a8592015-03-20 11:39:28 +090018from tempest.api_schema.response.compute.v2_1 import certificates as schema
Ken'ichi Ohmichi4771cbc2015-01-19 23:45:23 +000019from tempest.common import service_client
ivan-zhud57f3cf2013-11-06 16:59:52 +080020
21
Ken'ichi Ohmichi4771cbc2015-01-19 23:45:23 +000022class CertificatesClientJSON(service_client.ServiceClient):
ivan-zhud57f3cf2013-11-06 16:59:52 +080023
Ken'ichi Ohmichi3de6d982015-04-13 00:20:41 +000024 def show_certificate(self, id):
ivan-zhud57f3cf2013-11-06 16:59:52 +080025 url = "os-certificates/%s" % (id)
26 resp, body = self.get(url)
27 body = json.loads(body)
Eiichi Aikawaca36c2b2014-03-19 17:25:49 +090028 self.validate_response(schema.get_certificate, resp, body)
David Kranz5cf4ba42015-02-10 14:00:50 -050029 return service_client.ResponseBody(resp, body['certificate'])
ivan-zhud57f3cf2013-11-06 16:59:52 +080030
31 def create_certificate(self):
32 """create certificates."""
33 url = "os-certificates"
vponomaryovf4c27f92014-02-18 10:56:42 +020034 resp, body = self.post(url, None)
ivan-zhud57f3cf2013-11-06 16:59:52 +080035 body = json.loads(body)
ghanshyam405a8592015-03-20 11:39:28 +090036 self.validate_response(schema.create_certificate, resp, body)
David Kranz5cf4ba42015-02-10 14:00:50 -050037 return service_client.ResponseBody(resp, body['certificate'])