megam_api 1.50.11 → 1.50.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 00aff343d16f8112bed6492c995568295819c76e
4
- data.tar.gz: 282e16d1d90c6adfa4530666249bfe17dc88fcb5
3
+ metadata.gz: 071a799ae2b420a2e946e8dccd4c594b19fefff8
4
+ data.tar.gz: 5b84a6cb2c85d3a54ca105de17823f17970b0645
5
5
  SHA512:
6
- metadata.gz: ff45c05df2d770d398d486a358f3958b8ae10fe1dd78235bc541720f330559abe0a08ea6d136385e6174ec6cf75c83710fbd66aa13542c04db1bca7f19a935ad
7
- data.tar.gz: bde98349bb9c9d65c43ca96646b2c2e082e7b9260373a9789228945a97ebe8cc06f8e6a3bdd3df5afc51506faff4b64da6e7283a8abe739eb2b308592e4f7bf3
6
+ metadata.gz: 638258620d9fdc2f6b576f6bddef26ab2dd48c1ba0cb1c3262b29d4129eb8f28ac7ba887b672d5b6549256b50ca4379a49003dab587a4cbb26f05d29c176b5de
7
+ data.tar.gz: 1973d8904224ca1944c980c95b3100b098cd28e5068b5d8152fcc0dd190c154c17fd477a01191bb72436cfa143a0589b31d706fe05688795fa181ef50e8a2c80
@@ -0,0 +1,35 @@
1
+ module Megam
2
+ class API
3
+ # GET /nodes
4
+ def list_eventsMarketplaces(limit)
5
+ @options = {:path => "/eventsmarketplaces/#{limit}",:body => ""}.merge(@options)
6
+
7
+ request(
8
+ :expects => 200,
9
+ :method => :get,
10
+ :body => @options[:body]
11
+ )
12
+ end
13
+
14
+
15
+ def get_eventsMarketplaces(limit, new_events)
16
+ @options = {:path => "/eventsmarketplaces/show/#{limit}",
17
+ :body => Megam::JSONCompat.to_json(new_events)}.merge(@options)
18
+ request(
19
+ :expects => 200,
20
+ :method => :post,
21
+ :body => @options[:body]
22
+ )
23
+ end
24
+
25
+ def index_eventsMarketplaces
26
+ @options = {:path => "/eventsmarketplaces",:body => ""}.merge(@options)
27
+
28
+ request(
29
+ :expects => 200,
30
+ :method => :get,
31
+ :body => @options[:body]
32
+ )
33
+ end
34
+ end
35
+ end
@@ -1,5 +1,5 @@
1
1
  module Megam
2
2
  class API
3
- VERSION = "1.50.11"
3
+ VERSION = "1.50.12"
4
4
  end
5
5
  end
data/lib/megam/api.rb CHANGED
@@ -26,6 +26,7 @@ require 'megam/api/sensors'
26
26
  require 'megam/api/sshkeys'
27
27
  require 'megam/api/eventsall'
28
28
  require 'megam/api/eventsvm'
29
+ require 'megam/api/eventsmarketplaces'
29
30
  require 'megam/api/license'
30
31
  require 'megam/api/eventscontainer'
31
32
  require 'megam/api/eventsbilling'
@@ -64,9 +65,11 @@ require 'megam/core/license_collection'
64
65
  require 'megam/core/sshkey'
65
66
  require 'megam/core/sshkey_collection'
66
67
  require 'megam/core/eventsall'
67
- require 'megam/core/eventsvm'
68
68
  require 'megam/core/eventsall_collection'
69
+ require 'megam/core/eventsvm'
69
70
  require 'megam/core/eventsvm_collection'
71
+ require 'megam/core/eventsmarketplaces'
72
+ require 'megam/core/eventsmarketplaces_collection'
70
73
  require 'megam/core/eventscontainer'
71
74
  require 'megam/core/eventscontainer_collection'
72
75
  require 'megam/core/eventsbilling'
@@ -0,0 +1,187 @@
1
+ module Megam
2
+ class EventsMarketplaces < 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 eventsMarketplaces
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.assembly_id(o["assembly_id"]) if o.has_key?("assembly_id")
127
+ evt.id(o["id"]) if o.has_key?("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
+ # Load a account by email_p
167
+ def self.show(o)
168
+ evt = from_hash(o)
169
+ evt.megam_rest.get_eventsMarketplaces(o[:limit], evt.from_hash(o).for_json)
170
+ end
171
+
172
+ def self.list(params)
173
+ asm = self.new(params)
174
+ asm.megam_rest.list_eventsMarketplaces(params[:limit])
175
+ end
176
+
177
+ def self.index(params)
178
+ asm = self.new(params)
179
+ asm.megam_rest.index_eventsMarketplaces
180
+ end
181
+
182
+ def to_s
183
+ Megam::Stuff.styled_hash(to_hash)
184
+ end
185
+
186
+ end
187
+ end
@@ -0,0 +1,122 @@
1
+ module Megam
2
+ class EventsMarketplacesCollection
3
+ include Enumerable
4
+
5
+ attr_reader :iterator
6
+ def initialize
7
+ @eventsmarketplaces = Array.new
8
+ @eventsmarketplaces_by_name = Hash.new
9
+ @insert_after_idx = nil
10
+ end
11
+
12
+ def all_eventsmarketplaces
13
+ @eventsmarketplaces
14
+ end
15
+
16
+ def [](index)
17
+ @eventsmarketplaces[index]
18
+ end
19
+
20
+ def []=(index, arg)
21
+ is_megam_eventsvm(arg)
22
+ @eventsmarketplaces[index] = arg
23
+ @eventsmarketplaces_by_name[arg.account_id] = index
24
+ end
25
+
26
+ def <<(*args)
27
+ args.flatten.each do |a|
28
+ is_megam_events(a)
29
+ @eventsmarketplaces << a
30
+ @eventsmarketplaces_by_name[a.account_id] = @eventsmarketplaces.length - 1
31
+ end
32
+ self
33
+ end
34
+
35
+ # 'push' is an alias method to <<
36
+ alias_method :push, :<<
37
+
38
+ def insert(eventsmarketplaces)
39
+ is_megam_eventsmarketplaces(eventsmarketplaces)
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
+ @eventsmarketplaces.insert(@insert_after_idx + 1, eventsmarketplaces)
45
+ # update name -> location mappings and register new node
46
+ @eventsmarketplaces_by_name.each_key do |key|
47
+ @eventsmarketplaces_by_name[key] += 1 if @eventsmarketplaces_by_name[key] > @insert_after_idx
48
+ end
49
+ @eventsmarketplaces_by_name[eventsmarketplaces.account_id] = @insert_after_idx + 1
50
+ @insert_after_idx += 1
51
+ else
52
+ @eventsmarketplaces << eventsmarketplaces
53
+ @eventsmarketplaces_by_name[eventsmarketplaces.account_id] = @eventsmarketplaces.length - 1
54
+ end
55
+ end
56
+
57
+ def each
58
+ @eventsmarketplaces.each do |eventsmarketplaces|
59
+ yield eventsmarketplaces
60
+ end
61
+ end
62
+
63
+ def each_index
64
+ @eventsmarketplaces.each_index do |i|
65
+ yield i
66
+ end
67
+ end
68
+
69
+ def empty?
70
+ @eventsmarketplaces.empty?
71
+ end
72
+
73
+ def lookup(eventsmarketplaces)
74
+ lookup_by = nil
75
+ if events.kind_of?(Megam::EventsMarketplaces)
76
+ lookup_by = eventsmarketplaces.account_id
77
+ elsif eventsmarketplaces.kind_of?(String)
78
+ lookup_by = eventsmarketplaces
79
+ else
80
+ raise ArgumentError, "Must pass a Megam::EventsMarketplaces or String to lookup"
81
+ end
82
+ res = @eventsmarketplaces_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
+ @eventsmarketplaces[res]
87
+ end
88
+
89
+ def to_s
90
+ @eventsmarketplaces.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 |eventsmarketplaces_list|
104
+ eventsmarketplaces_array = eventsmarketplaces_list.kind_of?(Array) ? eventsmarketplaces_list : [ eventsmarketplaces_list ]
105
+ eventsmarketplaces_array.each do |eventsmarketplaces|
106
+ collection.insert(eventsmarketplaces)
107
+
108
+ end
109
+ end
110
+ collection
111
+ end
112
+
113
+ private
114
+
115
+ def is_megam_eventsmarketplaces(arg)
116
+ unless arg.kind_of?(Megam::EventsMarketplaces)
117
+ raise ArgumentError, "Members must be Megam::EventsMarketplaces's"
118
+ end
119
+ true
120
+ end
121
+ end
122
+ end
@@ -54,6 +54,8 @@ module Megam
54
54
  MEGAM_EVENTSVMCOLLECTION = 'Megam::EventsVmCollection'.freeze
55
55
  MEGAM_EVENTSCONTAINER = 'Megam::EventsContainer'.freeze
56
56
  MEGAM_EVENTSCONTAINERCOLLECTION = 'Megam::EventsContainerCollection'.freeze
57
+ MEGAM_EVENTSMARKETPLACES = 'Megam::EventsMarketplaces'.freeze
58
+ MEGAM_EVENTSMARKETPLACESCOLLECTION = 'Megam::EventsMarketplacesCollection'.freeze
57
59
  MEGAM_EVENTSBILLING = 'Megam::EventsBilling'.freeze
58
60
  MEGAM_EVENTSBILLINGCOLLECTION = 'Megam::EventsBillingCollection'.freeze
59
61
  MEGAM_EVENTSSTORAGE = 'Megam::EventsStorage'.freeze
@@ -182,6 +184,10 @@ module Megam
182
184
  Megam::EventsVm
183
185
  when MEGAM_EVENTSVMCOLLECTION
184
186
  Megam::EventsVmCollection
187
+ when MEGAM_EVENTSMARKETPLACES
188
+ Megam::EventsMarketplaces
189
+ when MEGAM_EVENTSMARKETPLACESCOLLECTION
190
+ Megam::EventsMarketplacesCollection
185
191
  when MEGAM_LICENSE
186
192
  Megam::License
187
193
  when MEGAM_LICENSECOLLECTION
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: megam_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.50.11
4
+ version: 1.50.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rajthilak, Kishorekumar Neelamegam, Ranjitha R, Vinodhini V, Rathish VBR, Rajesh
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-02-28 00:00:00.000000000 Z
12
+ date: 2017-03-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: excon
@@ -152,6 +152,7 @@ files:
152
152
  - lib/megam/api/eventsall.rb
153
153
  - lib/megam/api/eventsbilling.rb
154
154
  - lib/megam/api/eventscontainer.rb
155
+ - lib/megam/api/eventsmarketplaces.rb
155
156
  - lib/megam/api/eventsstorage.rb
156
157
  - lib/megam/api/eventsvm.rb
157
158
  - lib/megam/api/license.rb
@@ -198,6 +199,8 @@ files:
198
199
  - lib/megam/core/eventsbilling_collection.rb
199
200
  - lib/megam/core/eventscontainer.rb
200
201
  - lib/megam/core/eventscontainer_collection.rb
202
+ - lib/megam/core/eventsmarketplaces.rb
203
+ - lib/megam/core/eventsmarketplaces_collection.rb
201
204
  - lib/megam/core/eventsstorage.rb
202
205
  - lib/megam/core/eventsstorage_collection.rb
203
206
  - lib/megam/core/eventsvm.rb