virtengine_api 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +21 -0
- data/.travis.yml +11 -0
- data/Gemfile +5 -0
- data/LICENSE +21 -0
- data/README.md +27 -0
- data/Rakefile +10 -0
- data/lib/megam/api.rb +329 -0
- data/lib/megam/api/accounts.rb +96 -0
- data/lib/megam/api/addons.rb +27 -0
- data/lib/megam/api/assemblies.rb +49 -0
- data/lib/megam/api/assembly.rb +56 -0
- data/lib/megam/api/backups.rb +57 -0
- data/lib/megam/api/balances.rb +45 -0
- data/lib/megam/api/billedhistories.rb +35 -0
- data/lib/megam/api/billingtransactions.rb +25 -0
- data/lib/megam/api/components.rb +24 -0
- data/lib/megam/api/credits.rb +34 -0
- data/lib/megam/api/disks.rb +44 -0
- data/lib/megam/api/domains.rb +25 -0
- data/lib/megam/api/errors.rb +29 -0
- data/lib/megam/api/eventsall.rb +36 -0
- data/lib/megam/api/eventsbilling.rb +35 -0
- data/lib/megam/api/eventscontainer.rb +35 -0
- data/lib/megam/api/eventsmarketplace.rb +35 -0
- data/lib/megam/api/eventsstorage.rb +24 -0
- data/lib/megam/api/eventsvm.rb +35 -0
- data/lib/megam/api/flavors.rb +56 -0
- data/lib/megam/api/license.rb +26 -0
- data/lib/megam/api/marketplaces.rb +68 -0
- data/lib/megam/api/organizations.rb +50 -0
- data/lib/megam/api/promos.rb +18 -0
- data/lib/megam/api/quotas.rb +47 -0
- data/lib/megam/api/rawimages.rb +36 -0
- data/lib/megam/api/reports.rb +24 -0
- data/lib/megam/api/requests.rb +36 -0
- data/lib/megam/api/sensors.rb +35 -0
- data/lib/megam/api/snapshots.rb +46 -0
- data/lib/megam/api/sshkeys.rb +35 -0
- data/lib/megam/api/subscriptions.rb +26 -0
- data/lib/megam/api/version.rb +6 -0
- data/lib/megam/core/account.rb +245 -0
- data/lib/megam/core/account_collection.rb +122 -0
- data/lib/megam/core/addons.rb +169 -0
- data/lib/megam/core/addons_collection.rb +121 -0
- data/lib/megam/core/assemblies.rb +191 -0
- data/lib/megam/core/assemblies_collection.rb +122 -0
- data/lib/megam/core/assembly.rb +226 -0
- data/lib/megam/core/assembly_collection.rb +122 -0
- data/lib/megam/core/backups.rb +259 -0
- data/lib/megam/core/backups_collection.rb +122 -0
- data/lib/megam/core/balances.rb +187 -0
- data/lib/megam/core/balances_collection.rb +121 -0
- data/lib/megam/core/billedhistories.rb +190 -0
- data/lib/megam/core/billedhistories_collection.rb +121 -0
- data/lib/megam/core/billingtransactions.rb +214 -0
- data/lib/megam/core/billingtransactions_collection.rb +122 -0
- data/lib/megam/core/components.rb +326 -0
- data/lib/megam/core/components_collection.rb +123 -0
- data/lib/megam/core/credits.rb +146 -0
- data/lib/megam/core/credits_collection.rb +121 -0
- data/lib/megam/core/disks.rb +199 -0
- data/lib/megam/core/disks_collection.rb +122 -0
- data/lib/megam/core/domain_collection.rb +122 -0
- data/lib/megam/core/domains.rb +118 -0
- data/lib/megam/core/error.rb +70 -0
- data/lib/megam/core/eventsall.rb +186 -0
- data/lib/megam/core/eventsall_collection.rb +122 -0
- data/lib/megam/core/eventsbilling.rb +174 -0
- data/lib/megam/core/eventsbilling_collection.rb +122 -0
- data/lib/megam/core/eventscontainer.rb +187 -0
- data/lib/megam/core/eventscontainer_collection.rb +122 -0
- data/lib/megam/core/eventsmarketplace.rb +187 -0
- data/lib/megam/core/eventsmarketplace_collection.rb +122 -0
- data/lib/megam/core/eventsstorage.rb +156 -0
- data/lib/megam/core/eventsstorage_collection.rb +122 -0
- data/lib/megam/core/eventsvm.rb +187 -0
- data/lib/megam/core/eventsvm_collection.rb +122 -0
- data/lib/megam/core/flavors.rb +294 -0
- data/lib/megam/core/flavors_collection.rb +121 -0
- data/lib/megam/core/json_compat.rb +289 -0
- data/lib/megam/core/konipai.rb +42 -0
- data/lib/megam/core/license.rb +101 -0
- data/lib/megam/core/license_collection.rb +122 -0
- data/lib/megam/core/log.rb +19 -0
- data/lib/megam/core/marketplace.rb +308 -0
- data/lib/megam/core/marketplace_collection.rb +123 -0
- data/lib/megam/core/monologger.rb +89 -0
- data/lib/megam/core/organizations.rb +142 -0
- data/lib/megam/core/organizations_collection.rb +121 -0
- data/lib/megam/core/promos.rb +145 -0
- data/lib/megam/core/quotas.rb +215 -0
- data/lib/megam/core/quotas_collection.rb +121 -0
- data/lib/megam/core/rawimages.rb +194 -0
- data/lib/megam/core/rawimages_collection.rb +121 -0
- data/lib/megam/core/reports.rb +176 -0
- data/lib/megam/core/reports_collection.rb +121 -0
- data/lib/megam/core/request.rb +197 -0
- data/lib/megam/core/request_collection.rb +121 -0
- data/lib/megam/core/rest_adapter.rb +44 -0
- data/lib/megam/core/sensors.rb +141 -0
- data/lib/megam/core/sensors_collection.rb +121 -0
- data/lib/megam/core/snapshots.rb +268 -0
- data/lib/megam/core/snapshots_collection.rb +122 -0
- data/lib/megam/core/sshkey.rb +173 -0
- data/lib/megam/core/sshkey_collection.rb +122 -0
- data/lib/megam/core/stuff.rb +22 -0
- data/lib/megam/core/subscriptions.rb +167 -0
- data/lib/megam/core/subscriptions_collection.rb +121 -0
- data/lib/megam/core/text.rb +87 -0
- data/lib/megam/core/text_formatter.rb +64 -0
- data/lib/megam/mixins/assemblies.rb +16 -0
- data/lib/megam/mixins/assembly.rb +59 -0
- data/lib/megam/mixins/common_deployable.rb +78 -0
- data/lib/megam/mixins/components.rb +182 -0
- data/lib/megam/mixins/megam_attributes.rb +30 -0
- data/lib/megam/mixins/outputs.rb +23 -0
- data/lib/megam/mixins/policies.rb +27 -0
- data/lib/megam_api.rb +1 -0
- data/megam_api.gemspec +26 -0
- data/test/mixins/test_assemblies.rb +113 -0
- data/test/mixins/test_assembly.rb +74 -0
- data/test/mixins/test_component.rb +19 -0
- data/test/test_accounts.rb +127 -0
- data/test/test_addons.rb +26 -0
- data/test/test_assemblies.rb +88 -0
- data/test/test_assembly.rb +37 -0
- data/test/test_backups.rb +29 -0
- data/test/test_balances.rb +38 -0
- data/test/test_billedhistories.rb +30 -0
- data/test/test_billingtranscations.rb +35 -0
- data/test/test_components.rb +42 -0
- data/test/test_credits.rb +28 -0
- data/test/test_disks.rb +25 -0
- data/test/test_domains.rb +29 -0
- data/test/test_eventsbilling.rb +30 -0
- data/test/test_eventscontainer.rb +26 -0
- data/test/test_eventsstorage.rb +12 -0
- data/test/test_eventsvm.rb +26 -0
- data/test/test_helper.rb +77 -0
- data/test/test_marketplaces.rb +38 -0
- data/test/test_organizations.rb +45 -0
- data/test/test_promos.rb +11 -0
- data/test/test_quotas.rb +33 -0
- data/test/test_reports.rb +32 -0
- data/test/test_requests.rb +95 -0
- data/test/test_sensors.rb +50 -0
- data/test/test_snapshots.rb +30 -0
- data/test/test_sshkeys.rb +50 -0
- data/test/test_subscriptions.rb +22 -0
- metadata +325 -0
@@ -0,0 +1,101 @@
|
|
1
|
+
module Megam
|
2
|
+
class License < Megam::RestAdapter
|
3
|
+
def initialize(o)
|
4
|
+
@data = nil
|
5
|
+
@some_msg = {}
|
6
|
+
super(o)
|
7
|
+
end
|
8
|
+
|
9
|
+
def license
|
10
|
+
self
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
def data(arg=nil)
|
15
|
+
if arg != nil
|
16
|
+
@data = arg
|
17
|
+
else
|
18
|
+
@data
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def some_msg(arg=nil)
|
23
|
+
if arg != nil
|
24
|
+
@some_msg = arg
|
25
|
+
else
|
26
|
+
@some_msg
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def error?
|
31
|
+
crocked = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error")
|
32
|
+
end
|
33
|
+
|
34
|
+
# Transform the ruby obj -> to a Hash
|
35
|
+
def to_hash
|
36
|
+
index_hash = Hash.new
|
37
|
+
index_hash["json_claz"] = self.class.name
|
38
|
+
index_hash["data"] = data
|
39
|
+
index_hash
|
40
|
+
end
|
41
|
+
|
42
|
+
# Serialize this object as a hash: called from JsonCompat.
|
43
|
+
# Verify if this called from JsonCompat during testing.
|
44
|
+
def to_json(*a)
|
45
|
+
for_json.to_json(*a)
|
46
|
+
end
|
47
|
+
|
48
|
+
def for_json
|
49
|
+
result = {
|
50
|
+
"data" => data
|
51
|
+
}
|
52
|
+
result
|
53
|
+
end
|
54
|
+
|
55
|
+
#
|
56
|
+
def self.json_create(o)
|
57
|
+
license = new({})
|
58
|
+
license.data(o["results"]["data"]) if o["results"]
|
59
|
+
#success or error
|
60
|
+
license.some_msg[:code] = o["code"] if o.has_key?("code")
|
61
|
+
license.some_msg[:msg_type] = o["msg_type"] if o.has_key?("msg_type")
|
62
|
+
license.some_msg[:msg]= o["msg"] if o.has_key?("msg")
|
63
|
+
license.some_msg[:links] = o["links"] if o.has_key?("links")
|
64
|
+
license
|
65
|
+
end
|
66
|
+
|
67
|
+
def self.from_hash(o)
|
68
|
+
license = self.new(o)
|
69
|
+
license.from_hash(o)
|
70
|
+
license
|
71
|
+
end
|
72
|
+
|
73
|
+
def from_hash(o)
|
74
|
+
@data = o[:data] if o.has_key?(:data)
|
75
|
+
self
|
76
|
+
end
|
77
|
+
|
78
|
+
def self.create(params)
|
79
|
+
acct = from_hash(params)
|
80
|
+
acct.create
|
81
|
+
end
|
82
|
+
|
83
|
+
# Create the predef via the REST API
|
84
|
+
def create
|
85
|
+
megam_rest.post_license(to_hash)
|
86
|
+
end
|
87
|
+
|
88
|
+
# Show a particular License by id,
|
89
|
+
# Megam::License
|
90
|
+
def self.show(params)
|
91
|
+
pre = self.new(params)
|
92
|
+
pre.megam_rest.get_license(params["id"])
|
93
|
+
end
|
94
|
+
|
95
|
+
def to_s
|
96
|
+
Megam::Stuff.styled_hash(to_hash)
|
97
|
+
#"---> Megam::Account:[error=#{error?}]\n"+
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
101
|
+
end
|
@@ -0,0 +1,122 @@
|
|
1
|
+
module Megam
|
2
|
+
class LicenseCollection
|
3
|
+
include Enumerable
|
4
|
+
|
5
|
+
attr_reader :iterator
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@license = Array.new
|
9
|
+
@license_by_name = Hash.new
|
10
|
+
@insert_after_idx = nil
|
11
|
+
end
|
12
|
+
|
13
|
+
def all_license
|
14
|
+
@license
|
15
|
+
end
|
16
|
+
|
17
|
+
def [](index)
|
18
|
+
@license[index]
|
19
|
+
end
|
20
|
+
|
21
|
+
def []=(index, arg)
|
22
|
+
is_megam_license(arg)
|
23
|
+
@license[index] = arg
|
24
|
+
@license_by_name[arg.name] = index
|
25
|
+
end
|
26
|
+
|
27
|
+
def <<(*args)
|
28
|
+
args.flatten.each do |a|
|
29
|
+
is_megam_license(a)
|
30
|
+
@license << a
|
31
|
+
@license_by_name[a.name] =@license.length - 1
|
32
|
+
end
|
33
|
+
self
|
34
|
+
end
|
35
|
+
|
36
|
+
# 'push' is an alias method to <<
|
37
|
+
alias_method :push, :<<
|
38
|
+
|
39
|
+
def insert(license)
|
40
|
+
is_megam_license(license)
|
41
|
+
if @insert_after_idx
|
42
|
+
# in the middle of executing a run, so any license inserted now should
|
43
|
+
# be placed after the most recent addition done by the currently executing
|
44
|
+
# license
|
45
|
+
@license.insert(@insert_after_idx + 1, license)
|
46
|
+
# update name -> location mappings and register new license
|
47
|
+
@license_by_name.each_key do |key|
|
48
|
+
@license_by_name[key] += 1 if@license_by_name[key] > @insert_after_idx
|
49
|
+
end
|
50
|
+
@license_by_name[license.name] = @insert_after_idx + 1
|
51
|
+
@insert_after_idx += 1
|
52
|
+
else
|
53
|
+
@license << license
|
54
|
+
@license_by_name[license.name] =@license.length - 1
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def each
|
59
|
+
@license.each do |license|
|
60
|
+
yield license
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def each_index
|
65
|
+
@license.each_index do |i|
|
66
|
+
yield i
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def empty?
|
71
|
+
@license.empty?
|
72
|
+
end
|
73
|
+
|
74
|
+
def lookup(license)
|
75
|
+
lookup_by = nil
|
76
|
+
if license.kind_of?(Megam::License)
|
77
|
+
lookup_by = license.name
|
78
|
+
elsif license.kind_of?(String)
|
79
|
+
lookup_by = license
|
80
|
+
else
|
81
|
+
raise ArgumentError, "Must pass a Megam::license or String to lookup"
|
82
|
+
end
|
83
|
+
res =@license_by_name[lookup_by]
|
84
|
+
unless res
|
85
|
+
raise ArgumentError, "Cannot find a license matching #{lookup_by} (did you define it first?)"
|
86
|
+
end
|
87
|
+
@license[res]
|
88
|
+
end
|
89
|
+
|
90
|
+
def to_s
|
91
|
+
@license.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 |license_list|
|
105
|
+
license_array = license_list.kind_of?(Array) ? license_list : [ license_list ]
|
106
|
+
license_array.each do |license|
|
107
|
+
collection.insert(license)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
collection
|
111
|
+
end
|
112
|
+
|
113
|
+
private
|
114
|
+
|
115
|
+
def is_megam_license(arg)
|
116
|
+
unless arg.kind_of?(Megam::License)
|
117
|
+
raise ArgumentError, "Members must be Megam::License's"
|
118
|
+
end
|
119
|
+
true
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'logger'
|
2
|
+
require 'mixlib/log'
|
3
|
+
require 'megam/core/monologger'
|
4
|
+
|
5
|
+
module Megam
|
6
|
+
class Log
|
7
|
+
extend Mixlib::Log
|
8
|
+
|
9
|
+
# Force initialization of the primary log device (@logger)
|
10
|
+
init(Megam::MonoLogger.new(STDOUT))
|
11
|
+
|
12
|
+
class Formatter
|
13
|
+
def self.show_time=(*args)
|
14
|
+
Mixlib::Log::Formatter.show_time = *args
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,308 @@
|
|
1
|
+
module Megam
|
2
|
+
class MarketPlace < Megam::RestAdapter
|
3
|
+
def initialize(o)
|
4
|
+
@id = nil
|
5
|
+
@provided_by = nil
|
6
|
+
@cattype = nil
|
7
|
+
@catorder = nil
|
8
|
+
@status = nil
|
9
|
+
@flavor = nil
|
10
|
+
@image = nil
|
11
|
+
@url = nil
|
12
|
+
@envs = []
|
13
|
+
@options = []
|
14
|
+
@inputs = []
|
15
|
+
@outputs = []
|
16
|
+
@acl_policies = []
|
17
|
+
@plans = []
|
18
|
+
@created_at = nil
|
19
|
+
@updated_at = nil
|
20
|
+
@some_msg = {}
|
21
|
+
super(o)
|
22
|
+
end
|
23
|
+
|
24
|
+
def market_place
|
25
|
+
self
|
26
|
+
end
|
27
|
+
|
28
|
+
def provided_by(arg = nil)
|
29
|
+
if !arg.nil?
|
30
|
+
@provided_by = arg
|
31
|
+
else
|
32
|
+
@provided_by
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def id(arg = nil)
|
37
|
+
if !arg.nil?
|
38
|
+
@id = arg
|
39
|
+
else
|
40
|
+
@id
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def plans(arg = [])
|
45
|
+
if arg != []
|
46
|
+
@plans = arg
|
47
|
+
else
|
48
|
+
@plans
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def cattype(arg = nil)
|
53
|
+
if !arg.nil?
|
54
|
+
@cattype = arg
|
55
|
+
else
|
56
|
+
@cattype
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def flavor(arg = nil)
|
61
|
+
if !arg.nil?
|
62
|
+
@flavor = arg
|
63
|
+
else
|
64
|
+
@flavor
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def catorder(arg = nil)
|
69
|
+
if !arg.nil?
|
70
|
+
@catorder = arg
|
71
|
+
else
|
72
|
+
@catorder
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def image(arg = nil)
|
77
|
+
if !arg.nil?
|
78
|
+
@image = arg
|
79
|
+
else
|
80
|
+
@image
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def url(arg = nil)
|
85
|
+
if !arg.nil?
|
86
|
+
@url = arg
|
87
|
+
else
|
88
|
+
@url
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def envs(arg = [])
|
93
|
+
if arg != []
|
94
|
+
@envs = arg
|
95
|
+
else
|
96
|
+
@envs
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def options(arg = [])
|
101
|
+
if arg != []
|
102
|
+
@options = arg
|
103
|
+
else
|
104
|
+
@options
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
def inputs(arg = [])
|
109
|
+
if arg != []
|
110
|
+
@inputs = arg
|
111
|
+
else
|
112
|
+
@inputs
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
def outputs(arg = [])
|
117
|
+
if arg != []
|
118
|
+
@outputs = arg
|
119
|
+
else
|
120
|
+
@outputs
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
def status(arg = [])
|
125
|
+
if arg != []
|
126
|
+
@status = arg
|
127
|
+
else
|
128
|
+
@status
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
def acl_policies(arg = [])
|
133
|
+
if arg != []
|
134
|
+
@acl_policies = arg
|
135
|
+
else
|
136
|
+
@acl_policies
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
def created_at(arg = nil)
|
141
|
+
if !arg.nil?
|
142
|
+
@created_at = arg
|
143
|
+
else
|
144
|
+
@created_at
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
def updated_at(arg = nil)
|
149
|
+
if !arg.nil?
|
150
|
+
@updated_at = arg
|
151
|
+
else
|
152
|
+
@updated_at
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
def some_msg(arg = nil)
|
157
|
+
if !arg.nil?
|
158
|
+
@some_msg = arg
|
159
|
+
else
|
160
|
+
@some_msg
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
def error?
|
165
|
+
crocked = true if some_msg.key?(:msg_type) && some_msg[:msg_type] == 'error'
|
166
|
+
end
|
167
|
+
|
168
|
+
# Transform the ruby obj -> to a Hash
|
169
|
+
def to_hash
|
170
|
+
index_hash = {}
|
171
|
+
index_hash['json_claz'] = self.class.name
|
172
|
+
index_hash['id'] = id
|
173
|
+
index_hash['provided_by'] = provided_by
|
174
|
+
index_hash['cattype'] = cattype
|
175
|
+
index_hash['flavor'] = flavor
|
176
|
+
index_hash['image'] = image
|
177
|
+
index_hash['catorder'] = catorder
|
178
|
+
index_hash['url'] = url
|
179
|
+
index_hash['envs'] = envs
|
180
|
+
index_hash['options'] = options
|
181
|
+
index_hash['plans'] = plans
|
182
|
+
index_hash['created_at'] = created_at
|
183
|
+
index_hash['updated_at'] = updated_at
|
184
|
+
index_hash['status'] = status
|
185
|
+
index_hash['inputs'] = inputs
|
186
|
+
index_hash['outputs'] = outputs
|
187
|
+
index_hash['acl_policies'] = acl_policies
|
188
|
+
index_hash["some_msg"] = some_msg
|
189
|
+
index_hash
|
190
|
+
end
|
191
|
+
|
192
|
+
# Serialize this object as a hash: called from JsonCompat.
|
193
|
+
# Verify if this called from JsonCompat during testing.
|
194
|
+
def to_json(*a)
|
195
|
+
for_json.to_json(*a)
|
196
|
+
end
|
197
|
+
|
198
|
+
def for_json
|
199
|
+
result = {
|
200
|
+
'id' => id,
|
201
|
+
'provided_by' => provided_by,
|
202
|
+
'cattype' => cattype,
|
203
|
+
'flavor' => flavor,
|
204
|
+
'image' => image,
|
205
|
+
'catorder' => catorder,
|
206
|
+
'url' => url,
|
207
|
+
'envs' => envs,
|
208
|
+
'options' => options,
|
209
|
+
'plans' => plans,
|
210
|
+
'created_at' => created_at,
|
211
|
+
'updated_at' => updated_at,
|
212
|
+
'status' => status,
|
213
|
+
'inputs' => inputs,
|
214
|
+
'outputs' => outputs,
|
215
|
+
'acl_policies' => acl_policies
|
216
|
+
}
|
217
|
+
result
|
218
|
+
end
|
219
|
+
|
220
|
+
def self.json_create(o)
|
221
|
+
app = new({})
|
222
|
+
app.id(o['id']) if o.key?('id')
|
223
|
+
app.provided_by(o['provided_by']) if o.key?('provided_by')
|
224
|
+
app.cattype(o['cattype']) if o.key?('cattype')
|
225
|
+
app.flavor(o['flavor']) if o.key?('flavor')
|
226
|
+
app.image(o['image']) if o.key?('image')
|
227
|
+
app.catorder(o['catorder']) if o.key?('catorder')
|
228
|
+
app.url(o['url']) if o.key?('url')
|
229
|
+
app.envs(o['envs']) if o.key?('envs')
|
230
|
+
app.options(o['options']) if o.key?('options')
|
231
|
+
app.plans(o['plans']) if o.key?('plans')
|
232
|
+
app.created_at(o['created_at']) if o.key?('created_at')
|
233
|
+
app.updated_at(o['updated_at']) if o.key?('updated_at')
|
234
|
+
app.inputs(o['inputs']) if o.key?('inputs')
|
235
|
+
app.outputs(o['outputs']) if o.key?('outputs')
|
236
|
+
app.status(o['status']) if o.key?('status')
|
237
|
+
app.acl_policies(o['acl_policies']) if o.key?('acl_policies')
|
238
|
+
#success or error
|
239
|
+
app.some_msg[:code] = o["code"] if o.has_key?("code")
|
240
|
+
app.some_msg[:msg_type] = o["msg_type"] if o.has_key?("msg_type")
|
241
|
+
app.some_msg[:msg]= o["msg"] if o.has_key?("msg")
|
242
|
+
app.some_msg[:links] = o["links"] if o.has_key?("links")
|
243
|
+
app
|
244
|
+
end
|
245
|
+
|
246
|
+
def self.from_hash(o)
|
247
|
+
app = new(o)
|
248
|
+
app.from_hash(o)
|
249
|
+
app
|
250
|
+
end
|
251
|
+
|
252
|
+
def from_hash(o)
|
253
|
+
@provided_by = o['provided_by'] if o.key?('provided_by')
|
254
|
+
@id = o['id'] if o.key?('id')
|
255
|
+
@cattype = o['cattype'] if o.key?('cattype')
|
256
|
+
@flavor = o['flavor'] if o.key?('flavor')
|
257
|
+
@image = o['image'] if o.key?('image')
|
258
|
+
@catorder = o['catorder'] if o.key?('catorder')
|
259
|
+
@url = o['url'] if o.key?('url')
|
260
|
+
@envs = o['envs'] if o.key?('envs')
|
261
|
+
@options = o['options'] if o.key?('options')
|
262
|
+
@plans = o['plans'] if o.key?('plans')
|
263
|
+
@created_at = o['created_at'] if o.key?('created_at')
|
264
|
+
@updated_at = o['updated_at'] if o.key?('updated_at')
|
265
|
+
@status = o['status'] if o.key?('status')
|
266
|
+
@inputs = o['inputs'] if o.key?('inputs')
|
267
|
+
@outputs = o['outputs'] if o.key?('outputs')
|
268
|
+
@acl_policies = o['acl_policies'] if o.key?('acl_policies')
|
269
|
+
self
|
270
|
+
end
|
271
|
+
|
272
|
+
def self.create(params)
|
273
|
+
acct = from_hash(params)
|
274
|
+
acct.create
|
275
|
+
end
|
276
|
+
|
277
|
+
# Create the marketplace app via the REST API
|
278
|
+
def create
|
279
|
+
megam_rest.post_marketplaceapp(to_hash)
|
280
|
+
end
|
281
|
+
|
282
|
+
# Load a account by email_p
|
283
|
+
def self.show(params)
|
284
|
+
app = new(params)
|
285
|
+
app.megam_rest.get_marketplaceapp(params['id'])
|
286
|
+
end
|
287
|
+
|
288
|
+
def self.list(params)
|
289
|
+
app = new(params)
|
290
|
+
app.megam_rest.get_marketplaceapps
|
291
|
+
end
|
292
|
+
|
293
|
+
def self.list_provider(params)
|
294
|
+
app = new(params)
|
295
|
+
app.megam_rest.get_marketplaceprovider(params['provider'])
|
296
|
+
end
|
297
|
+
|
298
|
+
def self.list_flavor(params)
|
299
|
+
app = new(params)
|
300
|
+
app.megam_rest.get_marketplaceflavor(params['flavor'])
|
301
|
+
end
|
302
|
+
|
303
|
+
def to_s
|
304
|
+
Megam::Stuff.styled_hash(to_hash)
|
305
|
+
# "---> Megam::Account:[error=#{error?}]\n"+
|
306
|
+
end
|
307
|
+
end
|
308
|
+
end
|