Class: Fog::UKCloud::Service
- Inherits:
-
Object
- Object
- Fog::UKCloud::Service
- Defined in:
- lib/fog/ukcloud/service.rb
Instance Method Summary collapse
- #_request(options) ⇒ Object
- #headers(options = {}) ⇒ Object
- #login ⇒ Object
- #ws_enduser_url(url = nil) ⇒ Object
Instance Method Details
#_request(options) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/fog/ukcloud/service.rb', line 10 def _request() http_method = [:http_method] || :get @request_url = "#{@ws_enduser_url}/#{options[:method]}" params = {headers: headers} params[:expects] = [:expected] || [200, 201] unless [:body].nil? params[:body] = [:body] end params[:read_timeout] = 360 # initialize connection object @connection = Fog::Core::Connection.new(@request_url, false, params) # send request begin response = @connection.request(:method => http_method) rescue Excon::Errors::Timeout # raise an error raise Fog::UKCloud::Errors::RequestTimeOut.new( "Request timed out after: #{60 unless params[:read_timeout]}" ) end # decode the response and return it Fog::JSON.decode(response.body) end |
#headers(options = {}) ⇒ Object
38 39 40 |
# File 'lib/fog/ukcloud/service.rb', line 38 def headers(={}) {'Content-Type' => 'application/json'}.merge([:headers] || {}) end |
#login ⇒ Object
42 43 44 |
# File 'lib/fog/ukcloud/service.rb', line 42 def login end |
#ws_enduser_url(url = nil) ⇒ Object
6 7 8 |
# File 'lib/fog/ukcloud/service.rb', line 6 def ws_enduser_url(url=nil) @ws_enduser_url = url || Fog::UKCloud::DEFAULT_WS_ENDUSER_URL end |