blob: 356ded2d2d58a652eff2a7f2504c320b926d4d00 [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
Haiwei Xuab924622014-03-05 04:33:51 +090020from tempest.common import rest_client
Matthew Treinish684d8992014-01-30 16:27:40 +000021from tempest import config
22
23CONF = config.CONF
ivan-zhud57f3cf2013-11-06 16:59:52 +080024
25
Haiwei Xuab924622014-03-05 04:33:51 +090026class CertificatesClientJSON(rest_client.RestClient):
ivan-zhud57f3cf2013-11-06 16:59:52 +080027
Andrea Frittoli8bbdb162014-01-06 11:06:13 +000028 def __init__(self, auth_provider):
29 super(CertificatesClientJSON, self).__init__(auth_provider)
Matthew Treinish684d8992014-01-30 16:27:40 +000030 self.service = CONF.compute.catalog_type
ivan-zhud57f3cf2013-11-06 16:59:52 +080031
32 def get_certificate(self, id):
33 url = "os-certificates/%s" % (id)
34 resp, body = self.get(url)
35 body = json.loads(body)
Eiichi Aikawaca36c2b2014-03-19 17:25:49 +090036 self.validate_response(schema.get_certificate, resp, body)
ivan-zhud57f3cf2013-11-06 16:59:52 +080037 return resp, body['certificate']
38
39 def create_certificate(self):
40 """create certificates."""
41 url = "os-certificates"
vponomaryovf4c27f92014-02-18 10:56:42 +020042 resp, body = self.post(url, None)
ivan-zhud57f3cf2013-11-06 16:59:52 +080043 body = json.loads(body)
Eiichi Aikawaca36c2b2014-03-19 17:25:49 +090044 self.validate_response(v2schema.create_certificate, resp, body)
ivan-zhud57f3cf2013-11-06 16:59:52 +080045 return resp, body['certificate']