|
| 1 | +## |
| 2 | +# @api REST |
| 3 | +# Describes an Cartridge |
| 4 | +# @version 1.1 |
| 5 | +# |
| 6 | +# Example: |
| 7 | +# ``` |
| 8 | +# <cartridge> |
| 9 | +# <name>php-5.4</name> |
| 10 | +# <status-messages nil="true"/> |
| 11 | +# <version>5.4.10</version> |
| 12 | +# <display-name>PHP 5.4</display-name> |
| 13 | +# <description>PHP is a general-purpose server-side scripting language originally designed for Web development to produce dynamic Web pages. Popular development frameworks include: CakePHP, Zend, Symfony, and Code Igniter.</description> |
| 14 | +# <license>The PHP License, version 3.0</license> |
| 15 | +# <license-url>http://www.php.net/license/3_0.txt</license-url> |
| 16 | +# <tags> |
| 17 | +# <tag>service</tag> |
| 18 | +# <tag>php</tag> |
| 19 | +# <tag>web_framework</tag> |
| 20 | +# </tags> |
| 21 | +# <website>http://www.php.net</website> |
| 22 | +# <type>standalone</type> |
| 23 | +# <usage-rates/> |
| 24 | +# <scales-from>1</scales-from> |
| 25 | +# <scales-to>1</scales-to> |
| 26 | +# <current-scale>1</current-scale> |
| 27 | +# <gear-profile>small</gear-profile> |
| 28 | +# <base-gear-storage>1</base-gear-storage> |
| 29 | +# <additional-gear-storage>0</additional-gear-storage> |
| 30 | +# <collocated-with/> |
| 31 | +# <supported-scales-from>1</supported-scales-from> |
| 32 | +# <supported-scales-to>1</supported-scales-to> |
| 33 | +# <properties> |
| 34 | +# <property> |
| 35 | +# <name>OPENSHIFT_TMP_DIR</name> |
| 36 | +# <type>environment</type> |
| 37 | +# <description>Directory to store application temporary files.</description> |
| 38 | +# </property> |
| 39 | +# ... |
| 40 | +# </properties> |
| 41 | +# <scales-with nil="true"/> |
| 42 | +# <help-topics> |
| 43 | +# <Developer-Center>https://www.openshift.com/developers</Developer-Center> |
| 44 | +# </help-topics> |
| 45 | +# <links> |
| 46 | +# ... |
| 47 | +# </links> |
| 48 | +# </cartridge> |
| 49 | +# ``` |
| 50 | +# |
| 51 | +# @!attribute [r] type |
| 52 | +# @deprecated |
| 53 | +# @return [String] "standalone" or "embedded". |
| 54 | +# @!attribute [r] name |
| 55 | +# @return [String] Name of the cartridge |
| 56 | +# @!attribute [r] version |
| 57 | +# @return [String] Version of the packaged software in the cartridge |
| 58 | +# @!attribute [r] license |
| 59 | +# @return [String] License of the packaged software in the cartridge |
| 60 | +# @!attribute [r] license_url |
| 61 | +# @return [String] URI to the license file for the packaged software in the cartridge |
| 62 | +# @!attribute [r] tags |
| 63 | +# @return [Array<String>] Array of tags associated with the cartridge |
| 64 | +# @!attribute [r] website |
| 65 | +# @return [String] URI to the website for the packaged software in the cartridge |
| 66 | +# @!attribute [r] help_topics |
| 67 | +# @return [Hash] Map of topics and associated URIs that can provide help on how to use and configure this cartridge |
| 68 | +# @!attribute [r] properties |
| 69 | +# @return [Array<Property>] List of environment variables and property values that are exposed by this cartridge and usable in application code. |
| 70 | +# @!attribute [r] display_name |
| 71 | +# @return [String] Formatted name used by CLI and UIs |
| 72 | +# @!attribute [r] description |
| 73 | +# @return [String] Description of the cartridge used by CLI and UIs |
| 74 | +# @!attribute [r] scales_from |
| 75 | +# @return [Integer] User specified minimum scale for the cartridge |
| 76 | +# @!attribute [r] scales_to |
| 77 | +# @return [Integer] User specified maximum scale for the cartridge |
| 78 | +# @!attribute [r] supported_scales_from |
| 79 | +# @return [Integer] Cartridge supported minimum scale |
| 80 | +# @!attribute [r] supported_scales_from |
| 81 | +# @return [Integer] Cartridge supported maximum scale |
| 82 | +# @!attribute [r] current_scale |
| 83 | +# @return [Integer] Current number of gears used to run this cartridge |
| 84 | +# @!attribute [r] scales_with |
| 85 | +# @return [Array<String>] Names of other cartridges that scale along with this cartridge and run on the same set of gears |
| 86 | +# @!attribute [r] usage_rates |
| 87 | +# @return [Array<Object>] |
| 88 | +class RestCartridge16 < OpenShift::Model |
| 89 | + attr_accessor :id, :type, :name, :version, :license, :license_url, :tags, :website, |
| 90 | + :help_topics, :properties, :display_name, :description, :scales_from, :scales_to, |
| 91 | + :supported_scales_to, :supported_scales_from, :current_scale, :scales_with, :usage_rates, |
| 92 | + :creation_time, :automatic_updates |
| 93 | + |
| 94 | + def initialize(cart) |
| 95 | + self.name = cart.name |
| 96 | + self.id = cart.id |
| 97 | + self.version = cart.version |
| 98 | + self.display_name = cart.display_name |
| 99 | + self.description = cart.description |
| 100 | + self.license = cart.license |
| 101 | + self.license_url = cart.license_url |
| 102 | + self.tags = cart.categories |
| 103 | + self.website = cart.website |
| 104 | + self.type = "standalone" |
| 105 | + self.type = "embedded" unless cart.is_web_framework? |
| 106 | + scale = cart.components.first.scaling |
| 107 | + if not scale.nil? |
| 108 | + self.supported_scales_from = scale.min |
| 109 | + self.supported_scales_to = scale.max |
| 110 | + else |
| 111 | + self.supported_scales_from = 1 |
| 112 | + self.supported_scales_to = -1 |
| 113 | + end |
| 114 | + self.help_topics = cart.help_topics |
| 115 | + self.usage_rates = cart.usage_rates |
| 116 | + if requires = CartridgeCache.find_requires_for(cart).presence |
| 117 | + @requires = requires |
| 118 | + end |
| 119 | + |
| 120 | + @maintained_by = "redhat" if cart.cartridge_vendor == "redhat" |
| 121 | + self.automatic_updates = cart.manifest_url.blank? && !cart.categories.include?('no_updates') |
| 122 | + |
| 123 | + self.creation_time = cart.created_at |
| 124 | + if cart.activated_at |
| 125 | + @activation_time = cart.activated_at.in_time_zone |
| 126 | + end |
| 127 | + |
| 128 | + @obsolete = true if cart.is_obsolete? |
| 129 | + @url = cart.manifest_url if cart.manifest_url.present? |
| 130 | + end |
| 131 | + |
| 132 | + def to_xml(options={}) |
| 133 | + options[:tag_name] = "cartridge" |
| 134 | + super(options) |
| 135 | + end |
| 136 | +end |
0 commit comments