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,18 +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
1
|
module Megam
|
17
2
|
class ComponentsCollection
|
18
3
|
include Enumerable
|
@@ -1,18 +1,3 @@
|
|
1
|
-
# Copyright:: Copyright (c) 2012, 2014 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
2
|
class DomainsCollection
|
18
3
|
include Enumerable
|
@@ -103,7 +88,7 @@ module Megam
|
|
103
88
|
|
104
89
|
|
105
90
|
def to_s
|
106
|
-
|
91
|
+
@domains.join(", ")
|
107
92
|
end
|
108
93
|
|
109
94
|
def for_json
|
data/lib/megam/core/domains.rb
CHANGED
@@ -1,134 +1,118 @@
|
|
1
|
-
# Copyright:: Copyright (c) 2013-2016 Megam Systems, Inc.
|
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
|
-
|
2
|
+
class Domains < Megam::RestAdapter
|
3
|
+
def initialize(o)
|
4
|
+
@id = nil
|
5
|
+
@org_id = nil
|
6
|
+
@name = nil
|
7
|
+
@created_at = nil
|
8
|
+
super(o)
|
9
|
+
end
|
10
|
+
|
11
|
+
def domain
|
12
|
+
self
|
13
|
+
end
|
14
|
+
|
15
|
+
def id(arg=nil)
|
16
|
+
if arg != nil
|
17
|
+
@id = arg
|
18
|
+
else
|
19
|
+
@id
|
20
|
+
end
|
21
|
+
end
|
22
|
+
def org_id(arg=nil)
|
23
|
+
if arg != nil
|
24
|
+
@org_id = arg
|
25
|
+
else
|
26
|
+
@org_id
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
def name(arg=nil)
|
32
|
+
if arg != nil
|
33
|
+
@name = arg
|
34
|
+
else
|
35
|
+
@name
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def created_at(arg=nil)
|
40
|
+
if arg != nil
|
41
|
+
@created_at = arg
|
42
|
+
else
|
43
|
+
@created_at
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def to_hash
|
48
|
+
index_hash = Hash.new
|
49
|
+
index_hash["json_claz"] = self.class.name
|
50
|
+
index_hash["id"] = id
|
51
|
+
index_hash["org_id"] = org_id
|
52
|
+
index_hash["name"] = name
|
53
|
+
index_hash["created_at"] = created_at
|
54
|
+
index_hash
|
55
|
+
end
|
56
|
+
|
57
|
+
def to_json(*a)
|
58
|
+
for_json.to_json(*a)
|
59
|
+
end
|
60
|
+
|
61
|
+
def for_json
|
62
|
+
result = {
|
63
|
+
"id" => id,
|
64
|
+
"org_id" => org_id,
|
65
|
+
"name" => name,
|
66
|
+
"created_at" => created_at
|
67
|
+
}
|
68
|
+
result
|
69
|
+
end
|
70
|
+
|
71
|
+
# Create a Megam::Domains from JSON (used by the backgroud job workers)
|
72
|
+
def self.json_create(o)
|
73
|
+
dmn = new({})
|
74
|
+
dmn.id(o["id"]) if o.has_key?("id")
|
75
|
+
dmn.org_id(o["org_id"]) if o.has_key?("org_id")
|
76
|
+
dmn.name(o["name"]) if o.has_key?("name")
|
77
|
+
dmn.created_at(o["created_at"]) if o.has_key?("created_at")
|
78
|
+
dmn
|
79
|
+
end
|
80
|
+
|
81
|
+
def self.from_hash(o)
|
82
|
+
org = self.new(o)
|
83
|
+
org.from_hash(o)
|
84
|
+
org
|
85
|
+
end
|
86
|
+
|
87
|
+
|
88
|
+
def from_hash(o)
|
89
|
+
@id = o[:id] if o.has_key?(:id)
|
90
|
+
@org_id = o[:org_id] if o.has_key?(:org_id)
|
91
|
+
@name = o[:name] if o.has_key?(:name)
|
92
|
+
@created_at = o[:created_at] if o.has_key?(:created_at)
|
93
|
+
self
|
94
|
+
end
|
95
|
+
|
96
|
+
def self.create(o)
|
97
|
+
dom = from_hash(o)
|
98
|
+
dom.create
|
99
|
+
end
|
100
|
+
|
101
|
+
def self.list(o)
|
102
|
+
dom = from_hash(o)
|
103
|
+
dom.megam_rest.get_domains
|
104
|
+
end
|
105
|
+
|
106
|
+
def create
|
107
|
+
megam_rest.post_domains(to_hash)
|
108
|
+
end
|
109
|
+
|
110
|
+
def show
|
111
|
+
megam_rest.get_domains(to_hash)
|
112
|
+
end
|
113
|
+
|
114
|
+
def to_s
|
115
|
+
Megam::Stuff.styled_hash(to_hash)
|
116
|
+
end
|
24
117
|
end
|
25
|
-
|
26
|
-
def domain
|
27
|
-
self
|
28
|
-
end
|
29
|
-
|
30
|
-
def id(arg=nil)
|
31
|
-
if arg != nil
|
32
|
-
@id = arg
|
33
|
-
else
|
34
|
-
@id
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def org_id(arg=nil)
|
39
|
-
if arg != nil
|
40
|
-
@org_id = arg
|
41
|
-
else
|
42
|
-
@org_id
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
|
47
|
-
def name(arg=nil)
|
48
|
-
if arg != nil
|
49
|
-
@name = arg
|
50
|
-
else
|
51
|
-
@name
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
def created_at(arg=nil)
|
56
|
-
if arg != nil
|
57
|
-
@created_at = arg
|
58
|
-
else
|
59
|
-
@created_at
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def to_hash
|
64
|
-
index_hash = Hash.new
|
65
|
-
index_hash["json_claz"] = self.class.name
|
66
|
-
index_hash["id"] = id
|
67
|
-
index_hash["org_id"] = org_id
|
68
|
-
index_hash["name"] = name
|
69
|
-
index_hash["created_at"] = created_at
|
70
|
-
index_hash
|
71
|
-
end
|
72
|
-
|
73
|
-
def to_json(*a)
|
74
|
-
for_json.to_json(*a)
|
75
|
-
end
|
76
|
-
|
77
|
-
def for_json
|
78
|
-
result = {
|
79
|
-
"id" => id,
|
80
|
-
"org_id" => org_id,
|
81
|
-
"name" => name,
|
82
|
-
"created_at" => created_at
|
83
|
-
}
|
84
|
-
result
|
85
|
-
end
|
86
|
-
|
87
|
-
# Create a Megam::Domains from JSON (used by the backgroud job workers)
|
88
|
-
def self.json_create(o)
|
89
|
-
dmn = new({})
|
90
|
-
dmn.id(o["id"]) if o.has_key?("id")
|
91
|
-
dmn.org_id(o["org_id"]) if o.has_key?("org_id")
|
92
|
-
dmn.name(o["name"]) if o.has_key?("name")
|
93
|
-
dmn.created_at(o["created_at"]) if o.has_key?("created_at")
|
94
|
-
dmn
|
95
|
-
end
|
96
|
-
|
97
|
-
def self.from_hash(o)
|
98
|
-
org = self.new(o)
|
99
|
-
org.from_hash(o)
|
100
|
-
org
|
101
|
-
end
|
102
|
-
|
103
|
-
|
104
|
-
def from_hash(o)
|
105
|
-
@id = o[:id] if o.has_key?(:id)
|
106
|
-
@org_id = o[:org_id] if o.has_key?(:org_id)
|
107
|
-
@name = o[:name] if o.has_key?(:name)
|
108
|
-
@created_at = o[:created_at] if o.has_key?(:created_at)
|
109
|
-
self
|
110
|
-
end
|
111
|
-
|
112
|
-
def self.create(o)
|
113
|
-
dom = from_hash(o)
|
114
|
-
dom.create
|
115
|
-
end
|
116
|
-
|
117
|
-
def self.list(o)
|
118
|
-
dom = from_hash(o)
|
119
|
-
dom.megam_rest.get_domains
|
120
|
-
end
|
121
|
-
|
122
|
-
def create
|
123
|
-
megam_rest.post_domains(to_hash)
|
124
|
-
end
|
125
|
-
|
126
|
-
def show
|
127
|
-
megam_rest.get_domains(to_hash)
|
128
|
-
end
|
129
|
-
|
130
|
-
def to_s
|
131
|
-
Megam::Stuff.styled_hash(to_hash)
|
132
|
-
end
|
133
|
-
end
|
134
118
|
end
|
data/lib/megam/core/error.rb
CHANGED
@@ -1,85 +1,70 @@
|
|
1
|
-
# Copyright:: Copyright (c) 2013-2016 Megam Systems, Inc.
|
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
|
-
|
2
|
+
class Error
|
18
3
|
|
19
|
-
|
20
|
-
|
21
|
-
|
4
|
+
def initialize
|
5
|
+
@some_msg = {}
|
6
|
+
end
|
22
7
|
|
23
8
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
9
|
+
def some_msg(arg=nil)
|
10
|
+
if arg != nil
|
11
|
+
@some_msg = arg
|
12
|
+
else
|
13
|
+
@some_msg
|
14
|
+
end
|
15
|
+
end
|
31
16
|
|
32
|
-
|
33
|
-
|
34
|
-
|
17
|
+
def error?
|
18
|
+
crocked = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error")
|
19
|
+
end
|
35
20
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
21
|
+
# Transform the ruby obj -> to a Hash
|
22
|
+
def to_hash
|
23
|
+
index_hash = Hash.new
|
24
|
+
index_hash["json_claz"] = self.class.name
|
25
|
+
index_hash["some_msg"] = some_msg
|
26
|
+
index_hash
|
27
|
+
end
|
43
28
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
29
|
+
# Serialize this object as a hash: called from JsonCompat.
|
30
|
+
# Verify if this called from JsonCompat during testing.
|
31
|
+
def to_json(*a)
|
32
|
+
for_json.to_json(*a)
|
33
|
+
end
|
49
34
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
35
|
+
def for_json
|
36
|
+
result = { }
|
37
|
+
result
|
38
|
+
end
|
54
39
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
40
|
+
# Create a Megam::Account from JSON (used by the backgroud job workers)
|
41
|
+
def self.json_create(o)
|
42
|
+
acct = new
|
43
|
+
acct.some_msg[:code] = o["code"] if o.has_key?("code")
|
44
|
+
acct.some_msg[:msg_type] = o["msg_type"] if o.has_key?("msg_type")
|
45
|
+
acct.some_msg[:msg]= o["msg"] if o.has_key?("msg")
|
46
|
+
acct.some_msg[:links] = o["links"] if o.has_key?("links")
|
47
|
+
acct
|
48
|
+
end
|
64
49
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
50
|
+
def self.from_hash(o)
|
51
|
+
acct = self.new()
|
52
|
+
acct.from_hash(o)
|
53
|
+
acct
|
54
|
+
end
|
70
55
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
56
|
+
def from_hash(o)
|
57
|
+
@some_msg[:code] = o["code"] if o.has_key?("code")
|
58
|
+
@some_msg[:msg_type] = o["msg_type"] if o.has_key?("msg_type")
|
59
|
+
@some_msg[:msg]= o["msg"] if o.has_key?("msg")
|
60
|
+
@some_msg[:links] = o["links"] if o.has_key?("links")
|
61
|
+
self
|
62
|
+
end
|
78
63
|
|
79
64
|
|
80
|
-
|
81
|
-
|
82
|
-
|
65
|
+
def to_s
|
66
|
+
Megam::Stuff.styled_hash(to_hash)
|
67
|
+
#"---> Megam::Account:[error=#{error?}]\n"+
|
68
|
+
end
|
83
69
|
end
|
84
|
-
end
|
85
70
|
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 EventsBilling < Megam::RestAdapter
|
19
3
|
def initialize(o)
|