virtengine_api 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (151) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +21 -0
  3. data/.travis.yml +11 -0
  4. data/Gemfile +5 -0
  5. data/LICENSE +21 -0
  6. data/README.md +27 -0
  7. data/Rakefile +10 -0
  8. data/lib/megam/api.rb +329 -0
  9. data/lib/megam/api/accounts.rb +96 -0
  10. data/lib/megam/api/addons.rb +27 -0
  11. data/lib/megam/api/assemblies.rb +49 -0
  12. data/lib/megam/api/assembly.rb +56 -0
  13. data/lib/megam/api/backups.rb +57 -0
  14. data/lib/megam/api/balances.rb +45 -0
  15. data/lib/megam/api/billedhistories.rb +35 -0
  16. data/lib/megam/api/billingtransactions.rb +25 -0
  17. data/lib/megam/api/components.rb +24 -0
  18. data/lib/megam/api/credits.rb +34 -0
  19. data/lib/megam/api/disks.rb +44 -0
  20. data/lib/megam/api/domains.rb +25 -0
  21. data/lib/megam/api/errors.rb +29 -0
  22. data/lib/megam/api/eventsall.rb +36 -0
  23. data/lib/megam/api/eventsbilling.rb +35 -0
  24. data/lib/megam/api/eventscontainer.rb +35 -0
  25. data/lib/megam/api/eventsmarketplace.rb +35 -0
  26. data/lib/megam/api/eventsstorage.rb +24 -0
  27. data/lib/megam/api/eventsvm.rb +35 -0
  28. data/lib/megam/api/flavors.rb +56 -0
  29. data/lib/megam/api/license.rb +26 -0
  30. data/lib/megam/api/marketplaces.rb +68 -0
  31. data/lib/megam/api/organizations.rb +50 -0
  32. data/lib/megam/api/promos.rb +18 -0
  33. data/lib/megam/api/quotas.rb +47 -0
  34. data/lib/megam/api/rawimages.rb +36 -0
  35. data/lib/megam/api/reports.rb +24 -0
  36. data/lib/megam/api/requests.rb +36 -0
  37. data/lib/megam/api/sensors.rb +35 -0
  38. data/lib/megam/api/snapshots.rb +46 -0
  39. data/lib/megam/api/sshkeys.rb +35 -0
  40. data/lib/megam/api/subscriptions.rb +26 -0
  41. data/lib/megam/api/version.rb +6 -0
  42. data/lib/megam/core/account.rb +245 -0
  43. data/lib/megam/core/account_collection.rb +122 -0
  44. data/lib/megam/core/addons.rb +169 -0
  45. data/lib/megam/core/addons_collection.rb +121 -0
  46. data/lib/megam/core/assemblies.rb +191 -0
  47. data/lib/megam/core/assemblies_collection.rb +122 -0
  48. data/lib/megam/core/assembly.rb +226 -0
  49. data/lib/megam/core/assembly_collection.rb +122 -0
  50. data/lib/megam/core/backups.rb +259 -0
  51. data/lib/megam/core/backups_collection.rb +122 -0
  52. data/lib/megam/core/balances.rb +187 -0
  53. data/lib/megam/core/balances_collection.rb +121 -0
  54. data/lib/megam/core/billedhistories.rb +190 -0
  55. data/lib/megam/core/billedhistories_collection.rb +121 -0
  56. data/lib/megam/core/billingtransactions.rb +214 -0
  57. data/lib/megam/core/billingtransactions_collection.rb +122 -0
  58. data/lib/megam/core/components.rb +326 -0
  59. data/lib/megam/core/components_collection.rb +123 -0
  60. data/lib/megam/core/credits.rb +146 -0
  61. data/lib/megam/core/credits_collection.rb +121 -0
  62. data/lib/megam/core/disks.rb +199 -0
  63. data/lib/megam/core/disks_collection.rb +122 -0
  64. data/lib/megam/core/domain_collection.rb +122 -0
  65. data/lib/megam/core/domains.rb +118 -0
  66. data/lib/megam/core/error.rb +70 -0
  67. data/lib/megam/core/eventsall.rb +186 -0
  68. data/lib/megam/core/eventsall_collection.rb +122 -0
  69. data/lib/megam/core/eventsbilling.rb +174 -0
  70. data/lib/megam/core/eventsbilling_collection.rb +122 -0
  71. data/lib/megam/core/eventscontainer.rb +187 -0
  72. data/lib/megam/core/eventscontainer_collection.rb +122 -0
  73. data/lib/megam/core/eventsmarketplace.rb +187 -0
  74. data/lib/megam/core/eventsmarketplace_collection.rb +122 -0
  75. data/lib/megam/core/eventsstorage.rb +156 -0
  76. data/lib/megam/core/eventsstorage_collection.rb +122 -0
  77. data/lib/megam/core/eventsvm.rb +187 -0
  78. data/lib/megam/core/eventsvm_collection.rb +122 -0
  79. data/lib/megam/core/flavors.rb +294 -0
  80. data/lib/megam/core/flavors_collection.rb +121 -0
  81. data/lib/megam/core/json_compat.rb +289 -0
  82. data/lib/megam/core/konipai.rb +42 -0
  83. data/lib/megam/core/license.rb +101 -0
  84. data/lib/megam/core/license_collection.rb +122 -0
  85. data/lib/megam/core/log.rb +19 -0
  86. data/lib/megam/core/marketplace.rb +308 -0
  87. data/lib/megam/core/marketplace_collection.rb +123 -0
  88. data/lib/megam/core/monologger.rb +89 -0
  89. data/lib/megam/core/organizations.rb +142 -0
  90. data/lib/megam/core/organizations_collection.rb +121 -0
  91. data/lib/megam/core/promos.rb +145 -0
  92. data/lib/megam/core/quotas.rb +215 -0
  93. data/lib/megam/core/quotas_collection.rb +121 -0
  94. data/lib/megam/core/rawimages.rb +194 -0
  95. data/lib/megam/core/rawimages_collection.rb +121 -0
  96. data/lib/megam/core/reports.rb +176 -0
  97. data/lib/megam/core/reports_collection.rb +121 -0
  98. data/lib/megam/core/request.rb +197 -0
  99. data/lib/megam/core/request_collection.rb +121 -0
  100. data/lib/megam/core/rest_adapter.rb +44 -0
  101. data/lib/megam/core/sensors.rb +141 -0
  102. data/lib/megam/core/sensors_collection.rb +121 -0
  103. data/lib/megam/core/snapshots.rb +268 -0
  104. data/lib/megam/core/snapshots_collection.rb +122 -0
  105. data/lib/megam/core/sshkey.rb +173 -0
  106. data/lib/megam/core/sshkey_collection.rb +122 -0
  107. data/lib/megam/core/stuff.rb +22 -0
  108. data/lib/megam/core/subscriptions.rb +167 -0
  109. data/lib/megam/core/subscriptions_collection.rb +121 -0
  110. data/lib/megam/core/text.rb +87 -0
  111. data/lib/megam/core/text_formatter.rb +64 -0
  112. data/lib/megam/mixins/assemblies.rb +16 -0
  113. data/lib/megam/mixins/assembly.rb +59 -0
  114. data/lib/megam/mixins/common_deployable.rb +78 -0
  115. data/lib/megam/mixins/components.rb +182 -0
  116. data/lib/megam/mixins/megam_attributes.rb +30 -0
  117. data/lib/megam/mixins/outputs.rb +23 -0
  118. data/lib/megam/mixins/policies.rb +27 -0
  119. data/lib/megam_api.rb +1 -0
  120. data/megam_api.gemspec +26 -0
  121. data/test/mixins/test_assemblies.rb +113 -0
  122. data/test/mixins/test_assembly.rb +74 -0
  123. data/test/mixins/test_component.rb +19 -0
  124. data/test/test_accounts.rb +127 -0
  125. data/test/test_addons.rb +26 -0
  126. data/test/test_assemblies.rb +88 -0
  127. data/test/test_assembly.rb +37 -0
  128. data/test/test_backups.rb +29 -0
  129. data/test/test_balances.rb +38 -0
  130. data/test/test_billedhistories.rb +30 -0
  131. data/test/test_billingtranscations.rb +35 -0
  132. data/test/test_components.rb +42 -0
  133. data/test/test_credits.rb +28 -0
  134. data/test/test_disks.rb +25 -0
  135. data/test/test_domains.rb +29 -0
  136. data/test/test_eventsbilling.rb +30 -0
  137. data/test/test_eventscontainer.rb +26 -0
  138. data/test/test_eventsstorage.rb +12 -0
  139. data/test/test_eventsvm.rb +26 -0
  140. data/test/test_helper.rb +77 -0
  141. data/test/test_marketplaces.rb +38 -0
  142. data/test/test_organizations.rb +45 -0
  143. data/test/test_promos.rb +11 -0
  144. data/test/test_quotas.rb +33 -0
  145. data/test/test_reports.rb +32 -0
  146. data/test/test_requests.rb +95 -0
  147. data/test/test_sensors.rb +50 -0
  148. data/test/test_snapshots.rb +30 -0
  149. data/test/test_sshkeys.rb +50 -0
  150. data/test/test_subscriptions.rb +22 -0
  151. metadata +325 -0
@@ -0,0 +1,122 @@
1
+ module Megam
2
+ class AccountCollection
3
+ include Enumerable
4
+
5
+ attr_reader :iterator
6
+ def initialize
7
+ @accounts = Array.new
8
+ @accounts_by_name = Hash.new
9
+ @insert_after_idx = nil
10
+ end
11
+
12
+ def all_accounts
13
+ @accounts
14
+ end
15
+
16
+ def [](index)
17
+ @accounts[index]
18
+ end
19
+
20
+ def []=(index, arg)
21
+ is_account_hash(arg)
22
+ @accounts[index] = arg
23
+ @accounts_by_name[arg[:email]] = index
24
+ end
25
+
26
+ def <<(*args)
27
+ args.flatten.each do |a|
28
+ is_account_hash(a)
29
+ @accounts << a
30
+ @accounts_by_name[a[:email]] = @accounts.length - 1
31
+ end
32
+ self
33
+ end
34
+
35
+ # 'push' is an alias method to <<
36
+ alias_method :push, :<<
37
+
38
+ def insert(accounts)
39
+ is_account_hash(accounts)
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
+ @accounts.insert(@insert_after_idx + 1, accounts)
45
+ # update name -> location mappings and register new node
46
+ @accounts_by_name.each_key do |key|
47
+ @accounts_by_name[key] += 1 if @accounts_by_name[key] > @insert_after_idx
48
+ end
49
+ @accounts_by_name[accounts[:email]] = @insert_after_idx + 1
50
+ @insert_after_idx += 1
51
+ else
52
+ @accounts << accounts
53
+ @accounts_by_name[accounts[:email]] = @accounts.length - 1
54
+ end
55
+ end
56
+
57
+ def each
58
+ @accounts.each do |accounts|
59
+ yield accounts
60
+ end
61
+ end
62
+
63
+ def each_index
64
+ @accounts.each_index do |i|
65
+ yield i
66
+ end
67
+ end
68
+
69
+ def empty?
70
+ @accounts.empty?
71
+ end
72
+
73
+ def lookup(accounts)
74
+ lookup_by = nil
75
+ if accounts.kind_of?(Hash)
76
+ lookup_by = accounts[:email]
77
+ elsif accounts.kind_of?(String)
78
+ lookup_by = accounts
79
+ else
80
+ raise ArgumentError, "Must pass a Megam::Account or String to lookup"
81
+ end
82
+ res = @accounts_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
+ @accounts[res]
87
+ end
88
+
89
+ def to_s
90
+ @accounts.join(", ")
91
+ end
92
+
93
+ def for_json
94
+ to_a.map { |item| item.to_s }
95
+ end
96
+
97
+ def to_json(*a)
98
+ Megam::JSONCompat.to_json(for_json, *a)
99
+ end
100
+
101
+ def self.json_create(o)
102
+ collection = self.new()
103
+ o["results"].each do |accounts_list|
104
+ accounts_array = accounts_list.kind_of?(Array) ? accounts_list : [ accounts_list ]
105
+ accounts_array.each do |accounts|
106
+ collection.insert(accounts)
107
+
108
+ end
109
+ end
110
+ collection
111
+ end
112
+
113
+ private
114
+
115
+ def is_account_hash(arg)
116
+ unless arg.kind_of?(Hash)
117
+ raise ArgumentError, "Members must be a Hash"
118
+ end
119
+ true
120
+ end
121
+ end
122
+ end
@@ -0,0 +1,169 @@
1
+ module Megam
2
+ class Addons < Megam::RestAdapter
3
+ def initialize(o)
4
+ @id = nil
5
+ @provider_id = nil
6
+ @account_id = nil
7
+ @provider_name = nil
8
+ @options = []
9
+ @created_at = nil
10
+ @some_msg = {}
11
+ super(o)
12
+ end
13
+
14
+ def addons
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 provider_id(arg=nil)
27
+ if arg != nil
28
+ @provider_id= arg
29
+ else
30
+ @provider_id
31
+ end
32
+ end
33
+
34
+ def account_id(arg=nil)
35
+ if arg != nil
36
+ @account_id= arg
37
+ else
38
+ @account_id
39
+ end
40
+ end
41
+
42
+ def provider_name(arg=nil)
43
+ if arg != nil
44
+ @provider_name = arg
45
+ else
46
+ @provider_name
47
+ end
48
+ end
49
+
50
+ def options(arg=[])
51
+ if arg != []
52
+ @options = arg
53
+ else
54
+ @options
55
+ end
56
+ end
57
+
58
+ def created_at(arg=nil)
59
+ if arg != nil
60
+ @created_at = arg
61
+ else
62
+ @created_at
63
+ end
64
+ end
65
+
66
+ def some_msg(arg=nil)
67
+ if arg != nil
68
+ @some_msg = arg
69
+ else
70
+ @some_msg
71
+ end
72
+ end
73
+
74
+ def error?
75
+ crocked = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error")
76
+ end
77
+
78
+ # Transform the ruby obj -> to a Hash
79
+ def to_hash
80
+ index_hash = Hash.new
81
+ index_hash["json_claz"] = self.class.name
82
+ index_hash["id"] = id
83
+ index_hash["provider_id"] = provider_id
84
+ index_hash["account_id"] = account_id
85
+ index_hash["provider_name"] = provider_name
86
+ index_hash["options"] = options
87
+ index_hash["created_at"] = created_at
88
+ index_hash
89
+ end
90
+
91
+ # Serialize this object as a hash: called from JsonCompat.
92
+ # Verify if this called from JsonCompat during testing.
93
+ def to_json(*a)
94
+ for_json.to_json(*a)
95
+ end
96
+
97
+ def for_json
98
+ result = {
99
+ "id" => id,
100
+ "provider_id" => provider_id,
101
+ "account_id" => account_id,
102
+ "provider_name" => provider_name ,
103
+ "options" => options,
104
+ "created_at" => created_at
105
+ }
106
+ result
107
+ end
108
+
109
+ #
110
+ def self.json_create(o)
111
+ adn = new({})
112
+ adn.id(o["id"]) if o.has_key?("id")
113
+ adn.provider_id(o["provider_id"]) if o.has_key?("provider_id")
114
+ adn.account_id(o["account_id"]) if o.has_key?("account_id")
115
+ adn.provider_name(o["provider_name"]) if o.has_key?("provider_name")
116
+ adn.options(o["options"]) if o.has_key?("options")
117
+ adn.created_at(o["created_at"]) if o.has_key?("created_at")
118
+ #success or error
119
+ adn.some_msg[:code] = o["code"] if o.has_key?("code")
120
+ adn.some_msg[:msg_type] = o["msg_type"] if o.has_key?("msg_type")
121
+ adn.some_msg[:msg]= o["msg"] if o.has_key?("msg")
122
+ adn.some_msg[:links] = o["links"] if o.has_key?("links")
123
+ adn
124
+ end
125
+
126
+ def self.from_hash(o)
127
+ adn = self.new(o)
128
+ adn.from_hash(o)
129
+ adn
130
+ end
131
+
132
+ def from_hash(o)
133
+ @id = o[:id] if o.has_key?(:id)
134
+ @provider_id = o[:provider_id] if o.has_key?(:provider_id)
135
+ @account_id = o[:account_id] if o.has_key?(:account_id)
136
+ @provider_name = o[:provider_name] if o.has_key?(:provider_name)
137
+ @options = o[:options] if o.has_key?(:options)
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 addons via the REST API
148
+ def create
149
+ megam_rest.post_addons(to_hash)
150
+ end
151
+
152
+ # Load all addons -
153
+ # returns a AddonsCollection
154
+ # don't return self. check if the Megam::AddonsCollection is returned.
155
+
156
+ # Show a particular addon by provider_name,
157
+ # Megam::Addon
158
+ def self.show(params)
159
+ pre = self.new(params)
160
+ pre.megam_rest.get_addon(params["provider"])
161
+ end
162
+
163
+
164
+ def to_s
165
+ Megam::Stuff.styled_hash(to_hash)
166
+ end
167
+
168
+ end
169
+ end
@@ -0,0 +1,121 @@
1
+ module Megam
2
+ class AddonsCollection
3
+ include Enumerable
4
+
5
+ attr_reader :iterator
6
+ def initialize
7
+ @addons = Array.new
8
+ @addons_by_name = Hash.new
9
+ @insert_after_idx = nil
10
+ end
11
+
12
+ def all_addons
13
+ @addons
14
+ end
15
+
16
+ def [](index)
17
+ @addons[index]
18
+ end
19
+
20
+ def []=(index, arg)
21
+ is_megam_addons(arg)
22
+ @addons[index] = arg
23
+ @addons_by_name[arg.account_id] = index
24
+ end
25
+
26
+ def <<(*args)
27
+ args.flatten.each do |a|
28
+ is_megam_addons(a)
29
+ @addons << a
30
+ @addons_by_name[a.account_id] =@addons.length - 1
31
+ end
32
+ self
33
+ end
34
+
35
+ # 'push' is an alias method to <<
36
+ alias_method :push, :<<
37
+
38
+ def insert(addons)
39
+ is_megam_addons(addons)
40
+ if @insert_after_idx
41
+ # in the middle of executing a run, so any predefs inserted now should
42
+ # be placed after the most recent addition done by the currently executing
43
+ # addons
44
+ @addons.insert(@insert_after_idx + 1, addons)
45
+ # update name -> location mappings and register new addons
46
+ @addons_by_name.each_key do |key|
47
+ @addons_by_name[key] += 1 if@addons_by_name[key] > @insert_after_idx
48
+ end
49
+ @addons_by_name[addons.account_id] = @insert_after_idx + 1
50
+ @insert_after_idx += 1
51
+ else
52
+ @addons << addons
53
+ @addons_by_name[addons.account_id] =@addons.length - 1
54
+ end
55
+ end
56
+
57
+ def each
58
+ @addons.each do |addons|
59
+ yield addons
60
+ end
61
+ end
62
+
63
+ def each_index
64
+ @addons.each_index do |i|
65
+ yield i
66
+ end
67
+ end
68
+
69
+ def empty?
70
+ @addons.empty?
71
+ end
72
+
73
+ def lookup(addons)
74
+ lookup_by = nil
75
+ if Addons.kind_of?(Megam::Addons)
76
+ lookup_by = addons.account_id
77
+ elsif addons.kind_of?(String)
78
+ lookup_by = addons
79
+ else
80
+ raise ArgumentError, "Must pass a Megam::Addons or String to lookup"
81
+ end
82
+ res =@addons_by_name[lookup_by]
83
+ unless res
84
+ raise ArgumentError, "Cannot find a addons matching #{lookup_by} (did you define it first?)"
85
+ end
86
+ @addons[res]
87
+ end
88
+
89
+ def to_s
90
+ @addons.join(", ")
91
+ end
92
+
93
+ def for_json
94
+ to_a.map { |item| item.to_s }
95
+ end
96
+
97
+ def to_json(*a)
98
+ Megam::JSONCompat.to_json(for_json, *a)
99
+ end
100
+
101
+ def self.json_create(o)
102
+ collection = self.new()
103
+ o["results"].each do |addons_list|
104
+ addons_array = addons_list.kind_of?(Array) ? addons_list : [ addons_list ]
105
+ addons_array.each do |addons|
106
+ collection.insert(addons)
107
+ end
108
+ end
109
+ collection
110
+ end
111
+
112
+ private
113
+
114
+ def is_megam_addons(arg)
115
+ unless arg.kind_of?(Megam::Addons)
116
+ raise ArgumentError, "Members must be Megam::addons's"
117
+ end
118
+ true
119
+ end
120
+ end
121
+ end
@@ -0,0 +1,191 @@
1
+ module Megam
2
+ class Assemblies < Megam::RestAdapter
3
+ def initialize(o)
4
+ @id = nil
5
+ @accounts_id = nil
6
+ @org_id = nil
7
+ @name = nil
8
+ @password = nil
9
+ @assemblies = []
10
+ @inputs = []
11
+ @created_at = nil
12
+ @some_msg = {}
13
+ super(o)
14
+ end
15
+
16
+ def assemblies
17
+ self
18
+ end
19
+
20
+ def id(arg=nil)
21
+ if arg != nil
22
+ @id = arg
23
+ else
24
+ @id
25
+ end
26
+ end
27
+
28
+ def accounts_id(arg=nil)
29
+ if arg != nil
30
+ @accounts_id = arg
31
+ else
32
+ @accounts_id
33
+ end
34
+ end
35
+
36
+ def org_id(arg=nil)
37
+ if arg != nil
38
+ @org_id = arg
39
+ else
40
+ @org_id
41
+ end
42
+ end
43
+
44
+ def password(arg=nil)
45
+ if arg != nil
46
+ @password = arg
47
+ else
48
+ @password
49
+ end
50
+ end
51
+
52
+ def name(arg=nil)
53
+ if arg != nil
54
+ @name = arg
55
+ else
56
+ @name
57
+ end
58
+ end
59
+
60
+ def assemblies(arg=[])
61
+ if arg != []
62
+ @assemblies = arg
63
+ else
64
+ @assemblies
65
+ end
66
+ end
67
+
68
+ def inputs(arg=[])
69
+ if arg != []
70
+ @inputs = arg
71
+ else
72
+ @inputs
73
+ end
74
+ end
75
+
76
+ def created_at(arg=nil)
77
+ if arg != nil
78
+ @created_at = arg
79
+ else
80
+ @created_at
81
+ end
82
+ end
83
+
84
+ def error?
85
+ crocked = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error")
86
+ end
87
+
88
+
89
+ def some_msg(arg=nil)
90
+ if arg != nil
91
+ @some_msg = arg
92
+ else
93
+ @some_msg
94
+ end
95
+ end
96
+
97
+
98
+ # Transform the ruby obj -> to a Hash
99
+ def to_hash
100
+ index_hash = Hash.new
101
+ index_hash["json_claz"] = self.class.name
102
+ index_hash["id"] = id
103
+ index_hash["org_id"] = org_id
104
+ index_hash["name"] = name
105
+ index_hash["accounts_id"] = accounts_id
106
+ index_hash["inputs"] = inputs
107
+ index_hash["assemblies"] = assemblies
108
+ index_hash["created_at"] = created_at
109
+ index_hash["some_msg"] = some_msg
110
+ index_hash
111
+ end
112
+
113
+ # Serialize this object as a hash: called from JsonCompat.
114
+ # Verify if this called from JsonCompat during testing.
115
+ def to_json(*a)
116
+ for_json.to_json(*a)
117
+ end
118
+
119
+ def for_json
120
+ result = {
121
+ "id" => id,
122
+ "name" => name,
123
+ "accounts_id" => accounts_id,
124
+ "org_id" => org_id,
125
+ "assemblies" => assemblies,
126
+ "inputs" => inputs,
127
+ "created_at" => created_at
128
+ }
129
+ result
130
+ end
131
+
132
+ def self.json_create(o)
133
+ asm = new({})
134
+ asm.id(o["id"]) if o.has_key?("id")
135
+ asm.name(o["name"]) if o.has_key?("name")
136
+ asm.accounts_id(o["accounts_id"]) if o.has_key?("accounts_id")
137
+ asm.org_id(o["org_id"]) if o.has_key?("org_id")
138
+ asm.assemblies(o["assemblies"]) if o.has_key?("assemblies") #this will be an array? can hash store array?
139
+ asm.inputs(o["inputs"]) if o.has_key?("inputs")
140
+ asm.created_at(o["created_at"]) if o.has_key?("created_at")
141
+ asm.some_msg[:code] = o["code"] if o.has_key?("code")
142
+ asm.some_msg[:msg_type] = o["msg_type"] if o.has_key?("msg_type")
143
+ asm.some_msg[:msg]= o["msg"] if o.has_key?("msg")
144
+ asm.some_msg[:links] = o["links"] if o.has_key?("links")
145
+ asm
146
+ end
147
+
148
+ def self.from_hash(o)
149
+ asm = self.new(o)
150
+ asm.from_hash(o)
151
+ asm
152
+ end
153
+
154
+ def from_hash(o)
155
+ @id = o[:id] if o.has_key?(:id)
156
+ @name = o[:name] if o.has_key?(:name)
157
+ @accounts_id = o[:accounts_id] if o.has_key?(:accounts_id)
158
+ @org_id = o[:org_id] if o.has_key?(:org_id)
159
+ @assemblies = o[:assemblies] if o.has_key?(:assemblies)
160
+ @inputs = o[:inputs] if o.has_key?(:inputs)
161
+ @created_at = o[:created_at] if o.has_key?(:created_at)
162
+ self
163
+ end
164
+
165
+ def self.create(params)
166
+ asm = from_hash(params)
167
+ asm.create
168
+ end
169
+
170
+ # Create the node via the REST API
171
+ def create
172
+ megam_rest.post_assemblies(to_hash)
173
+ end
174
+
175
+ # Load a account by email_p
176
+ def self.show(o)
177
+ asm = self.new(o)
178
+ asm.megam_rest.get_one_assemblies(o[:assemblies_id])
179
+ end
180
+
181
+ def self.list(params)
182
+ asm = self.new(params)
183
+ asm.megam_rest.get_assemblies
184
+ end
185
+
186
+ def to_s
187
+ Megam::Stuff.styled_hash(to_hash)
188
+ end
189
+
190
+ end
191
+ end