Class: OVH::REST

Inherits:
Object
  • Object
show all
Defined in:
lib/ovh/rest.rb

Constant Summary collapse

API_URL =
"https://api.ovh.com/1.0"

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key, api_secret, consumer_key) ⇒ REST

Returns a new instance of REST.



26
27
28
29
# File 'lib/ovh/rest.rb', line 26

def initialize(api_key, api_secret, consumer_key)
  @api_url = API_URL
  @api_key, @api_secret, @consumer_key = api_key, api_secret, consumer_key
end

Class Method Details

.generate_consumer_key(api_key, access_rules) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/ovh/rest.rb', line 15

def generate_consumer_key(api_key, access_rules)
  uri = URI.parse("#{API_URL}/auth/credential")
  request = Net::HTTP::Post.new(uri.path, initheader = {"X-Ovh-Application" => api_key, "Content-type" => "application/json"})
  request.body = access_rules.to_json
  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = true
  response = http.request(request)
  JSON.parse(response.body)
end