module OEHClient
Constants
- VERSION
Attributes
space_mgr[RW]
spaces[RW]
Public Class Methods
configure_space() { |space_mgr| ... }
click to toggle source
configure provides the basic interface for passing tenancy configuration to the gem
# File lib/oehclient.rb, line 27 def configure_space # if space_mgr attribute is NIL then return a new instance of the OEHClient::Config::SpaceManager # singleton class @space_mgr ||= OEHClient::Config::SpaceManager.instance # yield control to the block passed in the configuration yield(@space_mgr) end
get(url, oauth_consumer=nil, *args)
click to toggle source
wraps the GET method of the RestClient::Resource and manages the response that is returned
# File lib/oehclient.rb, line 38 def get(url, oauth_consumer=nil, *args) # retrieved the passed options from the SPLAT options = (args.length > 0 ? args[0] : Hash.new) # if the oauth_consumer is not a proper OAuth::Consumer, then raise the Oeh::Exception::InvalidTokenException # exception to the calling method raise OEHClient::Exception::InvalidConsumerException if (!oauth_consumer.nil? && !oauth_consumer.kind_of?(OAuth::Consumer)) # reset execution processes RestClient.reset_before_execution_procs # if this request has an oauth token, sign the RestClient object unless (oauth_consumer.nil?) # add the oauth signature RestClient.add_before_execution_proc { |req, params| oauth_consumer.sign! req } end # force the new hash for the header and params if they are NIL header = (options.has_key?(:header) ? options[:header] : OEHClient::Helper::Request.default_JSON_header()) # merge parameters into the header if they are passed header.merge!(:params => options[:params] ) if (options.has_key?(:params)) #puts("URL: #{url} ; Header: #{header}") # send the GET request, manage the returned response, and return the body of the response to the # calling method RestClient::Request.execute(method: :get, url: url, headers: header, verify_ssl: OpenSSL::SSL::VERIFY_PEER) { | response, request, result | OEHClient::Helper::Response.handle(response)} end
post(url, oauth_consumer=nil, *args)
click to toggle source
post wraps the POST method of the access token and manages the response that is returned
# File lib/oehclient.rb, line 65 def post(url, oauth_consumer=nil, *args) # retrieved the passed options from the SPLAT options = (args.length > 0 ? args[0] : Hash.new) # if the oauth_consumer is not a proper OAuth::Consumer, then raise the Oeh::Exception::InvalidTokenException # exception to the calling method raise OEHClient::Exception::InvalidConsumerException if (!oauth_consumer.nil? && !oauth_consumer.kind_of?(OAuth::Consumer)) # reset execution processes RestClient.reset_before_execution_procs # if this request has an oauth token, sign the RestClient object unless (oauth_consumer.nil?) # add the oauth signature RestClient.add_before_execution_proc { |req, params| oauth_consumer.sign! req } end # force the new hash for the header and params if they are NIL header = (options.has_key?(:header) ? options[:header] : OEHClient::Helper::Request.default_JSON_header()) # merge parameters into the header if they are passed header.merge!(:params => options[:params] ) if (options.has_key?(:params)) puts "-----] payload: #{options[:payload]}\n" # send the POST request, manage the returned response, and return the body of the response to the # calling method RestClient::Request.execute(method: :post, url: url, payload: options[:payload], headers: header, verify_ssl: OpenSSL::SSL::VERIFY_PEER) { | response, request, result | OEHClient::Helper::Response.handle(response)} end
put(url, oauth_consumer=nil, *args)
click to toggle source
put wraps the PUT method of the access token and manages the response that is returned
# File lib/oehclient.rb, line 94 def put(url, oauth_consumer=nil, *args) # retrieved the passed options from the SPLAT options = (args.length > 0 ? args[0] : Hash.new) # if the oauth_consumer is not a proper OAuth::Consumer, then raise the Oeh::Exception::InvalidTokenException # exception to the calling method raise OEHClient::Exception::InvalidConsumerException if (!oauth_consumer.nil? && !oauth_consumer.kind_of?(OAuth::Consumer)) # reset execution processes RestClient.reset_before_execution_procs # if this request has an oauth token, sign the RestClient object unless (oauth_consumer.nil?) # add the oauth signature RestClient.add_before_execution_proc { |req, params| oauth_consumer.sign! req } end # force the new hash for the header and params if they are NIL header = (options.has_key?(:header) ? options[:header] : OEHClient::Helper::Request.default_JSON_header()) # merge parameters into the header if they are passed header.merge!(:params => options[:params] ) if (options.has_key?(:params)) # send the POST request, manage the returned response, and return the body of the response to the # calling method RestClient::Request.execute(method: :put, url: url, payload: options[:payload], headers: header, verify_ssl: OpenSSL::SSL::VERIFY_PEER) { | response, request, result | OEHClient::Helper::Response.handle(response)} end