@@ -32,59 +32,66 @@ class Certificates(Endpoint):
3232 def __init__ (self , client , endpoint , api_version = "v1" ):
3333 """Initialize the class.
3434
35- :param object client: An instantiated cert_manager.Client object
36- :param string endpoint: The URL of the API endpoint (ex. "/ssl")
37- :param string api_version: The API version to use; the default is "v1"
35+ Args:
36+ client: An instantiated cert_manager.Client object
37+ endpoint: The URL of the API endpoint (ex. "/ssl")
38+ api_version: The API version to use; the default is "v1"
3839 """
3940 super ().__init__ (client = client , endpoint = endpoint , api_version = api_version )
4041
4142 # Set to None initially. Will be filled in by methods later.
42- self .__cert_types = None
43- self .__custom_fields = None
44- self .__reason_maxlen = 512
43+ self ._cert_types = None
44+ self ._custom_fields = None
45+ self ._reason_maxlen = 512
4546
4647 @property
4748 def types (self ):
4849 """Retrieve all certificate types that are currently available.
4950
50- :return list: A list of dictionaries of certificate types
51+ Returns:
52+ A list of dictionaries of certificate types
5153 """
5254 # Only go to the API if we haven't done the API call yet, or if someone
5355 # specifically wants to refresh the internal cache
54- if not self .__cert_types :
56+ if not self ._cert_types :
5557 url = self ._url ("/types" )
5658 result = self ._client .get (url )
5759
5860 # Build a dictionary instead of a flat list of dictionaries
59- self .__cert_types = {}
61+ self ._cert_types = {}
6062 for res in result .json ():
6163 name = res ["name" ]
62- self .__cert_types [name ] = {}
63- self .__cert_types [name ]["id" ] = res ["id" ]
64- self .__cert_types [name ]["terms" ] = res ["terms" ]
64+ self ._cert_types [name ] = {}
65+ self ._cert_types [name ]["id" ] = res ["id" ]
66+ self ._cert_types [name ]["terms" ] = res ["terms" ]
6567
66- return self .__cert_types
68+ return self ._cert_types
6769
6870 @property
6971 def custom_fields (self ):
7072 """Retrieve all custom fields defined for SSL certificates.
7173
72- :return list: A list of dictionaries of custom fields
74+ Returns:
75+ A list of dictionaries of custom fields
7376 """
7477 # Only go to the API if we haven't done the API call yet, or if someone
7578 # specifically wants to refresh the internal cache
76- if not self .__custom_fields :
79+ if not self ._custom_fields :
7780 url = self ._url ("/customFields" )
7881 result = self ._client .get (url )
7982
80- self .__custom_fields = result .json ()
83+ self ._custom_fields = result .json ()
8184
82- return self .__custom_fields
85+ return self ._custom_fields
8386
8487 def _validate_custom_fields (self , custom_fields ):
8588 """Check the structure and contents of a list of custom fields dicts. Raise exceptions if validation fails.
8689
87- :raises Exception: if any of the validation steps fail
90+ Args:
91+ custom_fields: A list of dictionaries representing custom fields
92+
93+ Raises:
94+ CustomFieldsError: if any of the validation steps fail
8895 """
8996 # Make sure all custom fields are valid if present
9097 custom_field_names = [f ['name' ] for f in self .custom_fields ]
@@ -114,9 +121,11 @@ def collect(self, cert_id, cert_format):
114121
115122 This method will raise a PendingError exception if the certificate is still in a pending state.
116123
117- :param int cert_id: The certificate ID
118- :param str cert_format: The format in which to retreive the certificate. Allowed values: *self.valid_formats*
119- :return str: the string representing the certificate in the requested format
124+ Args:
125+ cert_id: The certificate ID
126+ cert_format: The format in which to retreive the certificate. Allowed values: *self.valid_formats*
127+ Returns:
128+ The string representing the certificate in the requested format
120129 """
121130 if cert_format not in self .valid_formats :
122131 raise ValueError (f"Invalid cert format { cert_format } provided" )
@@ -135,16 +144,20 @@ def collect(self, cert_id, cert_format):
135144 def enroll (self , ** kwargs ):
136145 """Enroll a certificate request with Sectigo to generate a certificate.
137146
138- :param string cert_type_name: The full cert type name
139- Note: the name must match names returned from the get_types() method
140- :param string csr: The Certificate Signing Request (CSR)
141- :param int term: The length, in days, for the certificate to be issued
142- :param int org_id: The ID of the organization in which to enroll the certificate
143- :param list subject_alt_names: A list of Subject Alternative Names
144- :param list external_requester: One or more e-mail addresses
145- :param list custom_fields: zero or more objects representing custom fields and their values
146- Note: each object must have a 'name' key and a 'value' key
147- :return dict: The certificate_id and the normal status messages for errors
147+ Args:
148+ kwargs: A dictionary of arguments to pass to the API.
149+ Required fields are:
150+ cert_type_name: The full cert type name
151+ Note: the name must match names returned from the get_types() method
152+ csr: The Certificate Signing Request (CSR)
153+ term: The length, in days, for the certificate to be issued
154+ org_id: The ID of the organization in which to enroll the certificate
155+ subject_alt_names: A list of Subject Alternative Names
156+ external_requester: One or more e-mail addresses
157+ custom_fields: zero or more objects representing custom fields and their values
158+ Note: each object must have a 'name' key and a 'value' key
159+ Returns:
160+ The certificate_id and the normal status messages for errors
148161 """
149162 # Retrieve all the arguments
150163 cert_type_name = kwargs .get ("cert_type_name" )
@@ -191,13 +204,17 @@ def enroll(self, **kwargs):
191204 def replace (self , ** kwargs ):
192205 """Replace a pre-existing certificate.
193206
194- :param int cert_id: The certificate ID
195- :param string csr: The Certificate Signing Request (CSR)
196- :param string common_name: Certificate common name.
197- :param str reason: Reason for replacement (up to 512 characters), can be blank: "", but must exist.
198- :param list subject_alt_names: A list of Subject Alternative Names.
199- :return: The result of the operation, "Successful" on success
200- :rtype: dict
207+ Args:
208+ kwargs: A dictionary of arguments to pass to the API.
209+ Required fields are:
210+ cert_id: The certificate ID
211+ csr: The Certificate Signing Request (CSR)
212+ common_name: Certificate common name.
213+ reason: Reason for replacement (up to 512 characters), can be blank: "", but must exist.
214+ subject_alt_names: A list of Subject Alternative Names.
215+
216+ Returns:
217+ An empty dictionary on success
201218 """
202219 # Retrieve all the arguments
203220 cert_id = kwargs .get ("cert_id" )
@@ -222,16 +239,19 @@ def replace(self, **kwargs):
222239 def revoke (self , cert_id , reason = "" ):
223240 """Revoke the certificate specified by the certificate ID.
224241
225- :param int cert_id: The certificate ID
226- :param str reason: The Reason for revocation.
227- Reason can be up to 512 characters and cannot be blank (i.e. empty string)
228- :return dict: The revocation result. "Successful" on success
242+ Args:
243+ cert_id: The certificate ID
244+ reason: The Reason for revocation.
245+ Reason can be up to 512 characters and cannot be blank (i.e. empty string)
246+
247+ Returns:
248+ An empty dictionary on success
229249 """
230250 url = self ._url (f"/revoke/{ cert_id } " )
231251
232252 # Sectigo has a 512 character limit on the "reason" message, so catch that here.
233- if not reason or len (reason ) >= self .__reason_maxlen :
234- raise ValueError (f"Sectigo limit: reason must be > 0 character and < { self .__reason_maxlen } characters" )
253+ if not reason or len (reason ) >= self ._reason_maxlen :
254+ raise ValueError (f"Sectigo limit: reason must be > 0 character and < { self ._reason_maxlen } characters" )
235255
236256 data = {"reason" : reason }
237257
0 commit comments