Class: Superset::Client
- Inherits:
-
Happi::Client
- Object
- Happi::Client
- Superset::Client
- Includes:
- Superset::Credential::ApiUser
- Defined in:
- lib/superset/client.rb
Instance Attribute Summary collapse
-
#authenticator ⇒ Object
readonly
Returns the value of attribute authenticator.
Instance Method Summary collapse
- #access_token ⇒ Object
-
#initialize ⇒ Client
constructor
A new instance of Client.
-
#put(resource, params = {}) ⇒ Object
TODO: Happi has not got a put method yet.
-
#raise_error(response) ⇒ Object
TODO: Happi is not surfacing the errors correctly overriding raise_error for now.
- #superset_host ⇒ Object
Methods included from Superset::Credential::ApiUser
Constructor Details
#initialize ⇒ Client
Returns a new instance of Client.
7 8 9 10 |
# File 'lib/superset/client.rb', line 7 def initialize @authenticator = Superset::Authenticator.new(credentials) super(log_level: :debug, host: superset_host) end |
Instance Attribute Details
#authenticator ⇒ Object (readonly)
Returns the value of attribute authenticator.
5 6 7 |
# File 'lib/superset/client.rb', line 5 def authenticator @authenticator end |
Instance Method Details
#access_token ⇒ Object
12 13 14 |
# File 'lib/superset/client.rb', line 12 def access_token @access_token ||= authenticator.access_token end |
#put(resource, params = {}) ⇒ Object
TODO: Happi has not got a put method yet
21 22 23 24 |
# File 'lib/superset/client.rb', line 21 def put(resource, params = {}) call(:put, url(resource), param_check(params)) .body.with_indifferent_access end |
#raise_error(response) ⇒ Object
TODO: Happi is not surfacing the errors correctly overriding raise_error for now
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/superset/client.rb', line 27 def raise_error(response) = if response.body['errors'] response.body['errors'] else response.body end puts "API Error: #{}" # display the error message for console debugging # binding.pry # helpfull to debug the response raise errors[response.status].new(, response) # message is not being surfaced from Happi correctly, :( end |
#superset_host ⇒ Object
16 17 18 |
# File 'lib/superset/client.rb', line 16 def superset_host @superset_host ||= authenticator.superset_host end |