vscale-api 0.2.39

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2dfadb7d39583a108dc9fc2cc440d3ba7621966e
4
+ data.tar.gz: b3d1852be9e3b2b5c14ef4b5b3f3530f4bf42d08
5
+ SHA512:
6
+ metadata.gz: 9f68eb88d89dc22a9c7888b224d419515c48d79ed880ab0c78c912d0b12900e5526dbaaf6364ceb97fb860bbf76423d16ec44e8e74fa644bc8f4663be0f0a1c4
7
+ data.tar.gz: 5cad1e995606f912f8ce43a2856fb91e871ec182050a882213e02cdfba7354b945d748d80ef4754e666ff93b4df07572ac46a6eb0a3e8e86eb9cd6aa5cdb086b
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /.idea/*
4
+ /Gemfile.lock
5
+ /_yardoc/
6
+ /coverage/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
11
+ *.gem
@@ -0,0 +1,8 @@
1
+ Documentation:
2
+ Enabled: false
3
+
4
+ AllCops:
5
+ Exclude:
6
+ - Guardfile
7
+ - Rakefile
8
+ - vscale-api.gemspec
@@ -0,0 +1,13 @@
1
+ language: ruby
2
+ cache: bundler
3
+
4
+ rvm:
5
+ - 2.2.2
6
+ - 2.2.3
7
+
8
+ notifications:
9
+ email:
10
+ recipients:
11
+ - ilya@codeplay.ru
12
+ on_failure: change
13
+ on_success: never
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
3
+
4
+ group :development do
5
+ gem 'guard-rspec', require: false
6
+ gem 'guard-rubocop'
7
+ gem 'coveralls', require: false
8
+ end
@@ -0,0 +1,76 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ ## Uncomment and set this to only include directories you want to watch
5
+ # directories %w(app lib config test spec features) \
6
+ directories %w(lib spec) \
7
+ .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
8
+
9
+ ## Note: if you are using the `directories` clause above and you are not
10
+ ## watching the project directory ('.'), then you will want to move
11
+ ## the Guardfile to a watched dir and symlink it back, e.g.
12
+ #
13
+ # $ mkdir config
14
+ # $ mv Guardfile config/
15
+ # $ ln -s config/Guardfile .
16
+ #
17
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
18
+
19
+ guard :rubocop do
20
+ watch(%r{.+\.rb$})
21
+ watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
22
+ end
23
+
24
+ # Note: The cmd option is now required due to the increasing number of ways
25
+ # rspec may be run, below are examples of the most common uses.
26
+ # * bundler: 'bundle exec rspec'
27
+ # * bundler binstubs: 'bin/rspec'
28
+ # * spring: 'bin/rspec' (This will use spring if running and you have
29
+ # installed the spring binstubs per the docs)
30
+ # * zeus: 'zeus rspec' (requires the server to be started separately)
31
+ # * 'just' rspec: 'rspec'
32
+
33
+ guard :rspec, cmd: 'bundle exec rspec' do
34
+ require 'guard/rspec/dsl'
35
+ dsl = Guard::RSpec::Dsl.new(self)
36
+
37
+ # Feel free to open issues for suggestions and improvements
38
+
39
+ # RSpec files
40
+ rspec = dsl.rspec
41
+ watch(rspec.spec_helper) { rspec.spec_dir }
42
+ watch(rspec.spec_support) { rspec.spec_dir }
43
+ watch(rspec.spec_files)
44
+
45
+ # Ruby files
46
+ ruby = dsl.ruby
47
+ dsl.watch_spec_files_for(ruby.lib_files)
48
+
49
+ # Rails files
50
+ rails = dsl.rails(view_extensions: %w(erb haml slim))
51
+ dsl.watch_spec_files_for(rails.app_files)
52
+ dsl.watch_spec_files_for(rails.views)
53
+
54
+ watch(rails.controllers) do |m|
55
+ [
56
+ rspec.spec.("routing/#{m[1]}_routing"),
57
+ rspec.spec.("controllers/#{m[1]}_controller"),
58
+ rspec.spec.("acceptance/#{m[1]}")
59
+ ]
60
+ end
61
+
62
+ # Rails config changes
63
+ watch(rails.spec_helper) { rspec.spec_dir }
64
+ watch(rails.routes) { "#{rspec.spec_dir}/routing" }
65
+ watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
66
+
67
+ # Capybara features specs
68
+ watch(rails.view_dirs) { |m| rspec.spec.("features/#{m[1]}") }
69
+ watch(rails.layouts) { |m| rspec.spec.("features/#{m[1]}") }
70
+
71
+ # Turnip features and steps
72
+ watch(%r{^spec/acceptance/(.+)\.feature$})
73
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
74
+ Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
75
+ end
76
+ end
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Ilya V
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.
@@ -0,0 +1,4 @@
1
+ ### WIP
2
+
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
+ [![Build Status](https://travis-ci.org/Smolget/vscale-api.svg?branch=master)](https://travis-ci.org/Smolget/vscale-api)
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'ruby/vscale/api'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require 'irb'
14
+ IRB.start
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,68 @@
1
+ require 'net/http'
2
+ require 'openssl'
3
+ require 'ostruct'
4
+ require 'json'
5
+ require 'uri'
6
+
7
+ require 'vscale/api/account'
8
+ require 'vscale/api/background'
9
+ require 'vscale/api/billing'
10
+ require 'vscale/api/configurations'
11
+ require 'vscale/api/request'
12
+ require 'vscale/api/servers'
13
+ require 'vscale/api/sshkeys'
14
+ require 'vscale/api/tickets'
15
+ require 'vscale/api/tokens'
16
+ require 'vscale/api/version'
17
+
18
+ module Vscale
19
+ module Api
20
+ class Client
21
+ include Account
22
+ include Background
23
+ include Billing
24
+ include Configurations
25
+ include Request
26
+ include Servers
27
+ include SSHKeys
28
+ include Tickets
29
+ include Tokens
30
+ def initialize(token, api_endpoint = API_ENDPOINT)
31
+ @token = token
32
+ @api_endpoint = api_endpoint
33
+
34
+ uri = URI.parse(@api_endpoint)
35
+
36
+ @http = Net::HTTP.start(uri.host, uri.port, use_ssl: true)
37
+ @http.verify_mode = OpenSSL::SSL::VERIFY_PEER
38
+ @http.ssl_version = :TLSv1_2
39
+ end
40
+
41
+ private
42
+
43
+ def request_json(method, path, params)
44
+ response = request(method, path, params)
45
+ body = JSON.parse(response.body)
46
+
47
+ OpenStruct.new(code: response.code, body: body)
48
+
49
+ rescue JSON::ParserError
50
+ response
51
+ end
52
+
53
+ def request(method, path, params = {})
54
+ full_path = encode_path_params(@api_endpoint + path, params)
55
+ request = VERB_MAP[method.to_sym].new(full_path)
56
+ request['Accept'] = 'application/json, text/plain'
57
+ request['Content-Type'] = 'application/json'
58
+ request['X-Token'] = @token
59
+ @http.request(request)
60
+ end
61
+
62
+ def encode_path_params(path, params)
63
+ encoded = URI.encode_www_form(params)
64
+ [path, encoded].join('?')
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,11 @@
1
+ module Vscale
2
+ module Account
3
+ def account
4
+ get('account')
5
+ end
6
+
7
+ def auth
8
+ get('auth')
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Vscale
2
+ module Background
3
+ def locations
4
+ get('locations')
5
+ end
6
+
7
+ def images
8
+ get('images')
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Vscale
2
+ module Billing
3
+ def payments
4
+ get('billing/payments')
5
+ end
6
+
7
+ def consumption(params)
8
+ get('billing/consumption', params)
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Vscale
2
+ module Configurations
3
+ def rplans
4
+ get('rplans')
5
+ end
6
+
7
+ def prices
8
+ get('billing/prices')
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,32 @@
1
+ module Vscale
2
+ module Request
3
+ API_ENDPOINT = 'https://api.vscale.io/v1/'.freeze
4
+
5
+ VERB_MAP = {
6
+ get: Net::HTTP::Get,
7
+ put: Net::HTTP::Put,
8
+ post: Net::HTTP::Post,
9
+ delete: Net::HTTP::Delete
10
+ }
11
+
12
+ def get(path, params = {})
13
+ request_json :get, path, params
14
+ end
15
+
16
+ def post(path, params = {})
17
+ request_json :post, path, params
18
+ end
19
+
20
+ def put(path, params = {})
21
+ request_json :put, path, params
22
+ end
23
+
24
+ def delete(path, params = {})
25
+ request_json :delete, path, params
26
+ end
27
+
28
+ def patch(path, params = {})
29
+ request_json :patch, path, params
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,43 @@
1
+ module Vscale
2
+ module Servers
3
+ def scalets # TODO: alias scalets
4
+ get('scalets')
5
+ end
6
+
7
+ def new_scalet(params = {}) # TODO: alias Vscale::API::Scalets.new(params)
8
+ post('scalets', params)
9
+ end
10
+
11
+ def find_scalet(id) # TODO: alias :scalet_info
12
+ get("scalets/#{id}")
13
+ end
14
+
15
+ def restart_scalet(id)
16
+ patch("scalets/#{id}/restart")
17
+ end
18
+
19
+ def stop_scalet(id)
20
+ patch("scalets/#{id}/stop")
21
+ end
22
+
23
+ def start_scalet(id)
24
+ patch("scalets/#{id}/start")
25
+ end
26
+
27
+ def upgrade_scalet(id, params)
28
+ post("scalets/#{id}/upgrade", params)
29
+ end
30
+
31
+ def delete_scalet(id)
32
+ delete("scalets/#{id}")
33
+ end
34
+
35
+ def task
36
+ get('tasks')
37
+ end
38
+
39
+ def scalet_sshkeys(params)
40
+ patch("sshkeys/scalets/#{id}", params)
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,15 @@
1
+ module Vscale
2
+ module SSHKeys
3
+ def sshkeys
4
+ get('sshkeys')
5
+ end
6
+
7
+ def sshkeys_new(params)
8
+ post('sshkeys', params)
9
+ end
10
+
11
+ def sshkeys_delete(id)
12
+ delete("sshkeys/#{id}")
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,23 @@
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
@@ -0,0 +1,19 @@
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
@@ -0,0 +1,5 @@
1
+ module Vscale
2
+ module Api
3
+ VERSION = '0.2.39' # TODO: {APIversion}.10
4
+ end
5
+ end
@@ -0,0 +1,35 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'vscale/api/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'vscale-api'
8
+ spec.version = Vscale::Api::VERSION
9
+ spec.authors = ['Ilya V']
10
+ spec.email = ['ilya@codeplay.ru']
11
+
12
+ spec.summary = 'Vscale API v1'
13
+ spec.description = <<-EOF
14
+ Vscale API v1
15
+ EOF
16
+ spec.homepage = 'https://github.com/Smolget/vscale-api'
17
+ spec.license = 'MIT'
18
+
19
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
20
+ # delete this section to allow pushing this gem to any host.
21
+ if spec.respond_to?(:metadata)
22
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
23
+ else
24
+ fail 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
25
+ end
26
+
27
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
28
+ spec.bindir = 'exe'
29
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ['lib']
31
+
32
+ spec.add_development_dependency 'bundler', '~> 1.9'
33
+ spec.add_development_dependency 'rake', '~> 10.0'
34
+ spec.add_development_dependency 'coveralls'
35
+ end
metadata ADDED
@@ -0,0 +1,120 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vscale-api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.39
5
+ platform: ruby
6
+ authors:
7
+ - Ilya V
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-10-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.9'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.9'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: coveralls
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: |2
56
+ Vscale API v1
57
+ email:
58
+ - ilya@codeplay.ru
59
+ executables: []
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".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
+ - ".rubocop.yml"
74
+ - ".travis.yml"
75
+ - CODE_OF_CONDUCT.md
76
+ - Gemfile
77
+ - Guardfile
78
+ - LICENSE.txt
79
+ - README.md
80
+ - Rakefile
81
+ - bin/console
82
+ - bin/setup
83
+ - lib/vscale/api.rb
84
+ - lib/vscale/api/account.rb
85
+ - lib/vscale/api/background.rb
86
+ - lib/vscale/api/billing.rb
87
+ - lib/vscale/api/configurations.rb
88
+ - lib/vscale/api/request.rb
89
+ - lib/vscale/api/servers.rb
90
+ - lib/vscale/api/sshkeys.rb
91
+ - lib/vscale/api/tickets.rb
92
+ - lib/vscale/api/tokens.rb
93
+ - lib/vscale/api/version.rb
94
+ - vscale-api.gemspec
95
+ homepage: https://github.com/Smolget/vscale-api
96
+ licenses:
97
+ - MIT
98
+ metadata:
99
+ allowed_push_host: https://rubygems.org
100
+ post_install_message:
101
+ rdoc_options: []
102
+ require_paths:
103
+ - lib
104
+ required_ruby_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ required_rubygems_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ requirements: []
115
+ rubyforge_project:
116
+ rubygems_version: 2.4.5.1
117
+ signing_key:
118
+ specification_version: 4
119
+ summary: Vscale API v1
120
+ test_files: []