megam_api 0.83 → 0.85
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/megam/api.rb +1 -7
- data/lib/megam/api/version.rb +1 -1
- data/lib/megam/core/config.rb +0 -4
- data/lib/megam/core/json_compat.rb +5 -13
- data/lib/megam/core/request.rb +0 -14
- data/lib/megam/mixins/assembly.rb +5 -6
- data/lib/megam/mixins/common_deployable.rb +5 -5
- data/lib/megam/mixins/components.rb +38 -38
- data/lib/megam/mixins/megam_attributes.rb +3 -3
- data/lib/megam/mixins/outputs.rb +0 -1
- data/lib/megam/mixins/policies.rb +14 -16
- metadata +32 -7
- data/lib/megam/api/marketplace_addons.rb +0 -27
- data/lib/megam/core/marketplace_addon.rb +0 -195
- data/lib/megam/core/marketplace_addon_collection.rb +0 -148
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7b28d854d2bc822f5e8948f61a254d8de1c4873
|
4
|
+
data.tar.gz: d03f30284539a0b2cdef981edd4eef32cbc0e24d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b974cd6149d3efdd35b100a4520b7cc2bda5430673c86eadd46c88f747f5c8d17c54016736015d4ae94fd2c3a3c8c0c688bedd39251361ca8d96af65c6298d5f
|
7
|
+
data.tar.gz: c46041ec809c04fdffd5ebcb149361c9c69ebfd02a0b3c2bc23fcd27eac3ccbf6e7027a13f4bae190a76f1999c7da022f00d0eef2f9b521725139f2b94e9ecea
|
data/lib/megam/api.rb
CHANGED
@@ -14,10 +14,8 @@ require 'megam/api/errors'
|
|
14
14
|
require 'megam/api/version'
|
15
15
|
require 'megam/api/accounts'
|
16
16
|
require 'megam/api/requests'
|
17
|
-
# require 'megam/api/cloud_tool_settings'
|
18
17
|
require 'megam/api/sshkeys'
|
19
18
|
require 'megam/api/marketplaces'
|
20
|
-
require 'megam/api/marketplace_addons'
|
21
19
|
require 'megam/api/organizations'
|
22
20
|
require 'megam/api/domains'
|
23
21
|
require 'megam/api/csars'
|
@@ -54,14 +52,10 @@ require 'megam/core/error'
|
|
54
52
|
require 'megam/core/account'
|
55
53
|
require 'megam/core/request'
|
56
54
|
require 'megam/core/request_collection'
|
57
|
-
# require 'megam/core/cloudtoolsetting'
|
58
|
-
# require 'megam/core/cloudtoolsetting_collection'
|
59
55
|
require 'megam/core/sshkey'
|
60
56
|
require 'megam/core/sshkey_collection'
|
61
57
|
require 'megam/core/marketplace'
|
62
58
|
require 'megam/core/marketplace_collection'
|
63
|
-
require 'megam/core/marketplace_addon'
|
64
|
-
require 'megam/core/marketplace_addon_collection'
|
65
59
|
require 'megam/core/organizations'
|
66
60
|
require 'megam/core/organizations_collection'
|
67
61
|
require 'megam/core/domains'
|
@@ -141,7 +135,7 @@ module Megam
|
|
141
135
|
end
|
142
136
|
|
143
137
|
def request(params, &block)
|
144
|
-
|
138
|
+
|
145
139
|
just_color_debug("#{@options[:path]}")
|
146
140
|
start = Time.now
|
147
141
|
Megam::Log.debug('START')
|
data/lib/megam/api/version.rb
CHANGED
data/lib/megam/core/config.rb
CHANGED
@@ -35,12 +35,8 @@ module Megam
|
|
35
35
|
MEGAM_BALANCESCOLLECTION = 'Megam::BalancesCollection'.freeze
|
36
36
|
MEGAM_BILLEDHISTORIES = 'Megam::Billedhistories'.freeze
|
37
37
|
MEGAM_BILLEDHISTORIESCOLLECTION = 'Megam::BilledhistoriesCollection'.freeze
|
38
|
-
|
39
|
-
MEGAM_INVOICES = 'Megam::Invoices'.freeze
|
40
|
-
MEGAM_BILLINGS = 'Megam::Billings'.freeze
|
38
|
+
MEGAM_BILLINGS = 'Megam::Billings'.freeze
|
41
39
|
MEGAM_BILLINGSCOLLECTION = 'Megam::BillingsCollection'.freeze
|
42
|
-
MEGAM_CLOUDTOOLSETTING = 'Megam::CloudToolSetting'.freeze
|
43
|
-
MEGAM_CLOUDTOOLSETTINGCOLLECTION = 'Megam::CloudToolSettingCollection'.freeze
|
44
40
|
MEGAM_COMPONENTS = 'Megam::Components'.freeze
|
45
41
|
MEGAM_COMPONENTSCOLLECTION = 'Megam::ComponentsCollection'.freeze
|
46
42
|
MEGAM_CREDITHISTORIES = 'Megam::Credithistories'.freeze
|
@@ -51,16 +47,16 @@ module Megam
|
|
51
47
|
MEGAM_DISCOUNTS = 'Megam::Discounts'.freeze
|
52
48
|
MEGAM_DISCOUNTSCOLLECTION = 'Megam::DiscountsCollection'.freeze
|
53
49
|
MEGAM_ERROR = 'Megam::Error'.freeze
|
54
|
-
|
55
|
-
|
50
|
+
MEGAM_INVOICESCOLLECTION = 'Megam::InvoicesCollection'.freeze
|
51
|
+
MEGAM_INVOICES = 'Megam::Invoices'.freeze
|
56
52
|
MEGAM_MARKETPLACE = 'Megam::MarketPlace'.freeze
|
57
53
|
MEGAM_MARKETPLACECOLLECTION = 'Megam::MarketPlaceCollection'.freeze
|
58
|
-
MEGAM_MARKETPLACEADDON = 'Megam::MarketPlaceAddons'.freeze
|
59
|
-
MEGAM_MARKETPLACEADDONCOLLECTION = 'Megam::MarketPlaceAddonsCollection'.freeze
|
60
54
|
MEGAM_ORGANIZATION = 'Megam::Organizations'.freeze
|
61
55
|
MEGAM_ORGANIZATIONSCOLLECTION = 'Megam::OrganizationsCollection'.freeze
|
62
56
|
MEGAM_REQUEST = 'Megam::Request'.freeze
|
63
57
|
MEGAM_REQUESTCOLLECTION = 'Megam::RequestCollection'.freeze
|
58
|
+
MEGAM_SENSORS = 'Megam::Sensors'.freeze
|
59
|
+
MEGAM_SENSORSCOLLECTION = 'Megam::SensorsCollection'.freeze
|
64
60
|
MEGAM_SSHKEY = 'Megam::SshKey'.freeze
|
65
61
|
MEGAM_SSHKEYCOLLECTION = 'Megam::SshKeyCollection'.freeze
|
66
62
|
MEGAM_SUBSCRIPTIONS = 'Megam::Subscriptions'.freeze
|
@@ -172,10 +168,6 @@ module Megam
|
|
172
168
|
Megam::MarketPlace
|
173
169
|
when MEGAM_MARKETPLACECOLLECTION
|
174
170
|
Megam::MarketPlaceCollection
|
175
|
-
when MEGAM_MARKETPLACEADDON
|
176
|
-
Megam::MarketPlaceAddons
|
177
|
-
when MEGAM_MARKETPLACEADDONCOLLECTION
|
178
|
-
Megam::MarketPlaceAddonsCollection
|
179
171
|
when MEGAM_ORGANIZATION
|
180
172
|
Megam::Organizations
|
181
173
|
when MEGAM_ORGANIZATIONSCOLLECTION
|
data/lib/megam/core/request.rb
CHANGED
@@ -20,7 +20,6 @@ module Megam
|
|
20
20
|
@cat_id = nil
|
21
21
|
@name = nil
|
22
22
|
@cattype = nil
|
23
|
-
@command =nil
|
24
23
|
@action = nil
|
25
24
|
@category = nil
|
26
25
|
@some_msg = {}
|
@@ -90,14 +89,6 @@ module Megam
|
|
90
89
|
end
|
91
90
|
end
|
92
91
|
|
93
|
-
def command(arg=nil)
|
94
|
-
if arg != nil
|
95
|
-
@command = arg
|
96
|
-
else
|
97
|
-
@command
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
92
|
def some_msg(arg=nil)
|
102
93
|
if arg != nil
|
103
94
|
@some_msg = arg
|
@@ -120,7 +111,6 @@ module Megam
|
|
120
111
|
index_hash["cattype"] = cattype
|
121
112
|
index_hash["action"] = action
|
122
113
|
index_hash["category"] = category
|
123
|
-
index_hash["command"] = command
|
124
114
|
index_hash["created_at"] = created_at
|
125
115
|
index_hash
|
126
116
|
end
|
@@ -139,7 +129,6 @@ module Megam
|
|
139
129
|
"cattype" => cattype,
|
140
130
|
"action" => action,
|
141
131
|
"category" => category,
|
142
|
-
"command" => command,
|
143
132
|
"created_at" => created_at
|
144
133
|
}
|
145
134
|
result
|
@@ -154,7 +143,6 @@ module Megam
|
|
154
143
|
node.cattype(o["cattype"]) if o.has_key?("cattype")
|
155
144
|
node.action(o["action"]) if o.has_key?("action")
|
156
145
|
node.category(o["category"]) if o.has_key?("category")
|
157
|
-
node.command(o["command"]) if o.has_key?("command")
|
158
146
|
node.created_at(o["created_at"]) if o.has_key?("created_at")
|
159
147
|
#success or error
|
160
148
|
node.some_msg[:code] = o["code"] if o.has_key?("code")
|
@@ -177,7 +165,6 @@ module Megam
|
|
177
165
|
@cattype = o[:cattype] if o.has_key?(:cattype)
|
178
166
|
@action = o[:action] if o.has_key?(:action)
|
179
167
|
@category = o[:category] if o.has_key?(:category)
|
180
|
-
@command = o[:command] if o.has_key?(:command)
|
181
168
|
@created_at = o[:created_at] if o.has_key?(:created_at)
|
182
169
|
self
|
183
170
|
end
|
@@ -206,7 +193,6 @@ module Megam
|
|
206
193
|
|
207
194
|
def to_s
|
208
195
|
Megam::Stuff.styled_hash(to_hash)
|
209
|
-
#"---> Megam::Account:[error=#{error?}]\n"+
|
210
196
|
end
|
211
197
|
|
212
198
|
end
|
@@ -3,11 +3,11 @@ require File.expand_path("#{File.dirname(__FILE__)}/components")
|
|
3
3
|
require File.expand_path("#{File.dirname(__FILE__)}/outputs")
|
4
4
|
|
5
5
|
module Megam
|
6
|
-
class
|
6
|
+
class Mixins
|
7
7
|
class Assembly
|
8
8
|
attr_reader :name, :components, :policies, :outputs, :mixins
|
9
9
|
def initialize(params)
|
10
|
-
params = Hash[params.map{ |k, v| [k.to_sym, v] }]
|
10
|
+
params = Hash[params.map { |k, v| [k.to_sym, v] }]
|
11
11
|
@name = params[:assemblyname]
|
12
12
|
@mixins = CommonDeployable.new(params)
|
13
13
|
@outputs = Outputs.new(params)
|
@@ -17,9 +17,9 @@ module Megam
|
|
17
17
|
|
18
18
|
def to_hash
|
19
19
|
result = @mixins.to_hash
|
20
|
-
result[:name]
|
21
|
-
result[:components]
|
22
|
-
result[:outputs] = @outputs.to_array
|
20
|
+
result[:name] = @name if @name
|
21
|
+
result[:components] = @components if @components
|
22
|
+
result[:outputs] = @outputs.to_array if @outputs
|
23
23
|
result[:policies] = @policies if @policies
|
24
24
|
result
|
25
25
|
end
|
@@ -38,7 +38,6 @@ module Megam
|
|
38
38
|
@components = []
|
39
39
|
end
|
40
40
|
end
|
41
|
-
|
42
41
|
end
|
43
42
|
end
|
44
43
|
end
|
@@ -20,8 +20,8 @@ module Megam
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def initialize(params)
|
23
|
-
@tosca_type =
|
24
|
-
@status =
|
23
|
+
@tosca_type = ''
|
24
|
+
@status = 'launching'
|
25
25
|
bld_toscatype(params)
|
26
26
|
@inputs = InputGroupData.new(params)
|
27
27
|
set_attributes(params)
|
@@ -29,9 +29,9 @@ module Megam
|
|
29
29
|
|
30
30
|
def to_hash
|
31
31
|
h = {
|
32
|
-
:
|
33
|
-
:
|
34
|
-
:
|
32
|
+
status: status,
|
33
|
+
tosca_type: tosca_type,
|
34
|
+
inputs: inputs.to_hash
|
35
35
|
}
|
36
36
|
end
|
37
37
|
|
@@ -18,18 +18,18 @@ module Megam
|
|
18
18
|
|
19
19
|
def to_hash
|
20
20
|
result = @mixins.to_hash
|
21
|
-
result[:name]
|
22
|
-
result[:artifacts]
|
23
|
-
result[:repo]
|
24
|
-
result[:operations]
|
25
|
-
result[:outputs] = @outputs.to_array
|
21
|
+
result[:name] = @name if @name
|
22
|
+
result[:artifacts] = @artifacts if @artifacts
|
23
|
+
result[:repo] = @repo if @repo
|
24
|
+
result[:operations] = @operations if @operations
|
25
|
+
result[:outputs] = @outputs.to_array if @outputs
|
26
26
|
result[:related_components] = @related_components if @related_components
|
27
27
|
result
|
28
28
|
end
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
def to_a
|
31
|
+
[to_hash]
|
32
|
+
end
|
33
33
|
|
34
34
|
private
|
35
35
|
|
@@ -38,13 +38,13 @@ module Megam
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def add_related_components(params)
|
41
|
-
|
41
|
+
related_components = []
|
42
42
|
related_components << "#{params[:assemblyname]}.#{params[:domain]}/#{params[:componentname]}" if params.key?(:bind_type)
|
43
43
|
end
|
44
44
|
|
45
45
|
def add_operations(params)
|
46
46
|
operations = []
|
47
|
-
operations.push(create_operation(Operations::CI, Operations::CI_DESCRIPTON,
|
47
|
+
operations.push(create_operation(Operations::CI, Operations::CI_DESCRIPTON, params)) unless params[:scm_name] && params[:scm_name].strip.empty?
|
48
48
|
operations.push(create_operation(Operations::BIND, Operations::BIND_DESCRIPTON, params)) if params.key?(:bind_type)
|
49
49
|
end
|
50
50
|
|
@@ -74,18 +74,17 @@ module Megam
|
|
74
74
|
set_attributes(params)
|
75
75
|
@type = params[:type]
|
76
76
|
@source = params[:scm_name]
|
77
|
-
|
78
|
-
|
77
|
+
@url = params[:source]
|
78
|
+
@oneclick = params[:oneclick]
|
79
79
|
end
|
80
80
|
|
81
81
|
def tohash
|
82
|
-
{ :
|
83
|
-
|
84
|
-
|
85
|
-
|
82
|
+
{ rtype: @type,
|
83
|
+
source: @source,
|
84
|
+
oneclick: @oneclick,
|
85
|
+
url: @url
|
86
86
|
}
|
87
87
|
end
|
88
|
-
|
89
88
|
end
|
90
89
|
|
91
90
|
class Operations
|
@@ -94,16 +93,16 @@ module Megam
|
|
94
93
|
|
95
94
|
ATTRIBUTES = []
|
96
95
|
|
97
|
-
CI =
|
98
|
-
CI_DESCRIPTON =
|
96
|
+
CI = 'CI'.freeze
|
97
|
+
CI_DESCRIPTON = 'always up to date code. sweet.'
|
99
98
|
|
100
|
-
BIND =
|
101
|
-
BIND_DESCRIPTON =
|
102
|
-
def initialize(params,type, desc)
|
99
|
+
BIND = 'bind'.freeze
|
100
|
+
BIND_DESCRIPTON = 'bind. sweet.'
|
101
|
+
def initialize(params, type, desc)
|
103
102
|
@type = type
|
104
103
|
@desc = desc
|
105
|
-
#set_attributes(params)
|
106
|
-
|
104
|
+
# set_attributes(params)
|
105
|
+
@prop = prop(params)
|
107
106
|
end
|
108
107
|
|
109
108
|
def attributes
|
@@ -111,19 +110,20 @@ module Megam
|
|
111
110
|
end
|
112
111
|
|
113
112
|
def tohash
|
114
|
-
{ :
|
115
|
-
|
116
|
-
|
113
|
+
{ operation_type: @type,
|
114
|
+
description: @desc,
|
115
|
+
properties: @prop
|
117
116
|
}
|
118
117
|
end
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
118
|
+
|
119
|
+
# Key_name mismatch. Key_name is to be changed.
|
120
|
+
def prop(params)
|
121
|
+
op = []
|
122
|
+
op << { 'key' => 'type', 'value' => params[:scm_name] }
|
123
|
+
op << { 'key' => 'token', 'value' => params[:scmtoken] || '' }
|
124
|
+
op << { 'key' => 'username', 'value' => params[:scmowner] || '' }
|
125
|
+
op
|
126
|
+
end
|
127
127
|
end
|
128
128
|
|
129
129
|
class Artifacts
|
@@ -142,9 +142,9 @@ module Megam
|
|
142
142
|
end
|
143
143
|
|
144
144
|
def tohash
|
145
|
-
{ :
|
146
|
-
|
147
|
-
|
145
|
+
{ artifact_type: '',
|
146
|
+
content: '',
|
147
|
+
requirements: []
|
148
148
|
}
|
149
149
|
end
|
150
150
|
end
|
@@ -1,14 +1,14 @@
|
|
1
1
|
module Nilavu
|
2
2
|
module MegamAttributes
|
3
3
|
ATTRIBUTES = []
|
4
|
-
KEY =
|
5
|
-
VALUE =
|
4
|
+
KEY = 'key'.freeze
|
5
|
+
VALUE = 'value'.freeze
|
6
6
|
attr_accessor *ATTRIBUTES
|
7
7
|
def attributes
|
8
8
|
NotImplementedError
|
9
9
|
end
|
10
10
|
|
11
|
-
def initialize(control_data={})
|
11
|
+
def initialize(control_data = {})
|
12
12
|
set_attributes(control_data)
|
13
13
|
end
|
14
14
|
|
data/lib/megam/mixins/outputs.rb
CHANGED
@@ -4,26 +4,24 @@ module Megam
|
|
4
4
|
attr_reader :bind_type, :policymembers
|
5
5
|
|
6
6
|
def initialize(params)
|
7
|
-
|
8
|
-
|
7
|
+
@bind_type = params[:bind_type] if params.key?(:bind_type)
|
8
|
+
@policymembers = params[:policymembers] if params.key?(:policymembers)
|
9
9
|
end
|
10
10
|
|
11
11
|
def to_array
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
12
|
+
com = []
|
13
|
+
if @bind_type && @bind_type != 'Unbound service'
|
14
|
+
value = {
|
15
|
+
name: 'bind policy',
|
16
|
+
ptype: 'colocated',
|
17
|
+
members: [
|
18
|
+
@policymembers
|
19
|
+
]
|
20
|
+
}
|
21
|
+
com << value
|
22
|
+
end
|
23
|
+
com
|
24
24
|
end
|
25
|
-
|
26
|
-
|
27
25
|
end
|
28
26
|
end
|
29
27
|
end
|
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: '0.
|
4
|
+
version: '0.85'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rajthilak, Kishorekumar Neelamegam, Thomas Alrin, Yeshwanth Kumar, Subash Sethurajan,
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-11-
|
12
|
+
date: 2015-11-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: excon
|
@@ -148,7 +148,6 @@ files:
|
|
148
148
|
- lib/megam/api/errors.rb
|
149
149
|
- lib/megam/api/invoices.rb
|
150
150
|
- lib/megam/api/login.rb
|
151
|
-
- lib/megam/api/marketplace_addons.rb
|
152
151
|
- lib/megam/api/marketplaces.rb
|
153
152
|
- lib/megam/api/organizations.rb
|
154
153
|
- lib/megam/api/promos.rb
|
@@ -188,8 +187,6 @@ files:
|
|
188
187
|
- lib/megam/core/konipai.rb
|
189
188
|
- lib/megam/core/log.rb
|
190
189
|
- lib/megam/core/marketplace.rb
|
191
|
-
- lib/megam/core/marketplace_addon.rb
|
192
|
-
- lib/megam/core/marketplace_addon_collection.rb
|
193
190
|
- lib/megam/core/marketplace_collection.rb
|
194
191
|
- lib/megam/core/monologger.rb
|
195
192
|
- lib/megam/core/organizations.rb
|
@@ -264,8 +261,36 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
264
261
|
version: '0'
|
265
262
|
requirements: []
|
266
263
|
rubyforge_project:
|
267
|
-
rubygems_version: 2.4.
|
264
|
+
rubygems_version: 2.4.8
|
268
265
|
signing_key:
|
269
266
|
specification_version: 4
|
270
267
|
summary: Ruby Client for the Megam
|
271
|
-
test_files:
|
268
|
+
test_files:
|
269
|
+
- test/mixins/test_assemblies.rb
|
270
|
+
- test/mixins/test_assembly.rb
|
271
|
+
- test/mixins/test_component.rb
|
272
|
+
- test/test_accounts.rb
|
273
|
+
- test/test_assemblies.rb
|
274
|
+
- test/test_assembly.rb
|
275
|
+
- test/test_availableunits.rb
|
276
|
+
- test/test_balances.rb
|
277
|
+
- test/test_billedhistories.rb
|
278
|
+
- test/test_billings.rb
|
279
|
+
- test/test_cat_requests.rb
|
280
|
+
- test/test_components.rb
|
281
|
+
- test/test_credithistories.rb
|
282
|
+
- test/test_csars.rb
|
283
|
+
- test/test_discounts.rb
|
284
|
+
- test/test_domains.rb
|
285
|
+
- test/test_helper.rb
|
286
|
+
- test/test_invoices.rb
|
287
|
+
- test/test_login.rb
|
288
|
+
- test/test_marketplaceaddons.rb
|
289
|
+
- test/test_marketplaces.rb
|
290
|
+
- test/test_organizations.rb
|
291
|
+
- test/test_predefclouds.rb
|
292
|
+
- test/test_promos.rb
|
293
|
+
- test/test_requests.rb
|
294
|
+
- test/test_sensors.rb
|
295
|
+
- test/test_sshkeys.rb
|
296
|
+
- test/test_subscriptions.rb
|
@@ -1,27 +0,0 @@
|
|
1
|
-
module Megam
|
2
|
-
class API
|
3
|
-
|
4
|
-
#=begin
|
5
|
-
def get_addons(node_name)
|
6
|
-
@options = {:path => "/marketplaceaddons/#{node_name}",:body => ""}.merge(@options)
|
7
|
-
|
8
|
-
request(
|
9
|
-
:expects => 200,
|
10
|
-
:method => :get,
|
11
|
-
:body => @options[:body]
|
12
|
-
)
|
13
|
-
end
|
14
|
-
#=end
|
15
|
-
def post_addon(new_addon)
|
16
|
-
@options = {:path => '/marketplaceaddons/content',
|
17
|
-
:body => Megam::JSONCompat.to_json(new_addon)}.merge(@options)
|
18
|
-
|
19
|
-
request(
|
20
|
-
:expects => 201,
|
21
|
-
:method => :post,
|
22
|
-
:body => @options[:body]
|
23
|
-
)
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
27
|
-
end
|
@@ -1,195 +0,0 @@
|
|
1
|
-
# Copyright:: Copyright (c) 2012, 2014 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
|
-
module Megam
|
17
|
-
class MarketPlaceAddons< Megam::ServerAPI
|
18
|
-
|
19
|
-
def initialize(email=nil, api_key=nil, host=nil)
|
20
|
-
@id = nil
|
21
|
-
@node_id = nil
|
22
|
-
@node_name = nil
|
23
|
-
@marketplace_id = nil
|
24
|
-
@config = nil
|
25
|
-
@config_id = nil
|
26
|
-
@created_at = nil
|
27
|
-
@some_msg = {}
|
28
|
-
super(email,api_key,host)
|
29
|
-
end
|
30
|
-
|
31
|
-
def market_place_addons
|
32
|
-
self
|
33
|
-
end
|
34
|
-
|
35
|
-
|
36
|
-
def id(arg=nil)
|
37
|
-
if arg != nil
|
38
|
-
@id = arg
|
39
|
-
else
|
40
|
-
@id
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def node_id(arg=nil)
|
45
|
-
if arg != nil
|
46
|
-
@node_id = arg
|
47
|
-
else
|
48
|
-
@node_id
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def node_name(arg=nil)
|
53
|
-
if arg != nil
|
54
|
-
@node_name = arg
|
55
|
-
else
|
56
|
-
@node_name
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
def marketplace_id(arg=nil)
|
61
|
-
if arg != nil
|
62
|
-
@marketplace_id = arg
|
63
|
-
else
|
64
|
-
@marketplace_id
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
def config_id(arg=nil)
|
69
|
-
if arg != nil
|
70
|
-
@config_id = arg
|
71
|
-
else
|
72
|
-
@config_id
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
def config(arg=nil)
|
77
|
-
if arg != nil
|
78
|
-
@config = arg
|
79
|
-
else
|
80
|
-
@config
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
def created_at(arg=nil)
|
85
|
-
if arg != nil
|
86
|
-
@created_at = arg
|
87
|
-
else
|
88
|
-
@created_at
|
89
|
-
end
|
90
|
-
end
|
91
|
-
def some_msg(arg=nil)
|
92
|
-
if arg != nil
|
93
|
-
@some_msg = arg
|
94
|
-
else
|
95
|
-
@some_msg
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
def error?
|
100
|
-
crocked = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error")
|
101
|
-
end
|
102
|
-
|
103
|
-
# Transform the ruby obj -> to a Hash
|
104
|
-
def to_hash
|
105
|
-
index_hash = Hash.new
|
106
|
-
index_hash["json_claz"] = self.class.name
|
107
|
-
index_hash["id"] = id
|
108
|
-
index_hash["node_id"] = node_id
|
109
|
-
index_hash["node_name"] = node_name
|
110
|
-
index_hash["marketplace_id"] = marketplace_id
|
111
|
-
index_hash["config"] = config
|
112
|
-
index_hash["config_id"] = config_id
|
113
|
-
index_hash["created_at"] = created_at
|
114
|
-
index_hash["some_msg"] = some_msg
|
115
|
-
index_hash
|
116
|
-
end
|
117
|
-
|
118
|
-
# Serialize this object as a hash: called from JsonCompat.
|
119
|
-
# Verify if this called from JsonCompat during testing.
|
120
|
-
def to_json(*a)
|
121
|
-
for_json.to_json(*a)
|
122
|
-
end
|
123
|
-
|
124
|
-
def for_json
|
125
|
-
result = {
|
126
|
-
"id" => id,
|
127
|
-
"node_id" => node_id,
|
128
|
-
"node_name" => node_name,
|
129
|
-
"marketplace_id" => marketplace_id,
|
130
|
-
"config" => {},
|
131
|
-
"config_id" => config_id,
|
132
|
-
"created_at" => created_at
|
133
|
-
}
|
134
|
-
result
|
135
|
-
end
|
136
|
-
|
137
|
-
|
138
|
-
def self.json_create(o)
|
139
|
-
addon = new
|
140
|
-
addon.id(o["id"]) if o.has_key?("id")
|
141
|
-
addon.node_id(o["node_id"]) if o.has_key?("node_id")
|
142
|
-
addon.node_name(o["node_name"]) if o.has_key?("node_name")
|
143
|
-
addon.marketplace_id(o["marketplace_id"]) if o.has_key?("marketplace_id")
|
144
|
-
addon.config(o["config"]) if o.has_key?("config")
|
145
|
-
addon.config_id(o["config_id"]) if o.has_key?("config_id")
|
146
|
-
addon.created_at(o["created_at"]) if o.has_key?("created_at")
|
147
|
-
|
148
|
-
addon.some_msg[:code] = o["code"] if o.has_key?("code")
|
149
|
-
addon.some_msg[:msg_type] = o["msg_type"] if o.has_key?("msg_type")
|
150
|
-
addon.some_msg[:msg]= o["msg"] if o.has_key?("msg")
|
151
|
-
addon.some_msg[:links] = o["links"] if o.has_key?("links")
|
152
|
-
|
153
|
-
addon
|
154
|
-
end
|
155
|
-
|
156
|
-
def self.from_hash(o,tmp_email=nil, tmp_api_key=nil, tmp_host=nil)
|
157
|
-
addon = self.new(tmp_email, tmp_api_key, tmp_host)
|
158
|
-
addon.from_hash(o)
|
159
|
-
addon
|
160
|
-
end
|
161
|
-
|
162
|
-
def from_hash(o)
|
163
|
-
@id = o["id"] if o.has_key?("id")
|
164
|
-
@node_id = o["node_id"] if o.has_key?("node_id")
|
165
|
-
@node_name = o["node_name"] if o.has_key?("node_name")
|
166
|
-
@marketplace_id = o["marketplace_id"] if o.has_key?("marketplace_id")
|
167
|
-
@config = o["config"] if o.has_key?("config")
|
168
|
-
@config_id = o["config_id"] if o.has_key?("config_id")
|
169
|
-
@created_at = o["created_at"] if o.has_key?("created_at")
|
170
|
-
self
|
171
|
-
end
|
172
|
-
|
173
|
-
def self.create(o,tmp_email=nil, tmp_api_key=nil, tmp_host=nil)
|
174
|
-
acct = from_hash(o,tmp_email, tmp_api_key, tmp_host)
|
175
|
-
acct.create
|
176
|
-
end
|
177
|
-
|
178
|
-
# Create the addon via the REST API
|
179
|
-
def create
|
180
|
-
megam_rest.post_addon(to_hash)
|
181
|
-
end
|
182
|
-
|
183
|
-
# Load a account by email_p
|
184
|
-
def self.list(node_name,tmp_email=nil, tmp_api_key=nil, tmp_host=nil)
|
185
|
-
addon = self.new(tmp_email, tmp_api_key, tmp_host)
|
186
|
-
addon.megam_rest.get_addons(node_name)
|
187
|
-
#self
|
188
|
-
end
|
189
|
-
|
190
|
-
def to_s
|
191
|
-
Megam::Stuff.styled_hash(to_hash)
|
192
|
-
end
|
193
|
-
|
194
|
-
end
|
195
|
-
end
|
@@ -1,148 +0,0 @@
|
|
1
|
-
# Copyright:: Copyright (c) 2012, 2014 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
|
-
module Megam
|
17
|
-
class MarketPlaceAddonsCollection
|
18
|
-
include Enumerable
|
19
|
-
|
20
|
-
|
21
|
-
attr_reader :iterator
|
22
|
-
def initialize
|
23
|
-
@addons = Array.new
|
24
|
-
@addons_by_name = Hash.new
|
25
|
-
@insert_after_idx = nil
|
26
|
-
end
|
27
|
-
|
28
|
-
def all_addons
|
29
|
-
@addons
|
30
|
-
end
|
31
|
-
|
32
|
-
def [](index)
|
33
|
-
@addons[index]
|
34
|
-
end
|
35
|
-
|
36
|
-
def []=(index, arg)
|
37
|
-
is_megam_addon(arg)
|
38
|
-
@addons[index] = arg
|
39
|
-
@addons_by_name[arg.id] = index
|
40
|
-
end
|
41
|
-
|
42
|
-
def <<(*args)
|
43
|
-
args.flatten.each do |a|
|
44
|
-
is_megam_addon(a)
|
45
|
-
@addons << a
|
46
|
-
@addons_by_name[a.id] = @addons.length - 1
|
47
|
-
end
|
48
|
-
self
|
49
|
-
end
|
50
|
-
|
51
|
-
# 'push' is an alias method to <<
|
52
|
-
alias_method :push, :<<
|
53
|
-
|
54
|
-
def insert(addon)
|
55
|
-
is_megam_addon(addon)
|
56
|
-
if @insert_after_idx
|
57
|
-
# in the middle of executing a run, so any addons inserted now should
|
58
|
-
# be placed after the most recent addition done by the currently executing
|
59
|
-
# addons
|
60
|
-
@addons.insert(@insert_after_idx + 1, addon)
|
61
|
-
# update name -> location mappings and register new addons
|
62
|
-
@addons_by_name.each_key do |key|
|
63
|
-
@addons_by_name[key] += 1 if @addons_by_name[key] > @insert_after_idx
|
64
|
-
end
|
65
|
-
@addons_by_name[addon.id] = @insert_after_idx + 1
|
66
|
-
@insert_after_idx += 1
|
67
|
-
else
|
68
|
-
@addons << addon
|
69
|
-
@addons_by_name[addon.id] = @addons.length - 1
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
def each
|
74
|
-
@addons.each do |addon|
|
75
|
-
yield addon
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
def each_index
|
80
|
-
@addons.each_index do |i|
|
81
|
-
yield i
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
def empty?
|
86
|
-
@addons.empty?
|
87
|
-
end
|
88
|
-
|
89
|
-
def lookup(addon)
|
90
|
-
lookup_by = nil
|
91
|
-
if addon.kind_of?(Megam::MarketPlaceAddons)
|
92
|
-
lookup_by = addon.id
|
93
|
-
elsif addon.kind_of?(String)
|
94
|
-
lookup_by = addon
|
95
|
-
else
|
96
|
-
raise ArgumentError, "Must pass a Megam::MarketPlaceAddons or String to lookup"
|
97
|
-
end
|
98
|
-
res = @addons_by_name[lookup_by]
|
99
|
-
unless res
|
100
|
-
raise ArgumentError, "Cannot find a appreq matching #{lookup_by} (did you define it first?)"
|
101
|
-
end
|
102
|
-
@addons[res]
|
103
|
-
end
|
104
|
-
|
105
|
-
# Transform the ruby obj -> to a Hash
|
106
|
-
def to_hash
|
107
|
-
index_hash = Hash.new
|
108
|
-
self.each do |addon|
|
109
|
-
index_hash[addon.id] = addon.to_s
|
110
|
-
end
|
111
|
-
index_hash
|
112
|
-
end
|
113
|
-
|
114
|
-
# Serialize this object as a hash: called from JsonCompat.
|
115
|
-
# Verify if this called from JsonCompat during testing.
|
116
|
-
def to_json(*a)
|
117
|
-
for_json.to_json(*a)
|
118
|
-
end
|
119
|
-
|
120
|
-
|
121
|
-
def self.json_create(o)
|
122
|
-
collection = self.new()
|
123
|
-
o["results"].each do |addons_list|
|
124
|
-
addons_array = addons_list.kind_of?(Array) ? addons_list : [ addons_list ]
|
125
|
-
addons_array.each do |addon|
|
126
|
-
collection.insert(addon)
|
127
|
-
end
|
128
|
-
end
|
129
|
-
collection
|
130
|
-
end
|
131
|
-
|
132
|
-
private
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
def is_megam_addon(arg)
|
137
|
-
unless arg.kind_of?(Megam::MarketPlaceAddons)
|
138
|
-
raise ArgumentError, "Members must be Megam::MarketPlaceAddons"
|
139
|
-
end
|
140
|
-
true
|
141
|
-
end
|
142
|
-
|
143
|
-
def to_s
|
144
|
-
Megam::Stuff.styled_hash(to_hash)
|
145
|
-
end
|
146
|
-
|
147
|
-
end
|
148
|
-
end
|