Class: Vault::AuthTLS
Instance Attribute Summary
Attributes inherited from Request
Instance Method Summary collapse
-
#certificate(name) ⇒ Secret?
Get the certificate by the given name.
-
#certificates(options = {}) ⇒ Array<String>
The list of certificates in vault auth backend.
-
#delete_certificate(name) ⇒ Object
Delete the certificate with the given name.
-
#set_certificate(name, options = {}) ⇒ true
Saves a certificate with the given name and attributes.
Methods inherited from Request
Methods included from EncodePath
Constructor Details
This class inherits a constructor from Vault::Request
Instance Method Details
#certificate(name) ⇒ Secret?
Get the certificate by the given name. If a certificate does not exist by that name, nil
is returned.
59 60 61 62 63 64 65 |
# File 'lib/vault/api/auth_tls.rb', line 59 def certificate(name) json = client.get("/v1/auth/cert/certs/#{encode_path(name)}") return Secret.decode(json) rescue HTTPError => e return nil if e.code == 404 raise end |
#certificates(options = {}) ⇒ Array<String>
The list of certificates in vault auth backend.
73 74 75 76 77 78 79 80 |
# File 'lib/vault/api/auth_tls.rb', line 73 def certificates( = {}) headers = extract_headers!() json = client.list("/v1/auth/cert/certs", , headers) return Secret.decode(json).data[:keys] || [] rescue HTTPError => e return [] if e.code == 404 raise end |
#delete_certificate(name) ⇒ Object
Delete the certificate with the given name. If a certificate does not exist, vault will not return an error.
90 91 92 93 |
# File 'lib/vault/api/auth_tls.rb', line 90 def delete_certificate(name) client.delete("/v1/auth/cert/certs/#{encode_path(name)}") return true end |
#set_certificate(name, options = {}) ⇒ true
Saves a certificate with the given name and attributes. The certificate with the given name must already exist.
46 47 48 49 50 |
# File 'lib/vault/api/auth_tls.rb', line 46 def set_certificate(name, = {}) headers = extract_headers!() client.post("/v1/auth/cert/certs/#{encode_path(name)}", JSON.fast_generate(), headers) return true end |