miasma 0.3.2 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +4 -0
- data/LICENSE +1 -1
- data/README.md +5 -2
- data/lib/miasma.rb +14 -15
- data/lib/miasma/error.rb +17 -10
- data/lib/miasma/models.rb +9 -9
- data/lib/miasma/models/auto_scale.rb +5 -7
- data/lib/miasma/models/auto_scale/group.rb +8 -13
- data/lib/miasma/models/auto_scale/groups.rb +2 -4
- data/lib/miasma/models/block_storage.rb +1 -0
- data/lib/miasma/models/compute.rb +4 -6
- data/lib/miasma/models/compute/server.rb +5 -6
- data/lib/miasma/models/compute/servers.rb +2 -4
- data/lib/miasma/models/dns.rb +1 -0
- data/lib/miasma/models/load_balancer.rb +5 -7
- data/lib/miasma/models/load_balancer/balancer.rb +9 -11
- data/lib/miasma/models/load_balancer/balancers.rb +2 -4
- data/lib/miasma/models/monitoring.rb +1 -0
- data/lib/miasma/models/orchestration.rb +37 -7
- data/lib/miasma/models/orchestration/event.rb +2 -5
- data/lib/miasma/models/orchestration/events.rb +5 -7
- data/lib/miasma/models/orchestration/plan.rb +87 -0
- data/lib/miasma/models/orchestration/plans.rb +52 -0
- data/lib/miasma/models/orchestration/resource.rb +8 -10
- data/lib/miasma/models/orchestration/resources.rb +3 -5
- data/lib/miasma/models/orchestration/stack.rb +106 -20
- data/lib/miasma/models/orchestration/stacks.rb +3 -5
- data/lib/miasma/models/queues.rb +1 -0
- data/lib/miasma/models/queuing.rb +72 -0
- data/lib/miasma/models/queuing/queue.rb +77 -0
- data/lib/miasma/models/queuing/queues.rb +32 -0
- data/lib/miasma/models/storage.rb +8 -9
- data/lib/miasma/models/storage/bucket.rb +4 -7
- data/lib/miasma/models/storage/buckets.rb +2 -4
- data/lib/miasma/models/storage/file.rb +13 -16
- data/lib/miasma/models/storage/files.rb +3 -5
- data/lib/miasma/specs.rb +4 -4
- data/lib/miasma/specs/compute_abstract.rb +24 -33
- data/lib/miasma/specs/load_balancer_abstract.rb +17 -27
- data/lib/miasma/specs/orchestration_abstract.rb +26 -37
- data/lib/miasma/specs/storage_abstract.rb +21 -27
- data/lib/miasma/types.rb +6 -8
- data/lib/miasma/types/api.rb +28 -31
- data/lib/miasma/types/collection.rb +8 -10
- data/lib/miasma/types/data.rb +2 -5
- data/lib/miasma/types/model.rb +13 -16
- data/lib/miasma/types/thin_model.rb +7 -10
- data/lib/miasma/utils.rb +7 -7
- data/lib/miasma/utils/animal_strings.rb +1 -3
- data/lib/miasma/utils/api_methoding.rb +2 -5
- data/lib/miasma/utils/immutable.rb +2 -6
- data/lib/miasma/utils/lazy.rb +2 -2
- data/lib/miasma/utils/memoization.rb +1 -1
- data/lib/miasma/utils/smash.rb +1 -1
- data/lib/miasma/version.rb +1 -1
- data/miasma.gemspec +21 -19
- metadata +44 -12
data/lib/miasma/types/data.rb
CHANGED
@@ -1,11 +1,10 @@
|
|
1
|
-
require
|
1
|
+
require "miasma"
|
2
2
|
|
3
3
|
module Miasma
|
4
4
|
module Types
|
5
5
|
|
6
6
|
# Base data container
|
7
7
|
class Data
|
8
|
-
|
9
8
|
include Miasma::Utils::Lazy
|
10
9
|
|
11
10
|
attribute :id, [String, Numeric]
|
@@ -14,7 +13,7 @@ module Miasma
|
|
14
13
|
#
|
15
14
|
# @param args [Hash] attribute values
|
16
15
|
# @return [self]
|
17
|
-
def initialize(args={})
|
16
|
+
def initialize(args = {})
|
18
17
|
load_data(args)
|
19
18
|
valid_state
|
20
19
|
end
|
@@ -45,9 +44,7 @@ module Miasma
|
|
45
44
|
def from_json(json)
|
46
45
|
self.new(MultiJson.load(json).to_smash)
|
47
46
|
end
|
48
|
-
|
49
47
|
end
|
50
|
-
|
51
48
|
end
|
52
49
|
end
|
53
50
|
end
|
data/lib/miasma/types/model.rb
CHANGED
@@ -1,15 +1,14 @@
|
|
1
|
-
require
|
1
|
+
require "miasma"
|
2
2
|
|
3
3
|
module Miasma
|
4
4
|
module Types
|
5
5
|
|
6
6
|
# Base model
|
7
7
|
class Model < Data
|
8
|
-
|
9
8
|
include Utils::Memoization
|
10
9
|
include Utils::ApiMethoding
|
11
10
|
|
12
|
-
attribute :custom, Smash, :coerce => lambda{|v| v.to_smash}, :default => Smash.new
|
11
|
+
attribute :custom, Smash, :coerce => lambda { |v| v.to_smash }, :default => Smash.new
|
13
12
|
|
14
13
|
# @return [Miasma::Types::Api] underlying service API
|
15
14
|
attr_reader :api
|
@@ -26,7 +25,6 @@ module Miasma
|
|
26
25
|
instance.from_json(json)
|
27
26
|
instance
|
28
27
|
end
|
29
|
-
|
30
28
|
end
|
31
29
|
|
32
30
|
# Build new model
|
@@ -34,12 +32,12 @@ module Miasma
|
|
34
32
|
# @param api [Miasma::Types::Api] service API
|
35
33
|
# @param model_data [Smash] load model data if provided
|
36
34
|
# @return [self]
|
37
|
-
def initialize(api, model_data=nil)
|
35
|
+
def initialize(api, model_data = nil)
|
38
36
|
@api = api
|
39
37
|
@data = Smash.new
|
40
38
|
@dirty = Smash.new
|
41
|
-
if
|
42
|
-
if
|
39
|
+
if model_data
|
40
|
+
if model_data.is_a?(Hash)
|
43
41
|
load_data(model_data) unless model_data.empty?
|
44
42
|
else
|
45
43
|
raise TypeError.new "Expecting `model_data` to be of type `Hash`. Received: `#{model_data.class}`"
|
@@ -53,7 +51,7 @@ module Miasma
|
|
53
51
|
# @return [TrueClass, FalseClass] save was performed
|
54
52
|
# @raises [Miasma::Error::Save]
|
55
53
|
def save
|
56
|
-
if
|
54
|
+
if dirty?
|
57
55
|
perform_save
|
58
56
|
reload
|
59
57
|
else
|
@@ -66,7 +64,7 @@ module Miasma
|
|
66
64
|
# @return [TrueClass, FalseClass] destruction was performed
|
67
65
|
# @raises [Miasma::Error::Destroy]
|
68
66
|
def destroy
|
69
|
-
if
|
67
|
+
if persisted?
|
70
68
|
perform_destroy
|
71
69
|
reload
|
72
70
|
true
|
@@ -101,10 +99,10 @@ module Miasma
|
|
101
99
|
# @return [TrueClass, FalseClass] performed remote action
|
102
100
|
# @raises [Miasma::Error::Save]
|
103
101
|
def perform_save
|
104
|
-
if
|
102
|
+
if m_name = api_method_for(:save)
|
105
103
|
api.send(m_name, self)
|
106
104
|
else
|
107
|
-
raise NotImplementedError.new
|
105
|
+
raise NotImplementedError.new "Remote API save has not been implemented"
|
108
106
|
end
|
109
107
|
end
|
110
108
|
|
@@ -113,10 +111,10 @@ module Miasma
|
|
113
111
|
# @return [TrueClass, FalseClass] performed remote action
|
114
112
|
# @raises [Miasma::Error::Save]
|
115
113
|
def perform_reload
|
116
|
-
if
|
114
|
+
if m_name = api_method_for(:reload)
|
117
115
|
api.send(m_name, self)
|
118
116
|
else
|
119
|
-
raise NotImplementedError.new
|
117
|
+
raise NotImplementedError.new "Remote API reload has not been implemented"
|
120
118
|
end
|
121
119
|
end
|
122
120
|
|
@@ -125,13 +123,12 @@ module Miasma
|
|
125
123
|
# @return [TrueClass, FalseClass] performed remote action
|
126
124
|
# @raises [Miasma::Error::Save]
|
127
125
|
def perform_destroy
|
128
|
-
if
|
126
|
+
if m_name = api_method_for(:destroy)
|
129
127
|
api.send(m_name, self)
|
130
128
|
else
|
131
|
-
raise NotImplementedError.new
|
129
|
+
raise NotImplementedError.new "Remote API destroy has not been implemented"
|
132
130
|
end
|
133
131
|
end
|
134
|
-
|
135
132
|
end
|
136
133
|
end
|
137
134
|
end
|
@@ -1,20 +1,19 @@
|
|
1
|
-
require
|
1
|
+
require "miasma"
|
2
2
|
|
3
3
|
module Miasma
|
4
4
|
module Types
|
5
5
|
|
6
6
|
# Base data container
|
7
7
|
class ThinModel < Data
|
8
|
-
|
9
8
|
class << self
|
10
9
|
|
11
10
|
# Get/Set fat model
|
12
11
|
#
|
13
12
|
# @param klass [Class] fat model class
|
14
13
|
# @return [Class] fat model class
|
15
|
-
def model(klass=nil)
|
16
|
-
if
|
17
|
-
unless
|
14
|
+
def model(klass = nil)
|
15
|
+
if klass
|
16
|
+
unless klass.ancestors.include?(Miasma::Types::Model)
|
18
17
|
raise TypeError.new "Expecting `Miasma::Types::Model` subclass! (got #{klass})"
|
19
18
|
else
|
20
19
|
self._model = klass
|
@@ -27,7 +26,6 @@ module Miasma
|
|
27
26
|
|
28
27
|
# @return [Class] fat model class
|
29
28
|
attr_accessor :_model
|
30
|
-
|
31
29
|
end
|
32
30
|
|
33
31
|
# @return [Miasma::Types::Api] service API
|
@@ -37,7 +35,7 @@ module Miasma
|
|
37
35
|
#
|
38
36
|
# @param api [Miasma::Types::Api] service API
|
39
37
|
# @param args [Hash] model data
|
40
|
-
def initialize(api, args={})
|
38
|
+
def initialize(api, args = {})
|
41
39
|
@api = api
|
42
40
|
super args
|
43
41
|
end
|
@@ -53,7 +51,7 @@ module Miasma
|
|
53
51
|
# @return [Class] of type Miasma::Types::Model
|
54
52
|
# @note will deconstruct namespace and rebuild using provider
|
55
53
|
def model
|
56
|
-
if
|
54
|
+
if self.class.model
|
57
55
|
self.class.model
|
58
56
|
else
|
59
57
|
raise NotImplementedError.new "No associated model for this thin model type (#{self.class})"
|
@@ -68,9 +66,8 @@ module Miasma
|
|
68
66
|
inst.data[:id] = self.id
|
69
67
|
inst.reload
|
70
68
|
end
|
71
|
-
alias_method :instance, :expand
|
72
69
|
|
70
|
+
alias_method :instance, :expand
|
73
71
|
end
|
74
|
-
|
75
72
|
end
|
76
73
|
end
|
data/lib/miasma/utils.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
|
-
require
|
1
|
+
require "miasma"
|
2
2
|
|
3
3
|
module Miasma
|
4
4
|
module Utils
|
5
|
-
autoload :ApiMethoding,
|
6
|
-
autoload :Lazy,
|
7
|
-
autoload :Memoization,
|
8
|
-
autoload :Immutable,
|
5
|
+
autoload :ApiMethoding, "miasma/utils/api_methoding"
|
6
|
+
autoload :Lazy, "miasma/utils/lazy"
|
7
|
+
autoload :Memoization, "miasma/utils/memoization"
|
8
|
+
autoload :Immutable, "miasma/utils/immutable"
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
require
|
13
|
-
require
|
12
|
+
require "miasma/utils/animal_strings"
|
13
|
+
require "miasma/utils/smash"
|
@@ -1,19 +1,16 @@
|
|
1
|
-
require
|
1
|
+
require "miasma"
|
2
2
|
|
3
3
|
module Miasma
|
4
4
|
module Utils
|
5
|
-
|
6
5
|
module ApiMethoding
|
7
6
|
|
8
7
|
# Generate the supported API method for
|
9
8
|
# a given action
|
10
9
|
def api_method_for(action)
|
11
10
|
klass = self.respond_to?(:model) ? model : self.class
|
12
|
-
m_name = "#{Bogo::Utility.snake(klass.name.split(
|
11
|
+
m_name = "#{Bogo::Utility.snake(klass.name.split("::").last)}_#{action}"
|
13
12
|
self.api.respond_to?(m_name) ? m_name : nil
|
14
13
|
end
|
15
|
-
|
16
14
|
end
|
17
|
-
|
18
15
|
end
|
19
16
|
end
|
@@ -1,7 +1,6 @@
|
|
1
|
-
require
|
1
|
+
require "miasma"
|
2
2
|
|
3
3
|
module Miasma
|
4
|
-
|
5
4
|
module Utils
|
6
5
|
# Make best effort to make model immutable
|
7
6
|
# @note this should be included at end of model definition
|
@@ -17,20 +16,17 @@ module Miasma
|
|
17
16
|
|
18
17
|
# @raises [Error::ImmutableError]
|
19
18
|
def save
|
20
|
-
raise Error::ImmutableError.new
|
19
|
+
raise Error::ImmutableError.new "Resource information cannot be mutated!"
|
21
20
|
end
|
22
21
|
|
23
22
|
class << self
|
24
|
-
|
25
23
|
def included(klass)
|
26
24
|
klass.class_eval do
|
27
25
|
alias_method :unfrozen_valid_state, :valid_state
|
28
26
|
alias_method :valid_state, :frozen_valid_state
|
29
27
|
end
|
30
28
|
end
|
31
|
-
|
32
29
|
end
|
33
|
-
|
34
30
|
end
|
35
31
|
end
|
36
32
|
end
|
data/lib/miasma/utils/lazy.rb
CHANGED
data/lib/miasma/utils/smash.rb
CHANGED
data/lib/miasma/version.rb
CHANGED
data/miasma.gemspec
CHANGED
@@ -1,22 +1,24 @@
|
|
1
|
-
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__)) +
|
2
|
-
require
|
1
|
+
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__)) + "/lib/"
|
2
|
+
require "miasma/version"
|
3
3
|
Gem::Specification.new do |s|
|
4
|
-
s.name =
|
4
|
+
s.name = "miasma"
|
5
5
|
s.version = Miasma::VERSION.version
|
6
|
-
s.summary =
|
7
|
-
s.author =
|
8
|
-
s.email =
|
9
|
-
s.homepage =
|
10
|
-
s.description =
|
11
|
-
s.license =
|
12
|
-
s.require_path =
|
13
|
-
s.add_runtime_dependency
|
14
|
-
s.add_runtime_dependency
|
15
|
-
s.add_runtime_dependency
|
16
|
-
s.add_runtime_dependency
|
17
|
-
s.add_runtime_dependency
|
18
|
-
s.add_development_dependency
|
19
|
-
s.add_development_dependency
|
20
|
-
s.add_development_dependency
|
21
|
-
s.
|
6
|
+
s.summary = "Smoggy API"
|
7
|
+
s.author = "Chris Roberts"
|
8
|
+
s.email = "code@chrisroberts.org"
|
9
|
+
s.homepage = "https://github.com/miasma-rb/miasma"
|
10
|
+
s.description = "Smoggy API"
|
11
|
+
s.license = "Apache 2.0"
|
12
|
+
s.require_path = "lib"
|
13
|
+
s.add_runtime_dependency "http", ">= 0.8.12", "< 2.0"
|
14
|
+
s.add_runtime_dependency "multi_json"
|
15
|
+
s.add_runtime_dependency "multi_xml"
|
16
|
+
s.add_runtime_dependency "xml-simple"
|
17
|
+
s.add_runtime_dependency "bogo", ">= 0.2.2", "< 1.0"
|
18
|
+
s.add_development_dependency "pry"
|
19
|
+
s.add_development_dependency "minitest"
|
20
|
+
s.add_development_dependency "rspec", "~> 3.5"
|
21
|
+
s.add_development_dependency "rake", "~> 10"
|
22
|
+
s.add_development_dependency "rufo", "~> 0.3.0"
|
23
|
+
s.files = Dir["{bin,lib}/**/*"] + %w(miasma.gemspec README.md CHANGELOG.md LICENSE)
|
22
24
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: miasma
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Roberts
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-06-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: 0.8.12
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
22
|
+
version: '2.0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
version: 0.8.12
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
32
|
+
version: '2.0'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: multi_json
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -107,7 +107,7 @@ dependencies:
|
|
107
107
|
- !ruby/object:Gem::Version
|
108
108
|
version: '0'
|
109
109
|
- !ruby/object:Gem::Dependency
|
110
|
-
name:
|
110
|
+
name: minitest
|
111
111
|
requirement: !ruby/object:Gem::Requirement
|
112
112
|
requirements:
|
113
113
|
- - ">="
|
@@ -121,19 +121,47 @@ dependencies:
|
|
121
121
|
- !ruby/object:Gem::Version
|
122
122
|
version: '0'
|
123
123
|
- !ruby/object:Gem::Dependency
|
124
|
-
name:
|
124
|
+
name: rspec
|
125
125
|
requirement: !ruby/object:Gem::Requirement
|
126
126
|
requirements:
|
127
|
-
- - "
|
127
|
+
- - "~>"
|
128
128
|
- !ruby/object:Gem::Version
|
129
|
-
version: '
|
129
|
+
version: '3.5'
|
130
130
|
type: :development
|
131
131
|
prerelease: false
|
132
132
|
version_requirements: !ruby/object:Gem::Requirement
|
133
133
|
requirements:
|
134
|
-
- - "
|
134
|
+
- - "~>"
|
135
135
|
- !ruby/object:Gem::Version
|
136
|
-
version: '
|
136
|
+
version: '3.5'
|
137
|
+
- !ruby/object:Gem::Dependency
|
138
|
+
name: rake
|
139
|
+
requirement: !ruby/object:Gem::Requirement
|
140
|
+
requirements:
|
141
|
+
- - "~>"
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '10'
|
144
|
+
type: :development
|
145
|
+
prerelease: false
|
146
|
+
version_requirements: !ruby/object:Gem::Requirement
|
147
|
+
requirements:
|
148
|
+
- - "~>"
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: '10'
|
151
|
+
- !ruby/object:Gem::Dependency
|
152
|
+
name: rufo
|
153
|
+
requirement: !ruby/object:Gem::Requirement
|
154
|
+
requirements:
|
155
|
+
- - "~>"
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: 0.3.0
|
158
|
+
type: :development
|
159
|
+
prerelease: false
|
160
|
+
version_requirements: !ruby/object:Gem::Requirement
|
161
|
+
requirements:
|
162
|
+
- - "~>"
|
163
|
+
- !ruby/object:Gem::Version
|
164
|
+
version: 0.3.0
|
137
165
|
description: Smoggy API
|
138
166
|
email: code@chrisroberts.org
|
139
167
|
executables: []
|
@@ -161,11 +189,16 @@ files:
|
|
161
189
|
- lib/miasma/models/orchestration.rb
|
162
190
|
- lib/miasma/models/orchestration/event.rb
|
163
191
|
- lib/miasma/models/orchestration/events.rb
|
192
|
+
- lib/miasma/models/orchestration/plan.rb
|
193
|
+
- lib/miasma/models/orchestration/plans.rb
|
164
194
|
- lib/miasma/models/orchestration/resource.rb
|
165
195
|
- lib/miasma/models/orchestration/resources.rb
|
166
196
|
- lib/miasma/models/orchestration/stack.rb
|
167
197
|
- lib/miasma/models/orchestration/stacks.rb
|
168
198
|
- lib/miasma/models/queues.rb
|
199
|
+
- lib/miasma/models/queuing.rb
|
200
|
+
- lib/miasma/models/queuing/queue.rb
|
201
|
+
- lib/miasma/models/queuing/queues.rb
|
169
202
|
- lib/miasma/models/storage.rb
|
170
203
|
- lib/miasma/models/storage/bucket.rb
|
171
204
|
- lib/miasma/models/storage/buckets.rb
|
@@ -211,9 +244,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
211
244
|
version: '0'
|
212
245
|
requirements: []
|
213
246
|
rubyforge_project:
|
214
|
-
rubygems_version: 2.
|
247
|
+
rubygems_version: 2.7.6
|
215
248
|
signing_key:
|
216
249
|
specification_version: 4
|
217
250
|
summary: Smoggy API
|
218
251
|
test_files: []
|
219
|
-
has_rdoc:
|