ovh 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +28 -0
- data/.rspec +3 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +64 -0
- data/LICENSE.txt +21 -0
- data/README.md +73 -0
- data/Rakefile +6 -0
- data/bin/console +16 -0
- data/bin/consumer_key +11 -0
- data/bin/setup +8 -0
- data/config/setup.rb +15 -0
- data/lib/ovh.rb +37 -0
- data/lib/ovh/client.rb +80 -0
- data/lib/ovh/configuration.rb +27 -0
- data/lib/ovh/endpoints/account.rb +11 -0
- data/lib/ovh/endpoints/consumer.rb +26 -0
- data/lib/ovh/endpoints/ips.rb +23 -0
- data/lib/ovh/endpoints/vps.rb +21 -0
- data/lib/ovh/version.rb +3 -0
- data/ovh.gemspec +36 -0
- metadata +192 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 630a0df8494df29a89d38e8820737df7875ef1fb6091ae16e418666b3ef513bd
|
4
|
+
data.tar.gz: 845245d9a703a6827e96e036d3f2dc26620231fa0d23c4df49a5b3c017f87812
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 03d9f95632d8148edda8a29b3a884d2dec0691404c682b0c937602db111a6918fd6108d13902906d90045bbb13d40a955eb0b740b46c8a45d27e0e7073e5644f
|
7
|
+
data.tar.gz: 86637af1e8f04380c3cf0dc892fe379c03bec957bb5a3c4d2b9b0a8209e8cf05b85587173f8523952be2e399af966aff73e9384bcc3faeb2f161148f7df50a89
|
data/.gitignore
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
/.bundle/
|
2
|
+
/.yardoc
|
3
|
+
/_yardoc/
|
4
|
+
/coverage/
|
5
|
+
/doc/
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/spec/tmp/
|
9
|
+
/tmp/
|
10
|
+
|
11
|
+
# rspec failure tracking
|
12
|
+
.rspec_status
|
13
|
+
|
14
|
+
# pry history
|
15
|
+
.pry_history
|
16
|
+
|
17
|
+
# appraisals
|
18
|
+
/gemfiles/*.lock
|
19
|
+
|
20
|
+
# Credentials
|
21
|
+
/config/credentials.yml
|
22
|
+
|
23
|
+
# RVM
|
24
|
+
.ruby-version
|
25
|
+
.ruby-gemset
|
26
|
+
|
27
|
+
# DS_Store
|
28
|
+
.DS_Store
|
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at sebastian.johnsson@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
ovh (0.1.0)
|
5
|
+
faraday (~> 0.15.2)
|
6
|
+
faraday_middleware (>= 0.12.2)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
addressable (2.5.2)
|
12
|
+
public_suffix (>= 2.0.2, < 4.0)
|
13
|
+
coderay (1.1.2)
|
14
|
+
crack (0.4.3)
|
15
|
+
safe_yaml (~> 1.0.0)
|
16
|
+
diff-lcs (1.3)
|
17
|
+
faraday (0.15.2)
|
18
|
+
multipart-post (>= 1.2, < 3)
|
19
|
+
faraday_middleware (0.12.2)
|
20
|
+
faraday (>= 0.7.4, < 1.0)
|
21
|
+
hashdiff (0.3.7)
|
22
|
+
method_source (0.9.0)
|
23
|
+
multipart-post (2.0.0)
|
24
|
+
pry (0.11.3)
|
25
|
+
coderay (~> 1.1.0)
|
26
|
+
method_source (~> 0.9.0)
|
27
|
+
public_suffix (3.0.2)
|
28
|
+
rake (12.3.1)
|
29
|
+
rdoc (6.0.4)
|
30
|
+
rspec (3.7.0)
|
31
|
+
rspec-core (~> 3.7.0)
|
32
|
+
rspec-expectations (~> 3.7.0)
|
33
|
+
rspec-mocks (~> 3.7.0)
|
34
|
+
rspec-core (3.7.1)
|
35
|
+
rspec-support (~> 3.7.0)
|
36
|
+
rspec-expectations (3.7.0)
|
37
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
38
|
+
rspec-support (~> 3.7.0)
|
39
|
+
rspec-mocks (3.7.0)
|
40
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
41
|
+
rspec-support (~> 3.7.0)
|
42
|
+
rspec-support (3.7.1)
|
43
|
+
safe_yaml (1.0.4)
|
44
|
+
vcr (4.0.0)
|
45
|
+
webmock (3.4.2)
|
46
|
+
addressable (>= 2.3.6)
|
47
|
+
crack (>= 0.3.2)
|
48
|
+
hashdiff
|
49
|
+
|
50
|
+
PLATFORMS
|
51
|
+
ruby
|
52
|
+
|
53
|
+
DEPENDENCIES
|
54
|
+
bundler (~> 1.16.2)
|
55
|
+
ovh!
|
56
|
+
pry (~> 0.11.3)
|
57
|
+
rake (~> 12.3.1)
|
58
|
+
rdoc (~> 6.0.4)
|
59
|
+
rspec (~> 3.7.0)
|
60
|
+
vcr (~> 4.0)
|
61
|
+
webmock (~> 3.4.2)
|
62
|
+
|
63
|
+
BUNDLED WITH
|
64
|
+
1.16.2
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Sebastian
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
# Ovh
|
2
|
+
|
3
|
+
Ovh is a lightweight Ruby HTTP client for interacting with [OVH's API](https://eu.api.ovh.com).
|
4
|
+
|
5
|
+
It's a work in progress - pull requests are appreciated for additional API endpoints etc.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'ovh'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install ovh
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
[Sign up here](https://eu.api.ovh.com/createApp/) in order to get your application key and application secret.
|
26
|
+
|
27
|
+
Setup the configuration for the client:
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
Ovh.configure do |config|
|
31
|
+
config.application_key = "YOUR_APPLICATION_KEY"
|
32
|
+
config.application_secret = "YOUR_APPLICATION_SECRET"
|
33
|
+
end
|
34
|
+
```
|
35
|
+
|
36
|
+
Request a new consumer key using either bin/consumer_key or manually (which allows you to customize the credentials you want):
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
client = Ovh::Client.new
|
40
|
+
response = client.request_consumer_key # Will default to only allow GET requests if invoked without custom access rules
|
41
|
+
```
|
42
|
+
|
43
|
+
In the response/hash you'll receive there'll be a validation url as well as a consumer key. Visit the validation url and grant privileges to the consumer key.
|
44
|
+
|
45
|
+
Now update your client configuration again:
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
Ovh.configure do |config|
|
49
|
+
config.application_key = "YOUR_APPLICATION_KEY"
|
50
|
+
config.application_secret = "YOUR_APPLICATION_SECRET"
|
51
|
+
config.consumer_key = "YOUR_CONSUMER_KEY"
|
52
|
+
end
|
53
|
+
```
|
54
|
+
|
55
|
+
Now you can use all of the available API:s!
|
56
|
+
|
57
|
+
## Development
|
58
|
+
|
59
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
60
|
+
|
61
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
62
|
+
|
63
|
+
## Contributing
|
64
|
+
|
65
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/SebastianJ/ovh. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
66
|
+
|
67
|
+
## License
|
68
|
+
|
69
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
70
|
+
|
71
|
+
## Code of Conduct
|
72
|
+
|
73
|
+
Everyone interacting in the Ovh project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/SebastianJ/ovh/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "ovh"
|
5
|
+
require_relative "../config/setup"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
require "pry"
|
12
|
+
Pry.config.history.file = File.join(__FILE__, "../.pry_history")
|
13
|
+
Pry.start
|
14
|
+
|
15
|
+
#require "irb"
|
16
|
+
#IRB.start(__FILE__)
|
data/bin/consumer_key
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "ovh"
|
5
|
+
require_relative "../config/setup"
|
6
|
+
|
7
|
+
client = Ovh::Client.new
|
8
|
+
response = client.request_consumer_key
|
9
|
+
|
10
|
+
puts "Please visit #{response&.fetch("validationUrl", nil)} to active your consumer key #{response&.fetch("consumerKey", nil)}."
|
11
|
+
puts "Afterwards, add your consumer key to your configuration."
|
data/bin/setup
ADDED
data/config/setup.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# This is just a helper file to configure the client from a credentials file
|
2
|
+
|
3
|
+
require "yaml"
|
4
|
+
|
5
|
+
cfg_path = File.join(File.dirname(__FILE__), "credentials.yml")
|
6
|
+
|
7
|
+
if ::File.exists?(cfg_path)
|
8
|
+
cfg = YAML.load_file(cfg_path)
|
9
|
+
|
10
|
+
::Ovh.configure do |config|
|
11
|
+
config.application_key = cfg.fetch("application_key", nil)
|
12
|
+
config.application_secret = cfg.fetch("application_secret", nil)
|
13
|
+
config.consumer_key = cfg.fetch("consumer_key", nil)
|
14
|
+
end
|
15
|
+
end
|
data/lib/ovh.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# Gems
|
2
|
+
require "faraday"
|
3
|
+
require "faraday_middleware"
|
4
|
+
|
5
|
+
# Standard library
|
6
|
+
require "digest/sha1"
|
7
|
+
|
8
|
+
# Gem
|
9
|
+
require "ovh/version"
|
10
|
+
require "ovh/configuration"
|
11
|
+
|
12
|
+
require "ovh/endpoints/consumer"
|
13
|
+
require "ovh/endpoints/account"
|
14
|
+
require "ovh/endpoints/ips"
|
15
|
+
require "ovh/endpoints/vps"
|
16
|
+
|
17
|
+
require "ovh/client"
|
18
|
+
|
19
|
+
module Ovh
|
20
|
+
|
21
|
+
class << self
|
22
|
+
attr_writer :configuration
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.configuration
|
26
|
+
@configuration ||= ::Ovh::Configuration.new
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.reset
|
30
|
+
@configuration = ::Ovh::Configuration.new
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.configure
|
34
|
+
yield(configuration)
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
data/lib/ovh/client.rb
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
module Ovh
|
2
|
+
class Client
|
3
|
+
attr_accessor :configuration, :endpoint
|
4
|
+
|
5
|
+
def initialize(configuration: ::Ovh.configuration)
|
6
|
+
self.configuration = configuration
|
7
|
+
self.endpoint = "#{self.configuration.api_host}/#{self.configuration.api_version}"
|
8
|
+
end
|
9
|
+
|
10
|
+
include ::Ovh::Endpoints::Consumer
|
11
|
+
include ::Ovh::Endpoints::Account
|
12
|
+
include ::Ovh::Endpoints::Ips
|
13
|
+
include ::Ovh::Endpoints::Vps
|
14
|
+
|
15
|
+
def to_uri(path)
|
16
|
+
"#{self.endpoint}#{path}"
|
17
|
+
end
|
18
|
+
|
19
|
+
def get(path, params: {}, headers: {}, options: {})
|
20
|
+
request path, method: :get, params: params, headers: headers, options: options
|
21
|
+
end
|
22
|
+
|
23
|
+
def post(path, params: {}, data: {}, headers: {}, options: {})
|
24
|
+
request path, method: :post, params: params, data: data, headers: headers, options: options
|
25
|
+
end
|
26
|
+
|
27
|
+
def put(path, params: {}, data: {}, headers: {}, options: {})
|
28
|
+
request path, method: :put, params: params, data: data, headers: headers, options: options
|
29
|
+
end
|
30
|
+
|
31
|
+
def delete(path, params: {}, data: {}, headers: {}, options: {})
|
32
|
+
request path, method: :delete, params: params, data: data, headers: headers, options: options
|
33
|
+
end
|
34
|
+
|
35
|
+
def auth(uri)
|
36
|
+
timestamp = Time.now.to_i
|
37
|
+
|
38
|
+
signature = "$1$#{Digest::SHA1.hexdigest("#{self.configuration.application_secret}+#{self.configuration.consumer_key}+GET+#{uri}++#{timestamp}")}"
|
39
|
+
|
40
|
+
headers = {
|
41
|
+
'X-Ovh-Timestamp' => timestamp.to_s,
|
42
|
+
'X-Ovh-Signature' => signature,
|
43
|
+
'x-Ovh-Consumer' => self.configuration.consumer_key
|
44
|
+
}
|
45
|
+
end
|
46
|
+
|
47
|
+
def request(path, method: :get, params: {}, data: {}, headers: {}, options: {}, retries: 3)
|
48
|
+
uri = to_uri(path)
|
49
|
+
|
50
|
+
headers["User-Agent"] = options.fetch(:user_agent, self.configuration.faraday.fetch(:user_agent, nil))
|
51
|
+
headers["X-Ovh-Application"] = self.configuration.application_key
|
52
|
+
headers = headers.merge(auth(uri)) if options.fetch(:sign_request, true)
|
53
|
+
|
54
|
+
connection = ::Faraday.new(url: uri) do |builder|
|
55
|
+
builder.headers = headers
|
56
|
+
|
57
|
+
builder.request :json
|
58
|
+
builder.response :json
|
59
|
+
builder.response :logger if self.configuration.verbose_faraday?
|
60
|
+
|
61
|
+
builder.adapter :net_http
|
62
|
+
end
|
63
|
+
|
64
|
+
response = case method
|
65
|
+
when :get, :head, :options
|
66
|
+
connection.send(method) do |request|
|
67
|
+
request.params = params if params && !params.empty?
|
68
|
+
end
|
69
|
+
when :post, :put, :patch, :delete
|
70
|
+
connection.send(method) do |request|
|
71
|
+
request.body = data if data && !data.empty?
|
72
|
+
request.params = params if params && !params.empty?
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
return response&.body
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Ovh
|
2
|
+
class Configuration
|
3
|
+
attr_accessor :api_host, :api_version
|
4
|
+
attr_accessor :application_key, :application_secret, :consumer_key
|
5
|
+
attr_accessor :faraday
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
self.api_host = "https://eu.api.ovh.com"
|
9
|
+
self.api_version = 1.0
|
10
|
+
|
11
|
+
self.application_key = nil
|
12
|
+
self.application_secret = nil
|
13
|
+
self.consumer_key = nil
|
14
|
+
|
15
|
+
self.faraday = {
|
16
|
+
adapter: :net_http,
|
17
|
+
user_agent: "OVH Ruby HTTP Client",
|
18
|
+
verbose: false
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
def verbose_faraday?
|
23
|
+
self.faraday.fetch(:verbose, false)
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Ovh
|
2
|
+
module Endpoints
|
3
|
+
module Consumer
|
4
|
+
|
5
|
+
def request_consumer_key(access_rules: {}, options: {})
|
6
|
+
# Don't sign the request since we don't have the consumer key yet.
|
7
|
+
options[:sign_request] = false
|
8
|
+
|
9
|
+
if access_rules.nil? || access_rules.empty?
|
10
|
+
# Grant default GET access if no access rules have been supplied
|
11
|
+
|
12
|
+
access_rules = [
|
13
|
+
{'method': 'GET', 'path': '/*'},
|
14
|
+
]
|
15
|
+
end
|
16
|
+
|
17
|
+
data = {
|
18
|
+
"accessRules" => access_rules
|
19
|
+
}
|
20
|
+
|
21
|
+
response = post("/auth/credential", data: data, options: options)
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Ovh
|
2
|
+
module Endpoints
|
3
|
+
module Ips
|
4
|
+
|
5
|
+
def ips(options: {})
|
6
|
+
get("/ip", options: options)
|
7
|
+
end
|
8
|
+
|
9
|
+
def ip_load_balancing(options: {})
|
10
|
+
get("/ip/loadBalancing", options: options)
|
11
|
+
end
|
12
|
+
|
13
|
+
def ip_services(options: {})
|
14
|
+
get("/ip/service", options: options)
|
15
|
+
end
|
16
|
+
|
17
|
+
def ip_service(service_name, options: {})
|
18
|
+
get("/ip/service/#{service_name}", options: options)
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Ovh
|
2
|
+
module Endpoints
|
3
|
+
module Vps
|
4
|
+
|
5
|
+
def vps(options: {})
|
6
|
+
get("/vps", options: options)
|
7
|
+
end
|
8
|
+
|
9
|
+
# Ips associated to this virtual server
|
10
|
+
def vps_ips(service_name, options: {})
|
11
|
+
get("/vps/#{service_name}/ips", options: options)
|
12
|
+
end
|
13
|
+
|
14
|
+
# Get the countries you can select for your IPs geolocation
|
15
|
+
def vps_ip_countries_available(service_name, options: {})
|
16
|
+
get("/vps/#{service_name}/ipCountryAvailable", options: options)
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/ovh/version.rb
ADDED
data/ovh.gemspec
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "ovh/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ovh"
|
8
|
+
spec.version = Ovh::VERSION
|
9
|
+
spec.authors = ["Sebastian"]
|
10
|
+
spec.email = ["sebastian.johnsson@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{OVH Ruby HTTP API Client}
|
13
|
+
spec.description = %q{Ruby client to interact with OVH's API}
|
14
|
+
spec.homepage = "https://github.com/SebastianJ/ovh"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Specify which files should be added to the gem when it is released.
|
18
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
19
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
20
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
21
|
+
end
|
22
|
+
spec.bindir = "exe"
|
23
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
|
+
spec.require_paths = ["lib"]
|
25
|
+
|
26
|
+
spec.add_dependency "faraday", '~> 0.15.2'
|
27
|
+
spec.add_dependency "faraday_middleware", ">= 0.12.2"
|
28
|
+
|
29
|
+
spec.add_development_dependency "bundler", "~> 1.16.2"
|
30
|
+
spec.add_development_dependency "rake", "~> 12.3.1"
|
31
|
+
spec.add_development_dependency "rspec", "~> 3.7.0"
|
32
|
+
spec.add_development_dependency "rdoc", "~> 6.0.4"
|
33
|
+
spec.add_development_dependency "vcr", "~> 4.0"
|
34
|
+
spec.add_development_dependency "webmock", "~> 3.4.2"
|
35
|
+
spec.add_development_dependency "pry", "~> 0.11.3"
|
36
|
+
end
|
metadata
ADDED
@@ -0,0 +1,192 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ovh
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sebastian
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-07-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.15.2
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.15.2
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: faraday_middleware
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.12.2
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.12.2
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.16.2
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.16.2
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 12.3.1
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 12.3.1
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 3.7.0
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 3.7.0
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rdoc
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 6.0.4
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 6.0.4
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: vcr
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '4.0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '4.0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: webmock
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 3.4.2
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 3.4.2
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: pry
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 0.11.3
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 0.11.3
|
139
|
+
description: Ruby client to interact with OVH's API
|
140
|
+
email:
|
141
|
+
- sebastian.johnsson@gmail.com
|
142
|
+
executables: []
|
143
|
+
extensions: []
|
144
|
+
extra_rdoc_files: []
|
145
|
+
files:
|
146
|
+
- ".gitignore"
|
147
|
+
- ".rspec"
|
148
|
+
- ".travis.yml"
|
149
|
+
- CODE_OF_CONDUCT.md
|
150
|
+
- Gemfile
|
151
|
+
- Gemfile.lock
|
152
|
+
- LICENSE.txt
|
153
|
+
- README.md
|
154
|
+
- Rakefile
|
155
|
+
- bin/console
|
156
|
+
- bin/consumer_key
|
157
|
+
- bin/setup
|
158
|
+
- config/setup.rb
|
159
|
+
- lib/ovh.rb
|
160
|
+
- lib/ovh/client.rb
|
161
|
+
- lib/ovh/configuration.rb
|
162
|
+
- lib/ovh/endpoints/account.rb
|
163
|
+
- lib/ovh/endpoints/consumer.rb
|
164
|
+
- lib/ovh/endpoints/ips.rb
|
165
|
+
- lib/ovh/endpoints/vps.rb
|
166
|
+
- lib/ovh/version.rb
|
167
|
+
- ovh.gemspec
|
168
|
+
homepage: https://github.com/SebastianJ/ovh
|
169
|
+
licenses:
|
170
|
+
- MIT
|
171
|
+
metadata: {}
|
172
|
+
post_install_message:
|
173
|
+
rdoc_options: []
|
174
|
+
require_paths:
|
175
|
+
- lib
|
176
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
182
|
+
requirements:
|
183
|
+
- - ">="
|
184
|
+
- !ruby/object:Gem::Version
|
185
|
+
version: '0'
|
186
|
+
requirements: []
|
187
|
+
rubyforge_project:
|
188
|
+
rubygems_version: 2.7.7
|
189
|
+
signing_key:
|
190
|
+
specification_version: 4
|
191
|
+
summary: OVH Ruby HTTP API Client
|
192
|
+
test_files: []
|