Sha256: 14761975b9acaa0a2357d3f31008aa1a4661857a6170ae926a8a5d179adf6733

Contents?: true

Size: 968 Bytes

Versions: 6

Compression:

Stored size: 968 Bytes

Contents

module Vcloud
  module Core
    class VappTemplate

      attr_reader :id

      def initialize(id)
        unless id =~ /^#{self.class.id_prefix}-[-0-9a-f]+$/
          raise "#{self.class.id_prefix} id : #{id} is not in correct format"
        end
        @id = id
      end

      def vcloud_attributes
        Vcloud::Fog::ServiceInterface.new.get_vapp_template(id)
      end

      def href
        vcloud_attributes[:href]
      end

      def name
        vcloud_attributes[:name]
      end

      def self.get catalog_name, catalog_item_name
        raise "provide catalog and catalog item name to load vappTemplate" unless catalog_name && catalog_item_name
        body = Vcloud::Fog::ServiceInterface.new.template(catalog_name, catalog_item_name)
        raise 'Could not find template vApp' unless body && body.key?(:href)
        self.new(body[:href].split('/').last)
      end

      def self.id_prefix
        'vappTemplate'
      end

    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
vcloud-core-0.0.6 lib/vcloud/core/vapp_template.rb
vcloud-core-0.0.5 lib/vcloud/core/vapp_template.rb
vcloud-core-0.0.4 lib/vcloud/core/vapp_template.rb
vcloud-core-0.0.3 lib/vcloud/core/vapp_template.rb
vcloud-core-0.0.2 lib/vcloud/core/vapp_template.rb
vcloud-core-0.0.1 lib/vcloud/core/vapp_template.rb