Class: Rhoconnect::Client
- Inherits:
-
Object
- Object
- Rhoconnect::Client
- Defined in:
- lib/rhoconnect/client.rb
Instance Attribute Summary collapse
-
#token ⇒ Object
Returns the value of attribute token.
-
#uri ⇒ Object
Returns the value of attribute uri.
Class Method Summary collapse
Instance Method Summary collapse
- #create(source_name, partition, obj = {}) ⇒ Object (also: #update)
- #destroy(source_name, partition, obj = {}) ⇒ Object
-
#initialize(params = {}) ⇒ Client
constructor
allow configuration, uri or environment variable initialization.
- #set_auth_callback(callback) ⇒ Object
- #set_query_callback(source_name, callback) ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ Client
allow configuration, uri or environment variable initialization
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rhoconnect/client.rb', line 16 def initialize(params = {}) uri = params[:uri] || Rhoconnect.configuration.uri || ENV['RHOCONNECT_URL'] raise ArgumentError.new("Please provide a :uri or set RHOCONNECT_URL") unless uri @uri = URI.parse(uri) @token = params[:token] || Rhoconnect.configuration.token || @uri.user @uri.user = nil; @uri = @uri.to_s raise ArgumentError.new("Please provide a :token or set it in uri") unless @token RestClient.proxy = ENV['HTTP_PROXY'] || ENV['http_proxy'] || Rhoconnect.configuration.http_proxy end |
Instance Attribute Details
#token ⇒ Object
Returns the value of attribute token.
5 6 7 |
# File 'lib/rhoconnect/client.rb', line 5 def token @token end |
#uri ⇒ Object
Returns the value of attribute uri.
5 6 7 |
# File 'lib/rhoconnect/client.rb', line 5 def uri @uri end |
Class Method Details
.set_app_endpoint(args) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/rhoconnect/client.rb', line 7 def self.set_app_endpoint(args) RestClient::Request.execute( :method => :post, :url => args[:url], :payload => args[:payload], :timeout => 2000, :headers => args[:headers] ) end |
Instance Method Details
#create(source_name, partition, obj = {}) ⇒ Object Also known as: update
29 30 31 |
# File 'lib/rhoconnect/client.rb', line 29 def create(source_name, partition, obj = {}) send_objects(:push_objects, source_name, partition, obj) end |
#destroy(source_name, partition, obj = {}) ⇒ Object
33 34 35 |
# File 'lib/rhoconnect/client.rb', line 33 def destroy(source_name, partition, obj = {}) send_objects(:push_deletes, source_name, partition, obj) end |
#set_auth_callback(callback) ⇒ Object
40 41 42 |
# File 'lib/rhoconnect/client.rb', line 40 def set_auth_callback(callback) process(:post, "/api/set_auth_callback", { :callback => callback }) end |
#set_query_callback(source_name, callback) ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/rhoconnect/client.rb', line 44 def set_query_callback(source_name, callback) process(:post, "/api/set_query_callback", { :source_id => source_name, :callback => callback } ) end |