lunanode 0.1.5

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.
Files changed (51) hide show
  1. checksums.yaml +7 -0
  2. data/.codeclimate.yml +16 -0
  3. data/.gitignore +13 -0
  4. data/.rspec +2 -0
  5. data/.rubocop.yml +94 -0
  6. data/.ruby-gemset +1 -0
  7. data/.ruby-version +1 -0
  8. data/.travis.yml +11 -0
  9. data/.yardopts +1 -0
  10. data/CODE_OF_CONDUCT.md +74 -0
  11. data/Gemfile +5 -0
  12. data/LICENSE.txt +21 -0
  13. data/README.md +50 -0
  14. data/Rakefile +19 -0
  15. data/bin/console +8 -0
  16. data/bin/setup +8 -0
  17. data/lib/lunanode.rb +12 -0
  18. data/lib/lunanode/action_generator.rb +105 -0
  19. data/lib/lunanode/api.rb +172 -0
  20. data/lib/lunanode/api_actions.rb +41 -0
  21. data/lib/lunanode/api_actions/default/dns.rb +55 -0
  22. data/lib/lunanode/api_actions/default/email.rb +59 -0
  23. data/lib/lunanode/api_actions/default/floating.rb +19 -0
  24. data/lib/lunanode/api_actions/default/image.rb +31 -0
  25. data/lib/lunanode/api_actions/default/lb.rb +35 -0
  26. data/lib/lunanode/api_actions/default/monitor.rb +47 -0
  27. data/lib/lunanode/api_actions/default/network.rb +19 -0
  28. data/lib/lunanode/api_actions/default/plan.rb +11 -0
  29. data/lib/lunanode/api_actions/default/region.rb +11 -0
  30. data/lib/lunanode/api_actions/default/script.rb +11 -0
  31. data/lib/lunanode/api_actions/default/securitygroup.rb +35 -0
  32. data/lib/lunanode/api_actions/default/vm.rb +99 -0
  33. data/lib/lunanode/api_actions/default/volume.rb +47 -0
  34. data/lib/lunanode/api_actions/dns.rb +10 -0
  35. data/lib/lunanode/api_actions/email.rb +10 -0
  36. data/lib/lunanode/api_actions/floating.rb +10 -0
  37. data/lib/lunanode/api_actions/image.rb +17 -0
  38. data/lib/lunanode/api_actions/lb.rb +10 -0
  39. data/lib/lunanode/api_actions/monitor.rb +10 -0
  40. data/lib/lunanode/api_actions/network.rb +10 -0
  41. data/lib/lunanode/api_actions/plan.rb +10 -0
  42. data/lib/lunanode/api_actions/region.rb +10 -0
  43. data/lib/lunanode/api_actions/script.rb +10 -0
  44. data/lib/lunanode/api_actions/securitygroup.rb +10 -0
  45. data/lib/lunanode/api_actions/vm.rb +10 -0
  46. data/lib/lunanode/api_actions/volume.rb +10 -0
  47. data/lib/lunanode/api_error.rb +5 -0
  48. data/lib/lunanode/version.rb +4 -0
  49. data/lunanode.gemspec +33 -0
  50. data/lunanode_api_def.yaml +391 -0
  51. metadata +191 -0
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lunanode
4
+ module APIActions
5
+ module Network
6
+ def network_list(region: nil)
7
+ action(:network, :list, region: region)
8
+ end
9
+
10
+ def network_create(region:, name:, subnet:, dns:)
11
+ action(:network, :create, region: region, name: name, subnet: subnet, dns: dns)
12
+ end
13
+
14
+ def network_delete(region:, net_id:)
15
+ action(:network, :delete, region: region, net_id: net_id)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lunanode
4
+ module APIActions
5
+ module Plan
6
+ def plan_list
7
+ action(:plan, :list)
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lunanode
4
+ module APIActions
5
+ module Region
6
+ def region_list
7
+ action(:region, :list)
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lunanode
4
+ module APIActions
5
+ module Script
6
+ def script_list
7
+ action(:script, :list)
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lunanode
4
+ module APIActions
5
+ module Securitygroup
6
+ def securitygroup_list
7
+ action(:securitygroup, :list)
8
+ end
9
+
10
+ def securitygroup_create(region:, name:)
11
+ action(:securitygroup, :create, region: region, name: name)
12
+ end
13
+
14
+ def securitygroup_delete(region:, group_id:)
15
+ action(:securitygroup, :delete, region: region, group_id: group_id)
16
+ end
17
+
18
+ def securitygroup_rename(region:, group_id:, name:)
19
+ action(:securitygroup, :rename, region: region, group_id: group_id, name: name)
20
+ end
21
+
22
+ def securitygroup_rule_list(region:, group_id:)
23
+ action(:securitygroup, :rule_list, region: region, group_id: group_id)
24
+ end
25
+
26
+ def securitygroup_rule_insert(region:, group_id:, direction:, type:, protocol:, remote_type:, remote_value:, port_min: nil, port_max: nil, label: nil)
27
+ action(:securitygroup, :rule_insert, region: region, group_id: group_id, direction: direction, type: type, protocol: protocol, remote_type: remote_type, remote_value: remote_value, port_min: port_min, port_max: port_max, label: label)
28
+ end
29
+
30
+ def securitygroup_rule_delete(region:, group_id:, rule_id:)
31
+ action(:securitygroup, :rule_delete, region: region, group_id: group_id, rule_id: rule_id)
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,99 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lunanode
4
+ module APIActions
5
+ module VM
6
+ def vm_start(vm_id:)
7
+ action(:vm, :start, vm_id: vm_id)
8
+ end
9
+
10
+ def vm_stop(vm_id:)
11
+ action(:vm, :stop, vm_id: vm_id)
12
+ end
13
+
14
+ def vm_reboot(vm_id:)
15
+ action(:vm, :reboot, vm_id: vm_id)
16
+ end
17
+
18
+ def vm_diskswap(vm_id:)
19
+ action(:vm, :diskswap, vm_id: vm_id)
20
+ end
21
+
22
+ def vm_info(vm_id:)
23
+ action(:vm, :info, vm_id: vm_id)
24
+ end
25
+
26
+ def vm_delete(vm_id:)
27
+ action(:vm, :delete, vm_id: vm_id)
28
+ end
29
+
30
+ def vm_reimage(vm_id:, image_id:)
31
+ action(:vm, :reimage, vm_id: vm_id, image_id: image_id)
32
+ end
33
+
34
+ def vm_resize(vm_id:, plan_id:)
35
+ action(:vm, :resize, vm_id: vm_id, plan_id: plan_id)
36
+ end
37
+
38
+ def vm_rescue(vm_id:)
39
+ action(:vm, :rescue, vm_id: vm_id)
40
+ end
41
+
42
+ def vm_vnc(vm_id:)
43
+ action(:vm, :vnc, vm_id: vm_id)
44
+ end
45
+
46
+ def vm_floatingip_add(vm_id:, ip: nil, private_ip: nil)
47
+ action(:vm, :floatingip_add, vm_id: vm_id, ip: ip, private_ip: private_ip)
48
+ end
49
+
50
+ def vm_floatingip_delete(vm_id:, ip: nil, keep: nil)
51
+ action(:vm, :floatingip_delete, vm_id: vm_id, ip: ip, keep: keep)
52
+ end
53
+
54
+ def vm_iplist(vm_id:)
55
+ action(:vm, :iplist, vm_id: vm_id)
56
+ end
57
+
58
+ def vm_ip_add(vm_id:, ip: nil)
59
+ action(:vm, :ip_add, vm_id: vm_id, ip: ip)
60
+ end
61
+
62
+ def vm_ip_delete(vm_id:, ip:)
63
+ action(:vm, :ip_delete, vm_id: vm_id, ip: ip)
64
+ end
65
+
66
+ def vm_securitygroup_add(vm_id:, group_id:)
67
+ action(:vm, :securitygroup_add, vm_id: vm_id, group_id: group_id)
68
+ end
69
+
70
+ def vm_securitygroup_remove(vm_id:, group_id:)
71
+ action(:vm, :securitygroup_remove, vm_id: vm_id, group_id: group_id)
72
+ end
73
+
74
+ def vm_create(hostname:, plan_id:, image_id:, region: nil, ip: nil, net_id: nil, securitygroups: nil, scripts: nil, volume_id: nil, volume_virtio: nil, key_id: nil, set_password: nil, affinity_group: nil)
75
+ action(:vm, :create, hostname: hostname, plan_id: plan_id, image_id: image_id, region: region, ip: ip, net_id: net_id, securitygroups: securitygroups, scripts: scripts, volume_id: volume_id, volume_virtio: volume_virtio, key_id: key_id, set_password: set_password, affinity_group: affinity_group)
76
+ end
77
+
78
+ def vm_snapshot(vm_id:, name:)
79
+ action(:vm, :snapshot, vm_id: vm_id, name: name)
80
+ end
81
+
82
+ def vm_list
83
+ action(:vm, :list)
84
+ end
85
+
86
+ def vm_shelve(vm_id:)
87
+ action(:vm, :shelve, vm_id: vm_id)
88
+ end
89
+
90
+ def vm_unshelve(vm_id:)
91
+ action(:vm, :unshelve, vm_id: vm_id)
92
+ end
93
+
94
+ def vm_rename(vm_id:, hostname:)
95
+ action(:vm, :rename, vm_id: vm_id, hostname: hostname)
96
+ end
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lunanode
4
+ module APIActions
5
+ module Volume
6
+ def volume_list(region:)
7
+ action(:volume, :list, region: region)
8
+ end
9
+
10
+ def volume_create(region:, label:, size:, image: nil, snapshot_id: nil)
11
+ action(:volume, :create, region: region, label: label, size: size, image: image, snapshot_id: snapshot_id)
12
+ end
13
+
14
+ def volume_delete(region:, volume_id:)
15
+ action(:volume, :delete, region: region, volume_id: volume_id)
16
+ end
17
+
18
+ def volume_attach(region:, volume_id:, vm_id:, target:)
19
+ action(:volume, :attach, region: region, volume_id: volume_id, vm_id: vm_id, target: target)
20
+ end
21
+
22
+ def volume_detach(region:, volume_id:)
23
+ action(:volume, :detach, region: region, volume_id: volume_id)
24
+ end
25
+
26
+ def volume_info(region:, volume_id:)
27
+ action(:volume, :info, region: region, volume_id: volume_id)
28
+ end
29
+
30
+ def volume_extend(region:, volume_id:, size:)
31
+ action(:volume, :extend, region: region, volume_id: volume_id, size: size)
32
+ end
33
+
34
+ def volume_snapshot_create(region:, volume_id:, label:)
35
+ action(:volume, :snapshot_create, region: region, volume_id: volume_id, label: label)
36
+ end
37
+
38
+ def volume_snapshot_delete(region:, snapshot_id:)
39
+ action(:volume, :snapshot_delete, region: region, snapshot_id: snapshot_id)
40
+ end
41
+
42
+ def volume_snapshot_list(region:)
43
+ action(:volume, :snapshot_list, region: region)
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+ require "lunanode/api_actions/default/dns"
3
+
4
+ module Lunanode
5
+ module APIActions
6
+ module DNS
7
+ # Contents may extend or overwrite methods from the default module.
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+ require "lunanode/api_actions/default/email"
3
+
4
+ module Lunanode
5
+ module APIActions
6
+ module Email
7
+ # Contents may extend or overwrite methods from the default module.
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+ require "lunanode/api_actions/default/floating"
3
+
4
+ module Lunanode
5
+ module APIActions
6
+ module Floating
7
+ # Contents may extend or overwrite methods from the default module.
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+ require "lunanode/api_actions/default/image"
3
+
4
+ module Lunanode
5
+ module APIActions
6
+ module Image
7
+ # Contents may extend or overwrite methods from the default module.
8
+
9
+ # Filters {#image_list} results for user's account images only.
10
+ def image_list_mine(region: nil)
11
+ image_list(region: region).select do |image|
12
+ image[:image_id].to_i > 9999
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+ require "lunanode/api_actions/default/lb"
3
+
4
+ module Lunanode
5
+ module APIActions
6
+ module LB
7
+ # Contents may extend or overwrite methods from the default module.
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+ require "lunanode/api_actions/default/monitor"
3
+
4
+ module Lunanode
5
+ module APIActions
6
+ module Monitor
7
+ # Contents may extend or overwrite methods from the default module.
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+ require "lunanode/api_actions/default/network"
3
+
4
+ module Lunanode
5
+ module APIActions
6
+ module Network
7
+ # Contents may extend or overwrite methods from the default module.
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+ require "lunanode/api_actions/default/plan"
3
+
4
+ module Lunanode
5
+ module APIActions
6
+ module Plan
7
+ # Contents may extend or overwrite methods from the default module.
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+ require "lunanode/api_actions/default/region"
3
+
4
+ module Lunanode
5
+ module APIActions
6
+ module Region
7
+ # Contents may extend or overwrite methods from the default module.
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+ require "lunanode/api_actions/default/script"
3
+
4
+ module Lunanode
5
+ module APIActions
6
+ module Script
7
+ # Contents may extend or overwrite methods from the default module.
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+ require "lunanode/api_actions/default/securitygroup"
3
+
4
+ module Lunanode
5
+ module APIActions
6
+ module Securitygroup
7
+ # Contents may extend or overwrite methods from the default module.
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+ require "lunanode/api_actions/default/vm"
3
+
4
+ module Lunanode
5
+ module APIActions
6
+ module VM
7
+ # Contents may extend or overwrite methods from the default module.
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+ require "lunanode/api_actions/default/volume"
3
+
4
+ module Lunanode
5
+ module APIActions
6
+ module Volume
7
+ # Contents may extend or overwrite methods from the default module.
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,5 @@
1
+ module Lunanode
2
+ # A RuntimeError raised when the API call returns unsuccessfully.
3
+ class APIError < RuntimeError
4
+ end
5
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+ module Lunanode
3
+ VERSION = "0.1.5".freeze
4
+ end
data/lunanode.gemspec ADDED
@@ -0,0 +1,33 @@
1
+ # coding: utf-8
2
+ # frozen_string_literal: true
3
+ lib = File.expand_path("../lib", __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require "lunanode/version"
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = "lunanode"
9
+ spec.version = Lunanode::VERSION
10
+ spec.authors = ["Tim Bellefleur"]
11
+ spec.email = ["nomoon@phoebus.ca"]
12
+
13
+ spec.summary = "Luna Node API for Ruby"
14
+ spec.homepage = "https://github.com/nomoon/lunanode"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+ spec.required_ruby_version = ">= 2.1.0"
24
+
25
+ spec.add_dependency "rest-client", "~> 2.0"
26
+
27
+ spec.add_development_dependency "bundler", "~> 1.14"
28
+ spec.add_development_dependency "rake", "~> 12.0"
29
+ spec.add_development_dependency "rspec", "~> 3.0"
30
+ spec.add_development_dependency "yard", "~> 0.9"
31
+ spec.add_development_dependency "pry", "~> 0.10"
32
+ spec.add_development_dependency "rubocop", "~> 0.47"
33
+ end