Sha256: 528e25b6719831269cd5540e29b8f1ec171194db243309271164385809b7333e

Contents?: true

Size: 932 Bytes

Versions: 2

Compression:

Stored size: 932 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
        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

2 entries across 2 versions & 1 rubygems

Version Path
ops_manager_ui_drivers-0.3.0 lib/ops_manager_ui_drivers/version14/api_1_4.rb
ops_manager_ui_drivers-0.2.0 lib/ops_manager_ui_drivers/version14/api_1_4.rb