Sha256: f77f3e9f53a15b188299a1f9c023fea961e151839c54324e1a4f65f86d137960

Contents?: true

Size: 987 Bytes

Versions: 19

Compression:

Stored size: 987 Bytes

Contents

require 'net/https'

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

      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

      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 = 1800
        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

19 entries across 19 versions & 1 rubygems

Version Path
ops_manager_ui_drivers-1.7.3 lib/ops_manager_ui_drivers/version14/api_1_4.rb
ops_manager_ui_drivers-1.7.1 lib/ops_manager_ui_drivers/version14/api_1_4.rb
ops_manager_ui_drivers-1.7.0 lib/ops_manager_ui_drivers/version14/api_1_4.rb
ops_manager_ui_drivers-1.6.3 lib/ops_manager_ui_drivers/version14/api_1_4.rb
ops_manager_ui_drivers-1.6.2 lib/ops_manager_ui_drivers/version14/api_1_4.rb
ops_manager_ui_drivers-1.5.1 lib/ops_manager_ui_drivers/version14/api_1_4.rb
ops_manager_ui_drivers-1.6.1 lib/ops_manager_ui_drivers/version14/api_1_4.rb
ops_manager_ui_drivers-1.6.0 lib/ops_manager_ui_drivers/version14/api_1_4.rb
ops_manager_ui_drivers-1.5.0 lib/ops_manager_ui_drivers/version14/api_1_4.rb
ops_manager_ui_drivers-1.4.0 lib/ops_manager_ui_drivers/version14/api_1_4.rb
ops_manager_ui_drivers-1.3.1 lib/ops_manager_ui_drivers/version14/api_1_4.rb
ops_manager_ui_drivers-1.3.0 lib/ops_manager_ui_drivers/version14/api_1_4.rb
ops_manager_ui_drivers-1.2.1 lib/ops_manager_ui_drivers/version14/api_1_4.rb
ops_manager_ui_drivers-1.2.0 lib/ops_manager_ui_drivers/version14/api_1_4.rb
ops_manager_ui_drivers-1.1.0 lib/ops_manager_ui_drivers/version14/api_1_4.rb
ops_manager_ui_drivers-1.0.0 lib/ops_manager_ui_drivers/version14/api_1_4.rb
ops_manager_ui_drivers-0.16.0 lib/ops_manager_ui_drivers/version14/api_1_4.rb
ops_manager_ui_drivers-0.15.2 lib/ops_manager_ui_drivers/version14/api_1_4.rb
ops_manager_ui_drivers-0.15.1 lib/ops_manager_ui_drivers/version14/api_1_4.rb