Class: Megam::MarketPlace

Inherits:
ServerAPI show all
Defined in:
lib/megam/core/marketplace.rb

Instance Attribute Summary

Attributes inherited from ServerAPI

#api_key, #email, #host, #org_id, #password

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ServerAPI

#megam_rest

Constructor Details

#initialize(o) ⇒ MarketPlace

Returns a new instance of MarketPlace.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/megam/core/marketplace.rb', line 20

def initialize(o)
  @id = nil
  @settings_name = nil
  @cattype = nil
  @flavor = nil
  @image = nil
  @catorder = nil
  @url = nil
  @envs = []
  @options = []
  @plans = nil
  @created_at = nil
  super(o)
end

Class Method Details

.create(params) ⇒ Object



218
219
220
221
# File 'lib/megam/core/marketplace.rb', line 218

def self.create(params)
  acct = from_hash(params)
  acct.create
end

.from_hash(o) ⇒ Object



197
198
199
200
201
# File 'lib/megam/core/marketplace.rb', line 197

def self.from_hash(o)
  app = new(o)
  app.from_hash(o)
  app
end

.json_create(o) ⇒ Object



180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# File 'lib/megam/core/marketplace.rb', line 180

def self.json_create(o)
  app = new({})
  app.id(o['id']) if o.key?('id')
  app.settings_name(o['settings_name']) if o.key?('settings_name')
  app.cattype(o['cattype']) if o.key?('cattype')
  app.flavor(o['flavor']) if o.key?('flavor')
  app.image(o['image']) if o.key?('image')
  app.catorder(o['catorder']) if o.key?('catorder')
  app.url(o['url']) if o.key?('url')
  app.envs(o['envs']) if o.key?('envs')
  app.options(o['options']) if o.key?('options')
  app.plans(o['plans']) if o.key?('plans')
  app.created_at(o['created_at']) if o.key?('created_at')

  app
end

.list(params) ⇒ Object



234
235
236
237
# File 'lib/megam/core/marketplace.rb', line 234

def self.list(params)
  app = new(params)
  app.megam_rest.get_marketplaceapps
end

.show(params) ⇒ Object

Load a account by email_p



229
230
231
232
# File 'lib/megam/core/marketplace.rb', line 229

def self.show(params)
  app = new(params)
  app.megam_rest.get_marketplaceapp(params['id'])
end

Instance Method Details

#catorder(arg = nil) ⇒ Object



79
80
81
82
83
84
85
# File 'lib/megam/core/marketplace.rb', line 79

def catorder(arg = nil)
  if !arg.nil?
    @catorder = arg
  else
    @catorder
  end
end

#cattype(arg = nil) ⇒ Object



63
64
65
66
67
68
69
# File 'lib/megam/core/marketplace.rb', line 63

def cattype(arg = nil)
  if !arg.nil?
    @cattype = arg
  else
    @cattype
  end
end

#createObject

Create the marketplace app via the REST API



224
225
226
# File 'lib/megam/core/marketplace.rb', line 224

def create
  megam_rest.post_marketplaceapp(to_hash)
end

#created_at(arg = nil) ⇒ Object



119
120
121
122
123
124
125
# File 'lib/megam/core/marketplace.rb', line 119

def created_at(arg = nil)
  if !arg.nil?
    @created_at = arg
  else
    @created_at
  end
end

#envs(arg = []) ⇒ Object



103
104
105
106
107
108
109
# File 'lib/megam/core/marketplace.rb', line 103

def envs(arg = [])
  if arg != []
    @envs = arg
  else
    @envs
  end
end

#error?Boolean

Returns:

  • (Boolean)


135
136
137
# File 'lib/megam/core/marketplace.rb', line 135

def error?
  crocked = true if some_msg.key?(:msg_type) && some_msg[:msg_type] == 'error'
end

#flavor(arg = nil) ⇒ Object



71
72
73
74
75
76
77
# File 'lib/megam/core/marketplace.rb', line 71

def flavor(arg = nil)
  if !arg.nil?
    @flavor = arg
  else
    @flavor
  end
end

#for_jsonObject



163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
# File 'lib/megam/core/marketplace.rb', line 163

def for_json
  result = {
    'id' => id,
    'settings_name' => settings_name,
    'cattype' => cattype,
    'flavor' => flavor,
    'image' => image,
    'catorder' => catorder,
    'url' => url,
    'envs' => envs,
    'options' => options,
    'plans' => plans,
    'created_at' => created_at
  }
  result
end

#from_hash(o) ⇒ Object



203
204
205
206
207
208
209
210
211
212
213
214
215
216
# File 'lib/megam/core/marketplace.rb', line 203

def from_hash(o)
  @settings_name  = o['settings_name'] if o.key?('settings_name')
  @id             = o['id'] if o.key?('id')
  @cattype        = o['cattype'] if o.key?('cattype')
  @flavor         = o['flavor'] if o.key?('flavor')
  @image          = o['image'] if o.key?('image')
  @catorder            = o['catorder'] if o.key?('catorder')
  @url            = o['url'] if o.key?('url')
  @envs           = o['envs'] if o.key?('envs')
  @options        = o['options'] if o.key?('options')
  @plans          = o['plans'] if o.key?('plans')
  @created_at     = o['created_at'] if o.key?('created_at')
  self
end

#id(arg = nil) ⇒ Object



47
48
49
50
51
52
53
# File 'lib/megam/core/marketplace.rb', line 47

def id(arg = nil)
  if !arg.nil?
    @id = arg
  else
    @id
  end
end

#image(arg = nil) ⇒ Object



87
88
89
90
91
92
93
# File 'lib/megam/core/marketplace.rb', line 87

def image(arg = nil)
  if !arg.nil?
    @image = arg
  else
    @image
  end
end

#market_placeObject



35
36
37
# File 'lib/megam/core/marketplace.rb', line 35

def market_place
  self
end

#options(arg = []) ⇒ Object



111
112
113
114
115
116
117
# File 'lib/megam/core/marketplace.rb', line 111

def options(arg = [])
  if arg != []
    @options = arg
  else
    @options
  end
end

#plans(arg = nil) ⇒ Object



55
56
57
58
59
60
61
# File 'lib/megam/core/marketplace.rb', line 55

def plans(arg = nil)
  if !arg.nil?
    @plans = arg
  else
    @plans
  end
end

#settings_name(arg = nil) ⇒ Object



39
40
41
42
43
44
45
# File 'lib/megam/core/marketplace.rb', line 39

def settings_name(arg = nil)
  if !arg.nil?
    @settings_name = arg
  else
    @settings_name
  end
end

#some_msg(arg = nil) ⇒ Object



127
128
129
130
131
132
133
# File 'lib/megam/core/marketplace.rb', line 127

def some_msg(arg = nil)
  if !arg.nil?
    @some_msg = arg
  else
    @some_msg
  end
end

#to_hashObject

Transform the ruby obj -> to a Hash



140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'lib/megam/core/marketplace.rb', line 140

def to_hash
  index_hash = {}
  index_hash['json_claz'] = self.class.name
  index_hash['id'] = id
  index_hash['settings_name'] = settings_name
  index_hash['cattype'] = cattype
  index_hash['flavor'] = flavor
  index_hash['image'] = image
  index_hash['catorder'] = catorder
  index_hash['url'] = url
  index_hash['envs'] = envs
  index_hash['options'] = options
  index_hash['plans'] = plans
  index_hash['created_at'] = created_at
  index_hash
end

#to_json(*a) ⇒ Object

Serialize this object as a hash: called from JsonCompat. Verify if this called from JsonCompat during testing.



159
160
161
# File 'lib/megam/core/marketplace.rb', line 159

def to_json(*a)
  for_json.to_json(*a)
end

#to_sObject



239
240
241
242
# File 'lib/megam/core/marketplace.rb', line 239

def to_s
  Megam::Stuff.styled_hash(to_hash)
  # "---> Megam::Account:[error=#{error?}]\n"+
end

#url(arg = nil) ⇒ Object



95
96
97
98
99
100
101
# File 'lib/megam/core/marketplace.rb', line 95

def url(arg = nil)
  if !arg.nil?
    @url = arg
  else
    @url
  end
end