blob: d6c72f44597341b4519d1146ba31aa678de586f0 [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
Matthew Treinish21905512015-07-13 10:33:35 -040016from oslo_serialization import jsonutils as json
ivan-zhud57f3cf2013-11-06 16:59:52 +080017
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 Ohmichia6287072015-07-02 02:43:15 +000022class CertificatesClient(service_client.ServiceClient):
ivan-zhud57f3cf2013-11-06 16:59:52 +080023
Ken'ichi Ohmichi9509b962015-07-07 05:30:15 +000024 def show_certificate(self, certificate_id):
25 url = "os-certificates/%s" % certificate_id
ivan-zhud57f3cf2013-11-06 16:59:52 +080026 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)
ghanshyamc7e09bf2015-08-04 15:42:24 +090029 return service_client.ResponseBody(resp, body)
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)
ghanshyamc7e09bf2015-08-04 15:42:24 +090037 return service_client.ResponseBody(resp, body)