class RestCartridge11

Attributes

help_topics[RW]
license[RW]
license_url[RW]
name[RW]
properties[RW]
tags[RW]
type[RW]
version[RW]
website[RW]

Public Class Methods

new(type, name, app, url) click to toggle source
# File lib/stickshift-controller/app/models/rest_cartridge11.rb, line 5
def initialize(type, name, app, url)
  self.name = name
  self.type = type

  prop_values = nil
  if app
    if CartridgeCache.cartridge_names('standalone').include? name
      app.comp_instance_map.each { |cname, cinst|
        next if cinst.parent_cart_name!=name
        prop_values = cinst.cart_properties
        break
      }
    else
      prop_values = app.embedded[name] 
    end
  end
  cart = CartridgeCache.find_cartridge(name)
  self.version = cart.version
  self.license = cart.license
  self.license_url = cart.license_url
  self.tags = cart.categories
  self.website = cart.website
  # self.suggests = cart.suggests_feature
  # self.requires = cart.requires_feature
  # self.depends = cart.profiles.map { |p| p.components.map { |c| c.depends_service }.flatten }.flatten.uniq
  # self.conflicts = cart.conflicts_feature
  self.help_topics = cart.help_topics
  
  self.properties = []
  cart.cart_data_def.each do |data_def|
    property = {}
    property["name"] = data_def["Key"]
    property["type"] = data_def["Type"]
    property["description"] = data_def["Description"]
    property["value"] = prop_values[data_def["Key"]] unless prop_values.nil? or prop_values[data_def["Key"]].nil?
    self.properties << property
  end
  
  if app
    domain_id = app.domain.namespace
    app_id = app.name
    if type == "embedded" and not app_id.nil? and not domain_id.nil?
      self.links = {
          "GET" => Link.new("Get embedded cartridge", "GET", URI::join(url, "domains/#{domain_id}/applications/#{app_id}/cartridges/#{name}")),
          "START" => Link.new("Start embedded cartridge", "POST", URI::join(url, "domains/#{domain_id}/applications/#{app_id}/cartridges/#{name}/events"), [
            Param.new("event", "string", "event", "start")
          ]),
          "STOP" => Link.new("Stop embedded cartridge", "POST", URI::join(url, "domains/#{domain_id}/applications/#{app_id}/cartridges/#{name}/events"), [
            Param.new("event", "string", "event", "stop")
          ]),
          "RESTART" => Link.new("Restart embedded cartridge", "POST", URI::join(url, "domains/#{domain_id}/applications/#{app_id}/cartridges/#{name}/events"), [
            Param.new("event", "string", "event", "restart")
          ]),
          "RELOAD" => Link.new("Reload embedded cartridge", "POST", URI::join(url, "domains/#{domain_id}/applications/#{app_id}/cartridges/#{name}/events"), [
            Param.new("event", "string", "event", "reload")
          ]),
          "DELETE" => Link.new("Delete embedded cartridge", "DELETE", URI::join(url, "domains/#{domain_id}/applications/#{app_id}/cartridges/#{name}"))
        }
    end
  end
end

Public Instance Methods

to_xml(options={}) click to toggle source
# File lib/stickshift-controller/app/models/rest_cartridge11.rb, line 67
def to_xml(options={})
  options[:tag_name] = "cartridge"
  super(options)
end