Class: Fog::UKCloud::Service

Inherits:
Object
  • Object
show all
Defined in:
lib/fog/ukcloud/service.rb

Instance Method Summary collapse

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(options)
  http_method = options[:http_method] || :get
  @request_url = "#{@ws_enduser_url}/#{options[:method]}"

  params = {headers: headers}
  params[:expects] = options[:expected] || [200, 201]
  unless options[:body].nil?
    params[:body] = options[: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(options={})
  {'Content-Type' => 'application/json'}.merge(options[:headers] || {})
end

#loginObject



42
43
44
# File 'lib/fog/ukcloud/service.rb', line 42

def 

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