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
data/lib/megam/core/snapshots.rb
CHANGED
@@ -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 Snapshots < Megam::RestAdapter
|
19
3
|
def initialize(o)
|
@@ -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 SnapshotsCollection
|
18
3
|
include Enumerable
|
data/lib/megam/core/sshkey.rb
CHANGED
@@ -1,188 +1,173 @@
|
|
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
|
-
|
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
|
-
|
2
|
+
class SshKey < Megam::RestAdapter
|
3
|
+
def initialize(o)
|
4
|
+
@id = nil
|
5
|
+
@name = nil
|
6
|
+
@org_id = nil
|
7
|
+
@privatekey=nil
|
8
|
+
@publickey=nil
|
9
|
+
@created_at = nil
|
10
|
+
@some_msg = {}
|
11
|
+
super(o)
|
12
|
+
end
|
13
|
+
|
14
|
+
def sshkey
|
15
|
+
self
|
16
|
+
end
|
17
|
+
|
18
|
+
def id(arg=nil)
|
19
|
+
if arg != nil
|
20
|
+
@id = arg
|
21
|
+
else
|
22
|
+
@id
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def name(arg=nil)
|
27
|
+
if arg != nil
|
28
|
+
@name = arg
|
29
|
+
else
|
30
|
+
@name
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def org_id(arg=nil)
|
35
|
+
if arg != nil
|
36
|
+
@org_id= arg
|
37
|
+
else
|
38
|
+
@org_id
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def privatekey(arg=nil)
|
43
|
+
if arg != nil
|
44
|
+
@privatekey = arg
|
45
|
+
else
|
46
|
+
@privatekey
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def publickey(arg=nil)
|
51
|
+
if arg != nil
|
52
|
+
@publickey = arg
|
53
|
+
else
|
54
|
+
@publickey
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
def created_at(arg=nil)
|
60
|
+
if arg != nil
|
61
|
+
@created_at = arg
|
62
|
+
else
|
63
|
+
@created_at
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def some_msg(arg=nil)
|
68
|
+
if arg != nil
|
69
|
+
@some_msg = arg
|
70
|
+
else
|
71
|
+
@some_msg
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def error?
|
76
|
+
crocked = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error")
|
77
|
+
end
|
78
|
+
|
79
|
+
# Transform the ruby obj -> to a Hash
|
80
|
+
def to_hash
|
81
|
+
index_hash = Hash.new
|
82
|
+
index_hash["json_claz"] = self.class.name
|
83
|
+
index_hash["id"] = id
|
84
|
+
index_hash["name"] = name
|
85
|
+
index_hash["org_id"] = org_id
|
86
|
+
index_hash["privatekey"] = privatekey
|
87
|
+
index_hash["publickey"] = publickey
|
88
|
+
index_hash["created_at"] = created_at
|
89
|
+
index_hash
|
90
|
+
end
|
91
|
+
|
92
|
+
# Serialize this object as a hash: called from JsonCompat.
|
93
|
+
# Verify if this called from JsonCompat during testing.
|
94
|
+
def to_json(*a)
|
95
|
+
for_json.to_json(*a)
|
96
|
+
end
|
97
|
+
|
98
|
+
def for_json
|
99
|
+
result = {
|
100
|
+
"id" => id,
|
101
|
+
"name" => name,
|
102
|
+
"org_id" => org_id,
|
103
|
+
"privatekey" => privatekey,
|
104
|
+
"publickey" => publickey,
|
105
|
+
"created_at" => created_at
|
106
|
+
}
|
107
|
+
result
|
108
|
+
end
|
109
|
+
|
110
|
+
#
|
111
|
+
def self.json_create(o)
|
112
|
+
sshKey = new({})
|
113
|
+
sshKey.id(o["id"]) if o.has_key?("id")
|
114
|
+
sshKey.name(o["name"]) if o.has_key?("name")
|
115
|
+
sshKey.privatekey(o["privatekey"]) if o.has_key?("privatekey")
|
116
|
+
sshKey.publickey(o["publickey"]) if o.has_key?("publickey")
|
117
|
+
sshKey.created_at(o["created_at"]) if o.has_key?("created_at")
|
118
|
+
#success or error
|
119
|
+
sshKey.some_msg[:code] = o["code"] if o.has_key?("code")
|
120
|
+
sshKey.some_msg[:msg_type] = o["msg_type"] if o.has_key?("msg_type")
|
121
|
+
sshKey.some_msg[:msg]= o["msg"] if o.has_key?("msg")
|
122
|
+
sshKey.some_msg[:links] = o["links"] if o.has_key?("links")
|
123
|
+
sshKey
|
124
|
+
end
|
125
|
+
|
126
|
+
def self.from_hash(o)
|
127
|
+
sshKey = self.new(o)
|
128
|
+
sshKey.from_hash(o)
|
129
|
+
sshKey
|
130
|
+
end
|
131
|
+
|
132
|
+
def from_hash(o)
|
133
|
+
@id = o[:id] if o.has_key?(:id)
|
134
|
+
@name = o[:name] if o.has_key?(:name)
|
135
|
+
@org_id = o[:org_id] if o.has_key?(:org_id)
|
136
|
+
@privatekey = o[:privatekey] if o.has_key?(:privatekey)
|
137
|
+
@publickey = o[:publickey] if o.has_key?(:publickey)
|
138
|
+
@created_at = o[:created_at] if o.has_key?(:created_at)
|
139
|
+
self
|
140
|
+
end
|
141
|
+
|
142
|
+
def self.create(params)
|
143
|
+
acct = from_hash(params)
|
144
|
+
acct.create
|
145
|
+
end
|
146
|
+
|
147
|
+
# Create the predef via the REST API
|
148
|
+
def create
|
149
|
+
megam_rest.post_sshkey(to_hash)
|
150
|
+
end
|
151
|
+
|
152
|
+
# Load all sshkeys -
|
153
|
+
# returns a sshkeysCollection
|
154
|
+
# don't return self. check if the Megam::SshKeyCollection is returned.
|
155
|
+
def self.list(params)
|
156
|
+
sshKey = self.new(params)
|
157
|
+
sshKey.megam_rest.get_sshkeys
|
158
|
+
end
|
159
|
+
|
160
|
+
# Show a particular sshKey by name,
|
161
|
+
# Megam::SshKey
|
162
|
+
def self.show(params)
|
163
|
+
pre = self.new(params)
|
164
|
+
pre.megam_rest.get_sshkey(params["name"])
|
165
|
+
end
|
166
|
+
|
167
|
+
def to_s
|
168
|
+
Megam::Stuff.styled_hash(to_hash)
|
169
|
+
#"---> Megam::Account:[error=#{error?}]\n"+
|
170
|
+
end
|
64
171
|
|
65
|
-
def publickey(arg=nil)
|
66
|
-
if arg != nil
|
67
|
-
@publickey = arg
|
68
|
-
else
|
69
|
-
@publickey
|
70
|
-
end
|
71
172
|
end
|
72
|
-
|
73
|
-
|
74
|
-
def created_at(arg=nil)
|
75
|
-
if arg != nil
|
76
|
-
@created_at = arg
|
77
|
-
else
|
78
|
-
@created_at
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
def some_msg(arg=nil)
|
83
|
-
if arg != nil
|
84
|
-
@some_msg = arg
|
85
|
-
else
|
86
|
-
@some_msg
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
def error?
|
91
|
-
crocked = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error")
|
92
|
-
end
|
93
|
-
|
94
|
-
# Transform the ruby obj -> to a Hash
|
95
|
-
def to_hash
|
96
|
-
index_hash = Hash.new
|
97
|
-
index_hash["json_claz"] = self.class.name
|
98
|
-
index_hash["id"] = id
|
99
|
-
index_hash["name"] = name
|
100
|
-
index_hash["org_id"] = org_id
|
101
|
-
index_hash["privatekey"] = privatekey
|
102
|
-
index_hash["publickey"] = publickey
|
103
|
-
index_hash["created_at"] = created_at
|
104
|
-
index_hash
|
105
|
-
end
|
106
|
-
|
107
|
-
# Serialize this object as a hash: called from JsonCompat.
|
108
|
-
# Verify if this called from JsonCompat during testing.
|
109
|
-
def to_json(*a)
|
110
|
-
for_json.to_json(*a)
|
111
|
-
end
|
112
|
-
|
113
|
-
def for_json
|
114
|
-
result = {
|
115
|
-
"id" => id,
|
116
|
-
"name" => name,
|
117
|
-
"org_id" => org_id,
|
118
|
-
"privatekey" => privatekey,
|
119
|
-
"publickey" => publickey,
|
120
|
-
"created_at" => created_at
|
121
|
-
}
|
122
|
-
result
|
123
|
-
end
|
124
|
-
|
125
|
-
#
|
126
|
-
def self.json_create(o)
|
127
|
-
sshKey = new({})
|
128
|
-
sshKey.id(o["id"]) if o.has_key?("id")
|
129
|
-
sshKey.name(o["name"]) if o.has_key?("name")
|
130
|
-
sshKey.privatekey(o["privatekey"]) if o.has_key?("privatekey")
|
131
|
-
sshKey.publickey(o["publickey"]) if o.has_key?("publickey")
|
132
|
-
sshKey.created_at(o["created_at"]) if o.has_key?("created_at")
|
133
|
-
#success or error
|
134
|
-
sshKey.some_msg[:code] = o["code"] if o.has_key?("code")
|
135
|
-
sshKey.some_msg[:msg_type] = o["msg_type"] if o.has_key?("msg_type")
|
136
|
-
sshKey.some_msg[:msg]= o["msg"] if o.has_key?("msg")
|
137
|
-
sshKey.some_msg[:links] = o["links"] if o.has_key?("links")
|
138
|
-
sshKey
|
139
|
-
end
|
140
|
-
|
141
|
-
def self.from_hash(o)
|
142
|
-
sshKey = self.new(o)
|
143
|
-
sshKey.from_hash(o)
|
144
|
-
sshKey
|
145
|
-
end
|
146
|
-
|
147
|
-
def from_hash(o)
|
148
|
-
@id = o[:id] if o.has_key?(:id)
|
149
|
-
@name = o[:name] if o.has_key?(:name)
|
150
|
-
@org_id = o[:org_id] if o.has_key?(:org_id)
|
151
|
-
@privatekey = o[:privatekey] if o.has_key?(:privatekey)
|
152
|
-
@publickey = o[:publickey] if o.has_key?(:publickey)
|
153
|
-
@created_at = o[:created_at] if o.has_key?(:created_at)
|
154
|
-
self
|
155
|
-
end
|
156
|
-
|
157
|
-
def self.create(params)
|
158
|
-
acct = from_hash(params)
|
159
|
-
acct.create
|
160
|
-
end
|
161
|
-
|
162
|
-
# Create the predef via the REST API
|
163
|
-
def create
|
164
|
-
megam_rest.post_sshkey(to_hash)
|
165
|
-
end
|
166
|
-
|
167
|
-
# Load all sshkeys -
|
168
|
-
# returns a sshkeysCollection
|
169
|
-
# don't return self. check if the Megam::SshKeyCollection is returned.
|
170
|
-
def self.list(params)
|
171
|
-
sshKey = self.new(params)
|
172
|
-
sshKey.megam_rest.get_sshkeys
|
173
|
-
end
|
174
|
-
|
175
|
-
# Show a particular sshKey by name,
|
176
|
-
# Megam::SshKey
|
177
|
-
def self.show(params)
|
178
|
-
pre = self.new(params)
|
179
|
-
pre.megam_rest.get_sshkey(params["name"])
|
180
|
-
end
|
181
|
-
|
182
|
-
def to_s
|
183
|
-
Megam::Stuff.styled_hash(to_hash)
|
184
|
-
#"---> Megam::Account:[error=#{error?}]\n"+
|
185
|
-
end
|
186
|
-
|
187
|
-
end
|
188
173
|
end
|
@@ -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 SshKeyCollection
|
18
3
|
include Enumerable
|
data/lib/megam/core/stuff.rb
CHANGED
@@ -1,37 +1,22 @@
|
|
1
|
-
#
|
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
|
-
|
2
|
+
module Stuff
|
3
|
+
extend self
|
4
|
+
def has_git?
|
5
|
+
%x{ git --version }
|
6
|
+
$?.success?
|
7
|
+
end
|
23
8
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
9
|
+
def git(args)
|
10
|
+
return "" unless has_git?
|
11
|
+
flattened_args = [args].flatten.compact.join(" ")
|
12
|
+
%x{ git #{flattened_args} 2>&1 }.strip
|
13
|
+
end
|
29
14
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
15
|
+
#
|
16
|
+
#left justified keyed hash with newlines.
|
17
|
+
def styled_hash(hash)
|
18
|
+
hash.map{|k,v| "#{k.ljust(15)}=#{v}"}.join("\n")
|
19
|
+
end
|
35
20
|
|
36
|
-
|
21
|
+
end
|
37
22
|
end
|