Method: Confidant::Client#get_service

Defined in:
lib/confidant/client.rb

#get_service(service = nil) ⇒ Object

Return a Hash of credentials from the confidant API for service, either explicitly-provided, or from config.



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/confidant/client.rb', line 26

def get_service(service = nil)
  log.debug "Requesting #{api_service_url(service_name(service))} " \
            "as user #{api_user}"
  response = RestClient::Request.execute(
    method: :get,
    url: api_service_url(service_name(service)),
    user: api_user,
    password: generate_token,
    headers: {
      user_agent: RestClient::Platform.default_user_agent.prepend(
        "confidant-client/#{Confidant::VERSION} "
      )
    }
  )

  JSON.parse(response.body)
rescue => ex
  Confidant.log_exception(self, ex)
  @suppress_errors ? api_error_response : raise
end