class OpsManagerUiDrivers::Version14::Api
Public Class Methods
new(host_uri:, username:, password:)
click to toggle source
# File lib/ops_manager_ui_drivers/version14/api.rb, line 6 def initialize(host_uri:, username:, password:) @host_uri = URI.parse(host_uri) # we expect "proto://host(:port)" @username = username @password = password end
Public Instance Methods
export_installation()
click to toggle source
# File lib/ops_manager_ui_drivers/version14/api.rb, line 12 def export_installation tmpfile = Tempfile.new('installation.zip') http.request(get('installation_asset_collection')) do |response| response.read_body do |chunk| tmpfile.write(chunk) end end tmpfile.close tmpfile end
Private Instance Methods
api_uri(endpoint)
click to toggle source
# File lib/ops_manager_ui_drivers/version14/api.rb, line 39 def api_uri(endpoint) URI.parse( URI.join(@host_uri.to_s, File.join('api', endpoint)).to_s ) end
get(endpoint)
click to toggle source
# File lib/ops_manager_ui_drivers/version14/api.rb, line 33 def get(endpoint) Net::HTTP::Get.new(api_uri(endpoint).request_uri).tap do |get| get.basic_auth(@username, @password) end end
http()
click to toggle source
# File lib/ops_manager_ui_drivers/version14/api.rb, line 25 def http Net::HTTP.new(@host_uri.host, @host_uri.port).tap do |http| http.use_ssl = @host_uri.is_a?(URI::HTTPS) http.verify_mode = OpenSSL::SSL::VERIFY_NONE http.read_timeout = 1800 end end