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, role_id, secret_id) ⇒ VaultClient
Returns a new instance of VaultClient.
5
6
7
8
9
10
|
# File 'app/services/foreman_vault/vault_client.rb', line 5
def initialize(base_url, token, role_id, secret_id)
@base_url = base_url
@token = token
@role_id = role_id
@secret_id = secret_id
end
|
Instance Method Details
#fetch_expire_time ⇒ Object
16
17
18
19
20
|
# File 'app/services/foreman_vault/vault_client.rb', line 16
def fetch_expire_time
response = client.auth_token.lookup_self
expire_time = response.data[:expire_time]
expire_time && Time.zone.parse(expire_time)
end
|
#fetch_secret(secret_path) ⇒ Object
22
23
24
25
26
27
|
# File 'app/services/foreman_vault/vault_client.rb', line 22
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
29
30
31
32
33
|
# File 'app/services/foreman_vault/vault_client.rb', line 29
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
35
36
37
|
# File 'app/services/foreman_vault/vault_client.rb', line 35
def renew_token
client.auth_token.renew_self
end
|