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.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -2
  3. data/LICENSE +21 -202
  4. data/README.md +3 -20
  5. data/lib/megam/api.rb +154 -169
  6. data/lib/megam/api/accounts.rb +0 -15
  7. data/lib/megam/api/assemblies.rb +0 -15
  8. data/lib/megam/api/assembly.rb +0 -15
  9. data/lib/megam/api/balances.rb +0 -15
  10. data/lib/megam/api/billedhistories.rb +0 -15
  11. data/lib/megam/api/billingtransactions.rb +0 -15
  12. data/lib/megam/api/components.rb +0 -15
  13. data/lib/megam/api/domains.rb +0 -15
  14. data/lib/megam/api/errors.rb +0 -15
  15. data/lib/megam/api/eventsbilling.rb +0 -15
  16. data/lib/megam/api/eventscontainer.rb +0 -15
  17. data/lib/megam/api/eventsstorage.rb +0 -15
  18. data/lib/megam/api/eventsvm.rb +0 -15
  19. data/lib/megam/api/marketplaces.rb +0 -15
  20. data/lib/megam/api/organizations.rb +0 -15
  21. data/lib/megam/api/promos.rb +0 -15
  22. data/lib/megam/api/requests.rb +0 -15
  23. data/lib/megam/api/sensors.rb +0 -15
  24. data/lib/megam/api/snapshots.rb +0 -15
  25. data/lib/megam/api/sshkeys.rb +0 -15
  26. data/lib/megam/api/version.rb +1 -16
  27. data/lib/megam/core/account.rb +241 -60
  28. data/lib/megam/core/assemblies.rb +0 -16
  29. data/lib/megam/core/assemblies_collection.rb +101 -116
  30. data/lib/megam/core/assembly.rb +201 -218
  31. data/lib/megam/core/assembly_collection.rb +101 -116
  32. data/lib/megam/core/balances.rb +182 -197
  33. data/lib/megam/core/balances_collection.rb +101 -116
  34. data/lib/megam/core/billedhistories.rb +186 -201
  35. data/lib/megam/core/billedhistories_collection.rb +101 -116
  36. data/lib/megam/core/billingtransactions.rb +0 -15
  37. data/lib/megam/core/billingtransactions_collection.rb +0 -15
  38. data/lib/megam/core/components.rb +300 -316
  39. data/lib/megam/core/components_collection.rb +0 -15
  40. data/lib/megam/core/domain_collection.rb +1 -16
  41. data/lib/megam/core/domains.rb +115 -131
  42. data/lib/megam/core/error.rb +55 -70
  43. data/lib/megam/core/eventsbilling.rb +0 -16
  44. data/lib/megam/core/eventsbilling_collection.rb +101 -116
  45. data/lib/megam/core/eventscontainer.rb +0 -16
  46. data/lib/megam/core/eventscontainer_collection.rb +101 -116
  47. data/lib/megam/core/eventsstorage.rb +0 -16
  48. data/lib/megam/core/eventsstorage_collection.rb +0 -15
  49. data/lib/megam/core/eventsvm.rb +0 -16
  50. data/lib/megam/core/eventsvm_collection.rb +101 -116
  51. data/lib/megam/core/json_compat.rb +0 -12
  52. data/lib/megam/core/konipai.rb +0 -15
  53. data/lib/megam/core/log.rb +0 -15
  54. data/lib/megam/core/marketplace.rb +224 -241
  55. data/lib/megam/core/marketplace_collection.rb +0 -15
  56. data/lib/megam/core/organizations.rb +0 -16
  57. data/lib/megam/core/organizations_collection.rb +0 -15
  58. data/lib/megam/core/promos.rb +0 -15
  59. data/lib/megam/core/request.rb +0 -15
  60. data/lib/megam/core/request_collection.rb +0 -15
  61. data/lib/megam/core/rest_adapter.rb +0 -15
  62. data/lib/megam/core/sensors.rb +138 -154
  63. data/lib/megam/core/sensors_collection.rb +0 -15
  64. data/lib/megam/core/snapshots.rb +0 -16
  65. data/lib/megam/core/snapshots_collection.rb +0 -15
  66. data/lib/megam/core/sshkey.rb +169 -184
  67. data/lib/megam/core/sshkey_collection.rb +0 -15
  68. data/lib/megam/core/stuff.rb +17 -32
  69. data/lib/megam/core/text.rb +82 -97
  70. data/lib/megam/mixins/assemblies.rb +10 -25
  71. data/lib/megam/mixins/assembly.rb +33 -49
  72. data/lib/megam/mixins/common_deployable.rb +64 -79
  73. data/lib/megam/mixins/components.rb +160 -175
  74. data/lib/megam/mixins/megam_attributes.rb +22 -37
  75. data/lib/megam/mixins/outputs.rb +14 -29
  76. data/lib/megam/mixins/policies.rb +21 -36
  77. data/lib/megam_api.rb +0 -15
  78. data/test/mixins/test_assemblies.rb +1 -2
  79. data/test/test_accounts.rb +84 -29
  80. data/test/test_billingtranscations.rb +17 -21
  81. data/test/test_eventscontainer.rb +19 -23
  82. data/test/test_eventsstorage.rb +8 -10
  83. data/test/test_eventsvm.rb +19 -23
  84. data/test/test_helper.rb +30 -30
  85. data/test/test_snapshots.rb +16 -22
  86. 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
- class EventsBillingCollection
18
- include Enumerable
19
-
20
- attr_reader :iterator
21
- def initialize
22
- @eventsbilling = Array.new
23
- @eventsbilling_by_name = Hash.new
24
- @insert_after_idx = nil
25
- end
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
- def all_eventsbilling
28
- @eventsbilling
29
- end
12
+ def all_eventsbilling
13
+ @eventsbilling
14
+ end
30
15
 
31
- def [](index)
32
- @eventsbilling[index]
33
- end
16
+ def [](index)
17
+ @eventsbilling[index]
18
+ end
34
19
 
35
- def []=(index, arg)
36
- is_megam_eventsbilling(arg)
37
- @eventsbilling[index] = arg
38
- @eventsbilling_by_name[arg.account_id] = index
39
- end
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
- def <<(*args)
42
- args.flatten.each do |a|
43
- is_megam_events(a)
44
- @eventsbilling << a
45
- @eventsbilling_by_name[a.account_id] = @eventsbilling.length - 1
46
- end
47
- self
48
- end
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
- # 'push' is an alias method to <<
51
- alias_method :push, :<<
52
-
53
- def insert(eventsbilling)
54
- is_megam_eventsbilling(eventsbilling)
55
- if @insert_after_idx
56
- # in the middle of executing a run, so any nodes inserted now should
57
- # be placed after the most recent addition done by the currently executing
58
- # node
59
- @eventsbilling.insert(@insert_after_idx + 1, eventsbilling)
60
- # update name -> location mappings and register new node
61
- @eventsbilling_by_name.each_key do |key|
62
- @eventsbilling_by_name[key] += 1 if @eventsbilling_by_name[key] > @insert_after_idx
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
- def each
73
- @eventsbilling.each do |eventsbilling|
74
- yield eventsbilling
75
- end
76
- end
57
+ def each
58
+ @eventsbilling.each do |eventsbilling|
59
+ yield eventsbilling
60
+ end
61
+ end
77
62
 
78
- def each_index
79
- @eventsbilling.each_index do |i|
80
- yield i
81
- end
82
- end
63
+ def each_index
64
+ @eventsbilling.each_index do |i|
65
+ yield i
66
+ end
67
+ end
83
68
 
84
- def empty?
85
- @eventsbilling.empty?
86
- end
69
+ def empty?
70
+ @eventsbilling.empty?
71
+ end
87
72
 
88
- def lookup(eventsbilling)
89
- lookup_by = nil
90
- if events.kind_of?(Megam::EventsBilling)
91
- lookup_by = eventsbilling.account_id
92
- elsif events.kind_of?(String)
93
- lookup_by = eventsbilling
94
- else
95
- raise ArgumentError, "Must pass a Megam::EventsBilling or String to lookup"
96
- end
97
- res = @eventsbilling_by_name[lookup_by]
98
- unless res
99
- raise ArgumentError, "Cannot find a node matching #{lookup_by} (did you define it first?)"
100
- end
101
- @eventsbilling[res]
102
- end
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
- def to_s
105
- @eventsbilling.join(", ")
106
- end
89
+ def to_s
90
+ @eventsbilling.join(", ")
91
+ end
107
92
 
108
- def for_json
109
- to_a.map { |item| item.to_s }
110
- end
93
+ def for_json
94
+ to_a.map { |item| item.to_s }
95
+ end
111
96
 
112
- def to_json(*a)
113
- Megam::JSONCompat.to_json(for_json, *a)
114
- end
97
+ def to_json(*a)
98
+ Megam::JSONCompat.to_json(for_json, *a)
99
+ end
115
100
 
116
- def self.json_create(o)
117
- collection = self.new()
118
- o["results"].each do |eventsbilling_list|
119
- eventsbilling_array = eventsbilling_list.kind_of?(Array) ? eventsbilling_list : [ eventsbilling_list ]
120
- eventsbilling_array.each do |eventsbilling|
121
- collection.insert(eventsbilling)
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
- private
113
+ private
129
114
 
130
- def is_megam_eventsbilling(arg)
131
- unless arg.kind_of?(Megam::EventsBilling)
132
- raise ArgumentError, "Members must be Megam::EventsBilling's"
133
- end
134
- true
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
- class EventsContainerCollection
18
- include Enumerable
19
-
20
- attr_reader :iterator
21
- def initialize
22
- @eventscontainer = Array.new
23
- @eventscontainer_by_name = Hash.new
24
- @insert_after_idx = nil
25
- end
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
- def all_eventscontainer
28
- @eventscontainer
29
- end
12
+ def all_eventscontainer
13
+ @eventscontainer
14
+ end
30
15
 
31
- def [](index)
32
- @eventscontainer[index]
33
- end
16
+ def [](index)
17
+ @eventscontainer[index]
18
+ end
34
19
 
35
- def []=(index, arg)
36
- is_megam_eventsvm(arg)
37
- @eventscontainer[index] = arg
38
- @eventscontainer_by_name[arg.account_id] = index
39
- end
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
- def <<(*args)
42
- args.flatten.each do |a|
43
- is_megam_events(a)
44
- @eventscontainer << a
45
- @eventscontainer_by_name[a.account_id] = @eventscontainer.length - 1
46
- end
47
- self
48
- end
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
- # 'push' is an alias method to <<
51
- alias_method :push, :<<
52
-
53
- def insert(eventscontainer)
54
- is_megam_eventscontainer(eventscontainer)
55
- if @insert_after_idx
56
- # in the middle of executing a run, so any nodes inserted now should
57
- # be placed after the most recent addition done by the currently executing
58
- # node
59
- @eventscontainer.insert(@insert_after_idx + 1, eventscontainer)
60
- # update name -> location mappings and register new node
61
- @eventscontainer_by_name.each_key do |key|
62
- @eventscontainer_by_name[key] += 1 if @eventscontainer_by_name[key] > @insert_after_idx
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
- def each
73
- @eventscontainer.each do |eventscontainer|
74
- yield eventscontainer
75
- end
76
- end
57
+ def each
58
+ @eventscontainer.each do |eventscontainer|
59
+ yield eventscontainer
60
+ end
61
+ end
77
62
 
78
- def each_index
79
- @eventscontainer.each_index do |i|
80
- yield i
81
- end
82
- end
63
+ def each_index
64
+ @eventscontainer.each_index do |i|
65
+ yield i
66
+ end
67
+ end
83
68
 
84
- def empty?
85
- @eventscontainer.empty?
86
- end
69
+ def empty?
70
+ @eventscontainer.empty?
71
+ end
87
72
 
88
- def lookup(eventscontainer)
89
- lookup_by = nil
90
- if events.kind_of?(Megam::EventsContainer)
91
- lookup_by = eventscontainer.account_id
92
- elsif eventscontainer.kind_of?(String)
93
- lookup_by = eventscontainer
94
- else
95
- raise ArgumentError, "Must pass a Megam::EventsContainer or String to lookup"
96
- end
97
- res = @eventscontainer_by_name[lookup_by]
98
- unless res
99
- raise ArgumentError, "Cannot find a node matching #{lookup_by} (did you define it first?)"
100
- end
101
- @eventscontainer[res]
102
- end
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
- def to_s
105
- @eventscontainer.join(", ")
106
- end
89
+ def to_s
90
+ @eventscontainer.join(", ")
91
+ end
107
92
 
108
- def for_json
109
- to_a.map { |item| item.to_s }
110
- end
93
+ def for_json
94
+ to_a.map { |item| item.to_s }
95
+ end
111
96
 
112
- def to_json(*a)
113
- Megam::JSONCompat.to_json(for_json, *a)
114
- end
97
+ def to_json(*a)
98
+ Megam::JSONCompat.to_json(for_json, *a)
99
+ end
115
100
 
116
- def self.json_create(o)
117
- collection = self.new()
118
- o["results"].each do |eventscontainer_list|
119
- eventscontainer_array = eventscontainer_list.kind_of?(Array) ? eventscontainer_list : [ eventscontainer_list ]
120
- eventscontainer_array.each do |eventscontainer|
121
- collection.insert(eventscontainer)
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
- private
113
+ private
129
114
 
130
- def is_megam_eventscontainer(arg)
131
- unless arg.kind_of?(Megam::EventsContainer)
132
- raise ArgumentError, "Members must be Megam::EventsContainer's"
133
- end
134
- true
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