/usr/share/pyshared/SoftLayer/managers/ssl.py is in python-softlayer 3.0.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | """
SoftLayer.ssl
~~~~~~~~~~~~~
SSL Manager/helpers
:copyright: (c) 2013, SoftLayer Technologies, Inc. All rights reserved.
:license: MIT, see LICENSE for more details.
"""
class SSLManager(object):
"""
Manages SSL certificates.
:param SoftLayer.API.Client client: an API client instance
"""
def __init__(self, client):
#: A valid `SoftLayer.API.Client` object that will be used for all
#: actions.
self.client = client
#: Reference to the SoftLayer_Security_Certificate API object.
self.ssl = self.client['Security_Certificate']
def list_certs(self, method='all'):
""" List all certificates.
:param string method: The type of certificates to list. Options are
'all', 'expired', and 'valid'.
:returns: A list of dictionaries representing the requested SSL certs.
"""
ssl = self.client['Account']
methods = {
'all': 'getSecurityCertificates',
'expired': 'getExpiredSecurityCertificates',
'valid': 'getValidSecurityCertificates'
}
mask = "mask[id, commonName, validityDays, notes]"
func = getattr(ssl, methods[method])
return func(mask=mask)
def add_certificate(self, certificate):
""" Creates a new certificate.
:param dict certificate: A dictionary representing the parts of the
certificate. See SLDN for more information.
"""
return self.ssl.createObject(certificate)
def remove_certificate(self, id):
""" Removes a certificate.
:param integer id: a certificate ID to remove
"""
return self.ssl.deleteObject(id=id)
def edit_certificate(self, certificate):
""" Updates a certificate with the included options.
The provided dict must include an 'id' key and value corresponding to
the certificate ID that should be updated.
:param dict certificate: the certificate to update.
"""
return self.ssl.editObject(certificate, id=certificate['id'])
def get_certificate(self, id):
""" Gets a certificate with the ID specified.
:param integer id: the certificate ID to retrieve
"""
return self.ssl.getObject(id=id)
|