class Hawkular::Token::Client
Client
class to interact with the Secret Store
Public Class Methods
new(entrypoint, credentials = {}, options = {})
click to toggle source
Create a new Secret Store client @param entrypoint [String] base url of Hawkular
- e.g localhost:8080 @param credentials [Hash{String=>String}] Hash of username, password @param options [Hash{String=>String}] Additional rest client options
Calls superclass method
Hawkular::BaseClient::new
# File lib/hawkular/tokens/tokens_api.rb 11 def initialize(entrypoint, credentials = {}, options = {}) 12 super(entrypoint, credentials, options) 13 end
Public Instance Methods
create_token(credentials = {}, persona = nil, name = 'Token created via Hawkular Ruby Client', expires_at = nil)
click to toggle source
# File lib/hawkular/tokens/tokens_api.rb 25 def create_token(credentials = {}, persona = nil, name = 'Token created via Hawkular Ruby Client', expires_at = nil) 26 creds = credentials.empty? ? @credentials : credentials 27 auth_header = { Authorization: base_64_credentials(creds) } 28 auth_header['Hawkular-Persona'] = persona if persona 29 30 token_attributes = { expiresAt: expires_at, attributes: { name: name } } 31 http_post('/secret-store/v1/tokens/create', token_attributes, auth_header) 32 end
get_tokens(credentials = {})
click to toggle source
Retrieve the tenant id for the passed credentials. If no credentials are passed, the ones from the constructor are used @param credentials [Hash{String=>String}] Hash of username, password, token(optional) @return [String] tenant id
# File lib/hawkular/tokens/tokens_api.rb 19 def get_tokens(credentials = {}) 20 creds = credentials.empty? ? @credentials : credentials 21 auth_header = { Authorization: base_64_credentials(creds) } 22 http_get('/secret-store/v1/tokens', auth_header) 23 end