Sha256: 59cb9229a061b5ee18e8a8d148a94a7054b534816514396277b37348c5ff2158

Contents?: true

Size: 932 Bytes

Versions: 29

Compression:

Stored size: 932 Bytes

Contents

require 'net/https'

module OpsManagerUiDrivers
  module Version13
    class Api
      def initialize(host: nil, user: nil, password: nil)
        @host = host
        @user = user
        @password = password
      end

      def export_installation
        response = http.request(get('installation_asset_collection'))

        Tempfile.new('installation.zip').tap do |tempfile|
          tempfile.write(response.body)
          tempfile.close
        end
      end

      private

      def http
        uri = URI(@host)
        Net::HTTP.new(uri.host, uri.port).tap do |http|
          http.use_ssl = true
          http.verify_mode = OpenSSL::SSL::VERIFY_NONE
          http.read_timeout = 900
        end
      end

      def get(endpoint)
        uri = URI("#{@host}/api/#{endpoint}")
        Net::HTTP::Get.new(uri.request_uri).tap do |get|
          get.basic_auth(@user, @password)
        end
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
ops_manager_ui_drivers-0.15.0 lib/ops_manager_ui_drivers/version13/api_1_3.rb
ops_manager_ui_drivers-0.14.1 lib/ops_manager_ui_drivers/version13/api_1_3.rb
ops_manager_ui_drivers-0.14.0 lib/ops_manager_ui_drivers/version13/api_1_3.rb
ops_manager_ui_drivers-0.13.0 lib/ops_manager_ui_drivers/version13/api_1_3.rb
ops_manager_ui_drivers-0.12.0 lib/ops_manager_ui_drivers/version13/api_1_3.rb
ops_manager_ui_drivers-0.11.0 lib/ops_manager_ui_drivers/version13/api_1_3.rb
ops_manager_ui_drivers-0.10.0 lib/ops_manager_ui_drivers/version13/api_1_3.rb
ops_manager_ui_drivers-0.9.9 lib/ops_manager_ui_drivers/version13/api_1_3.rb
ops_manager_ui_drivers-0.9.8 lib/ops_manager_ui_drivers/version13/api_1_3.rb
ops_manager_ui_drivers-0.9.7 lib/ops_manager_ui_drivers/version13/api_1_3.rb
ops_manager_ui_drivers-0.9.6 lib/ops_manager_ui_drivers/version13/api_1_3.rb
ops_manager_ui_drivers-0.9.5 lib/ops_manager_ui_drivers/version13/api_1_3.rb
ops_manager_ui_drivers-0.9.4 lib/ops_manager_ui_drivers/version13/api_1_3.rb
ops_manager_ui_drivers-0.9.3 lib/ops_manager_ui_drivers/version13/api_1_3.rb
ops_manager_ui_drivers-0.9.2 lib/ops_manager_ui_drivers/version13/api_1_3.rb
ops_manager_ui_drivers-0.9.1 lib/ops_manager_ui_drivers/version13/api_1_3.rb
ops_manager_ui_drivers-0.9.0 lib/ops_manager_ui_drivers/version13/api_1_3.rb
ops_manager_ui_drivers-0.8.2 lib/ops_manager_ui_drivers/version13/api_1_3.rb
ops_manager_ui_drivers-0.8.1 lib/ops_manager_ui_drivers/version13/api_1_3.rb
ops_manager_ui_drivers-0.8.0 lib/ops_manager_ui_drivers/version13/api_1_3.rb