class DHClient::Datahub
Public Class Methods
new(base_url="http://localhost:8080/datahub-webapp/v1", username="admin", password="nimda")
click to toggle source
# File lib/dhclient/datahub.rb, line 4 def initialize(base_url="http://localhost:8080/datahub-webapp/v1", username="admin", password="nimda") uri = URI.parse(base_url) @datahub_base_url = "#{uri.scheme}://#{username}:#{password}@#{uri.host}:#{uri.port}#{uri.path}" end
Public Instance Methods
compositions(pool_name='GLOBAL', opts={})
click to toggle source
# File lib/dhclient/datahub.rb, line 21 def compositions(pool_name='GLOBAL', opts={}) response = RestClient.get "#{@datahub_base_url}/pools/#{pool_name}/compositions", accept: opts[:format] ||:json response.body end
load_data(file, feed_name='DEFAULT_FEED', raw_item_name)
click to toggle source
POST
# File lib/dhclient/datahub.rb, line 33 def load_data(file, feed_name='DEFAULT_FEED', raw_item_name) data = File.new(file, 'rb') http_post "#{@datahub_base_url}/data-feeds/#{feed_name}/items/#{raw_item_name}", data, content_type: 'application/octet-stream', accept: :json end
publications(pool_name='GLOBAL', opts={})
click to toggle source
# File lib/dhclient/datahub.rb, line 26 def publications(pool_name='GLOBAL', opts={}) response = RestClient.get "#{@datahub_base_url}/pools/#{pool_name}/publications", accept: opts[:format] ||:json response.body end
start_composition(pool_name='GLOBAL')
click to toggle source
# File lib/dhclient/datahub.rb, line 38 def start_composition(pool_name='GLOBAL') http_post "#{@datahub_base_url}/pools/#{pool_name}/compositions", {}, {accept: :json} end
start_publication(pool_name='GLOBAL', target_system)
click to toggle source
# File lib/dhclient/datahub.rb, line 42 def start_publication(pool_name='GLOBAL', target_system) json_payload = {targetSystemPublications: [ {targetSystemName: target_system} ]}.to_json http_post "#{@datahub_base_url}/pools/#{pool_name}/publications", json_payload, {content_type: :json, accept: :json} end
status(opts={})
click to toggle source
# File lib/dhclient/datahub.rb, line 16 def status(opts={}) response = RestClient.get "#{@datahub_base_url}/status-counts", {}, accept: opts[:format] ||:json response.body end
version()
click to toggle source
GET
# File lib/dhclient/datahub.rb, line 11 def version response = ::RestClient.get "#{@datahub_base_url}/version" response.body end
Private Instance Methods
http_post(url, payload={}, headers={})
click to toggle source
# File lib/dhclient/datahub.rb, line 51 def http_post(url, payload={}, headers={}) RestClient.post url, payload, headers end