Class: Fog::Hetznercloud::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/fog/hetznercloud/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(endpoint, token, connection_options) ⇒ Client

Returns a new instance of Client.



4
5
6
7
8
# File 'lib/fog/hetznercloud/client.rb', line 4

def initialize(endpoint, token, connection_options)
  @endpoint           = endpoint
  @token              = token
  @connection_options = connection_options
end

Instance Method Details

#request(params) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/fog/hetznercloud/client.rb', line 10

def request(params)
  params[:headers] ||= {}
  params[:headers]['Content-Type'] ||= 'application/json'
  params[:headers]['Authorization'] ||= "Bearer #{@token}"

  params[:body] = encode_body(params)

  response = connection.request(params)

  response.body = decode_body(response)

  response
end