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.
56 57 58 59 60 61 62 |
# File 'lib/vault/api/auth_tls.rb', line 56 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.
70 71 72 73 74 75 76 77 |
# File 'lib/vault/api/auth_tls.rb', line 70 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.
87 88 89 90 |
# File 'lib/vault/api/auth_tls.rb', line 87 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.
43 44 45 46 47 |
# File 'lib/vault/api/auth_tls.rb', line 43 def set_certificate(name, = {}) headers = extract_headers!() client.post("/v1/auth/cert/certs/#{encode_path(name)}", JSON.fast_generate(), headers) return true end |