class OpsManagerUiDrivers::Version18::Api
Constants
- NETWORKS_AND_AZS_PATH
- PRODUCTS_PATH
- PRODUCTS_UPLOAD_PATH
- SETUP_PATH
- STEMCELLS_UPLOAD_PATH
Public Instance Methods
add_product!(name:, product_version:)
click to toggle source
# File lib/ops_manager_ui_drivers/version18/api.rb, line 33 def add_product!(name:, product_version:) params = { name: name, product_version: product_version } post_request(endpoint: PRODUCTS_PATH, params: params) end
assign_azs_and_network(product_guid:, singleton_availability_zone:, availability_zones:, network:, service_network: nil)
click to toggle source
# File lib/ops_manager_ui_drivers/version18/api.rb, line 68 def assign_azs_and_network(product_guid:, singleton_availability_zone:, availability_zones:, network:, service_network: nil) params = { networks_and_azs: { singleton_availability_zone: { name: singleton_availability_zone }, other_availability_zones: availability_zones.map{|az| { name: az } }, network: { name: network }, } } params[:networks_and_azs].merge!(service_network: { name: service_network }) if service_network endpoint = url_for_product(product_id: product_guid, route: NETWORKS_AND_AZS_PATH) put_request(endpoint: endpoint, params: params) end
internal_setup!()
click to toggle source
# File lib/ops_manager_ui_drivers/version18/api.rb, line 19 def internal_setup! setup_params = { eula_accepted: 'true', admin_user_name: @username, admin_password: @password, admin_password_confirmation: @password, decryption_passphrase: @password, decryption_passphrase_confirmation: @password, identity_provider: 'internal', } post_request(endpoint: SETUP_PATH, params: setup_params) end
product_guid(product_name:)
click to toggle source
# File lib/ops_manager_ui_drivers/version18/api.rb, line 83 def product_guid(product_name:) response = get_request(endpoint: PRODUCTS_PATH) JSON.parse(response.body).find {|product_hash| product_hash['type'] == product_name }['guid'] end
set_feature_flag(_flag_name, _value)
click to toggle source
# File lib/ops_manager_ui_drivers/version18/api.rb, line 15 def set_feature_flag(_flag_name, _value) Logger.error 'This method is a no-op. Ops Manager 1.8 does not support turning feature_flags on/off' end
upload_product_zip(path:)
click to toggle source
# File lib/ops_manager_ui_drivers/version18/api.rb, line 42 def upload_product_zip(path:) post_file( endpoint: PRODUCTS_UPLOAD_PATH, path: path, type: 'application/zip') do |file_param| { 'product' => { 'file' => file_param } } end end
upload_stemcell(path:)
click to toggle source
# File lib/ops_manager_ui_drivers/version18/api.rb, line 55 def upload_stemcell(path:) post_file( endpoint: STEMCELLS_UPLOAD_PATH, path: path, type: 'application/zip') do |file_param| { 'stemcell' => { 'file' => file_param } } end end
Private Instance Methods
faraday_connection() { |faraday| ... }
click to toggle source
# File lib/ops_manager_ui_drivers/version18/api.rb, line 131 def faraday_connection Faraday.new(:url => @host_uri) do |faraday| yield(faraday) if block_given? faraday.adapter :net_http end end
faraday_request(conn: faraday_connection, endpoint:, body: nil, method: ) { |req| ... }
click to toggle source
# File lib/ops_manager_ui_drivers/version18/api.rb, line 122 def faraday_request(conn: faraday_connection, endpoint:, body: nil, method: ) conn.send(method) do |req| yield(req) if block_given? req.body = body if body req.url(endpoint) req.headers['Authorization'] = uaa_token.auth_header end end
get_request(endpoint:)
click to toggle source
# File lib/ops_manager_ui_drivers/version18/api.rb, line 102 def get_request(endpoint:) faraday_request(method: :get, endpoint: endpoint) end
post_file(endpoint:, path:, type:) { |upload_io| ... }
click to toggle source
# File lib/ops_manager_ui_drivers/version18/api.rb, line 95 def post_file(endpoint:, path:, type:) conn = faraday_connection { |faraday |faraday.request :multipart } body = yield(Faraday::UploadIO.new(path, type)) faraday_request(method: :post, conn: conn, body: body, endpoint: endpoint) end
post_request(endpoint:, params:)
click to toggle source
# File lib/ops_manager_ui_drivers/version18/api.rb, line 106 def post_request(endpoint:, params:) json_body = params.to_json faraday_request(method: :post, body: json_body, endpoint: endpoint) do |req| req.headers['Content-Type'] = 'application/json' end end
put_request(endpoint:, params:)
click to toggle source
# File lib/ops_manager_ui_drivers/version18/api.rb, line 114 def put_request(endpoint:, params:) json_body = params.to_json faraday_request(method: :put, body: json_body, endpoint: endpoint) do |req| req.headers['Content-Type'] = 'application/json' end end
url_for_product(product_id:, route:)
click to toggle source
# File lib/ops_manager_ui_drivers/version18/api.rb, line 91 def url_for_product(product_id:, route:) route.gsub(':product_id', product_id) end