Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rivsc/ruby_ovh
Ruby Ovh API
https://github.com/rivsc/ruby_ovh
Last synced: 20 days ago
JSON representation
Ruby Ovh API
- Host: GitHub
- URL: https://github.com/rivsc/ruby_ovh
- Owner: rivsc
- License: mit
- Created: 2019-06-06T14:16:55.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-03-19T14:51:28.000Z (almost 4 years ago)
- Last Synced: 2024-10-31T18:12:39.855Z (2 months ago)
- Language: Ruby
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.markdown
- License: MIT-LICENSE
Awesome Lists containing this project
README
# RubyOvh
## Install
Add this in your Gemfile :
```ruby
gem 'ruby_ovh'
```## Prerequisites
1. Create your app at Ovh : [https://eu.api.ovh.com/createApp/](https://eu.api.ovh.com/createApp/) and get an application_key (ak) and an application_secret (as).
2. The first time you need a consumer_key (ck). You can generate as follow (thanks to your application_key and application_secret) :#### Create a consumer_key with default AccessRules (GET/POST/PUT)
```ruby
client = RubyOvh::Client.new({application_key: 'XXXX', application_secret: 'YYYY' })
response = client.generate_consumer_key
puts "You need to memorize your consumer_key : #{response[:consumer_key]}"
puts "You need visit this address in your browser in order to activate your consumer key #{response[:validation_url]}"
```### OR
#### create a consumer_key with specific AccessRules (here GET/POST/PUT/DELETE)
```ruby
client = RubyOvh::Client.new({application_key: 'XXXX', application_secret: 'YYYY' })
response = client.generate_consumer_key({ access_rules: [
{
"method": "GET",
"path": "/*"
},{
"method": "POST",
"path": "/*"
},{
"method": "PUT",
"path": "/*"
},{
"method": "DELETE",
"path": "/*"
}
] })
puts "You need to memorize your consumer_key : #{response[:consumer_key]}"
puts "You need visit this address in your browser in order to activate your consumer key #{response[:validation_url]}"
```## Usage
After that, thanks to your consumer key, you can call Ovh API as follow :
GET request :
```ruby
client = RubyOvh::Client.new({application_key: 'XXXX', application_secret: 'YYYY', consumer_key: 'ZZZZZ' })
puts client.query({ method: 'GET', url: "/me", query: {} })
```Another GET request with params :
```ruby
puts client.query({ url: "/domain/zone/mydomain.org/record?fieldType=A" , method: "GET", query: {} })
```POST request :
```ruby
client.query({ url: "/domain/zone/mydomain.org/record" , method: "POST", query: {
"subDomain": "blog",
"target": "XX.X.X.XXX",
"fieldType": "A"
}})
```List Ovh API : [https://eu.api.ovh.com/console/#/](https://eu.api.ovh.com/console/#/)
Rivsc.