vscale-api 0.2.45 → 0.2.46
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -4
- data/README.md +6 -0
- data/Rakefile +6 -0
- data/lib/vscale/api.rb +22 -13
- data/lib/vscale/api/account.rb +0 -4
- data/lib/vscale/api/backups.rb +15 -0
- data/lib/vscale/api/billing.rb +1 -1
- data/lib/vscale/api/domains.rb +97 -0
- data/lib/vscale/api/notifications.rb +11 -0
- data/lib/vscale/api/request.rb +2 -2
- data/lib/vscale/api/servers.rb +21 -1
- data/lib/vscale/api/version.rb +1 -1
- data/vscale-api.gemspec +4 -2
- metadata +24 -19
- data/lib/vscale/api/tickets.rb +0 -23
- data/lib/vscale/api/tokens.rb +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55a759f760acb59de98213ddd7055077549dba0e
|
4
|
+
data.tar.gz: bc740e8e471c5388b910deb7653cc65824f53c59
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b38bfbd7ff70d9547f44b6f249013c3798ce6ed7c381bea5a4d40612bf6ad35f438fd2cb90c67bd1e27759146d463fb4b40879eb9d3c2d0c28a820557644eca3
|
7
|
+
data.tar.gz: 75b8771f65ed1f374902ebf3d7cc325cf9b01137dac5df7c1130bb38692de6bc16e2dc1a7cfd535a15abe7855b72213b24213efa4c5e2fed72671f639070e3e6
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
[![Coverage Status](https://coveralls.io/repos/Smolget/vscale-api/badge.svg?branch=master&service=github)](https://coveralls.io/github/Smolget/vscale-api?branch=master)
|
4
4
|
[![Build Status](https://travis-ci.org/Smolget/vscale-api.svg?branch=master)](https://travis-ci.org/Smolget/vscale-api)
|
5
5
|
[![Gem Version](https://badge.fury.io/rb/vscale-api.svg)](https://badge.fury.io/rb/vscale-api)
|
6
|
+
![](http://ruby-gem-downloads-badge.herokuapp.com/vscale-api?type=total)
|
6
7
|
|
7
8
|
## Vscale API v1
|
8
9
|
|
@@ -30,4 +31,9 @@ api.images
|
|
30
31
|
02. Change
|
31
32
|
03. PR
|
32
33
|
|
34
|
+
## TODO
|
35
|
+
* [ ] Refactoring
|
36
|
+
* [ ] Usage examples
|
37
|
+
* [ ] Tests
|
38
|
+
|
33
39
|
*WIP*
|
data/Rakefile
CHANGED
data/lib/vscale/api.rb
CHANGED
@@ -6,56 +6,65 @@ require 'uri'
|
|
6
6
|
|
7
7
|
require 'vscale/api/account'
|
8
8
|
require 'vscale/api/background'
|
9
|
+
require 'vscale/api/backups'
|
9
10
|
require 'vscale/api/billing'
|
10
11
|
require 'vscale/api/configurations'
|
12
|
+
require 'vscale/api/domains'
|
13
|
+
require 'vscale/api/notifications'
|
11
14
|
require 'vscale/api/request'
|
12
15
|
require 'vscale/api/servers'
|
13
16
|
require 'vscale/api/sshkeys'
|
14
|
-
require 'vscale/api/tickets'
|
15
|
-
require 'vscale/api/tokens'
|
16
17
|
require 'vscale/api/version'
|
17
18
|
|
19
|
+
## TODO :
|
20
|
+
## API Chain: api.add_tag(params).restart_server(id)
|
21
|
+
## Batch Request: API_queue{job1, job2, job3}.batch
|
22
|
+
|
18
23
|
module Vscale
|
19
24
|
module Api
|
20
25
|
class Client
|
21
26
|
include Account
|
22
27
|
include Background
|
28
|
+
include Backups
|
23
29
|
include Billing
|
24
30
|
include Configurations
|
31
|
+
include Domains
|
32
|
+
include Notifications
|
25
33
|
include Request
|
26
34
|
include Servers
|
27
35
|
include SSHKeys
|
28
|
-
|
29
|
-
include Tokens
|
36
|
+
|
30
37
|
def initialize(token, api_endpoint = API_ENDPOINT)
|
31
38
|
@token = token
|
32
39
|
@api_endpoint = api_endpoint
|
33
40
|
|
34
41
|
uri = URI.parse(@api_endpoint)
|
35
42
|
|
43
|
+
# TODO: rescue StandardError
|
36
44
|
@http = Net::HTTP.start(uri.host, uri.port, use_ssl: true)
|
37
45
|
@http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
38
46
|
@http.ssl_version = :TLSv1_2
|
39
47
|
end
|
40
48
|
|
41
|
-
|
42
|
-
|
43
|
-
def request_json(method, path, params)
|
44
|
-
response = request(method, path, params)
|
45
|
-
body = JSON.parse(response.body)
|
49
|
+
private
|
46
50
|
|
51
|
+
def request_json(meth, path, params = {})
|
52
|
+
response = request(meth, path, params)
|
53
|
+
body = JSON.parse(response.body)
|
47
54
|
OpenStruct.new(code: response.code, body: body)
|
48
|
-
|
49
55
|
rescue JSON::ParserError
|
50
|
-
response
|
56
|
+
response # TODO: convert to Hash
|
51
57
|
end
|
52
58
|
|
53
|
-
def request(
|
59
|
+
def request(meth, path, params = {})
|
54
60
|
full_path = encode_path_params(@api_endpoint + path, params)
|
55
|
-
request = VERB_MAP[
|
61
|
+
request = VERB_MAP[meth.to_sym].new(full_path)
|
56
62
|
request['Accept'] = 'application/json, text/plain'
|
57
63
|
request['Content-Type'] = 'application/json'
|
58
64
|
request['X-Token'] = @token
|
65
|
+
|
66
|
+
request.set_form_data(params) if ['post', 'put', 'patch'].include?(meth)
|
67
|
+
|
59
68
|
@http.request(request)
|
60
69
|
end
|
61
70
|
|
data/lib/vscale/api/account.rb
CHANGED
data/lib/vscale/api/billing.rb
CHANGED
@@ -0,0 +1,97 @@
|
|
1
|
+
module Vscale
|
2
|
+
module Domains
|
3
|
+
def domains
|
4
|
+
get('domains/')
|
5
|
+
end
|
6
|
+
|
7
|
+
def add_domain(params = {})
|
8
|
+
post('domains/', params)
|
9
|
+
end
|
10
|
+
|
11
|
+
def domain_id(id)
|
12
|
+
get("domains/#{id}")
|
13
|
+
end
|
14
|
+
|
15
|
+
alias_method :find_domain, :domain_id
|
16
|
+
alias_method :domain_info, :domain_id
|
17
|
+
|
18
|
+
def update_domain(domain_id, params = {})
|
19
|
+
patch("domains/#{domain_id}", params)
|
20
|
+
end
|
21
|
+
|
22
|
+
alias_method :change_domain, :update_domain
|
23
|
+
|
24
|
+
def remove_domain(domain_id)
|
25
|
+
delete("domains/#{domain_id}")
|
26
|
+
end
|
27
|
+
|
28
|
+
alias_method :delete_domain, :remove_domain
|
29
|
+
alias_method :rm_domain, :remove_domain
|
30
|
+
|
31
|
+
## Domains Records
|
32
|
+
|
33
|
+
def domain_records(domain_id)
|
34
|
+
get("domains/#{domain_id}/records/")
|
35
|
+
end
|
36
|
+
|
37
|
+
def add_domain_record(domain_id, params = {})
|
38
|
+
post("domains/#{domain_id}/records/", params)
|
39
|
+
end
|
40
|
+
|
41
|
+
def update_domain_record(domain_id, record_id, params = {})
|
42
|
+
put("domains/#{domain_id}/records/#{record_id}", params)
|
43
|
+
end
|
44
|
+
|
45
|
+
def remove_domain_record(domain_id, record_id)
|
46
|
+
delete("domains/#{domain_id}/records/#{record_id}")
|
47
|
+
end
|
48
|
+
|
49
|
+
def domain_record(domain_id, record_id)
|
50
|
+
get("domains/#{domain_id}/records/#{record_id}")
|
51
|
+
end
|
52
|
+
|
53
|
+
## Domains Tags
|
54
|
+
|
55
|
+
def add_domains_tags(params = {})
|
56
|
+
post('domains/tags/', params)
|
57
|
+
end
|
58
|
+
|
59
|
+
def domains_tags
|
60
|
+
get('domains/tags/')
|
61
|
+
end
|
62
|
+
|
63
|
+
def domains_tag_id(tag_id)
|
64
|
+
get("domains/tags/#{tag_id}")
|
65
|
+
end
|
66
|
+
|
67
|
+
def update_domains_tag(tag_id, params = {})
|
68
|
+
put("domains/tags/#{tag_id}", params)
|
69
|
+
end
|
70
|
+
|
71
|
+
def remove_domains_tag(tag_id)
|
72
|
+
delete("domains/tags/#{tag_id}")
|
73
|
+
end
|
74
|
+
|
75
|
+
## PTR Records
|
76
|
+
|
77
|
+
def add_domains_ptr(params = {})
|
78
|
+
post('domains/ptr/', params)
|
79
|
+
end
|
80
|
+
|
81
|
+
def domains_ptr
|
82
|
+
get('domains/ptr/')
|
83
|
+
end
|
84
|
+
|
85
|
+
def domains_ptr_id(ptr_id)
|
86
|
+
get("domains/ptr/#{ptr_id}")
|
87
|
+
end
|
88
|
+
|
89
|
+
def update_ptr_id(ptr_id, params = {})
|
90
|
+
put("domains/ptr/#{ptr_id}", params)
|
91
|
+
end
|
92
|
+
|
93
|
+
def remove_ptr_id(ptr_id)
|
94
|
+
delete("domains/ptr/#{ptr_id}")
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
data/lib/vscale/api/request.rb
CHANGED
data/lib/vscale/api/servers.rb
CHANGED
@@ -36,8 +36,28 @@ module Vscale
|
|
36
36
|
get('tasks')
|
37
37
|
end
|
38
38
|
|
39
|
-
def scalet_sshkeys(params)
|
39
|
+
def scalet_sshkeys(id, params)
|
40
40
|
patch("sshkeys/scalets/#{id}", params)
|
41
41
|
end
|
42
|
+
|
43
|
+
def add_scalet_tag(params)
|
44
|
+
post('scalets/tags', params)
|
45
|
+
end
|
46
|
+
|
47
|
+
def scalets_tags
|
48
|
+
get('scalets/tags')
|
49
|
+
end
|
50
|
+
|
51
|
+
def scalet_tag(tag_id)
|
52
|
+
get("scalets/tags/#{tag_id}")
|
53
|
+
end
|
54
|
+
|
55
|
+
def update_scalet_tag(tag_id, params)
|
56
|
+
put("scalets/tags/#{tag_id}", params)
|
57
|
+
end
|
58
|
+
|
59
|
+
def remove_scalet_tag(tag_id)
|
60
|
+
delete("scalets/tags/#{tag_id}")
|
61
|
+
end
|
42
62
|
end
|
43
63
|
end
|
data/lib/vscale/api/version.rb
CHANGED
data/vscale-api.gemspec
CHANGED
@@ -27,9 +27,11 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
28
28
|
spec.bindir = 'exe'
|
29
29
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
30
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
30
31
|
spec.require_paths = ['lib']
|
31
32
|
|
32
|
-
spec.add_development_dependency 'bundler', '~> 1.
|
33
|
+
spec.add_development_dependency 'bundler', '~> 1.7'
|
33
34
|
spec.add_development_dependency 'rake', '~> 10.0'
|
34
|
-
spec.add_development_dependency '
|
35
|
+
spec.add_development_dependency 'rspec'
|
36
|
+
spec.add_development_dependency 'rubocop'
|
35
37
|
end
|
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.46
|
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-
|
11
|
+
date: 2016-10-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
19
|
+
version: '1.7'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
26
|
+
version: '1.7'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
@@ -52,8 +52,21 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
-
|
56
|
-
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: " Vscale API v1\n"
|
57
70
|
email:
|
58
71
|
- ilya@codeplay.ru
|
59
72
|
executables: []
|
@@ -61,15 +74,6 @@ extensions: []
|
|
61
74
|
extra_rdoc_files: []
|
62
75
|
files:
|
63
76
|
- ".gitignore"
|
64
|
-
- ".idea/.name"
|
65
|
-
- ".idea/.rakeTasks"
|
66
|
-
- ".idea/encodings.xml"
|
67
|
-
- ".idea/misc.xml"
|
68
|
-
- ".idea/modules.xml"
|
69
|
-
- ".idea/ruby-vscale-api.iml"
|
70
|
-
- ".idea/scopes/scope_settings.xml"
|
71
|
-
- ".idea/vcs.xml"
|
72
|
-
- ".idea/workspace.xml"
|
73
77
|
- ".rubocop.yml"
|
74
78
|
- ".travis.yml"
|
75
79
|
- CODE_OF_CONDUCT.md
|
@@ -83,13 +87,14 @@ files:
|
|
83
87
|
- lib/vscale/api.rb
|
84
88
|
- lib/vscale/api/account.rb
|
85
89
|
- lib/vscale/api/background.rb
|
90
|
+
- lib/vscale/api/backups.rb
|
86
91
|
- lib/vscale/api/billing.rb
|
87
92
|
- lib/vscale/api/configurations.rb
|
93
|
+
- lib/vscale/api/domains.rb
|
94
|
+
- lib/vscale/api/notifications.rb
|
88
95
|
- lib/vscale/api/request.rb
|
89
96
|
- lib/vscale/api/servers.rb
|
90
97
|
- lib/vscale/api/sshkeys.rb
|
91
|
-
- lib/vscale/api/tickets.rb
|
92
|
-
- lib/vscale/api/tokens.rb
|
93
98
|
- lib/vscale/api/version.rb
|
94
99
|
- vscale-api.gemspec
|
95
100
|
homepage: https://github.com/Smolget/vscale-api
|
@@ -113,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
113
118
|
version: '0'
|
114
119
|
requirements: []
|
115
120
|
rubyforge_project:
|
116
|
-
rubygems_version: 2.
|
121
|
+
rubygems_version: 2.5.1
|
117
122
|
signing_key:
|
118
123
|
specification_version: 4
|
119
124
|
summary: Vscale API v1
|
data/lib/vscale/api/tickets.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
module Vscale
|
2
|
-
module Tickets
|
3
|
-
def tickets
|
4
|
-
get('tickets')
|
5
|
-
end
|
6
|
-
|
7
|
-
def tickets_new(params)
|
8
|
-
post('tickets', params)
|
9
|
-
end
|
10
|
-
|
11
|
-
def ticket_comments
|
12
|
-
get("tickets/#{id}/comments")
|
13
|
-
end
|
14
|
-
|
15
|
-
def tickets_add_comment(params)
|
16
|
-
post('tickets', params)
|
17
|
-
end
|
18
|
-
|
19
|
-
def tickets_close(id)
|
20
|
-
post("tickets/#{id}/close")
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
data/lib/vscale/api/tokens.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
module Vscale
|
2
|
-
module Tokens
|
3
|
-
def tokens(params = {})
|
4
|
-
params.empty? ? get('tokens') : post('tokens', params)
|
5
|
-
end
|
6
|
-
|
7
|
-
def find_token(id)
|
8
|
-
get("tokens/#{id}")
|
9
|
-
end
|
10
|
-
|
11
|
-
def update_token(id, params)
|
12
|
-
post("tokens/#{id}", params)
|
13
|
-
end
|
14
|
-
|
15
|
-
def remove_token(id)
|
16
|
-
delete("tokens/#{id}")
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|