Class: Hawkular::Token::Client
- Inherits:
-
BaseClient
- Object
- BaseClient
- Hawkular::Token::Client
- Defined in:
- lib/hawkular/tokens/tokens_api.rb
Overview
Client class to interact with the Secret Store
Instance Attribute Summary
Attributes inherited from BaseClient
Instance Method Summary collapse
- #create_token(credentials = {}, persona = nil, name = 'Token created via Hawkular Ruby Client', expires_at = nil) ⇒ Object
-
#get_tokens(credentials = {}) ⇒ String
Retrieve the tenant id for the passed credentials.
-
#initialize(entrypoint, credentials = {}, options = {}) ⇒ Client
constructor
Create a new Secret Store client.
Methods inherited from BaseClient
#admin_header, #base_64_credentials, #generate_query_params, #http_delete, #http_get, #http_post, #http_put, #normalize_entrypoint_url, #now, #url_with_websocket_scheme
Methods included from ClientUtils
Constructor Details
#initialize(entrypoint, credentials = {}, options = {}) ⇒ Client
Create a new Secret Store client
11 12 13 |
# File 'lib/hawkular/tokens/tokens_api.rb', line 11 def initialize(entrypoint, credentials = {}, = {}) super(entrypoint, credentials, ) end |
Instance Method Details
#create_token(credentials = {}, persona = nil, name = 'Token created via Hawkular Ruby Client', expires_at = nil) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/hawkular/tokens/tokens_api.rb', line 25 def create_token(credentials = {}, persona = nil, name = 'Token created via Hawkular Ruby Client', expires_at = nil) creds = credentials.empty? ? @credentials : credentials auth_header = { Authorization: base_64_credentials(creds) } auth_header['Hawkular-Persona'] = persona if persona token_attributes = { expiresAt: expires_at, attributes: { name: name } } http_post('/secret-store/v1/tokens/create', token_attributes, auth_header) end |
#get_tokens(credentials = {}) ⇒ String
Retrieve the tenant id for the passed credentials. If no credentials are passed, the ones from the constructor are used
19 20 21 22 23 |
# File 'lib/hawkular/tokens/tokens_api.rb', line 19 def get_tokens(credentials = {}) creds = credentials.empty? ? @credentials : credentials auth_header = { Authorization: base_64_credentials(creds) } http_get('/secret-store/v1/tokens', auth_header) end |