virtengine_api 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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 DisksCollection
3
+ include Enumerable
4
+
5
+ attr_reader :iterator
6
+ def initialize
7
+ @disks = Array.new
8
+ @disks_by_name = Hash.new
9
+ @insert_after_idx = nil
10
+ end
11
+
12
+ def all_disks
13
+ @disks
14
+ end
15
+
16
+ def [](index)
17
+ @disks[index]
18
+ end
19
+
20
+ def []=(index, arg)
21
+ is_megam_disks(arg)
22
+ @disks[index] = arg
23
+ @disks_by_name[arg.account_id] = index
24
+ end
25
+
26
+ def <<(*args)
27
+ args.flatten.each do |a|
28
+ is_megam_events(a)
29
+ @disks << a
30
+ @disks_by_name[a.account_id] = @disks.length - 1
31
+ end
32
+ self
33
+ end
34
+
35
+ # 'push' is an alias method to <<
36
+ alias_method :push, :<<
37
+
38
+ def insert(disks)
39
+ is_megam_disks(disks)
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
+ @disks.insert(@insert_after_idx + 1, disks)
45
+ # update name -> location mappings and register new node
46
+ @disks_by_name.each_key do |key|
47
+ @disks_by_name[key] += 1 if @disks_by_name[key] > @insert_after_idx
48
+ end
49
+ @disks_by_name[disks.account_id] = @insert_after_idx + 1
50
+ @insert_after_idx += 1
51
+ else
52
+ @disks << disks
53
+ @disks_by_name[disks.account_id] = @disks.length - 1
54
+ end
55
+ end
56
+
57
+ def each
58
+ @disks.each do |disks|
59
+ yield disks
60
+ end
61
+ end
62
+
63
+ def each_index
64
+ @disks.each_index do |i|
65
+ yield i
66
+ end
67
+ end
68
+
69
+ def empty?
70
+ @disks.empty?
71
+ end
72
+
73
+ def lookup(disks)
74
+ lookup_by = nil
75
+ if events.kind_of?(Megam::Disks)
76
+ lookup_by = disks.account_id
77
+ elsif disks.kind_of?(String)
78
+ lookup_by = disks
79
+ else
80
+ raise ArgumentError, "Must pass a Megam::Disks or String to lookup"
81
+ end
82
+ res = @disks_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
+ @disks[res]
87
+ end
88
+
89
+ def to_s
90
+ @disks.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 |disks_list|
104
+ disks_array = disks_list.kind_of?(Array) ? disks_list : [ disks_list ]
105
+ disks_array.each do |disks|
106
+ collection.insert(disks)
107
+
108
+ end
109
+ end
110
+ collection
111
+ end
112
+
113
+ private
114
+
115
+ def is_megam_disks(arg)
116
+ unless arg.kind_of?(Megam::Disks)
117
+ raise ArgumentError, "Members must be Megam::Disks's"
118
+ end
119
+ true
120
+ end
121
+ end
122
+ end
@@ -0,0 +1,122 @@
1
+ module Megam
2
+ class DomainsCollection
3
+ include Enumerable
4
+
5
+ attr_reader :iterator
6
+ def initialize
7
+ @domains = Array.new
8
+ @domains_by_name = Hash.new
9
+ @insert_after_idx = nil
10
+ end
11
+
12
+ def all_domains
13
+ @domains
14
+ end
15
+
16
+ def [](index)
17
+ @domains[index]
18
+ end
19
+
20
+ def []=(index, arg)
21
+ is_megam_domains(arg)
22
+ @domains[index] = arg
23
+ @domains_by_name[arg.name] = index
24
+ end
25
+
26
+ def <<(*args)
27
+ args.flatten.each do |a|
28
+ is_megam_domains(a)
29
+ @domains << a
30
+ @domains_by_name[a.name] =@domains.length - 1
31
+ end
32
+ self
33
+ end
34
+
35
+ # 'push' is an alias method to <<
36
+ alias_method :push, :<<
37
+
38
+ def insert(domains)
39
+ is_megam_domains(domains)
40
+ if @insert_after_idx
41
+ # in the middle of executing a run, so any domain inserted now should
42
+ # be placed after the most recent addition done by the currently executing
43
+ # domain
44
+ @domains.insert(@insert_after_idx + 1, domains)
45
+ # update name -> location mappings and register new sshkeys
46
+ @domains_by_name.each_key do |key|
47
+ @domains_by_name[key] += 1 if@domains_by_name[key] > @insert_after_idx
48
+ end
49
+ @domains_by_name[domains.name] = @insert_after_idx + 1
50
+ @insert_after_idx += 1
51
+ else
52
+ @domains << domains
53
+ @domains_by_name[domains.name] =@domains.length - 1
54
+ end
55
+ end
56
+
57
+ def each
58
+ @domains.each do |domains|
59
+ yield domains
60
+ end
61
+ end
62
+
63
+ def each_index
64
+ @domains.each_index do |i|
65
+ yield i
66
+ end
67
+ end
68
+
69
+ def empty?
70
+ @domains.empty?
71
+ end
72
+
73
+ def lookup(domains)
74
+ lookup_by = nil
75
+ if domains.kind_of?(Megam::Domains)
76
+ lookup_by = domains.name
77
+ elsif domains.kind_of?(String)
78
+ lookup_by = domains
79
+ else
80
+ raise ArgumentError, "Must pass a Megam::Domains or String to lookup"
81
+ end
82
+ res =@domains_by_name[lookup_by]
83
+ unless res
84
+ raise ArgumentError, "Cannot find a domain matching #{lookup_by} (did you define it first?)"
85
+ end
86
+ @domains[res]
87
+ end
88
+
89
+
90
+ def to_s
91
+ @domains.join(", ")
92
+ end
93
+
94
+ def for_json
95
+ to_a.map { |item| item.to_s }
96
+ end
97
+
98
+ def to_json(*a)
99
+ Megam::JSONCompat.to_json(for_json, *a)
100
+ end
101
+
102
+ def self.json_create(o)
103
+ collection = self.new()
104
+ o["results"].each do |domains_list|
105
+ domains_array = domains_list.kind_of?(Array) ? domains_list : [ domains_list ]
106
+ domains_array.each do |domains|
107
+ collection.insert(domains)
108
+ end
109
+ end
110
+ collection
111
+ end
112
+
113
+ private
114
+
115
+ def is_megam_domains(arg)
116
+ unless arg.kind_of?(Megam::Domains)
117
+ raise ArgumentError, "Members must be Megam::Domains's"
118
+ end
119
+ true
120
+ end
121
+ end
122
+ end
@@ -0,0 +1,118 @@
1
+ module Megam
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
117
+ end
118
+ end
@@ -0,0 +1,70 @@
1
+ module Megam
2
+ class Error
3
+
4
+ def initialize
5
+ @some_msg = {}
6
+ end
7
+
8
+
9
+ def some_msg(arg=nil)
10
+ if arg != nil
11
+ @some_msg = arg
12
+ else
13
+ @some_msg
14
+ end
15
+ end
16
+
17
+ def error?
18
+ crocked = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error")
19
+ end
20
+
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
28
+
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
34
+
35
+ def for_json
36
+ result = { }
37
+ result
38
+ end
39
+
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
49
+
50
+ def self.from_hash(o)
51
+ acct = self.new()
52
+ acct.from_hash(o)
53
+ acct
54
+ end
55
+
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
63
+
64
+
65
+ def to_s
66
+ Megam::Stuff.styled_hash(to_hash)
67
+ #"---> Megam::Account:[error=#{error?}]\n"+
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,186 @@
1
+ module Megam
2
+ class EventsAll < Megam::RestAdapter
3
+ def initialize(o)
4
+ @account_id = nil
5
+ @assembly_id = nil
6
+ @event_type = nil
7
+ @data = []
8
+ @created_at = nil
9
+ @id = nil
10
+ @limit = nil
11
+ @some_msg = {}
12
+ super(o)
13
+ end
14
+
15
+ def eventsall
16
+ self
17
+ end
18
+
19
+ def account_id(arg=nil)
20
+ if arg != nil
21
+ @account_id = arg
22
+ else
23
+ @account_id
24
+ end
25
+ end
26
+
27
+ def id(arg=nil)
28
+ if arg != nil
29
+ @id = arg
30
+ else
31
+ @id
32
+ end
33
+ end
34
+
35
+ def assembly_id(arg=nil)
36
+ if arg != nil
37
+ @assembly_id = arg
38
+ else
39
+ @assembly_id
40
+ end
41
+ end
42
+
43
+ def event_type(arg=nil)
44
+ if arg != nil
45
+ @event_type = arg
46
+ else
47
+ @event_type
48
+ end
49
+ end
50
+
51
+
52
+ def data(arg=[])
53
+ if arg != []
54
+ @data = arg
55
+ else
56
+ @data
57
+ end
58
+ end
59
+
60
+ def limit(arg=[])
61
+ if arg != []
62
+ @limit = arg
63
+ else
64
+ @limit
65
+ end
66
+ end
67
+ def created_at(arg=nil)
68
+ if arg != nil
69
+ @created_at = arg
70
+ else
71
+ @created_at
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
+
80
+ def some_msg(arg=nil)
81
+ if arg != nil
82
+ @some_msg = arg
83
+ else
84
+ @some_msg
85
+ end
86
+ end
87
+
88
+
89
+ # Transform the ruby obj -> to a Hash
90
+ def to_hash
91
+ index_hash = Hash.new
92
+ index_hash["json_claz"] = self.class.name
93
+ index_hash["account_id"] = account_id
94
+ index_hash["assembly_id"] = assembly_id
95
+ index_hash["event_type"] = event_type
96
+ index_hash["data"] = data
97
+ index_hash["limit"] = limit
98
+ index_hash["created_at"] = created_at
99
+ index_hash["id"] = id
100
+ index_hash["some_msg"] = some_msg
101
+ index_hash
102
+ end
103
+
104
+ # Serialize this object as a hash: called from JsonCompat.
105
+ # Verify if this called from JsonCompat during testing.
106
+ def to_json(*a)
107
+ for_json.to_json(*a)
108
+ end
109
+
110
+ def for_json
111
+ result = {
112
+ "account_id" => account_id,
113
+ "assembly_id" => assembly_id,
114
+ "event_type" => event_type,
115
+ "data" => data,
116
+ "limit" => limit,
117
+ "created_at" => created_at,
118
+ "id" => id
119
+ }
120
+ result
121
+ end
122
+
123
+ def self.json_create(o)
124
+ evt = new({})
125
+ evt.account_id(o["account_id"]) if o.has_key?("account_id")
126
+ evt.id(o["id"]) if o.has_key?("id")
127
+ evt.assembly_id(o["assembly_id"]) if o.has_key?("assembly_id")
128
+ evt.event_type(o["event_type"]) if o.has_key?("event_type") #this will be an array? can hash store array?
129
+ evt.data(o["data"]) if o.has_key?("data")
130
+ evt.limit(o["limit"]) if o.has_key?("limit")
131
+ evt.created_at(o["created_at"]) if o.has_key?("created_at")
132
+ evt.some_msg[:code] = o["code"] if o.has_key?("code")
133
+ evt.some_msg[:msg_type] = o["msg_type"] if o.has_key?("msg_type")
134
+ evt.some_msg[:msg]= o["msg"] if o.has_key?("msg")
135
+ evt.some_msg[:links] = o["links"] if o.has_key?("links")
136
+ evt
137
+ end
138
+
139
+ def self.from_hash(o)
140
+ evt = self.new(o)
141
+ evt.from_hash(o)
142
+ evt
143
+ end
144
+
145
+ def from_hash(o)
146
+ @account_id = o[:account_id] if o.has_key?(:account_id)
147
+ @assembly_id = o[:assembly_id] if o.has_key?(:assembly_id)
148
+ @event_type = o[:event_type] if o.has_key?(:event_type)
149
+ @data = o[:data] if o.has_key?(:data)
150
+ @limit = o[:limit] if o.has_key?(:limit)
151
+ @created_at = o[:created_at] if o.has_key?(:created_at)
152
+ @id = o[:id] if o.has_key?(:id)
153
+ self
154
+ end
155
+
156
+ def self.create(params)
157
+ evt = from_hash(params)
158
+ evt.create
159
+ end
160
+
161
+ # Create the node via the REST API
162
+ def create
163
+ megam_rest.post_events(to_hash)
164
+ end
165
+
166
+ def self.show(o)
167
+ evt = from_hash(o)
168
+ evt.megam_rest.get_eventsall(o[:limit], evt.from_hash(o).for_json)
169
+ end
170
+
171
+ def self.list(params)
172
+ asm = self.new(params)
173
+ asm.megam_rest.list_eventsall(params[:limit])
174
+ end
175
+
176
+ def self.index(params)
177
+ asm = self.new(params)
178
+ asm.megam_rest.index_eventsall
179
+ end
180
+
181
+ def to_s
182
+ Megam::Stuff.styled_hash(to_hash)
183
+ end
184
+
185
+ end
186
+ end