blob: 123f0b92b5f2e702b8deec9aad27067f0a8c61ff [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
Marc Koderer6fbd74f2014-08-04 09:38:19 +020018from tempest.api_schema.response.compute import certificates as schema
19from tempest.api_schema.response.compute.v2 import certificates as v2schema
Ken'ichi Ohmichiebf0f8c2014-12-24 03:47:35 +000020from tempest.services.compute.json import base
ivan-zhud57f3cf2013-11-06 16:59:52 +080021
22
Ken'ichi Ohmichiebf0f8c2014-12-24 03:47:35 +000023class CertificatesClientJSON(base.ComputeClient):
ivan-zhud57f3cf2013-11-06 16:59:52 +080024
25 def get_certificate(self, id):
26 url = "os-certificates/%s" % (id)
27 resp, body = self.get(url)
28 body = json.loads(body)
Eiichi Aikawaca36c2b2014-03-19 17:25:49 +090029 self.validate_response(schema.get_certificate, resp, body)
ivan-zhud57f3cf2013-11-06 16:59:52 +080030 return resp, body['certificate']
31
32 def create_certificate(self):
33 """create certificates."""
34 url = "os-certificates"
vponomaryovf4c27f92014-02-18 10:56:42 +020035 resp, body = self.post(url, None)
ivan-zhud57f3cf2013-11-06 16:59:52 +080036 body = json.loads(body)
Eiichi Aikawaca36c2b2014-03-19 17:25:49 +090037 self.validate_response(v2schema.create_certificate, resp, body)
ivan-zhud57f3cf2013-11-06 16:59:52 +080038 return resp, body['certificate']