Sha256: 3f379ab4417b5b11d5363334b9414b51959d6c64e3fd388e58ed4fe5b175ade2
Contents?: true
Size: 1.94 KB
Versions: 2
Compression:
Stored size: 1.94 KB
Contents
module DHClient class Datahub 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 #GET def version response = ::RestClient.get "#{@datahub_base_url}/version" response.body end def status(opts={}) response = RestClient.get "#{@datahub_base_url}/status-counts", {}, accept: opts[:format] ||:json response.body end def compositions(pool_name='GLOBAL', opts={}) response = RestClient.get "#{@datahub_base_url}/pools/#{pool_name}/compositions", accept: opts[:format] ||:json response.body end def publications(pool_name='GLOBAL', opts={}) response = RestClient.get "#{@datahub_base_url}/pools/#{pool_name}/publications", accept: opts[:format] ||:json response.body end #POST 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 def start_composition(pool_name='GLOBAL') http_post "#{@datahub_base_url}/pools/#{pool_name}/compositions", {}, {accept: :json} end 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 private def http_post(url, payload={}, headers={}) RestClient.post url, payload, headers end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dhclient-0.1.6 | lib/dhclient/datahub.rb |
dhclient-0.1.5 | lib/dhclient/datahub.rb |