Project

ovh-api

0.0
No commit activity in last 3 years
No release in over 3 years
Library wrapping OVH API v6 (see: https://api.ovh.com)
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 2.0.2, ~> 2.0
~> 3.3
~> 1.21
 Project Readme

Important note

This is not an official repository of OVH and this is a work in progress

Lightweight wrapper around OVH's APIs. Handles all the hard work including credential creation and requests signing.

require_relative 'client'

client = OVH::Client.new(
  application_key: '<app key>',
  application_secret: '<app secret>',
  consumer_key: '<consumer key>'
)

puts client.get('/me').body['firstname']

Installation

For now you have to clone the repo and make a bundle.

Example usage

Use the API on behalf of a user

  1. Create an application

To interact with the APIs, the SDK needs to identify itself using an application_key and an application_secret. To get them, you need to register your application. For now only the OVH Europe API is supported. - OVH Europe

Once created, you will obtain an application key (AK) and an application secret (AS).

  1. Configure your application

The easiest and safest way to use your application's credentials is create a conf.yml configuration file in application's working directory. Here is how it looks like:

application_key: app_key
application_secret: app_secret
# consumer_key: consumer_key
  1. Authorize your application to access a customer account

To allow your application to access a customer account using the API on your behalf, you need a consumer key (CK).

Here is a sample code you can use to allow your application to access a customer's informations:

require_relative 'client'
# create a client using configuration
client =  OVH::Client.new

# Request RO, /me API access
access_rules = {
  accessRules: [
    {'method' => 'GET', 'path' => '/me'}
  ]
}

# Request token
validation = JSON.parse(client.request_consumerkey(access_rules).body)

puts "Please visit #{validation['validationUrl']}"
puts "Then press Enter"
gets

puts "Welcome #{JSON.parse(client.get('/me').body)['firstname']}"
puts "Btw, your consumerKey is #{validation['consumerKey']}"

Returned consumerKey should then be kept to avoid re-authenticating your end-user on each use.

To request full and unlimited access to the API, you may use wildcards:

access_rules = [
  {'method': 'GET', 'path': '/*'},
  {'method': 'POST', 'path': '/*'},
  {'method': 'PUT', 'path': '/*'},
  {'method': 'DELETE', 'path': '/*'}
]

Run the tests

For now the only test is a Cucumber test (integration test). More tests will come (cucmber and Rspec)

cucumber

Build the documentation

Documentation is managed with Yard

yard