ivapi 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +1 -1
- data/.travis.yml +2 -1
- data/CONTRIBUTING.md +8 -4
- data/Gemfile +6 -6
- data/LICENSE +21 -0
- data/README.md +2 -1
- data/Rakefile +1 -1
- data/ivapi.gemspec +2 -2
- data/lib/faraday/response/raise_ivapi_error.rb +1 -1
- data/lib/ivapi.rb +1 -1
- data/lib/ivapi/authentication.rb +1 -1
- data/lib/ivapi/client.rb +2 -2
- data/lib/ivapi/client/account.rb +12 -8
- data/lib/ivapi/client/server.rb +72 -42
- data/lib/ivapi/configuration.rb +3 -2
- data/lib/ivapi/connection.rb +2 -2
- data/lib/ivapi/error.rb +1 -1
- data/lib/ivapi/request.rb +4 -4
- data/lib/ivapi/version.rb +1 -1
- data/spec/fixtures/account_bonuses.json +1 -1
- data/spec/fixtures/account_info.json +1 -1
- data/spec/fixtures/account_orders.json +1 -1
- data/spec/fixtures/account_services.json +1 -1
- data/spec/fixtures/server_change.json +1 -1
- data/spec/fixtures/server_domain.json +1 -1
- data/spec/fixtures/server_flush_iptables.json +1 -1
- data/spec/fixtures/server_graphs.json +1 -1
- data/spec/fixtures/server_info.json +1 -1
- data/spec/fixtures/server_os.json +1 -1
- data/spec/fixtures/server_reboot.json +1 -1
- data/spec/fixtures/server_recreate.json +1 -1
- data/spec/fixtures/server_reset_password.json +1 -1
- data/spec/fixtures/server_tasks.json +1 -1
- data/spec/fixtures/version.json +1 -1
- data/spec/ivapi/client/account_spec.rb +26 -13
- data/spec/ivapi/client/server_spec.rb +53 -41
- data/spec/ivapi/client_spec.rb +21 -7
- data/spec/ivapi_spec.rb +5 -5
- data/spec/spec_helper.rb +8 -8
- metadata +8 -8
- data/LICENSE.md +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14d8f0abbc80a600939fc7ac3a1c81a3ea22e47b
|
4
|
+
data.tar.gz: 6cbbf8322b4186982f36db9230a57e77d1dc596b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cbb878f44d033f5828404fdf56bbe666e80349c81f40812797f7645b4d97face5408cfdd08fd348c98b11c273822540d1f82ed1a5cc3cf87ac4daa09dc13f318
|
7
|
+
data.tar.gz: ac15b5f60eb95e680cf72ee609861ea499da56e05dbfeef6172c425f7fc7f549c2593af1ae4ff96a3549f6a9f4b93b75ae49a6e597ccda985c0ca46e10df98ca
|
data/.rspec
CHANGED
data/.travis.yml
CHANGED
data/CONTRIBUTING.md
CHANGED
@@ -8,17 +8,19 @@ The following guidelines for contribution should be followed if you want to subm
|
|
8
8
|
|
9
9
|
* You need a [GitHub account](https://github.com/signup/free)
|
10
10
|
* Submit an [issue ticket](https://github.com/jpalumickas/ivapi/issues) for your issue if the is no one yet.
|
11
|
-
* Describe the issue and include steps to reproduce
|
11
|
+
* Describe the issue and include steps to reproduce if it's a bug.
|
12
12
|
* Ensure to mention the earliest version that you know is affected.
|
13
|
-
*
|
13
|
+
* If you are able and want to fix this, fork the repository on GitHub
|
14
14
|
|
15
15
|
## Make Changes
|
16
16
|
|
17
|
-
* In your forked repository, create a topic branch for your upcoming patch.
|
17
|
+
* In your forked repository, create a topic branch for your upcoming patch. (e.g. `feature--autoplay` or `bugfix--ios-crash`)
|
18
18
|
* Usually this is based on the master branch.
|
19
19
|
* Create a branch based on master; `git branch
|
20
20
|
fix/master/my_contribution master` then checkout the new branch with `git
|
21
21
|
checkout fix/master/my_contribution`. Please avoid working directly on the `master` branch.
|
22
|
+
* Make sure you stick to the coding style that is used already.
|
23
|
+
* Make use of the `.editorconfig`-file if provided with the repository.
|
22
24
|
* Make commits of logical units and describe them properly.
|
23
25
|
* Check for unnecessary whitespace with `git diff --check` before committing.
|
24
26
|
|
@@ -29,7 +31,9 @@ The following guidelines for contribution should be followed if you want to subm
|
|
29
31
|
|
30
32
|
* Push your changes to a topic branch in your fork of the repository.
|
31
33
|
* Open a pull request to the original repository and choose the right original branch you want to patch.
|
32
|
-
|
34
|
+
_Advanced users may use [`hub`](https://github.com/defunkt/hub#git-pull-request) gem for that._
|
35
|
+
* If not done in commit messages (which you really should do) please reference and update your issue with the code changes. But _please do not close the issue yourself_.
|
36
|
+
_Notice: You can [turn your previously filed issues into a pull-request here](http://issue2pr.herokuapp.com/)._
|
33
37
|
* Even if you have write access to the repository, do not directly push or merge pull-requests. Let another team member review your pull request and approve.
|
34
38
|
|
35
39
|
# Additional Resources
|
data/Gemfile
CHANGED
@@ -3,12 +3,12 @@ source 'https://rubygems.org'
|
|
3
3
|
gem 'rake'
|
4
4
|
|
5
5
|
group :test do
|
6
|
-
gem 'json',
|
7
|
-
gem 'rspec',
|
8
|
-
gem 'simplecov', require: false
|
9
|
-
gem 'webmock'
|
10
|
-
gem 'coveralls', require: false
|
11
|
-
gem 'guard-rspec'
|
6
|
+
gem 'json', '~> 1.8.0', platforms: [:ruby_18, :jruby]
|
7
|
+
gem 'rspec', '~> 2.14.1'
|
8
|
+
gem 'simplecov', '~> 0.7.1', require: false
|
9
|
+
gem 'webmock', '~> 1.13.0'
|
10
|
+
gem 'coveralls', '~> 0.6.7', require: false
|
11
|
+
gem 'guard-rspec', '~> 3.0.2'
|
12
12
|
end
|
13
13
|
|
14
14
|
gemspec
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
|
2
|
+
The MIT License (MIT)
|
3
|
+
|
4
|
+
Copyright (c) 2012 Justas Palumickas
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
7
|
+
this software and associated documentation files (the "Software"), to deal in
|
8
|
+
the Software without restriction, including without limitation the rights to
|
9
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
10
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
11
|
+
subject to the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
14
|
+
copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
18
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
19
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
20
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
21
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Ivapi
|
2
2
|
|
3
|
-
Gem which helps to communicate with [iv.lt][] API
|
3
|
+
Gem which helps to communicate with [http://iv.lt][iv.lt] ([http://dedikuoti.lt][dedikuoti.lt]) API.
|
4
4
|
|
5
5
|
[![Gem Version](https://badge.fury.io/rb/ivapi.png)][rubygems]
|
6
6
|
[![Build Status](https://secure.travis-ci.org/jpalumickas/ivapi.png?branch=master)][travis]
|
@@ -56,4 +56,5 @@ See [LICENSE][] for details.
|
|
56
56
|
[codeclimate]: https://codeclimate.com/github/jpalumickas/ivapi
|
57
57
|
|
58
58
|
[iv.lt]: http://www.iv.lt
|
59
|
+
[dedikuoti.lt]: http://www.dedikuoti.lt
|
59
60
|
[license]: LICENSE.md
|
data/Rakefile
CHANGED
data/ivapi.gemspec
CHANGED
@@ -18,11 +18,11 @@ Gem::Specification.new do |gem|
|
|
18
18
|
gem.require_paths = ["lib"]
|
19
19
|
|
20
20
|
gem.add_development_dependency 'bundler', '~> 1.0'
|
21
|
-
gem.add_dependency 'addressable', '~> 2.
|
21
|
+
gem.add_dependency 'addressable', '~> 2.3'
|
22
22
|
gem.add_dependency 'faraday', '~> 0.8'
|
23
23
|
gem.add_dependency 'faraday_middleware', '~> 0.9'
|
24
24
|
gem.add_dependency 'hashie', '~> 2.0'
|
25
|
-
gem.add_dependency 'multi_json', '~> 1.
|
25
|
+
gem.add_dependency 'multi_json', '~> 1.7'
|
26
26
|
|
27
27
|
gem.version = Ivapi::VERSION
|
28
28
|
end
|
data/lib/ivapi.rb
CHANGED
data/lib/ivapi/authentication.rb
CHANGED
data/lib/ivapi/client.rb
CHANGED
@@ -9,7 +9,7 @@ module Ivapi
|
|
9
9
|
class Client
|
10
10
|
attr_accessor(*Configuration::VALID_OPTIONS_KEYS)
|
11
11
|
|
12
|
-
def initialize(options={})
|
12
|
+
def initialize(options = {})
|
13
13
|
options = Ivapi.options.merge(options)
|
14
14
|
Configuration::VALID_OPTIONS_KEYS.each do |key|
|
15
15
|
send("#{key}=", options[key])
|
@@ -24,4 +24,4 @@ module Ivapi
|
|
24
24
|
include Ivapi::Client::Server
|
25
25
|
|
26
26
|
end
|
27
|
-
end
|
27
|
+
end
|
data/lib/ivapi/client/account.rb
CHANGED
@@ -2,9 +2,9 @@ module Ivapi
|
|
2
2
|
class Client
|
3
3
|
module Account
|
4
4
|
|
5
|
-
# Get account
|
5
|
+
# Get information about account.
|
6
6
|
#
|
7
|
-
# Returns the
|
7
|
+
# Returns the Hash of account information.
|
8
8
|
def account_info
|
9
9
|
params = { command: 'account_info' }
|
10
10
|
get('/json.php', params)
|
@@ -12,7 +12,7 @@ module Ivapi
|
|
12
12
|
|
13
13
|
# Get account orders.
|
14
14
|
#
|
15
|
-
# Returns the
|
15
|
+
# Returns the Hash of account orders.
|
16
16
|
def account_orders
|
17
17
|
params = { command: 'account_orders' }
|
18
18
|
get('/json.php', params)
|
@@ -20,7 +20,7 @@ module Ivapi
|
|
20
20
|
|
21
21
|
# Get account services.
|
22
22
|
#
|
23
|
-
# Returns the
|
23
|
+
# Returns the Hash of account services.
|
24
24
|
def account_services
|
25
25
|
params = { command: 'account_services' }
|
26
26
|
get('/json.php', params)
|
@@ -28,17 +28,21 @@ module Ivapi
|
|
28
28
|
|
29
29
|
# Get account credits.
|
30
30
|
#
|
31
|
-
#
|
31
|
+
# count - The Integer of how many rows need to return (default: 10).
|
32
|
+
#
|
33
|
+
# Returns the Hash of account credits.
|
32
34
|
def account_credits(count = 10)
|
33
|
-
|
35
|
+
params = { command: 'account_credits', count: count }
|
34
36
|
get('/json.php', params)
|
35
37
|
end
|
36
38
|
|
37
39
|
# Get account bonuses.
|
38
40
|
#
|
39
|
-
#
|
41
|
+
# count - The Integer of how many rows need to return (default: 10).
|
42
|
+
#
|
43
|
+
# Returns the Hash of account bonuses.
|
40
44
|
def account_bonuses(count = 10)
|
41
|
-
params = { :
|
45
|
+
params = { command: 'account_bonuses', count: count }
|
42
46
|
get('/json.php', params)
|
43
47
|
end
|
44
48
|
end
|
data/lib/ivapi/client/server.rb
CHANGED
@@ -2,9 +2,9 @@ module Ivapi
|
|
2
2
|
class Client
|
3
3
|
module Server
|
4
4
|
|
5
|
-
# Get server
|
5
|
+
# Get information about server.
|
6
6
|
#
|
7
|
-
# Returns the
|
7
|
+
# Returns the Hash of server information.
|
8
8
|
def server_info
|
9
9
|
params = { command: 'server_info', id: server_id }
|
10
10
|
get('/json.php', params)
|
@@ -12,29 +12,39 @@ module Ivapi
|
|
12
12
|
|
13
13
|
# Get server tasks.
|
14
14
|
#
|
15
|
-
# count
|
16
|
-
# options - The Hash
|
15
|
+
# count - The Integer number of results count (max: 1000).
|
16
|
+
# options - The Hash options (default: {}):
|
17
|
+
# :task - The String of task name (optional).
|
18
|
+
# :task_id - The Integer of task id (optional).
|
17
19
|
#
|
18
|
-
# Returns
|
19
|
-
def server_tasks(count, options={})
|
20
|
-
params = options.merge({
|
20
|
+
# Returns the Hash of server tasks.
|
21
|
+
def server_tasks(count, options = {})
|
22
|
+
params = options.merge({
|
23
|
+
command: 'server_tasks', id: server_id, count: count })
|
24
|
+
|
21
25
|
get('/json.php', params)
|
22
26
|
end
|
23
27
|
|
24
28
|
# Get server graphs.
|
25
29
|
#
|
26
|
-
# width
|
27
|
-
# ip
|
30
|
+
# width - The Integer number of graphs width (max: 1000, optimal: 768).
|
31
|
+
# ip - The String of ip, from which graphs can be viewed.
|
28
32
|
#
|
29
|
-
# Returns the
|
33
|
+
# Returns the Hash of server graphs.
|
30
34
|
def server_graphs(width, ip)
|
31
|
-
params = {
|
35
|
+
params = {
|
36
|
+
command: 'server_graphs',
|
37
|
+
id: server_id,
|
38
|
+
width: width,
|
39
|
+
ip: ip
|
40
|
+
}
|
41
|
+
|
32
42
|
get('/json.php', params)
|
33
43
|
end
|
34
44
|
|
35
|
-
# Get all available server
|
45
|
+
# Get all available server operating systems.
|
36
46
|
#
|
37
|
-
# Returns the
|
47
|
+
# Returns the Hash of available server os.
|
38
48
|
def server_os
|
39
49
|
params = { command: 'server_os', id: server_id }
|
40
50
|
get('/json.php', params)
|
@@ -42,7 +52,7 @@ module Ivapi
|
|
42
52
|
|
43
53
|
# Send command to reboot the server.
|
44
54
|
#
|
45
|
-
# Returns
|
55
|
+
# Returns the Integer of task id.
|
46
56
|
def server_reboot
|
47
57
|
params = { command: 'server_reboot', id: server_id }
|
48
58
|
get('/json.php', params)
|
@@ -50,56 +60,76 @@ module Ivapi
|
|
50
60
|
|
51
61
|
# Send command to recreate the server.
|
52
62
|
#
|
53
|
-
# os
|
54
|
-
#
|
55
|
-
#
|
56
|
-
#
|
57
|
-
|
58
|
-
|
63
|
+
# os - The String of os (operating system) id.
|
64
|
+
# options - The Hash options (default: {}):
|
65
|
+
# :new_password - The String of new server
|
66
|
+
# password (min: 8, max: 64).
|
67
|
+
#
|
68
|
+
# Returns the Integer of task id.
|
69
|
+
def server_recreate(os, options = {})
|
70
|
+
params = options.merge({
|
71
|
+
command: 'server_recreate',
|
72
|
+
id: server_id,
|
73
|
+
os: os
|
74
|
+
})
|
75
|
+
|
59
76
|
get('/json.php', params)
|
60
77
|
end
|
61
78
|
|
62
79
|
# Send command to reset server password.
|
63
80
|
#
|
64
|
-
#
|
81
|
+
# options - The Hash options (default: {}):
|
82
|
+
# :new_password - The String of new server
|
83
|
+
# password (min: 8, max: 64).
|
65
84
|
#
|
66
|
-
# Returns
|
67
|
-
def server_reset_password(options={})
|
68
|
-
params = options.merge({
|
85
|
+
# Returns the Integer of task id.
|
86
|
+
def server_reset_password(options = {})
|
87
|
+
params = options.merge({
|
88
|
+
command: 'server_reset_password',
|
89
|
+
id: server_id
|
90
|
+
})
|
91
|
+
|
69
92
|
get('/json.php', params)
|
70
93
|
end
|
71
94
|
|
72
95
|
# Send command to clean server firewall rules.
|
73
96
|
#
|
74
|
-
# Returns
|
97
|
+
# Returns the Integer of task id.
|
75
98
|
def server_flush_iptables
|
76
99
|
params = { command: 'server_flush_iptables', id: server_id }
|
77
100
|
get('/json.php', params)
|
78
101
|
end
|
79
102
|
|
80
|
-
# Send command to change firewall settings
|
81
|
-
#
|
82
|
-
#
|
83
|
-
#
|
84
|
-
#
|
85
|
-
#
|
86
|
-
#
|
87
|
-
#
|
88
|
-
#
|
89
|
-
|
103
|
+
# Send command to change firewall settings.
|
104
|
+
#
|
105
|
+
# options - The Hash options (default: {}):
|
106
|
+
# :pps - The Integer of incoming ICMP, UDP, TCP joins per
|
107
|
+
# second (min: 1000, max: 5000).
|
108
|
+
# :pps_icmp - The Integer of ICMP packets per
|
109
|
+
# second (0 or min: 10, max: 500).
|
110
|
+
# :pps_udp - The Integer of UDP packets per
|
111
|
+
# second (0 or min: 10, max: 500).
|
112
|
+
# :pps_syn - The Integer of TCP SYN packets per second from
|
113
|
+
# one IP (0 or min: 2, max: 20).
|
114
|
+
# :connlimit - The Integer of collateral connections from one
|
115
|
+
# IP (0 or min: 16, max: 512).
|
116
|
+
#
|
117
|
+
# Returns the Hash of new firewall settings.
|
118
|
+
def server_firewall(options = {})
|
90
119
|
params = options.merge({ command: 'server_firewall', id: server_id })
|
91
120
|
get('/json.php', params)
|
92
121
|
end
|
93
122
|
|
94
123
|
# Send command to change server plan.
|
95
124
|
#
|
96
|
-
#
|
97
|
-
#
|
98
|
-
#
|
99
|
-
#
|
125
|
+
# options - The Hash options (default: {}):
|
126
|
+
# :cpu - The Integer of GHz (min: 2, max: 16).
|
127
|
+
# :ram - The Integer of MB (min: 2048, max: 16384).
|
128
|
+
# :quota - The Integer of GB (min: 20, max: 800).
|
129
|
+
# :bandwidth - The Integer of Mbps (min: 20, max: 400).
|
100
130
|
#
|
101
|
-
# Returns
|
102
|
-
def server_change(options={})
|
131
|
+
# Returns the Integer of task id.
|
132
|
+
def server_change(options = {})
|
103
133
|
params = options.merge({ command: 'server_change', id: server_id })
|
104
134
|
get('/json.php', params)
|
105
135
|
end
|
@@ -108,7 +138,7 @@ module Ivapi
|
|
108
138
|
#
|
109
139
|
# domain - The String of new server hostname.
|
110
140
|
#
|
111
|
-
# Returns
|
141
|
+
# Returns the Integer of task id.
|
112
142
|
def server_domain(domain)
|
113
143
|
params = { command: 'server_domain', id: server_id, domain: domain }
|
114
144
|
get('/json.php', params)
|
data/lib/ivapi/configuration.rb
CHANGED
@@ -26,7 +26,7 @@ module Ivapi
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def options
|
29
|
-
VALID_OPTIONS_KEYS.
|
29
|
+
VALID_OPTIONS_KEYS.reduce({}) { |a, e| a.merge!(e => send(e)) }
|
30
30
|
end
|
31
31
|
|
32
32
|
def faraday_config(&block)
|
@@ -37,7 +37,8 @@ module Ivapi
|
|
37
37
|
self.adapter = DEFAULT_ADAPTER
|
38
38
|
self.username = nil
|
39
39
|
self.password = nil
|
40
|
+
self.server_id = nil
|
40
41
|
self.user_agent = DEFAULT_USER_AGENT
|
41
42
|
end
|
42
43
|
end
|
43
|
-
end
|
44
|
+
end
|
data/lib/ivapi/connection.rb
CHANGED
@@ -5,7 +5,7 @@ module Ivapi
|
|
5
5
|
module Connection
|
6
6
|
private
|
7
7
|
|
8
|
-
def connection(options={})
|
8
|
+
def connection(options = {})
|
9
9
|
connection = Faraday.new(options) do |builder|
|
10
10
|
|
11
11
|
builder.request :json
|
@@ -26,4 +26,4 @@ module Ivapi
|
|
26
26
|
connection
|
27
27
|
end
|
28
28
|
end
|
29
|
-
end
|
29
|
+
end
|
data/lib/ivapi/error.rb
CHANGED
data/lib/ivapi/request.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
module Ivapi
|
2
2
|
module Request
|
3
|
-
def get(path, options={})
|
3
|
+
def get(path, options = {})
|
4
4
|
request(:get, path, options).body
|
5
5
|
end
|
6
6
|
|
7
|
-
def request(method, path, options={})
|
7
|
+
def request(method, path, options = {})
|
8
8
|
|
9
9
|
conn_options = {
|
10
|
-
:
|
10
|
+
url: 'https://api.iv.lt'
|
11
11
|
}
|
12
12
|
|
13
13
|
options.merge!(authentication)
|
@@ -19,4 +19,4 @@ module Ivapi
|
|
19
19
|
response
|
20
20
|
end
|
21
21
|
end
|
22
|
-
end
|
22
|
+
end
|
data/lib/ivapi/version.rb
CHANGED
@@ -23,4 +23,4 @@
|
|
23
23
|
"cpu_weekly": "//stats.serveriai.lt/graph.php?Ds252x+6Lek1o0SV2+u99fqhNaiflbCcb6QuGzlRJ9yy2R1VycHOc6baz3zRB6Am1RJcniVrpCjj+A47DMwkyfQ==",
|
24
24
|
"cpu_monthly": "//stats.serveriai.lt/graph.php?Ds252x+6Lek1o0SV2+u99fqhNaiflbCcb6QuGzlRJ9yxK/MZyMfdX4eflJC8xIf8j1/FtFwPGQkKJH2lwumDXzw==",
|
25
25
|
"cpu_yearly": "//stats.serveriai.lt/graph.php?Ds252x+6Lek1o0SV2+u99fqhNaiflbCcb6QuGzlRJ9yxZA7jroJOYQwMT3OKsz00xRJcniVrpCjj+A47DMwkyfQ=="
|
26
|
-
}
|
26
|
+
}
|
@@ -11,4 +11,4 @@
|
|
11
11
|
},
|
12
12
|
"ta_results": "Stopping container ...\nContainer was stopped\nContainer is unmounted\nDestroying container private area: /vz/private/11\nContainer private area was destroyed\nCreating container private area (debian-6.0-x86_64)\nPerforming postcreate actions\nCT configuration saved to /etc/vz/conf/1.conf\nContainer private area was created\nStarting container...\nContainer is mounted\nContainer start in progress...\nKilling container ...\nContainer was stopped\nContainer is unmounted\nCT configuration saved to /etc/vz/conf/1.conf\nCT configuration saved to /etc/vz/conf/1.conf\nStarting container...\nContainer is mounted\nAdding IP address(es): 12.23.34.45\nSetting CPU limit: 0\nSetting CPU units: 200\nSetting CPUs: 1\nContainer start in progress...\n\nID: 1\nHost: server.example.com\nBandwidth: 10240 Kbps\nQuota: 10 GB\nCPU: 1 unit(s)\nRAM: 1024 MB\nIP: 12.23.34.45\nPassword: secret"
|
13
13
|
}
|
14
|
-
]
|
14
|
+
]
|
data/spec/fixtures/version.json
CHANGED
@@ -6,29 +6,42 @@ describe Ivapi::Client::Account do
|
|
6
6
|
@client = Ivapi::Client.new(username: 'foo', password: 'bar')
|
7
7
|
end
|
8
8
|
|
9
|
-
it
|
10
|
-
stub_command(
|
9
|
+
it 'returns account information' do
|
10
|
+
stub_command('account_info').to_return(json_response('account_info.json'))
|
11
|
+
|
11
12
|
account_info = @client.account_info
|
12
|
-
|
13
|
+
|
14
|
+
expect(account_info.ac_name).to eq('Name Surname')
|
13
15
|
end
|
14
16
|
|
15
|
-
it
|
16
|
-
stub_command(
|
17
|
+
it 'returns account orders' do
|
18
|
+
stub_command('account_orders')
|
19
|
+
.to_return(json_response('account_orders.json'))
|
20
|
+
|
17
21
|
account_orders = @client.account_orders
|
22
|
+
|
18
23
|
expect(account_orders.count).to eq(3)
|
19
|
-
expect(account_orders.first.or_cost).to eq(
|
24
|
+
expect(account_orders.first.or_cost).to eq('11.11')
|
20
25
|
end
|
21
26
|
|
22
|
-
it
|
23
|
-
stub_command(
|
27
|
+
it 'returns account services' do
|
28
|
+
stub_command('account_services')
|
29
|
+
.to_return(json_response('account_services.json'))
|
30
|
+
|
24
31
|
account_services = @client.account_services
|
32
|
+
|
25
33
|
expect(account_services.count).to eq(3)
|
26
|
-
expect(account_services.first.se_description)
|
34
|
+
expect(account_services.first.se_description)
|
35
|
+
.to eq('Adreso metinis mokestis (example.com)')
|
27
36
|
end
|
28
37
|
|
29
|
-
it
|
30
|
-
stub_command(
|
38
|
+
it 'returns account bonuses' do
|
39
|
+
stub_command('account_bonuses', { count: 10 })
|
40
|
+
.to_return(json_response('account_bonuses.json'))
|
41
|
+
|
31
42
|
account_bonuses = @client.account_bonuses
|
32
|
-
|
43
|
+
|
44
|
+
expect(account_bonuses[2].bo_description)
|
45
|
+
.to eq('SMS +370.61234569 (example)')
|
33
46
|
end
|
34
|
-
end
|
47
|
+
end
|
@@ -6,77 +6,89 @@ describe Ivapi::Client::Server do
|
|
6
6
|
@client = Ivapi::Client.new(username: 'foo', password: 'bar', server_id: 3)
|
7
7
|
end
|
8
8
|
|
9
|
-
it
|
10
|
-
stub_command(
|
9
|
+
it 'should return server information' do
|
10
|
+
stub_command('server_info', { id: 3 })
|
11
|
+
.to_return(json_response('server_info.json'))
|
11
12
|
server_info = @client.server_info
|
12
|
-
expect(server_info.se_domain).to eq(
|
13
|
-
expect(server_info.se_info.in_node).to eq(
|
13
|
+
expect(server_info.se_domain).to eq('server.example.com')
|
14
|
+
expect(server_info.se_info.in_node).to eq('Robinija')
|
14
15
|
end
|
15
16
|
|
16
|
-
it
|
17
|
-
stub_command(
|
17
|
+
it 'should return server tasks' do
|
18
|
+
stub_command('server_tasks', { id: 3, count: 1 })
|
19
|
+
.to_return(json_response('server_tasks.json'))
|
18
20
|
server_tasks = @client.server_tasks(1)
|
19
|
-
expect(server_tasks.first.ta_params.domain).to eq(
|
21
|
+
expect(server_tasks.first.ta_params.domain).to eq('server.example.com')
|
20
22
|
end
|
21
23
|
|
22
|
-
it
|
23
|
-
stub_command(
|
24
|
-
|
25
|
-
|
24
|
+
it 'should return server tasks with specified options' do
|
25
|
+
stub_command('server_tasks', { id: 3, count: 1, task_id: 1 })
|
26
|
+
.to_return(json_response('server_tasks.json'))
|
27
|
+
server_tasks = @client.server_tasks(1, { task_id: 1 })
|
28
|
+
expect(server_tasks.first.ta_params.domain).to eq('server.example.com')
|
26
29
|
end
|
27
30
|
|
28
|
-
it
|
29
|
-
stub_command(
|
30
|
-
|
31
|
-
|
31
|
+
it 'should return server graphs' do
|
32
|
+
stub_command('server_graphs', { id: 3, width: 1000, ip: '12.23.34.45' })
|
33
|
+
.to_return(json_response('server_graphs.json'))
|
34
|
+
server_graphs = @client.server_graphs(1000, '12.23.34.45')
|
35
|
+
expect(server_graphs.cpu_weekly).to eq('//stats.serveriai.lt/graph.php?Ds252x+6Lek1o0SV2+u99fqhNaiflbCcb6QuGzlRJ9yy2R1VycHOc6baz3zRB6Am1RJcniVrpCjj+A47DMwkyfQ==')
|
32
36
|
end
|
33
37
|
|
34
|
-
it
|
35
|
-
stub_command(
|
38
|
+
it 'should return server os' do
|
39
|
+
stub_command('server_os', { id: 3 })
|
40
|
+
.to_return(json_response('server_os.json'))
|
36
41
|
server_os = @client.server_os
|
37
|
-
expect(server_os[
|
42
|
+
expect(server_os['debian-6.0-x86_64'].title).to eq('Debian 6')
|
38
43
|
end
|
39
44
|
|
40
|
-
it
|
41
|
-
stub_command(
|
45
|
+
it 'should reboot server' do
|
46
|
+
stub_command('server_reboot', { id: 3 })
|
47
|
+
.to_return(json_response('server_reboot.json'))
|
42
48
|
server_reboot = @client.server_reboot
|
43
|
-
expect(server_reboot.task_id).to eq(
|
49
|
+
expect(server_reboot.task_id).to eq('11')
|
44
50
|
end
|
45
51
|
|
46
|
-
it
|
47
|
-
stub_command(
|
48
|
-
|
49
|
-
|
52
|
+
it 'should recreate server' do
|
53
|
+
stub_command('server_recreate', { id: 3, os: 'debian-6.0-x86_64' })
|
54
|
+
.to_return(json_response('server_recreate.json'))
|
55
|
+
server_recreate = @client.server_recreate('debian-6.0-x86_64')
|
56
|
+
expect(server_recreate.task_id).to eq('12')
|
50
57
|
end
|
51
58
|
|
52
|
-
it
|
53
|
-
stub_command(
|
59
|
+
it 'should reset server password' do
|
60
|
+
stub_command('server_reset_password', { id: 3 })
|
61
|
+
.to_return(json_response('server_reset_password.json'))
|
54
62
|
server_reset_password = @client.server_reset_password
|
55
|
-
expect(server_reset_password.task_id).to eq(
|
63
|
+
expect(server_reset_password.task_id).to eq('13')
|
56
64
|
end
|
57
65
|
|
58
|
-
it
|
59
|
-
stub_command(
|
66
|
+
it 'should flush server iptables' do
|
67
|
+
stub_command('server_flush_iptables', { id: 3 })
|
68
|
+
.to_return(json_response('server_flush_iptables.json'))
|
60
69
|
server_flush_iptables = @client.server_flush_iptables
|
61
|
-
expect(server_flush_iptables.task_id).to eq(
|
70
|
+
expect(server_flush_iptables.task_id).to eq('16')
|
62
71
|
end
|
63
72
|
|
64
|
-
it
|
65
|
-
stub_command(
|
73
|
+
it 'should change server firewall settings' do
|
74
|
+
stub_command('server_firewall', { id: 3 })
|
75
|
+
.to_return(json_response('server_firewall.json'))
|
66
76
|
server_firewall = @client.server_firewall
|
67
|
-
expect(server_firewall.pps).to eq(
|
77
|
+
expect(server_firewall.pps).to eq('1000')
|
68
78
|
end
|
69
79
|
|
70
|
-
it
|
71
|
-
stub_command(
|
80
|
+
it 'should change server plan' do
|
81
|
+
stub_command('server_change', { id: 3 })
|
82
|
+
.to_return(json_response('server_change.json'))
|
72
83
|
server_change = @client.server_change
|
73
|
-
expect(server_change.task_id).to eq(
|
84
|
+
expect(server_change.task_id).to eq('14')
|
74
85
|
end
|
75
86
|
|
76
|
-
it
|
77
|
-
stub_command(
|
78
|
-
|
79
|
-
|
87
|
+
it 'should change server hostname' do
|
88
|
+
stub_command('server_domain', { id: 3, domain: 'example.com' })
|
89
|
+
.to_return(json_response('server_domain.json'))
|
90
|
+
server_domain = @client.server_domain('example.com')
|
91
|
+
expect(server_domain.task_id).to eq('15')
|
80
92
|
end
|
81
93
|
|
82
94
|
end
|
data/spec/ivapi/client_spec.rb
CHANGED
@@ -2,12 +2,26 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Ivapi::Client do
|
4
4
|
|
5
|
-
it
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
5
|
+
it 'works with basic auth and password' do
|
6
|
+
url = 'https://api.iv.lt/json.php?nick=foo&password=bar&command=version'
|
7
|
+
|
8
|
+
stub_request(:get, url)
|
9
|
+
.to_return(status: 200, body: '{"commits":[]}', headers: {})
|
10
|
+
|
11
|
+
expect { Ivapi::Client.new(username: 'foo', password: 'bar') }
|
12
|
+
.not_to raise_exception
|
13
|
+
end
|
14
|
+
|
15
|
+
describe 'authentication' do
|
16
|
+
it 'is authenticated with username and password' do
|
17
|
+
client = Ivapi::Client.new(username: 'foo', password: 'bar')
|
18
|
+
expect(client).to be_authenticated
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'is not authenticated without username and password' do
|
22
|
+
client = Ivapi::Client.new
|
23
|
+
expect(client).to_not be_authenticated
|
24
|
+
end
|
11
25
|
end
|
12
26
|
|
13
|
-
end
|
27
|
+
end
|
data/spec/ivapi_spec.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
describe Ivapi do
|
3
3
|
|
4
|
-
describe
|
5
|
-
it
|
4
|
+
describe '.respond_to?' do
|
5
|
+
it 'is true if method exists' do
|
6
6
|
expect(Ivapi.respond_to?(:new, true)).to eq(true)
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
|
-
describe
|
11
|
-
it
|
10
|
+
describe '.new' do
|
11
|
+
it 'is a Ivapi::Client' do
|
12
12
|
expect(Ivapi.new).to be_a Ivapi::Client
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
end
|
16
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -23,17 +23,17 @@ def stub_get(url)
|
|
23
23
|
stub_request(:get, iv_url(url))
|
24
24
|
end
|
25
25
|
|
26
|
-
def stub_command(command, options={})
|
26
|
+
def stub_command(command, options = {})
|
27
27
|
|
28
28
|
params = { command: command }
|
29
29
|
params.merge!(options)
|
30
30
|
params.merge!(@client.authentication)
|
31
31
|
|
32
|
-
stub_request(:get,
|
32
|
+
stub_request(:get, 'https://api.iv.lt/json.php').with(query: params)
|
33
33
|
end
|
34
34
|
|
35
35
|
def fixture_path
|
36
|
-
File.expand_path(
|
36
|
+
File.expand_path('../fixtures', __FILE__)
|
37
37
|
end
|
38
38
|
|
39
39
|
def fixture(file)
|
@@ -42,9 +42,9 @@ end
|
|
42
42
|
|
43
43
|
def json_response(file)
|
44
44
|
{
|
45
|
-
:
|
46
|
-
:
|
47
|
-
:
|
45
|
+
body: fixture(file),
|
46
|
+
headers: {
|
47
|
+
content_type: 'application/json; charset=utf-8'
|
48
48
|
}
|
49
49
|
}
|
50
50
|
end
|
@@ -59,8 +59,8 @@ end
|
|
59
59
|
|
60
60
|
def iv_command_url(command)
|
61
61
|
if @client && @client.authenticated?
|
62
|
-
"
|
62
|
+
iv_url("?nick=#{@client.username}&password=#{@client.password}&command=#{command}")
|
63
63
|
else
|
64
|
-
"
|
64
|
+
iv_url("?command=#{command}")
|
65
65
|
end
|
66
66
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ivapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justas Palumickas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-09-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '2.
|
33
|
+
version: '2.3'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '2.
|
40
|
+
version: '2.3'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: faraday
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,14 +86,14 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - ~>
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '1.
|
89
|
+
version: '1.7'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - ~>
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '1.
|
96
|
+
version: '1.7'
|
97
97
|
description: ' Gem which helps to communicate with iv.lt API '
|
98
98
|
email:
|
99
99
|
- justas@elish.lt
|
@@ -107,7 +107,7 @@ files:
|
|
107
107
|
- CONTRIBUTING.md
|
108
108
|
- Gemfile
|
109
109
|
- Guardfile
|
110
|
-
- LICENSE
|
110
|
+
- LICENSE
|
111
111
|
- README.md
|
112
112
|
- Rakefile
|
113
113
|
- ivapi.gemspec
|
@@ -163,7 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
163
163
|
version: '0'
|
164
164
|
requirements: []
|
165
165
|
rubyforge_project:
|
166
|
-
rubygems_version: 2.0.
|
166
|
+
rubygems_version: 2.0.7
|
167
167
|
signing_key:
|
168
168
|
specification_version: 4
|
169
169
|
summary: Gem which helps to communicate with iv.lt API
|
data/LICENSE.md
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
Copyright (c) 2012 Justas Palumickas
|
2
|
-
|
3
|
-
MIT License
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
-
a copy of this software and associated documentation files (the
|
7
|
-
"Software"), to deal in the Software without restriction, including
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
11
|
-
the following conditions:
|
12
|
-
|
13
|
-
The above copyright notice and this permission notice shall be
|
14
|
-
included in all copies or substantial portions of the Software.
|
15
|
-
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|