Sha256: 651d23e55ed4d9682781c083d1e4e469806b8dd54e46a31e71f8f367d4b2b2f2

Contents?: true

Size: 1.29 KB

Versions: 35

Compression:

Stored size: 1.29 KB

Contents

require 'ops_manager_ui_drivers/version16/api'
require 'uaa'

module OpsManagerUiDrivers
  module Version17
    class Api < Version16::Api
      def set_feature_flag(flag_name, value)
        feature_flag_path = File.join('feature_flags', flag_name)

        http.request(put(feature_flag_path, enabled: value))
      end

      def get_products
        http.request(get('v0/products'), uaa_token.auth_header)
      end

      private

      def uaa_token
        target_url   = @host_uri.to_s + '/uaa'
        token_issuer = CF::UAA::TokenIssuer.new(target_url, 'opsman', nil, {:skip_ssl_validation => true})
        token_issuer.owner_password_grant('admin', 'admin')
      end

      def get(endpoint, token=nil)
        Net::HTTP::Get.new(api_uri(endpoint).request_uri).tap do |get|
          add_auth_to_request(get, token)
        end
      end

      def put(endpoint, form_data, token=nil)
        Net::HTTP::Put.new(api_uri(endpoint).request_uri).tap do |put_request|
          add_auth_to_request(put_request, token)
          put_request.set_form_data(form_data)
        end
      end

      def add_auth_to_request(request, token)
        if token.present?
          request['Authorization'] = token
        else
          request.basic_auth(@username, @password)
        end
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
ops_manager_ui_drivers-2.9.0 lib/ops_manager_ui_drivers/version17/api.rb
ops_manager_ui_drivers-2.8.0 lib/ops_manager_ui_drivers/version17/api.rb
ops_manager_ui_drivers-2.7.3 lib/ops_manager_ui_drivers/version17/api.rb
ops_manager_ui_drivers-2.7.2 lib/ops_manager_ui_drivers/version17/api.rb
ops_manager_ui_drivers-2.7.1 lib/ops_manager_ui_drivers/version17/api.rb
ops_manager_ui_drivers-2.7.0 lib/ops_manager_ui_drivers/version17/api.rb
ops_manager_ui_drivers-2.6.4 lib/ops_manager_ui_drivers/version17/api.rb
ops_manager_ui_drivers-2.6.3 lib/ops_manager_ui_drivers/version17/api.rb
ops_manager_ui_drivers-2.6.2 lib/ops_manager_ui_drivers/version17/api.rb
ops_manager_ui_drivers-2.6.1 lib/ops_manager_ui_drivers/version17/api.rb
ops_manager_ui_drivers-2.6.0 lib/ops_manager_ui_drivers/version17/api.rb
ops_manager_ui_drivers-2.5.2 lib/ops_manager_ui_drivers/version17/api.rb
ops_manager_ui_drivers-2.5.1 lib/ops_manager_ui_drivers/version17/api.rb
ops_manager_ui_drivers-2.5.0 lib/ops_manager_ui_drivers/version17/api.rb
ops_manager_ui_drivers-2.4.2 lib/ops_manager_ui_drivers/version17/api.rb
ops_manager_ui_drivers-2.4.1 lib/ops_manager_ui_drivers/version17/api.rb
ops_manager_ui_drivers-2.4.0 lib/ops_manager_ui_drivers/version17/api.rb
ops_manager_ui_drivers-2.3.2 lib/ops_manager_ui_drivers/version17/api.rb
ops_manager_ui_drivers-2.3.1 lib/ops_manager_ui_drivers/version17/api.rb
ops_manager_ui_drivers-2.3.0 lib/ops_manager_ui_drivers/version17/api.rb