Module: Hyperkit::Client::Certificates
- Included in:
- Hyperkit::Client
- Defined in:
- lib/hyperkit/client/certificates.rb
Overview
Methods for the certificates API
Instance Method Summary collapse
-
#certificate(fingerprint) ⇒ Sawyer::Resource
Retrieve a trusted certificate from the server.
-
#certificates ⇒ Array<String>
List of trusted certificates on the server.
-
#create_certificate(cert, options = {}) ⇒ Sawyer::Resource
Add a new trusted certificate to the server.
-
#delete_certificate(fingerprint) ⇒ Sawyer::Resource
Delete a trusted certificate from the server.
Instance Method Details
#certificate(fingerprint) ⇒ Sawyer::Resource
Retrieve a trusted certificate from the server
65 66 67 |
# File 'lib/hyperkit/client/certificates.rb', line 65 def certificate(fingerprint) get(certificate_path(fingerprint)). end |
#certificates ⇒ Array<String>
List of trusted certificates on the server
23 24 25 26 |
# File 'lib/hyperkit/client/certificates.rb', line 23 def certificates response = get(certificates_path) response..map { |path| path.split('/').last } end |
#create_certificate(cert, options = {}) ⇒ Sawyer::Resource
Add a new trusted certificate to the server
41 42 43 44 45 |
# File 'lib/hyperkit/client/certificates.rb', line 41 def create_certificate(cert, ={}) = .slice(:name, :password) = .merge(type: "client", certificate: Base64.strict_encode64(OpenSSL::X509::Certificate.new(cert).to_der)) post(certificates_path, ). end |
#delete_certificate(fingerprint) ⇒ Sawyer::Resource
Delete a trusted certificate from the server
79 80 81 |
# File 'lib/hyperkit/client/certificates.rb', line 79 def delete_certificate(fingerprint) delete(certificate_path(fingerprint)). end |