vscale-api 0.2.46 → 0.2.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.coveralls.yml +1 -0
- data/README.md +1 -1
- data/lib/vscale/api.rb +19 -13
- data/lib/vscale/api/backups.rb +8 -0
- data/lib/vscale/api/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9ac876acdea7222da72661d422f9305e3b8226a3
|
|
4
|
+
data.tar.gz: 555e9cf0095d7a126c7d2dd63938a22f8c0fb511
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b80fcefe8bcdc4b3d150cfeb412d11f48515de0273f5b3311eec19f265e2cd3cc9724622f4636ca8b38ccab42defc595eba6eea437fc4f828e5e46739b8e6bf5
|
|
7
|
+
data.tar.gz: a091c6e04ca8a0971fbfec310618ab86ab80bcd8248f519edacd457d904b82e28b35880ac371605fb459beecfcd38fa6a7444441f4bf7df37eadc1ea80b6cad1
|
data/.coveralls.yml
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
service_name: travis-ci
|
data/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
### VScale API v1 (WIP)
|
|
2
2
|
|
|
3
|
-
[](https://coveralls.io/github/Smolget/vscale-api?branch=feature%2Fcoveralls)
|
|
4
4
|
[](https://travis-ci.org/Smolget/vscale-api)
|
|
5
5
|
[](https://badge.fury.io/rb/vscale-api)
|
|
6
6
|

|
data/lib/vscale/api.rb
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
require 'net/http'
|
|
2
2
|
require 'openssl'
|
|
3
|
-
require 'ostruct'
|
|
4
3
|
require 'json'
|
|
5
4
|
require 'uri'
|
|
6
5
|
|
|
@@ -34,11 +33,10 @@ module Vscale
|
|
|
34
33
|
include Servers
|
|
35
34
|
include SSHKeys
|
|
36
35
|
|
|
37
|
-
def initialize(token
|
|
36
|
+
def initialize(token)
|
|
38
37
|
@token = token
|
|
39
|
-
@api_endpoint = api_endpoint
|
|
40
38
|
|
|
41
|
-
uri = URI.parse(
|
|
39
|
+
uri = URI.parse(API_ENDPOINT)
|
|
42
40
|
|
|
43
41
|
# TODO: rescue StandardError
|
|
44
42
|
@http = Net::HTTP.start(uri.host, uri.port, use_ssl: true)
|
|
@@ -50,27 +48,35 @@ module Vscale
|
|
|
50
48
|
|
|
51
49
|
def request_json(meth, path, params = {})
|
|
52
50
|
response = request(meth, path, params)
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
response
|
|
51
|
+
|
|
52
|
+
result = Struct.new(:code, :body)
|
|
53
|
+
|
|
54
|
+
if response.body.nil? || response.body.empty?
|
|
55
|
+
result.new(nil, nil)
|
|
56
|
+
else
|
|
57
|
+
json_body = JSON.parse(response.body, quirks_mode: true) # TODO: TypeError if nil
|
|
58
|
+
result.new(response.code, json_body)
|
|
59
|
+
end
|
|
57
60
|
end
|
|
58
61
|
|
|
59
62
|
def request(meth, path, params = {})
|
|
60
|
-
full_path = encode_path_params(
|
|
63
|
+
full_path = encode_path_params([API_ENDPOINT, path].join, params)
|
|
64
|
+
|
|
61
65
|
request = VERB_MAP[meth.to_sym].new(full_path)
|
|
66
|
+
|
|
62
67
|
request['Accept'] = 'application/json, text/plain'
|
|
63
68
|
request['Content-Type'] = 'application/json'
|
|
64
69
|
request['X-Token'] = @token
|
|
65
70
|
|
|
66
|
-
|
|
67
|
-
|
|
71
|
+
if ['post', 'put', 'patch'].include?(meth.to_s)
|
|
72
|
+
request.body = params.to_json
|
|
73
|
+
return @http.request(request)
|
|
74
|
+
end
|
|
68
75
|
@http.request(request)
|
|
69
76
|
end
|
|
70
77
|
|
|
71
78
|
def encode_path_params(path, params)
|
|
72
|
-
|
|
73
|
-
[path, encoded].join('?')
|
|
79
|
+
[path, URI.encode_www_form(params)].join('?')
|
|
74
80
|
end
|
|
75
81
|
end
|
|
76
82
|
end
|
data/lib/vscale/api/backups.rb
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
module Vscale
|
|
2
2
|
module Backups
|
|
3
|
+
def create_backup(scalet_id, params)
|
|
4
|
+
post("#{scalet_id}/backup", params)
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def create_from_backup(scalet_id, params)
|
|
8
|
+
patch("scalets/#{scalet_id}/rebuild", params)
|
|
9
|
+
end
|
|
10
|
+
|
|
3
11
|
def backups
|
|
4
12
|
get('backups')
|
|
5
13
|
end
|
data/lib/vscale/api/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: vscale-api
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.47
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ilya V
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-10-
|
|
11
|
+
date: 2016-10-31 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -73,6 +73,7 @@ executables: []
|
|
|
73
73
|
extensions: []
|
|
74
74
|
extra_rdoc_files: []
|
|
75
75
|
files:
|
|
76
|
+
- ".coveralls.yml"
|
|
76
77
|
- ".gitignore"
|
|
77
78
|
- ".rubocop.yml"
|
|
78
79
|
- ".travis.yml"
|