-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue #32: Add support for SSL certificate management. #33
Changes from 3 commits
80ca2ba
01d5058
9a75404
7d16fac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -345,3 +345,97 @@ def enable_cron(self, cron_id: str) -> Session: | |
response = self.request(uri=uri, method="POST", data="") | ||
|
||
return response | ||
|
||
def get_ssl_settings(self) -> dict: | ||
""" | ||
Return the SSL settings for the environment. | ||
""" | ||
uri = f"{self.uri}/ssl" | ||
response = self.request(uri=uri) | ||
|
||
return response.json() | ||
|
||
def get_ssl_certs(self) -> dict: | ||
""" | ||
Return a list of SSL certificates. | ||
""" | ||
uri = f"{self.uri}/ssl/certificates" | ||
response = self.request(uri=uri) | ||
|
||
return response.json().get('_embedded', {}).get('items') | ||
|
||
def get_ssl_cert(self, cert_id) -> dict: | ||
""" | ||
Return an SSL cert. | ||
""" | ||
uri = f"{self.uri}/ssl/certificates/{cert_id}" | ||
response = self.request(uri=uri) | ||
|
||
return response.json() | ||
|
||
def install_ssl_cert( | ||
self, | ||
label: str, | ||
certificate: str, | ||
private_key: str, | ||
ca_certificates: str = None, | ||
legacy: bool = False, | ||
csr_id: int = None, | ||
) -> Session: | ||
""" | ||
Add a new SSL cert to the environment. | ||
:param: label: Human-friendly identifier for the cert. | ||
:param: certificate: The certificate in PEM format. | ||
:param: private_key: The private keyfor the cert in PEM format. | ||
:param: ca_certificates: Any chain certificates, in PEM format. | ||
Defaults to None. | ||
:param: legacy: Legacy in the sense of Acquia's legacy architecture, | ||
not an old version of the SSL or TLS standards. See Acquia's docs | ||
for more details. Defaults to False. | ||
:param: csr_id: Associate with an existing installed CSR. Defaults | ||
to None. | ||
""" | ||
uri = f"{self.uri}/ssl/certificates" | ||
data = { | ||
"legacy": legacy, | ||
"label": label, | ||
"certificate": certificate, | ||
"private_key": private_key, | ||
} | ||
if csr_id is not None: | ||
data['csr_id'] = csr_id | ||
if ca_certificates is not None: | ||
data['ca_certificates'] = ca_certificates | ||
response = self.request(uri=uri, method="POST", data=data) | ||
|
||
return response | ||
|
||
def delete_ssl_cert(self, cert_id) -> Session: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. |
||
""" | ||
Remove an SSL cert. | ||
:param: cert_id: The Acquia certificate ID. | ||
""" | ||
uri = f"{self.uri}/ssl/certificates/{cert_id}" | ||
response = self.request(uri=uri, method="DELETE") | ||
|
||
return response | ||
|
||
def activate_ssl_cert(self, cert_id) -> Session: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And here. |
||
""" | ||
Activate a previously installed SSL cert. | ||
:param: cert_id: The Acquia certificate ID. | ||
""" | ||
uri = f"{self.uri}/ssl/certificates/{cert_id}/actions/activate" | ||
response = self.request(uri=uri, method="POST", data={}) | ||
|
||
return response | ||
|
||
def deactivate_ssl_cert(self, cert_id) -> Session: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And also here :) |
||
""" | ||
Deactivate a previously installed SSL cert. | ||
:param: cert_id: The Acquia certificate ID. | ||
""" | ||
uri = f"{self.uri}/ssl/certificates/{cert_id}/actions/deactivate" | ||
response = self.request(uri=uri, method="POST", data={}) | ||
|
||
return response |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you forgot the type hint here for
cert_id
:)