GithubHelp home page GithubHelp logo

ruby-ovh's Introduction

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

ruby-ovh's People

Contributors

bvasseursiliconsalad avatar

Watchers

James Cloos avatar Gareste avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.