Sha256: 9e295ea7e8d17f69969ba781c18eef35810f4fca687e18d7c32388ee15752144
Contents?: true
Size: 1.28 KB
Versions: 2
Compression:
Stored size: 1.28 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ops_manager_ui_drivers-1.28.1 | lib/ops_manager_ui_drivers/version17/api.rb |
ops_manager_ui_drivers-1.28.0 | lib/ops_manager_ui_drivers/version17/api.rb |