def initialize(client, preferred_api_versions=[])
super(nil, client)
@server_api_versions = []
debug "Client supports API versions #{preferred_api_versions.join(', ')}"
@client_api_versions = preferred_api_versions
@server_api_versions, @current_api_version, links = api_info({
:url => client.url,
:method => :get,
:accept => :json,
:no_auth => true,
})
debug "Server supports API versions #{@server_api_versions.join(', ')}"
if api_version_negotiated
debug " Using API version #{api_version_negotiated}"
unless client_api_version_current?
debug "Client API version #{api_version_negotiated} is not current. Refetching API"
@server_api_versions, @current_api_version, links = api_info({
:url => client.url,
:method => :get,
:accept => :json,
:api_version => api_version_negotiated,
:no_auth => true,
})
end
else
warn_about_api_versions
end
attributes['links'] = links
rescue RHC::Rest::ResourceNotFoundException => e
raise ApiEndpointNotFound.new(
"The OpenShift server is not responding correctly. Check "\
"that '#{client.url}' is the correct URL for your server. "\
"The server may be offline or misconfigured.")
end