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,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
@@ -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
- class SshKey < Megam::RestAdapter
18
- def initialize(o)
19
- @id = nil
20
- @name = nil
21
- @org_id = nil
22
- @privatekey=nil
23
- @publickey=nil
24
- @created_at = nil
25
- @some_msg = {}
26
- super(o)
27
- end
28
-
29
- def sshkey
30
- self
31
- end
32
-
33
- def id(arg=nil)
34
- if arg != nil
35
- @id = arg
36
- else
37
- @id
38
- end
39
- end
40
-
41
- def name(arg=nil)
42
- if arg != nil
43
- @name = arg
44
- else
45
- @name
46
- end
47
- end
48
-
49
- def org_id(arg=nil)
50
- if arg != nil
51
- @org_id= arg
52
- else
53
- @org_id
54
- end
55
- end
56
-
57
- def privatekey(arg=nil)
58
- if arg != nil
59
- @privatekey = arg
60
- else
61
- @privatekey
62
- end
63
- end
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
@@ -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
- module Stuff
18
- extend self
19
- def has_git?
20
- %x{ git --version }
21
- $?.success?
22
- end
2
+ module Stuff
3
+ extend self
4
+ def has_git?
5
+ %x{ git --version }
6
+ $?.success?
7
+ end
23
8
 
24
- def git(args)
25
- return "" unless has_git?
26
- flattened_args = [args].flatten.compact.join(" ")
27
- %x{ git #{flattened_args} 2>&1 }.strip
28
- end
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
- #left justified keyed hash with newlines.
32
- def styled_hash(hash)
33
- hash.map{|k,v| "#{k.ljust(15)}=#{v}"}.join("\n")
34
- end
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
- end
21
+ end
37
22
  end