megam_api 1.5.rc5 → 1.5.rc7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -2
- data/LICENSE +21 -202
- data/README.md +3 -20
- data/lib/megam/api.rb +154 -169
- data/lib/megam/api/accounts.rb +0 -15
- data/lib/megam/api/assemblies.rb +0 -15
- data/lib/megam/api/assembly.rb +0 -15
- data/lib/megam/api/balances.rb +0 -15
- data/lib/megam/api/billedhistories.rb +0 -15
- data/lib/megam/api/billingtransactions.rb +0 -15
- data/lib/megam/api/components.rb +0 -15
- data/lib/megam/api/domains.rb +0 -15
- data/lib/megam/api/errors.rb +0 -15
- data/lib/megam/api/eventsbilling.rb +0 -15
- data/lib/megam/api/eventscontainer.rb +0 -15
- data/lib/megam/api/eventsstorage.rb +0 -15
- data/lib/megam/api/eventsvm.rb +0 -15
- data/lib/megam/api/marketplaces.rb +0 -15
- data/lib/megam/api/organizations.rb +0 -15
- data/lib/megam/api/promos.rb +0 -15
- data/lib/megam/api/requests.rb +0 -15
- data/lib/megam/api/sensors.rb +0 -15
- data/lib/megam/api/snapshots.rb +0 -15
- data/lib/megam/api/sshkeys.rb +0 -15
- data/lib/megam/api/version.rb +1 -16
- data/lib/megam/core/account.rb +241 -60
- data/lib/megam/core/assemblies.rb +0 -16
- data/lib/megam/core/assemblies_collection.rb +101 -116
- data/lib/megam/core/assembly.rb +201 -218
- data/lib/megam/core/assembly_collection.rb +101 -116
- data/lib/megam/core/balances.rb +182 -197
- data/lib/megam/core/balances_collection.rb +101 -116
- data/lib/megam/core/billedhistories.rb +186 -201
- data/lib/megam/core/billedhistories_collection.rb +101 -116
- data/lib/megam/core/billingtransactions.rb +0 -15
- data/lib/megam/core/billingtransactions_collection.rb +0 -15
- data/lib/megam/core/components.rb +300 -316
- data/lib/megam/core/components_collection.rb +0 -15
- data/lib/megam/core/domain_collection.rb +1 -16
- data/lib/megam/core/domains.rb +115 -131
- data/lib/megam/core/error.rb +55 -70
- data/lib/megam/core/eventsbilling.rb +0 -16
- data/lib/megam/core/eventsbilling_collection.rb +101 -116
- data/lib/megam/core/eventscontainer.rb +0 -16
- data/lib/megam/core/eventscontainer_collection.rb +101 -116
- data/lib/megam/core/eventsstorage.rb +0 -16
- data/lib/megam/core/eventsstorage_collection.rb +0 -15
- data/lib/megam/core/eventsvm.rb +0 -16
- data/lib/megam/core/eventsvm_collection.rb +101 -116
- data/lib/megam/core/json_compat.rb +0 -12
- data/lib/megam/core/konipai.rb +0 -15
- data/lib/megam/core/log.rb +0 -15
- data/lib/megam/core/marketplace.rb +224 -241
- data/lib/megam/core/marketplace_collection.rb +0 -15
- data/lib/megam/core/organizations.rb +0 -16
- data/lib/megam/core/organizations_collection.rb +0 -15
- data/lib/megam/core/promos.rb +0 -15
- data/lib/megam/core/request.rb +0 -15
- data/lib/megam/core/request_collection.rb +0 -15
- data/lib/megam/core/rest_adapter.rb +0 -15
- data/lib/megam/core/sensors.rb +138 -154
- data/lib/megam/core/sensors_collection.rb +0 -15
- data/lib/megam/core/snapshots.rb +0 -16
- data/lib/megam/core/snapshots_collection.rb +0 -15
- data/lib/megam/core/sshkey.rb +169 -184
- data/lib/megam/core/sshkey_collection.rb +0 -15
- data/lib/megam/core/stuff.rb +17 -32
- data/lib/megam/core/text.rb +82 -97
- data/lib/megam/mixins/assemblies.rb +10 -25
- data/lib/megam/mixins/assembly.rb +33 -49
- data/lib/megam/mixins/common_deployable.rb +64 -79
- data/lib/megam/mixins/components.rb +160 -175
- data/lib/megam/mixins/megam_attributes.rb +22 -37
- data/lib/megam/mixins/outputs.rb +14 -29
- data/lib/megam/mixins/policies.rb +21 -36
- data/lib/megam_api.rb +0 -15
- data/test/mixins/test_assemblies.rb +1 -2
- data/test/test_accounts.rb +84 -29
- data/test/test_billingtranscations.rb +17 -21
- data/test/test_eventscontainer.rb +19 -23
- data/test/test_eventsstorage.rb +8 -10
- data/test/test_eventsvm.rb +19 -23
- data/test/test_helper.rb +30 -30
- data/test/test_snapshots.rb +16 -22
- metadata +2 -2
@@ -1,182 +1,167 @@
|
|
1
|
-
# Copyright:: Copyright (c) 2013-2016 Megam Systems
|
2
|
-
# License:: Apache License, Version 2.0
|
3
|
-
#
|
4
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
# you may not use this file except in compliance with the License.
|
6
|
-
# You may obtain a copy of the License at
|
7
|
-
#
|
8
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
#
|
10
|
-
# Unless required by applicable law or agreed to in writing, software
|
11
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
# See the License for the specific language governing permissions and
|
14
|
-
# limitations under the License.
|
15
|
-
#
|
16
1
|
require File.expand_path("#{File.dirname(__FILE__)}/megam_attributes")
|
17
2
|
require File.expand_path("#{File.dirname(__FILE__)}/common_deployable")
|
18
3
|
require File.expand_path("#{File.dirname(__FILE__)}/outputs")
|
19
4
|
|
20
5
|
module Megam
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
6
|
+
class Mixins
|
7
|
+
class Components
|
8
|
+
attr_reader :mixins, :name, :repo, :related_components, :operations, :artifacts, :envs, :outputs, :id
|
9
|
+
def initialize(params)
|
10
|
+
@mixins = CommonDeployable.new(params)
|
11
|
+
@id = params[:id] if params[:id]
|
12
|
+
@name = params[:componentname] || params[:name] || ''
|
13
|
+
@outputs = Outputs.new(params)
|
14
|
+
@operations = add_operations(params)
|
15
|
+
@related_components = add_related_components(params)
|
16
|
+
@artifacts = add_artifacts(params)
|
17
|
+
@repo = add_repo(params)
|
18
|
+
@envs = params[:envs]
|
19
|
+
end
|
20
|
+
|
21
|
+
def to_hash
|
22
|
+
result = @mixins.to_hash
|
23
|
+
result[:id] = @id if @id
|
24
|
+
result[:name] = @name if @name
|
25
|
+
result[:artifacts] = @artifacts if @artifacts
|
26
|
+
result[:repo] = @repo if @repo
|
27
|
+
result[:operations] = @operations if @operations
|
28
|
+
result[:outputs] = @outputs.to_array if @outputs
|
29
|
+
result[:related_components] = @related_components if @related_components
|
30
|
+
result[:envs] = @envs if @envs
|
31
|
+
result.to_hash
|
32
|
+
end
|
33
|
+
|
34
|
+
def to_a
|
35
|
+
[to_hash]
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def add_repo(params)
|
41
|
+
Repo.new(params).tohash
|
42
|
+
end
|
43
|
+
|
44
|
+
def add_related_components(params)
|
45
|
+
@related_components = []
|
46
|
+
@related_components << "#{params[:bind_type]}" if params.key?(:bind_type)
|
47
|
+
end
|
48
|
+
|
49
|
+
def add_operations(params)
|
50
|
+
operations = []
|
51
|
+
operations.push(create_operation(Operations::CI, Operations::CI_DESCRIPTON, params)) if params.key?(:scm_name) && params.key?(:scmtoken)
|
52
|
+
operations.push(create_operation(Operations::BIND, Operations::BIND_DESCRIPTON, params)) if params.key?(:bind_type)
|
53
|
+
operations
|
54
|
+
end
|
55
|
+
|
56
|
+
def create_operation(type, desc, params)
|
57
|
+
Operations.new(params, type, desc).tohash
|
58
|
+
end
|
59
|
+
|
60
|
+
def add_artifacts(params)
|
61
|
+
Artifacts.new(params).tohash
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
class Repo
|
66
|
+
include Nilavu::MegamAttributes
|
67
|
+
attr_reader :type, :source, :url, :oneclick
|
68
|
+
ATTRIBUTES = [
|
69
|
+
:type,
|
70
|
+
:source,
|
71
|
+
:oneclick,
|
72
|
+
:url]
|
73
|
+
|
74
|
+
def attributes
|
75
|
+
ATTRIBUTES
|
76
|
+
end
|
77
|
+
|
78
|
+
def initialize(params)
|
79
|
+
set_attributes(params)
|
80
|
+
@type = params[:type] || ""
|
81
|
+
@source = params[:scm_name] || ""
|
82
|
+
@url = params[:source] || ""
|
83
|
+
@oneclick = params[:oneclick] || ""
|
84
|
+
end
|
85
|
+
|
86
|
+
def tohash
|
87
|
+
{ rtype: @type,
|
88
|
+
source: @source,
|
89
|
+
oneclick: @oneclick,
|
90
|
+
url: @url
|
91
|
+
}
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
class Operations
|
96
|
+
include Nilavu::MegamAttributes
|
97
|
+
attr_reader :type, :desc, :prop, :status
|
98
|
+
|
99
|
+
ATTRIBUTES = [
|
100
|
+
:type,
|
101
|
+
:desc,
|
102
|
+
:prop,
|
103
|
+
:status]
|
104
|
+
|
105
|
+
def attributes
|
106
|
+
ATTRIBUTES
|
107
|
+
end
|
108
|
+
|
109
|
+
CI = 'CI'.freeze
|
110
|
+
CI_DESCRIPTON = 'always up to date code. sweet.'
|
111
|
+
NOTBOUND = "notbound".freeze
|
112
|
+
BIND = 'bind'.freeze
|
113
|
+
BIND_DESCRIPTON = 'bind. sweet.'
|
114
|
+
|
115
|
+
def initialize(params, type, desc)
|
116
|
+
@type = type
|
117
|
+
@desc = desc
|
118
|
+
@prop = prop(params)
|
119
|
+
end
|
120
|
+
|
121
|
+
def attributes
|
122
|
+
ATTRIBUTES
|
123
|
+
end
|
124
|
+
|
125
|
+
def tohash
|
126
|
+
{ operation_type: @type,
|
127
|
+
description: @desc,
|
128
|
+
properties: @prop,
|
129
|
+
status: NOTBOUND
|
130
|
+
}
|
131
|
+
end
|
132
|
+
|
133
|
+
# Key_name mismatch. Key_name is to be changed.
|
134
|
+
def prop(params)
|
135
|
+
op = []
|
136
|
+
op << { 'key' => 'type', 'value' => params[:scm_name] } if params.key?(:scm_name)
|
137
|
+
op << { 'key' => 'token', 'value' => params[:scmtoken] } if params.key?(:scmtoken)
|
138
|
+
op << { 'key' => 'username', 'value' => params[:scmowner] } if params.key?(:scmowner)
|
139
|
+
op << { 'key' => 'related_component', 'value' => params[:bind_type] } if params.key?(:bind_type)
|
140
|
+
op
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
class Artifacts
|
145
|
+
include Nilavu::MegamAttributes
|
146
|
+
ATTRIBUTES = [
|
147
|
+
:type,
|
148
|
+
:content,
|
149
|
+
:requirements]
|
150
|
+
|
151
|
+
def attributes
|
152
|
+
ATTRIBUTES
|
153
|
+
end
|
154
|
+
|
155
|
+
def initialize(params)
|
156
|
+
set_attributes(params)
|
157
|
+
end
|
158
|
+
|
159
|
+
def tohash
|
160
|
+
{ artifact_type: '',
|
161
|
+
content: '',
|
162
|
+
requirements: []
|
163
|
+
}
|
164
|
+
end
|
165
|
+
end
|
78
166
|
end
|
79
|
-
|
80
|
-
class Repo
|
81
|
-
include Nilavu::MegamAttributes
|
82
|
-
attr_reader :type, :source, :url, :oneclick
|
83
|
-
ATTRIBUTES = [
|
84
|
-
:type,
|
85
|
-
:source,
|
86
|
-
:oneclick,
|
87
|
-
:url]
|
88
|
-
|
89
|
-
def attributes
|
90
|
-
ATTRIBUTES
|
91
|
-
end
|
92
|
-
|
93
|
-
def initialize(params)
|
94
|
-
set_attributes(params)
|
95
|
-
@type = params[:type] || ""
|
96
|
-
@source = params[:scm_name] || ""
|
97
|
-
@url = params[:source] || ""
|
98
|
-
@oneclick = params[:oneclick] || ""
|
99
|
-
end
|
100
|
-
|
101
|
-
def tohash
|
102
|
-
{ rtype: @type,
|
103
|
-
source: @source,
|
104
|
-
oneclick: @oneclick,
|
105
|
-
url: @url
|
106
|
-
}
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
class Operations
|
111
|
-
include Nilavu::MegamAttributes
|
112
|
-
attr_reader :type, :desc, :prop, :status
|
113
|
-
|
114
|
-
ATTRIBUTES = [
|
115
|
-
:type,
|
116
|
-
:desc,
|
117
|
-
:prop,
|
118
|
-
:status]
|
119
|
-
|
120
|
-
def attributes
|
121
|
-
ATTRIBUTES
|
122
|
-
end
|
123
|
-
|
124
|
-
CI = 'CI'.freeze
|
125
|
-
CI_DESCRIPTON = 'always up to date code. sweet.'
|
126
|
-
NOTBOUND = "notbound".freeze
|
127
|
-
BIND = 'bind'.freeze
|
128
|
-
BIND_DESCRIPTON = 'bind. sweet.'
|
129
|
-
|
130
|
-
def initialize(params, type, desc)
|
131
|
-
@type = type
|
132
|
-
@desc = desc
|
133
|
-
@prop = prop(params)
|
134
|
-
end
|
135
|
-
|
136
|
-
def attributes
|
137
|
-
ATTRIBUTES
|
138
|
-
end
|
139
|
-
|
140
|
-
def tohash
|
141
|
-
{ operation_type: @type,
|
142
|
-
description: @desc,
|
143
|
-
properties: @prop,
|
144
|
-
status: NOTBOUND
|
145
|
-
}
|
146
|
-
end
|
147
|
-
|
148
|
-
# Key_name mismatch. Key_name is to be changed.
|
149
|
-
def prop(params)
|
150
|
-
op = []
|
151
|
-
op << { 'key' => 'type', 'value' => params[:scm_name] } if params.key?(:scm_name)
|
152
|
-
op << { 'key' => 'token', 'value' => params[:scmtoken] } if params.key?(:scmtoken)
|
153
|
-
op << { 'key' => 'username', 'value' => params[:scmowner] } if params.key?(:scmowner)
|
154
|
-
op << { 'key' => 'related_component', 'value' => params[:bind_type] } if params.key?(:bind_type)
|
155
|
-
op
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
class Artifacts
|
160
|
-
include Nilavu::MegamAttributes
|
161
|
-
ATTRIBUTES = [
|
162
|
-
:type,
|
163
|
-
:content,
|
164
|
-
:requirements]
|
165
|
-
|
166
|
-
def attributes
|
167
|
-
ATTRIBUTES
|
168
|
-
end
|
169
|
-
|
170
|
-
def initialize(params)
|
171
|
-
set_attributes(params)
|
172
|
-
end
|
173
|
-
|
174
|
-
def tohash
|
175
|
-
{ artifact_type: '',
|
176
|
-
content: '',
|
177
|
-
requirements: []
|
178
|
-
}
|
179
|
-
end
|
180
|
-
end
|
181
|
-
end
|
182
167
|
end
|
@@ -1,45 +1,30 @@
|
|
1
|
-
# Copyright:: Copyright (c) 2013-2016 Megam Systems
|
2
|
-
# License:: Apache License, Version 2.0
|
3
|
-
#
|
4
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
# you may not use this file except in compliance with the License.
|
6
|
-
# You may obtain a copy of the License at
|
7
|
-
#
|
8
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
#
|
10
|
-
# Unless required by applicable law or agreed to in writing, software
|
11
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
# See the License for the specific language governing permissions and
|
14
|
-
# limitations under the License.
|
15
|
-
#
|
16
1
|
module Nilavu
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
2
|
+
module MegamAttributes
|
3
|
+
ATTRIBUTES = []
|
4
|
+
KEY = 'key'.freeze
|
5
|
+
VALUE = 'value'.freeze
|
21
6
|
|
22
|
-
|
7
|
+
attr_accessor *ATTRIBUTES
|
23
8
|
|
24
|
-
|
25
|
-
|
26
|
-
|
9
|
+
def attributes
|
10
|
+
NotImplementedError
|
11
|
+
end
|
27
12
|
|
28
|
-
|
29
|
-
|
30
|
-
|
13
|
+
def initialize(control_data = {})
|
14
|
+
set_attributes(control_data)
|
15
|
+
end
|
31
16
|
|
32
|
-
|
33
|
-
|
34
|
-
|
17
|
+
def set_attributes(control_data)
|
18
|
+
attributes.each { |a| instance_variable_set("@#{a}", control_data[a]) unless control_data[a].nil? }
|
19
|
+
end
|
35
20
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
21
|
+
def to_hash
|
22
|
+
h = attributes.reduce([]) do |res, key|
|
23
|
+
val = instance_variable_get("@#{key}".to_sym)
|
24
|
+
res << { KEY => key.to_s, VALUE => val } unless val.nil?
|
25
|
+
res
|
26
|
+
end
|
27
|
+
h
|
28
|
+
end
|
43
29
|
end
|
44
|
-
end
|
45
30
|
end
|
data/lib/megam/mixins/outputs.rb
CHANGED
@@ -1,38 +1,23 @@
|
|
1
|
-
# Copyright:: Copyright (c) 2013-2016 Megam Systems
|
2
|
-
# License:: Apache License, Version 2.0
|
3
|
-
#
|
4
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
# you may not use this file except in compliance with the License.
|
6
|
-
# You may obtain a copy of the License at
|
7
|
-
#
|
8
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
#
|
10
|
-
# Unless required by applicable law or agreed to in writing, software
|
11
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
# See the License for the specific language governing permissions and
|
14
|
-
# limitations under the License.
|
15
|
-
#
|
16
1
|
require File.expand_path("#{File.dirname(__FILE__)}/megam_attributes")
|
17
2
|
|
18
3
|
module Megam
|
19
|
-
|
20
|
-
|
4
|
+
class Outputs
|
5
|
+
include Nilavu::MegamAttributes
|
21
6
|
|
22
|
-
|
7
|
+
attr_reader :nodeip, :publicip, :privateip, :lastsuccessfulupdate, :laststatus
|
23
8
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
9
|
+
ATTRIBUTES = []
|
10
|
+
|
11
|
+
def attributes
|
12
|
+
ATTRIBUTES
|
13
|
+
end
|
29
14
|
|
30
|
-
|
31
|
-
|
32
|
-
|
15
|
+
def initialize(params)
|
16
|
+
set_attributes(params)
|
17
|
+
end
|
33
18
|
|
34
|
-
|
35
|
-
|
19
|
+
def to_array
|
20
|
+
array = []
|
21
|
+
end
|
36
22
|
end
|
37
|
-
end
|
38
23
|
end
|