Class: DHClient::Datahub
- Inherits:
-
Object
- Object
- DHClient::Datahub
- Defined in:
- lib/dhclient/datahub.rb
Instance Method Summary collapse
- #compositions(pool_name = 'GLOBAL') ⇒ Object
-
#initialize(base_url = "http://localhost:8080/datahub-webapp/v1", username = "admin", password = "nimda") ⇒ Datahub
constructor
A new instance of Datahub.
-
#load_data(file, feed_name = 'DEFAULT_FEED', raw_item_name) ⇒ Object
POST.
- #publications(pool_name = 'GLOBAL') ⇒ Object
- #start_composition(pool_name = 'GLOBAL') ⇒ Object
- #start_publication(pool_name = 'GLOBAL', target_system) ⇒ Object
- #status ⇒ Object
-
#version ⇒ Object
GET.
Constructor Details
#initialize(base_url = "http://localhost:8080/datahub-webapp/v1", username = "admin", password = "nimda") ⇒ Datahub
Returns a new instance of Datahub.
4 5 6 7 |
# 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 |
Instance Method Details
#compositions(pool_name = 'GLOBAL') ⇒ Object
21 22 23 24 |
# File 'lib/dhclient/datahub.rb', line 21 def compositions(pool_name='GLOBAL') response = RestClient.get "#{@datahub_base_url}/pools/#{pool_name}/compositions" response.body end |
#load_data(file, feed_name = 'DEFAULT_FEED', raw_item_name) ⇒ Object
POST
33 34 35 36 |
# 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' end |
#publications(pool_name = 'GLOBAL') ⇒ Object
26 27 28 29 |
# File 'lib/dhclient/datahub.rb', line 26 def publications(pool_name='GLOBAL') response = RestClient.get "#{@datahub_base_url}/pools/#{pool_name}/publications" response.body end |
#start_composition(pool_name = 'GLOBAL') ⇒ Object
38 39 40 |
# File 'lib/dhclient/datahub.rb', line 38 def start_composition(pool_name='GLOBAL') http_post "#{@datahub_base_url}/pools/#{pool_name}/compositions" end |
#start_publication(pool_name = 'GLOBAL', target_system) ⇒ Object
42 43 44 45 46 47 |
# 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 ⇒ Object
16 17 18 19 |
# File 'lib/dhclient/datahub.rb', line 16 def status response = RestClient.get "#{@datahub_base_url}/status-counts" response.body end |
#version ⇒ Object
GET
11 12 13 14 |
# File 'lib/dhclient/datahub.rb', line 11 def version response = ::RestClient.get "#{@datahub_base_url}/version" response.body end |