lib/fog/aliyun/models/compute/image.rb in fog-aliyun-0.1.0 vs lib/fog/aliyun/models/compute/image.rb in fog-aliyun-0.2.0
- old
+ new
@@ -1,44 +1,43 @@
require 'fog/core/model'
module Fog
module Compute
class Aliyun
class Image < Fog::Model
+ identity :id, aliases: 'ImageId'
- identity :id, :aliases => 'ImageId'
+ attribute :description, aliases: 'Description'
+ attribute :product_code, aliases: 'ProductCode'
+ attribute :os_type, aliases: 'OSType'
+ attribute :architecture, aliases: 'Architecture'
+ attribute :os_name, aliases: 'OSName'
+ attribute :disk_device_mappings, aliases: 'DiskDeviceMappings'
+ attribute :owner_alias, aliases: 'ImageOwnerAlias'
+ attribute :progress, aliases: 'Progress'
+ attribute :usage, aliases: 'Usage'
+ attribute :created_at, aliases: 'CreationTime'
+ attribute :tags, aliases: 'Tags'
+ attribute :version, aliases: 'ImageVersion'
+ attribute :state, aliases: 'Status'
+ attribute :name, aliases: 'ImageName'
+ attribute :is_self_shared, aliases: 'IsSelfShared'
+ attribute :is_copied, aliases: 'IsCopied'
+ attribute :is_subscribed, aliases: 'IsSubscribed'
+ attribute :platform, aliases: 'Platform'
+ attribute :size, aliases: 'Size'
+ attribute :snapshot_id, aliases: 'SnapshotId'
- attribute :description, :aliases => 'Description'
- attribute :product_code, :aliases => 'ProductCode'
- attribute :os_type, :aliases => 'OSType'
- attribute :architecture, :aliases => 'Architecture'
- attribute :os_name, :aliases => 'OSName'
- attribute :disk_device_mappings, :aliases => 'DiskDeviceMappings'
- attribute :owner_alias, :aliases => 'ImageOwnerAlias'
- attribute :progress, :aliases => 'Progress'
- attribute :usage, :aliases => 'Usage'
- attribute :created_at, :aliases => 'CreationTime'
- attribute :tags, :aliases => 'Tags'
- attribute :version, :aliases => 'ImageVersion'
- attribute :state, :aliases => 'Status'
- attribute :name, :aliases => 'ImageName'
- attribute :is_self_shared, :aliases => 'IsSelfShared'
- attribute :is_copied, :aliases => 'IsCopied'
- attribute :is_subscribed, :aliases => 'IsSubscribed'
- attribute :platform, :aliases => 'Platform'
- attribute :size, :aliases => 'Size'
- attribute :snapshot_id, :aliases => 'SnapshotId'
-
def initialize(attributes)
- self.snapshot_id=attributes["DiskDeviceMappings"]["DiskDeviceMapping"][0]["SnapshotId"]
+ self.snapshot_id = attributes['DiskDeviceMappings']['DiskDeviceMapping'][0]['SnapshotId']
super
end
- def save (options={})
+ def save(options = {})
requires :snapshot_id
options[:name] = name if name
- options[:description]=description if description
- data=Fog::JSON.decode(service.create_image(snapshot_id,options).body)
+ options[:description] = description if description
+ data = Fog::JSON.decode(service.create_image(snapshot_id, options).body)
merge_attributes(data)
true
end
def destroy
@@ -51,18 +50,17 @@
state == 'Available'
end
def snapshot
requires :snapshot_id
- Fog::Compute::Aliyun::Snapshots.new(:service=>service).all(:snapshotIds=>[snapshot_id])[0]
+ Fog::Compute::Aliyun::Snapshots.new(service: service).all(snapshotIds: [snapshot_id])[0]
end
private
def snapshot=(new_snapshot)
self.snapshot_id = new_snapshot.id
end
-
end
end
end
end