megam_api 0.35 → 0.36

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: aae6629f953f8f7bd92fac453843fb32cbe38af2
4
- data.tar.gz: f0d6668fed5fd78cea8101d41248d4664697ad22
3
+ metadata.gz: cbd4ffa63fecbfe5d3ab29cac888381c44bbbddb
4
+ data.tar.gz: 137a76192ae6c04f4adad619e061ce5b56ae10e3
5
5
  SHA512:
6
- metadata.gz: 2337896a7037f7488409e38574cd5b25591bad2d2a2c19b453992ea4c1b6aec9e3428edebe2241f64b2a4aec05028ee8d670fe99b1943867a7de46bfc22d3e66
7
- data.tar.gz: b64275323798bfa8e5e60311ce1f9bad7076e7553561898084c6bcde7cbb911fd6af14916927ca6cc1638b9834a2dfb7a8a6d3eff92a4c3dcd1f138e4781db67
6
+ metadata.gz: f8e299ecc9867a6163a33ce88a822ff37fadba0631ea101a906d72062cf1b5f90cb721aff032ba58227ac430e87a536f30da781dad29a70f1bc63b4f22accc66
7
+ data.tar.gz: 9b39eb75519b6301ebdef61693a2263acb746bf8f81be849f51f77b31e1a39453d38d053302784f6ed81158196530ad3c0a878dcbb0a387eb5faf07d91088e8b
data/lib/megam/api.rb CHANGED
@@ -30,6 +30,7 @@ require "megam/api/csars"
30
30
  require "megam/api/assemblies"
31
31
  require "megam/api/assembly"
32
32
  require "megam/api/components"
33
+ require "megam/api/event"
33
34
 
34
35
  require "megam/core/server_api"
35
36
  require "megam/core/config"
@@ -66,6 +67,7 @@ require "megam/core/components"
66
67
  require "megam/core/components_collection"
67
68
  require "megam/core/app_request"
68
69
  require "megam/core/app_request_collection"
70
+ require "megam/core/event"
69
71
 
70
72
 
71
73
 
@@ -0,0 +1,23 @@
1
+ module Megam
2
+ class API
3
+ def get_events
4
+
5
+ end
6
+
7
+ def post_event(new_event)
8
+ @options = {:path => '/events/content',
9
+ :body => Megam::JSONCompat.to_json(new_event)}.merge(@options)
10
+
11
+ request(
12
+ :expects => 201,
13
+ :method => :post,
14
+ :body => @options[:body]
15
+ )
16
+
17
+ end
18
+
19
+ def delete_event(event)
20
+ end
21
+
22
+ end
23
+ end
@@ -1,5 +1,5 @@
1
1
  module Megam
2
2
  class API
3
- VERSION = "0.35"
3
+ VERSION = "0.36"
4
4
  end
5
5
  end
@@ -1,4 +1,4 @@
1
- # Copyright:: Copyright (c) 2012-2013 Megam Systems, Inc.
1
+ # Copyright:: Copyright (c) 2012-2015 Megam Systems, Inc.
2
2
  # License:: Apache License, Version 2.0
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,7 +21,7 @@ module Megam
21
21
  @name = nil
22
22
  @components = []
23
23
  @policies=[]
24
- @inputs = {}
24
+ @inputs = []
25
25
  @operations = nil
26
26
  @outputs = []
27
27
  @status = nil
@@ -0,0 +1,146 @@
1
+ # Copyright:: Copyright (c) 2013, 2015 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
+ module Megam
18
+ class Event < Megam::ServerAPI
19
+ def initialize(email=nil, api_key=nil)
20
+ @a_id = nil
21
+ @a_name = nil
22
+ @command = nil
23
+ @launch_type = nil
24
+ super(email, api_key)
25
+ end
26
+
27
+ def event
28
+ self
29
+ end
30
+
31
+
32
+ def a_id(arg=nil)
33
+ if arg != nil
34
+ @a_id = arg
35
+ else
36
+ @a_id
37
+ end
38
+ end
39
+
40
+
41
+ def a_name(arg=nil)
42
+ if arg != nil
43
+ @a_name = arg
44
+ else
45
+ @a_name
46
+ end
47
+ end
48
+
49
+
50
+
51
+
52
+ def command(arg=nil)
53
+ if arg != nil
54
+ @command = arg
55
+ else
56
+ @command
57
+ end
58
+ end
59
+
60
+ def launch_type(arg=nil)
61
+ if arg != nil
62
+ @launch_type = arg
63
+ else
64
+ @launch_type
65
+ end
66
+ end
67
+
68
+ def error?
69
+ crocked = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error")
70
+ end
71
+
72
+ # Transform the ruby obj -> to a Hash
73
+ def to_hash
74
+ index_hash = Hash.new
75
+ index_hash["json_claz"] = self.class.name
76
+ index_hash["a_id"] = a_id
77
+ index_hash["a_name"] = a_name
78
+ index_hash["command"] = command
79
+ index_hash["launch_type"] = launch_type
80
+ index_hash
81
+ end
82
+
83
+ # Serialize this object as a hash: called from JsonCompat.
84
+ # Verify if this called from JsonCompat during testing.
85
+ def to_json(*a)
86
+ for_json.to_json(*a)
87
+ end
88
+
89
+ def for_json
90
+ result = {
91
+ "a_id" => a_id,
92
+ "a_name" => a_name,
93
+ "command" => command,
94
+ "launch_type" => launch_type
95
+ }
96
+ result
97
+ end
98
+
99
+ def self.json_create(o)
100
+ event = new
101
+ event.a_id(o["a_id"]) if o.has_key?("a_id")
102
+ event.a_name(o["a_name"]) if o.has_key?("a_name")
103
+ event.command(o["command"]) if o.has_key?("command")
104
+ event.launch_type(o["launch_type"]) if o.has_key?("launch_type") #this will be an array? can hash store array?
105
+ event
106
+ end
107
+
108
+ def self.from_hash(o,tmp_email=nil, tmp_api_key=nil)
109
+ event = self.new(tmp_email, tmp_api_key)
110
+ event.from_hash(o)
111
+ event
112
+ end
113
+
114
+ def from_hash(o)
115
+ @a_id = o[:a_id] if o.has_key?(:a_id)
116
+ @a_name = o[:a_name] if o.has_key?(:a_name)
117
+ @command = o[:command] if o.has_key?(:command)
118
+ @launch_type = o[:launch_type] if o.has_key?(:launch_type)
119
+
120
+ self
121
+ end
122
+
123
+ def self.create(o,tmp_email=nil, tmp_api_key=nil)
124
+
125
+ event = from_hash(o, tmp_email, tmp_api_key)
126
+ event.create
127
+ end
128
+
129
+ # Create the node via the REST API
130
+ def create
131
+ megam_rest.post_event(to_hash)
132
+ end
133
+
134
+
135
+
136
+ def self.list(tmp_email=nil, tmp_api_key=nil, inflated=false)
137
+ event = self.new(tmp_email, tmp_api_key)
138
+ event.megam_rest.get_events
139
+ end
140
+
141
+ def to_s
142
+ Megam::Stuff.styled_hash(to_hash)
143
+ end
144
+
145
+ end
146
+ end
@@ -38,6 +38,7 @@ module Megam
38
38
  MEGAM_DOMAIN = "Megam::Domains".freeze
39
39
  MEGAM_APPREQUEST = "Megam::AppRequest".freeze
40
40
  MEGAM_APPREQUESTCOLLECTION = "Megam::AppRequestCollection".freeze
41
+ MEGAM_EVENT = "Megam::Event".freeze
41
42
 
42
43
  MEGAM_PREDEFCLOUD = "Megam::PredefCloud".freeze
43
44
  MEGAM_PREDEFCLOUDCOLLECTION = "Megam::PredefCloudCollection".freeze
@@ -180,6 +181,8 @@ module Megam
180
181
  Megam::AppRequest
181
182
  when MEGAM_APPREQUESTCOLLECTION
182
183
  Megam::AppRequestCollection
184
+ when MEGAM_EVENT
185
+ Megam::Event
183
186
  else
184
187
  raise JSON::ParserError, "Unsupported `json_class` type '#{json_class}'"
185
188
  end
@@ -0,0 +1,21 @@
1
+ require File.expand_path("#{File.dirname(__FILE__)}/test_helper")
2
+
3
+ class TestApps < MiniTest::Unit::TestCase
4
+ def test_get_events
5
+
6
+ end
7
+
8
+ def test_post_event()
9
+ tmp_hash = {
10
+ "id" => "ASM1139235178976247808",
11
+ "name" => "calcines",
12
+
13
+ "command" => "Start",
14
+ "type" => "APP",
15
+ }
16
+
17
+ response = megams.post_event(tmp_hash)
18
+ assert_equal(201, response.status)
19
+ end
20
+
21
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: megam_api
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.35'
4
+ version: '0.36'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rajthilak, Kishorekumar Neelamegam, Thomas Alrin, Yeshwanth Kumar, Subash Sethurajan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-27 00:00:00.000000000 Z
11
+ date: 2015-04-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: excon
@@ -139,6 +139,7 @@ files:
139
139
  - lib/megam/api/csars.rb
140
140
  - lib/megam/api/domains.rb
141
141
  - lib/megam/api/errors.rb
142
+ - lib/megam/api/event.rb
142
143
  - lib/megam/api/login.rb
143
144
  - lib/megam/api/marketplace_addons.rb
144
145
  - lib/megam/api/marketplaces.rb
@@ -164,6 +165,7 @@ files:
164
165
  - lib/megam/core/csar_collection.rb
165
166
  - lib/megam/core/domains.rb
166
167
  - lib/megam/core/error.rb
168
+ - lib/megam/core/event.rb
167
169
  - lib/megam/core/json_compat.rb
168
170
  - lib/megam/core/konipai.rb
169
171
  - lib/megam/core/log.rb
@@ -194,6 +196,7 @@ files:
194
196
  - test/test_components.rb
195
197
  - test/test_csars.rb
196
198
  - test/test_domains.rb
199
+ - test/test_event.rb
197
200
  - test/test_helper.rb
198
201
  - test/test_login.rb
199
202
  - test/test_logs.rb
@@ -227,21 +230,4 @@ rubygems_version: 2.4.6
227
230
  signing_key:
228
231
  specification_version: 4
229
232
  summary: Ruby Client for the Megam
230
- test_files:
231
- - test/test_accounts.rb
232
- - test/test_app_requests.rb
233
- - test/test_assemblies.rb
234
- - test/test_assembly.rb
235
- - test/test_cloudtoolsettings.rb
236
- - test/test_components.rb
237
- - test/test_csars.rb
238
- - test/test_domains.rb
239
- - test/test_helper.rb
240
- - test/test_login.rb
241
- - test/test_logs.rb
242
- - test/test_marketplaceaddons.rb
243
- - test/test_marketplaces.rb
244
- - test/test_organizations.rb
245
- - test/test_predefclouds.rb
246
- - test/test_requests.rb
247
- - test/test_sshkeys.rb
233
+ test_files: []