##############################################################################
# Copyright 2023 IBM Corp.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
##############################################################################
"""
Hardware Management Console Certificate interface.
"""
from pyds8k.base import ManagerMeta, ResourceMeta
from pyds8k.resources.ds8k.v1.common.base import Base, BaseManager
from pyds8k.resources.ds8k.v1.common.types import DS8K_HMC_CERTIFICATE
[docs]class HmcCertificate(Base, metaclass=ResourceMeta):
resource_type = DS8K_HMC_CERTIFICATE
# id_field = ''
# _template = {}
# readonly_fields = {''}
# related_resources_collection = ()
# def __repr__(self):
# return "<HMC Certificate: {0}>".format(self.id)
[docs]class HmcCertificateManager(BaseManager, metaclass=ManagerMeta):
"""
Manage Hardware Management Console Certificate resources.
"""
resource_class = HmcCertificate
resource_type = DS8K_HMC_CERTIFICATE
# CAVEAT: Meta classes are built using the dir structure and the resulting
# url is /hmc/certificate/certificate.
# Force the default to be the correct url.
[docs] def post(self, url='/hmc/certificate', body=None):
files = {'file': body}
# CAVEAT: self._post() underlying code from _post in
# BaseManager -> Manager expects the body to be json.
# Call the client directly, which calls requests.
# Side effect is the REQ not being logged correctly.
return self.client.post(url=url, files=files)