def rest_client(opts={})
@rest_client ||= begin
core_auth = if (options.ssl_client_cert_file && options.ssl_client_key_file)
RHC::Auth::X509.new(options)
else
RHC::Auth::Basic.new(options)
end
auth = if options.rhlogin && options.password
RHC::Auth::Basic.new(options)
elsif (options.use_authorization_tokens || options.token)
RHC::Auth::Token.new(options, core_auth, token_store)
else
core_auth
end
debug "Authenticating with #{auth.class}"
client_from_options(:auth => auth)
end
if opts[:min_api] && opts[:min_api].to_f > @rest_client.api_version_negotiated.to_f
raise RHC::ServerAPINotSupportedException.new(opts[:min_api], @rest_client.api_version_negotiated)
end
@rest_client
end