megam_api 0.100 → 1.5.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -69
- data/lib/megam/api.rb +15 -37
- data/lib/megam/api/errors.rb +19 -19
- data/lib/megam/api/version.rb +1 -1
- data/lib/megam/core/account.rb +1 -1
- data/lib/megam/core/assemblies.rb +1 -1
- data/lib/megam/core/assemblies_collection.rb +7 -15
- data/lib/megam/core/assembly.rb +1 -1
- data/lib/megam/core/assembly_collection.rb +7 -15
- data/lib/megam/core/balances.rb +1 -1
- data/lib/megam/core/balances_collection.rb +8 -16
- data/lib/megam/core/billedhistories.rb +1 -1
- data/lib/megam/core/billedhistories_collection.rb +7 -15
- data/lib/megam/core/components.rb +1 -1
- data/lib/megam/core/components_collection.rb +103 -110
- data/lib/megam/core/domain_collection.rb +102 -109
- data/lib/megam/core/domains.rb +1 -1
- data/lib/megam/core/error.rb +1 -15
- data/lib/megam/core/json_compat.rb +170 -208
- data/lib/megam/core/marketplace.rb +1 -1
- data/lib/megam/core/marketplace_collection.rb +7 -16
- data/lib/megam/core/organizations.rb +1 -1
- data/lib/megam/core/organizations_collection.rb +8 -40
- data/lib/megam/core/promos.rb +1 -1
- data/lib/megam/core/request.rb +1 -1
- data/lib/megam/core/request_collection.rb +7 -16
- data/lib/megam/core/rest_adapter.rb +54 -0
- data/lib/megam/core/sensors.rb +1 -1
- data/lib/megam/core/sensors_collection.rb +7 -14
- data/lib/megam/core/sshkey.rb +1 -1
- data/lib/megam/core/sshkey_collection.rb +103 -110
- data/lib/megam/core/stuff.rb +2 -34
- data/lib/megam/core/text.rb +1 -0
- data/lib/megam/core/text_formatter.rb +2 -1
- data/megam_api.gemspec +2 -2
- metadata +10 -56
- data/lib/megam/api/availableunits.rb +0 -50
- data/lib/megam/api/billings.rb +0 -50
- data/lib/megam/api/credithistories.rb +0 -50
- data/lib/megam/api/csars.rb +0 -75
- data/lib/megam/api/discounts.rb +0 -50
- data/lib/megam/api/invoices.rb +0 -50
- data/lib/megam/api/login.rb +0 -29
- data/lib/megam/api/subscriptions.rb +0 -50
- data/lib/megam/core/auth.rb +0 -91
- data/lib/megam/core/availableunits.rb +0 -182
- data/lib/megam/core/availableunits_collection.rb +0 -144
- data/lib/megam/core/billings.rb +0 -242
- data/lib/megam/core/billings_collection.rb +0 -144
- data/lib/megam/core/config.rb +0 -41
- data/lib/megam/core/credithistories.rb +0 -191
- data/lib/megam/core/credithistories_collection.rb +0 -144
- data/lib/megam/core/csar.rb +0 -179
- data/lib/megam/core/csar_collection.rb +0 -148
- data/lib/megam/core/discounts.rb +0 -204
- data/lib/megam/core/discounts_collection.rb +0 -164
- data/lib/megam/core/invoices.rb +0 -231
- data/lib/megam/core/invoices_collection.rb +0 -144
- data/lib/megam/core/server_api.rb +0 -52
- data/lib/megam/core/subscriptions.rb +0 -191
- data/lib/megam/core/subscriptions_collection.rb +0 -144
- data/test/test_availableunits.rb +0 -28
- data/test/test_billings.rb +0 -33
- data/test/test_cat_requests.rb +0 -20
- data/test/test_credithistories.rb +0 -29
- data/test/test_csars.rb +0 -22
- data/test/test_discounts.rb +0 -31
- data/test/test_invoices.rb +0 -31
- data/test/test_login.rb +0 -10
- data/test/test_marketplaceaddons.rb +0 -46
- data/test/test_predefclouds.rb +0 -80
- data/test/test_subscriptions.rb +0 -29
@@ -101,19 +101,16 @@ module Megam
|
|
101
101
|
@billedhistories[res]
|
102
102
|
end
|
103
103
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
index_hash
|
104
|
+
def to_s
|
105
|
+
@billedhistories.join(", ")
|
106
|
+
end
|
107
|
+
|
108
|
+
def for_json
|
109
|
+
to_a.map { |item| item.to_s }
|
111
110
|
end
|
112
111
|
|
113
|
-
# Serialize this object as a hash: called from JsonCompat.
|
114
|
-
# Verify if this called from JsonCompat during testing.
|
115
112
|
def to_json(*a)
|
116
|
-
|
113
|
+
Megam::JSONCompat.to_json(for_json, *a)
|
117
114
|
end
|
118
115
|
|
119
116
|
def self.json_create(o)
|
@@ -135,10 +132,5 @@ module Megam
|
|
135
132
|
end
|
136
133
|
true
|
137
134
|
end
|
138
|
-
|
139
|
-
def to_s
|
140
|
-
Megam::Stuff.styled_hash(to_hash)
|
141
|
-
end
|
142
|
-
|
143
135
|
end
|
144
136
|
end
|
@@ -14,132 +14,125 @@
|
|
14
14
|
# limitations under the License.
|
15
15
|
#
|
16
16
|
module Megam
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
def all_components
|
28
|
-
@components
|
29
|
-
end
|
17
|
+
class ComponentsCollection
|
18
|
+
include Enumerable
|
19
|
+
|
20
|
+
attr_reader :iterator
|
21
|
+
def initialize
|
22
|
+
@components = Array.new
|
23
|
+
@components_by_name = Hash.new
|
24
|
+
@insert_after_idx = nil
|
25
|
+
end
|
30
26
|
|
31
|
-
|
32
|
-
|
33
|
-
|
27
|
+
def all_components
|
28
|
+
@components
|
29
|
+
end
|
34
30
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
@components_by_name[arg.name] = index
|
39
|
-
end
|
31
|
+
def [](index)
|
32
|
+
@components[index]
|
33
|
+
end
|
40
34
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
end
|
47
|
-
self
|
48
|
-
end
|
35
|
+
def []=(index, arg)
|
36
|
+
is_megam_components(arg)
|
37
|
+
@components[index] = arg
|
38
|
+
@components_by_name[arg.name] = index
|
39
|
+
end
|
49
40
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
# be placed after the most recent addition done by the currently executing
|
58
|
-
# node
|
59
|
-
@components.insert(@insert_after_idx + 1, components)
|
60
|
-
# update name -> location mappings and register new node
|
61
|
-
@components_by_name.each_key do |key|
|
62
|
-
@components_by_name[key] += 1 if @components_by_name[key] > @insert_after_idx
|
41
|
+
def <<(*args)
|
42
|
+
args.flatten.each do |a|
|
43
|
+
is_megam_components(a)
|
44
|
+
@components << a
|
45
|
+
@components_by_name[a.name] = @components.length - 1
|
46
|
+
end
|
47
|
+
self
|
63
48
|
end
|
64
|
-
@components_by_name[components.name] = @insert_after_idx + 1
|
65
|
-
@insert_after_idx += 1
|
66
|
-
else
|
67
|
-
@components << components
|
68
|
-
@components_by_name[components.name] = @components.length - 1
|
69
|
-
end
|
70
|
-
end
|
71
49
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
50
|
+
# 'push' is an alias method to <<
|
51
|
+
alias_method :push, :<<
|
52
|
+
|
53
|
+
def insert(components)
|
54
|
+
is_megam_components(components)
|
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
|
+
@components.insert(@insert_after_idx + 1, components)
|
60
|
+
# update name -> location mappings and register new node
|
61
|
+
@components_by_name.each_key do |key|
|
62
|
+
@components_by_name[key] += 1 if @components_by_name[key] > @insert_after_idx
|
63
|
+
end
|
64
|
+
@components_by_name[components.name] = @insert_after_idx + 1
|
65
|
+
@insert_after_idx += 1
|
66
|
+
else
|
67
|
+
@components << components
|
68
|
+
@components_by_name[components.name] = @components.length - 1
|
69
|
+
end
|
70
|
+
end
|
77
71
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
72
|
+
def each
|
73
|
+
@components.each do |components|
|
74
|
+
yield components
|
75
|
+
end
|
76
|
+
end
|
83
77
|
|
84
|
-
|
85
|
-
|
86
|
-
|
78
|
+
def each_index
|
79
|
+
@components.each_index do |i|
|
80
|
+
yield i
|
81
|
+
end
|
82
|
+
end
|
87
83
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
lookup_by = components.name
|
92
|
-
elsif components.kind_of?(String)
|
93
|
-
lookup_by = components
|
94
|
-
else
|
95
|
-
raise ArgumentError, "Must pass a Megam::components or String to lookup"
|
96
|
-
end
|
97
|
-
res = @components_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
|
-
@components[res]
|
102
|
-
end
|
84
|
+
def empty?
|
85
|
+
@components.empty?
|
86
|
+
end
|
103
87
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
88
|
+
def lookup(components)
|
89
|
+
lookup_by = nil
|
90
|
+
if components.kind_of?(Megam::Components)
|
91
|
+
lookup_by = components.name
|
92
|
+
elsif components.kind_of?(String)
|
93
|
+
lookup_by = components
|
94
|
+
else
|
95
|
+
raise ArgumentError, "Must pass a Megam::components or String to lookup"
|
96
|
+
end
|
97
|
+
res = @components_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
|
+
@components[res]
|
102
|
+
end
|
112
103
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
for_json.to_json(*a)
|
117
|
-
end
|
104
|
+
def to_s
|
105
|
+
@components.join(", ")
|
106
|
+
end
|
118
107
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
components_array = components_list.kind_of?(Array) ? components_list : [ components_list ]
|
123
|
-
components_array.each do |components|
|
124
|
-
collection.insert(components)
|
108
|
+
def for_json
|
109
|
+
to_a.map { |item| item.to_s }
|
110
|
+
end
|
125
111
|
|
112
|
+
def to_json(*a)
|
113
|
+
Megam::JSONCompat.to_json(for_json, *a)
|
126
114
|
end
|
127
|
-
end
|
128
|
-
collection
|
129
|
-
end
|
130
115
|
|
131
|
-
private
|
132
116
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
117
|
+
def self.json_create(o)
|
118
|
+
collection = self.new()
|
119
|
+
o["results"].each do |components_list|
|
120
|
+
components_array = components_list.kind_of?(Array) ? components_list : [ components_list ]
|
121
|
+
components_array.each do |components|
|
122
|
+
collection.insert(components)
|
139
123
|
|
140
|
-
|
141
|
-
|
142
|
-
|
124
|
+
end
|
125
|
+
end
|
126
|
+
collection
|
127
|
+
end
|
143
128
|
|
144
|
-
|
129
|
+
private
|
130
|
+
|
131
|
+
def is_megam_components(arg)
|
132
|
+
unless arg.kind_of?(Megam::Components)
|
133
|
+
raise ArgumentError, "Members must be Megam::components"
|
134
|
+
end
|
135
|
+
true
|
136
|
+
end
|
137
|
+
end
|
145
138
|
end
|
@@ -14,131 +14,124 @@
|
|
14
14
|
# limitations under the License.
|
15
15
|
#
|
16
16
|
module Megam
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
17
|
+
class DomainsCollection
|
18
|
+
include Enumerable
|
19
|
+
|
20
|
+
attr_reader :iterator
|
21
|
+
def initialize
|
22
|
+
@domains = Array.new
|
23
|
+
@domains_by_name = Hash.new
|
24
|
+
@insert_after_idx = nil
|
25
|
+
end
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
27
|
+
def all_domains
|
28
|
+
@domains
|
29
|
+
end
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
31
|
+
def [](index)
|
32
|
+
@domains[index]
|
33
|
+
end
|
34
34
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
35
|
+
def []=(index, arg)
|
36
|
+
is_megam_domains(arg)
|
37
|
+
@domains[index] = arg
|
38
|
+
@domains_by_name[arg.name] = index
|
39
|
+
end
|
40
40
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
41
|
+
def <<(*args)
|
42
|
+
args.flatten.each do |a|
|
43
|
+
is_megam_domains(a)
|
44
|
+
@domains << a
|
45
|
+
@domains_by_name[a.name] =@domains.length - 1
|
46
|
+
end
|
47
|
+
self
|
48
|
+
end
|
49
49
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
50
|
+
# 'push' is an alias method to <<
|
51
|
+
alias_method :push, :<<
|
52
|
+
|
53
|
+
def insert(domains)
|
54
|
+
is_megam_domains(domains)
|
55
|
+
if @insert_after_idx
|
56
|
+
# in the middle of executing a run, so any domain inserted now should
|
57
|
+
# be placed after the most recent addition done by the currently executing
|
58
|
+
# domain
|
59
|
+
@domains.insert(@insert_after_idx + 1, domains)
|
60
|
+
# update name -> location mappings and register new sshkeys
|
61
|
+
@domains_by_name.each_key do |key|
|
62
|
+
@domains_by_name[key] += 1 if@domains_by_name[key] > @insert_after_idx
|
63
|
+
end
|
64
|
+
@domains_by_name[domains.name] = @insert_after_idx + 1
|
65
|
+
@insert_after_idx += 1
|
66
|
+
else
|
67
|
+
@domains << domains
|
68
|
+
@domains_by_name[domains.name] =@domains.length - 1
|
69
|
+
end
|
63
70
|
end
|
64
|
-
@domains_by_name[domains.name] = @insert_after_idx + 1
|
65
|
-
@insert_after_idx += 1
|
66
|
-
else
|
67
|
-
@domains << domains
|
68
|
-
@domains_by_name[domains.name] =@domains.length - 1
|
69
|
-
end
|
70
|
-
end
|
71
71
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
72
|
+
def each
|
73
|
+
@domains.each do |domains|
|
74
|
+
yield domains
|
75
|
+
end
|
76
|
+
end
|
77
77
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
78
|
+
def each_index
|
79
|
+
@domains.each_index do |i|
|
80
|
+
yield i
|
81
|
+
end
|
82
|
+
end
|
83
83
|
|
84
|
-
|
85
|
-
|
86
|
-
|
84
|
+
def empty?
|
85
|
+
@domains.empty?
|
86
|
+
end
|
87
87
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
88
|
+
def lookup(domains)
|
89
|
+
lookup_by = nil
|
90
|
+
if domains.kind_of?(Megam::Domains)
|
91
|
+
lookup_by = domains.name
|
92
|
+
elsif domains.kind_of?(String)
|
93
|
+
lookup_by = domains
|
94
|
+
else
|
95
|
+
raise ArgumentError, "Must pass a Megam::Domains or String to lookup"
|
96
|
+
end
|
97
|
+
res =@domains_by_name[lookup_by]
|
98
|
+
unless res
|
99
|
+
raise ArgumentError, "Cannot find a domain matching #{lookup_by} (did you define it first?)"
|
100
|
+
end
|
101
|
+
@domains[res]
|
102
|
+
end
|
103
103
|
|
104
|
-
# Transform the ruby obj -> to a Hash
|
105
|
-
def to_hash
|
106
|
-
index_hash = Hash.new
|
107
|
-
self.each do |domains|
|
108
|
-
index_hash[domains.name] = domains.to_s
|
109
|
-
end
|
110
|
-
index_hash
|
111
|
-
end
|
112
104
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
for_json.to_json(*a)
|
117
|
-
end
|
105
|
+
def to_s
|
106
|
+
@domains.join(", ")
|
107
|
+
end
|
118
108
|
|
119
|
-
|
120
|
-
|
121
|
-
o["results"].each do |domains_list|
|
122
|
-
domains_array = domains_list.kind_of?(Array) ? domains_list : [ domains_list ]
|
123
|
-
domains_array.each do |domains|
|
124
|
-
collection.insert(domains)
|
109
|
+
def for_json
|
110
|
+
to_a.map { |item| item.to_s }
|
125
111
|
end
|
126
|
-
end
|
127
|
-
collection
|
128
|
-
end
|
129
112
|
|
130
|
-
|
113
|
+
def to_json(*a)
|
114
|
+
Megam::JSONCompat.to_json(for_json, *a)
|
115
|
+
end
|
131
116
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
117
|
+
def self.json_create(o)
|
118
|
+
collection = self.new()
|
119
|
+
o["results"].each do |domains_list|
|
120
|
+
domains_array = domains_list.kind_of?(Array) ? domains_list : [ domains_list ]
|
121
|
+
domains_array.each do |domains|
|
122
|
+
collection.insert(domains)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
collection
|
126
|
+
end
|
138
127
|
|
139
|
-
|
140
|
-
Megam::Stuff.styled_hash(to_hash)
|
141
|
-
end
|
128
|
+
private
|
142
129
|
|
143
|
-
|
130
|
+
def is_megam_domains(arg)
|
131
|
+
unless arg.kind_of?(Megam::Domains)
|
132
|
+
raise ArgumentError, "Members must be Megam::Domains's"
|
133
|
+
end
|
134
|
+
true
|
135
|
+
end
|
136
|
+
end
|
144
137
|
end
|