Class: ForemanVault::VaultClient
- Inherits:
-
Object
- Object
- ForemanVault::VaultClient
show all
- Defined in:
- app/services/foreman_vault/vault_client.rb
Defined Under Namespace
Classes: NoDataError, VaultClientError
Instance Method Summary
collapse
Constructor Details
#initialize(base_url, token) ⇒ VaultClient
Returns a new instance of VaultClient.
5
6
7
8
|
# File 'app/services/foreman_vault/vault_client.rb', line 5
def initialize(base_url, token)
@base_url = base_url
@token = token
end
|
Instance Method Details
#fetch_expire_time ⇒ Object
14
15
16
17
|
# File 'app/services/foreman_vault/vault_client.rb', line 14
def fetch_expire_time
response = client.auth_token.lookup_self
Time.zone.parse(response.data[:expire_time])
end
|
#fetch_secret(secret_path) ⇒ Object
19
20
21
22
23
24
|
# File 'app/services/foreman_vault/vault_client.rb', line 19
def fetch_secret(secret_path)
response = client.logical.read(secret_path)
raise NoDataError.new(N_('There is no available data for path: %s'), secret_path) unless response
response.data
end
|
#issue_certificate(secret_path, *options) ⇒ Object
26
27
28
29
30
|
# File 'app/services/foreman_vault/vault_client.rb', line 26
def issue_certificate(secret_path, *options)
response = client.logical.write(secret_path, *options)
raise NoDataError.new(N_('Could not issue certificate: %s'), secret_path) unless response
response.data
end
|
#renew_token ⇒ Object
32
33
34
|
# File 'app/services/foreman_vault/vault_client.rb', line 32
def renew_token
client.auth_token.renew_self
end
|