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,137 +1,122 @@
|
|
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 Megam
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
2
|
+
class EventsBillingCollection
|
3
|
+
include Enumerable
|
4
|
+
|
5
|
+
attr_reader :iterator
|
6
|
+
def initialize
|
7
|
+
@eventsbilling = Array.new
|
8
|
+
@eventsbilling_by_name = Hash.new
|
9
|
+
@insert_after_idx = nil
|
10
|
+
end
|
26
11
|
|
27
|
-
|
28
|
-
|
29
|
-
|
12
|
+
def all_eventsbilling
|
13
|
+
@eventsbilling
|
14
|
+
end
|
30
15
|
|
31
|
-
|
32
|
-
|
33
|
-
|
16
|
+
def [](index)
|
17
|
+
@eventsbilling[index]
|
18
|
+
end
|
34
19
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
20
|
+
def []=(index, arg)
|
21
|
+
is_megam_eventsbilling(arg)
|
22
|
+
@eventsbilling[index] = arg
|
23
|
+
@eventsbilling_by_name[arg.account_id] = index
|
24
|
+
end
|
40
25
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
26
|
+
def <<(*args)
|
27
|
+
args.flatten.each do |a|
|
28
|
+
is_megam_events(a)
|
29
|
+
@eventsbilling << a
|
30
|
+
@eventsbilling_by_name[a.account_id] = @eventsbilling.length - 1
|
31
|
+
end
|
32
|
+
self
|
33
|
+
end
|
49
34
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
35
|
+
# 'push' is an alias method to <<
|
36
|
+
alias_method :push, :<<
|
37
|
+
|
38
|
+
def insert(eventsbilling)
|
39
|
+
is_megam_eventsbilling(eventsbilling)
|
40
|
+
if @insert_after_idx
|
41
|
+
# in the middle of executing a run, so any nodes inserted now should
|
42
|
+
# be placed after the most recent addition done by the currently executing
|
43
|
+
# node
|
44
|
+
@eventsbilling.insert(@insert_after_idx + 1, eventsbilling)
|
45
|
+
# update name -> location mappings and register new node
|
46
|
+
@eventsbilling_by_name.each_key do |key|
|
47
|
+
@eventsbilling_by_name[key] += 1 if @eventsbilling_by_name[key] > @insert_after_idx
|
48
|
+
end
|
49
|
+
@eventsbilling_by_name[eventsbilling.account_id] = @insert_after_idx + 1
|
50
|
+
@insert_after_idx += 1
|
51
|
+
else
|
52
|
+
@eventsbilling << eventsbilling
|
53
|
+
@eventsbilling_by_name[eventsbilling.account_id] = @eventsbilling.length - 1
|
54
|
+
end
|
63
55
|
end
|
64
|
-
@eventsbilling_by_name[eventsbilling.account_id] = @insert_after_idx + 1
|
65
|
-
@insert_after_idx += 1
|
66
|
-
else
|
67
|
-
@eventsbilling << eventsbilling
|
68
|
-
@eventsbilling_by_name[eventsbilling.account_id] = @eventsbilling.length - 1
|
69
|
-
end
|
70
|
-
end
|
71
56
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
57
|
+
def each
|
58
|
+
@eventsbilling.each do |eventsbilling|
|
59
|
+
yield eventsbilling
|
60
|
+
end
|
61
|
+
end
|
77
62
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
63
|
+
def each_index
|
64
|
+
@eventsbilling.each_index do |i|
|
65
|
+
yield i
|
66
|
+
end
|
67
|
+
end
|
83
68
|
|
84
|
-
|
85
|
-
|
86
|
-
|
69
|
+
def empty?
|
70
|
+
@eventsbilling.empty?
|
71
|
+
end
|
87
72
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
73
|
+
def lookup(eventsbilling)
|
74
|
+
lookup_by = nil
|
75
|
+
if events.kind_of?(Megam::EventsBilling)
|
76
|
+
lookup_by = eventsbilling.account_id
|
77
|
+
elsif events.kind_of?(String)
|
78
|
+
lookup_by = eventsbilling
|
79
|
+
else
|
80
|
+
raise ArgumentError, "Must pass a Megam::EventsBilling or String to lookup"
|
81
|
+
end
|
82
|
+
res = @eventsbilling_by_name[lookup_by]
|
83
|
+
unless res
|
84
|
+
raise ArgumentError, "Cannot find a node matching #{lookup_by} (did you define it first?)"
|
85
|
+
end
|
86
|
+
@eventsbilling[res]
|
87
|
+
end
|
103
88
|
|
104
|
-
|
105
|
-
|
106
|
-
|
89
|
+
def to_s
|
90
|
+
@eventsbilling.join(", ")
|
91
|
+
end
|
107
92
|
|
108
|
-
|
109
|
-
|
110
|
-
|
93
|
+
def for_json
|
94
|
+
to_a.map { |item| item.to_s }
|
95
|
+
end
|
111
96
|
|
112
|
-
|
113
|
-
|
114
|
-
|
97
|
+
def to_json(*a)
|
98
|
+
Megam::JSONCompat.to_json(for_json, *a)
|
99
|
+
end
|
115
100
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
101
|
+
def self.json_create(o)
|
102
|
+
collection = self.new()
|
103
|
+
o["results"].each do |eventsbilling_list|
|
104
|
+
eventsbilling_array = eventsbilling_list.kind_of?(Array) ? eventsbilling_list : [ eventsbilling_list ]
|
105
|
+
eventsbilling_array.each do |eventsbilling|
|
106
|
+
collection.insert(eventsbilling)
|
122
107
|
|
108
|
+
end
|
109
|
+
end
|
110
|
+
collection
|
123
111
|
end
|
124
|
-
end
|
125
|
-
collection
|
126
|
-
end
|
127
112
|
|
128
|
-
|
113
|
+
private
|
129
114
|
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
115
|
+
def is_megam_eventsbilling(arg)
|
116
|
+
unless arg.kind_of?(Megam::EventsBilling)
|
117
|
+
raise ArgumentError, "Members must be Megam::EventsBilling's"
|
118
|
+
end
|
119
|
+
true
|
120
|
+
end
|
135
121
|
end
|
136
|
-
end
|
137
122
|
end
|
@@ -1,19 +1,3 @@
|
|
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
|
-
|
17
1
|
module Megam
|
18
2
|
class EventsContainer < Megam::RestAdapter
|
19
3
|
def initialize(o)
|
@@ -1,137 +1,122 @@
|
|
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 Megam
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
2
|
+
class EventsContainerCollection
|
3
|
+
include Enumerable
|
4
|
+
|
5
|
+
attr_reader :iterator
|
6
|
+
def initialize
|
7
|
+
@eventscontainer = Array.new
|
8
|
+
@eventscontainer_by_name = Hash.new
|
9
|
+
@insert_after_idx = nil
|
10
|
+
end
|
26
11
|
|
27
|
-
|
28
|
-
|
29
|
-
|
12
|
+
def all_eventscontainer
|
13
|
+
@eventscontainer
|
14
|
+
end
|
30
15
|
|
31
|
-
|
32
|
-
|
33
|
-
|
16
|
+
def [](index)
|
17
|
+
@eventscontainer[index]
|
18
|
+
end
|
34
19
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
20
|
+
def []=(index, arg)
|
21
|
+
is_megam_eventsvm(arg)
|
22
|
+
@eventscontainer[index] = arg
|
23
|
+
@eventscontainer_by_name[arg.account_id] = index
|
24
|
+
end
|
40
25
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
26
|
+
def <<(*args)
|
27
|
+
args.flatten.each do |a|
|
28
|
+
is_megam_events(a)
|
29
|
+
@eventscontainer << a
|
30
|
+
@eventscontainer_by_name[a.account_id] = @eventscontainer.length - 1
|
31
|
+
end
|
32
|
+
self
|
33
|
+
end
|
49
34
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
35
|
+
# 'push' is an alias method to <<
|
36
|
+
alias_method :push, :<<
|
37
|
+
|
38
|
+
def insert(eventscontainer)
|
39
|
+
is_megam_eventscontainer(eventscontainer)
|
40
|
+
if @insert_after_idx
|
41
|
+
# in the middle of executing a run, so any nodes inserted now should
|
42
|
+
# be placed after the most recent addition done by the currently executing
|
43
|
+
# node
|
44
|
+
@eventscontainer.insert(@insert_after_idx + 1, eventscontainer)
|
45
|
+
# update name -> location mappings and register new node
|
46
|
+
@eventscontainer_by_name.each_key do |key|
|
47
|
+
@eventscontainer_by_name[key] += 1 if @eventscontainer_by_name[key] > @insert_after_idx
|
48
|
+
end
|
49
|
+
@eventscontainer_by_name[eventscontainer.account_id] = @insert_after_idx + 1
|
50
|
+
@insert_after_idx += 1
|
51
|
+
else
|
52
|
+
@eventscontainer << eventscontainer
|
53
|
+
@eventscontainer_by_name[eventscontainer.account_id] = @eventscontainer.length - 1
|
54
|
+
end
|
63
55
|
end
|
64
|
-
@eventscontainer_by_name[eventscontainer.account_id] = @insert_after_idx + 1
|
65
|
-
@insert_after_idx += 1
|
66
|
-
else
|
67
|
-
@eventscontainer << eventscontainer
|
68
|
-
@eventscontainer_by_name[eventscontainer.account_id] = @eventscontainer.length - 1
|
69
|
-
end
|
70
|
-
end
|
71
56
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
57
|
+
def each
|
58
|
+
@eventscontainer.each do |eventscontainer|
|
59
|
+
yield eventscontainer
|
60
|
+
end
|
61
|
+
end
|
77
62
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
63
|
+
def each_index
|
64
|
+
@eventscontainer.each_index do |i|
|
65
|
+
yield i
|
66
|
+
end
|
67
|
+
end
|
83
68
|
|
84
|
-
|
85
|
-
|
86
|
-
|
69
|
+
def empty?
|
70
|
+
@eventscontainer.empty?
|
71
|
+
end
|
87
72
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
73
|
+
def lookup(eventscontainer)
|
74
|
+
lookup_by = nil
|
75
|
+
if events.kind_of?(Megam::EventsContainer)
|
76
|
+
lookup_by = eventscontainer.account_id
|
77
|
+
elsif eventscontainer.kind_of?(String)
|
78
|
+
lookup_by = eventscontainer
|
79
|
+
else
|
80
|
+
raise ArgumentError, "Must pass a Megam::EventsContainer or String to lookup"
|
81
|
+
end
|
82
|
+
res = @eventscontainer_by_name[lookup_by]
|
83
|
+
unless res
|
84
|
+
raise ArgumentError, "Cannot find a node matching #{lookup_by} (did you define it first?)"
|
85
|
+
end
|
86
|
+
@eventscontainer[res]
|
87
|
+
end
|
103
88
|
|
104
|
-
|
105
|
-
|
106
|
-
|
89
|
+
def to_s
|
90
|
+
@eventscontainer.join(", ")
|
91
|
+
end
|
107
92
|
|
108
|
-
|
109
|
-
|
110
|
-
|
93
|
+
def for_json
|
94
|
+
to_a.map { |item| item.to_s }
|
95
|
+
end
|
111
96
|
|
112
|
-
|
113
|
-
|
114
|
-
|
97
|
+
def to_json(*a)
|
98
|
+
Megam::JSONCompat.to_json(for_json, *a)
|
99
|
+
end
|
115
100
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
101
|
+
def self.json_create(o)
|
102
|
+
collection = self.new()
|
103
|
+
o["results"].each do |eventscontainer_list|
|
104
|
+
eventscontainer_array = eventscontainer_list.kind_of?(Array) ? eventscontainer_list : [ eventscontainer_list ]
|
105
|
+
eventscontainer_array.each do |eventscontainer|
|
106
|
+
collection.insert(eventscontainer)
|
122
107
|
|
108
|
+
end
|
109
|
+
end
|
110
|
+
collection
|
123
111
|
end
|
124
|
-
end
|
125
|
-
collection
|
126
|
-
end
|
127
112
|
|
128
|
-
|
113
|
+
private
|
129
114
|
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
115
|
+
def is_megam_eventscontainer(arg)
|
116
|
+
unless arg.kind_of?(Megam::EventsContainer)
|
117
|
+
raise ArgumentError, "Members must be Megam::EventsContainer's"
|
118
|
+
end
|
119
|
+
true
|
120
|
+
end
|
135
121
|
end
|
136
|
-
end
|
137
122
|
end
|